Skip to content

Commit 8b5ba1d

Browse files
authored
feat: add presets which are kintone-customize-es5 and kintone-customize-es5-prettier (#39)
* feat: add kintone-customize-es5 preset * add tests for kintone-customize-es5 * update docs and add presets/kintone-customize-es5-prettier
1 parent 700c0a1 commit 8b5ba1d

File tree

14 files changed

+136
-10
lines changed

14 files changed

+136
-10
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,16 @@ In order to this, you have to install `prettier` and choose a preset from the fo
152152
- `@cybozu/eslint-config/presets/es5-prettier`
153153

154154
**Currently, we don't support customized Prettier config**
155+
156+
## For kintone customize developers
157+
158+
`@cybozu/eslint-config/preset/kintone-customize-es5` is a preset for kintone customize(plug-in) developers, which is based on `preset/es5` and add some `globals` for kintone.
159+
160+
```js
161+
module.exports = {
162+
extends:
163+
"@cybozu/eslint-config/presets/@cybozu/eslint-config/preset/kintone-customize-es5"
164+
};
165+
```
166+
167+
We also provide `@cybozu/eslint-config/presets/@cybozu/eslint-config/preset/kintone-customize-es5` to use it with `prettier`.

globals/kintone.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Taken from https://github.com/kintone/eslint-config-kintone
2+
module.exports = {
3+
globals: {
4+
$: false,
5+
jQuery: false,
6+
kintone: false,
7+
moment: false,
8+
Handsontable: false,
9+
hljs: false,
10+
marked: false,
11+
sweetAlert: false,
12+
swal: false,
13+
Chart: false,
14+
DOMPurify: false,
15+
Spinner: false,
16+
UltraDate: false
17+
}
18+
};

lib/kintone.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
rules: {
3+
strict: ["error", "function"]
4+
}
5+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
extends: [
3+
"../lib/es5.js",
4+
"../lib/kintone.js",
5+
"../globals/kintone.js",
6+
"../lib/prettier.js"
7+
]
8+
};

presets/kintone-customize-es5.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ["../lib/es5.js", "../lib/kintone.js", "../globals/kintone.js"]
3+
};

test/fixtures/es5/ok.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
var foos = [''];
2-
foos.map(function(foo) {
3-
return foo + foo;
4-
});
1+
(function() {
2+
'use strict';
3+
var foos = [''];
4+
foos.map(function(foo) {
5+
return foo + foo;
6+
});
7+
}());

test/fixtures/es5/warning.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
var a = 1;
2-
var b = 2;
1+
(function() {
2+
'use strict';
3+
var a = 1;
4+
var b = 2;
35

4-
alert(a + b);
6+
alert(a + b);
57

6-
[].map(function(v) {
7-
alert(v);
8-
});
8+
[].map(function(v) {
9+
alert(v);
10+
});
11+
}());
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*eslint no-undef: "error"*/
2+
unknown();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/*eslint no-undef: "error"*/
2+
$('<div />');
3+
4+
moment();

test/fixtures/kintone/error.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(function() {
2+
var a = '';
3+
alert(a);
4+
}());
5+
6+
7+
function foo() {
8+
}
9+
10+
foo();

0 commit comments

Comments
 (0)