@agilebot/eslint-config 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/eslint-agilebot +2 -0
- package/lib/cli.js +49 -0
- package/lib/configs/eslint.js +1 -1
- package/lib/configs/ts.js +1 -0
- package/lib/index.js +6 -1
- package/package.json +14 -3
package/lib/cli.js
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
const fs = require('node:fs');
|
2
|
+
const path = require('node:path');
|
3
|
+
|
4
|
+
module.exports = function (filename) {
|
5
|
+
filename = filename || path.join(__dirname, 'index');
|
6
|
+
|
7
|
+
const isEslint = /^\.eslint.*/;
|
8
|
+
const cwd = process.cwd();
|
9
|
+
const has = {
|
10
|
+
fix: false,
|
11
|
+
config: false
|
12
|
+
};
|
13
|
+
|
14
|
+
process.argv.forEach(function (arg) {
|
15
|
+
has.fix = has.fix || arg === '--fix';
|
16
|
+
has.config = has.config || arg === '-c' || arg === '--config';
|
17
|
+
});
|
18
|
+
|
19
|
+
if (!has.fix) {
|
20
|
+
process.argv.splice(2, 0, '--fix');
|
21
|
+
}
|
22
|
+
|
23
|
+
//
|
24
|
+
// Only force our config file if there is one not in the current
|
25
|
+
// directory AND not specified by the command line.
|
26
|
+
//
|
27
|
+
|
28
|
+
// eslint-disable-next-line n/prefer-promises/fs -- Not available in Node.js 10
|
29
|
+
fs.readdir(cwd, function (err, files) {
|
30
|
+
if (err) {
|
31
|
+
throw err;
|
32
|
+
}
|
33
|
+
|
34
|
+
has.config =
|
35
|
+
has.config ||
|
36
|
+
files.some(function (file) {
|
37
|
+
return isEslint.test(file);
|
38
|
+
});
|
39
|
+
|
40
|
+
if (!has.config) {
|
41
|
+
process.argv.splice(2, 0, '-c', require.resolve(filename));
|
42
|
+
}
|
43
|
+
|
44
|
+
const pkg = require.resolve('eslint/package.json');
|
45
|
+
const bin = path.join(pkg, '..', 'bin', 'eslint.js');
|
46
|
+
|
47
|
+
require(bin);
|
48
|
+
});
|
49
|
+
};
|
package/lib/configs/eslint.js
CHANGED
@@ -11,7 +11,7 @@ module.exports = {
|
|
11
11
|
'eslint-comments/no-duplicate-disable': 'error',
|
12
12
|
// 禁止聚合的eslint-enable注释
|
13
13
|
'eslint-comments/no-aggregating-enable': 'error',
|
14
|
-
// eslint-disable
|
14
|
+
// 须说明原因eslint-disable
|
15
15
|
'eslint-comments/require-description': [
|
16
16
|
'error',
|
17
17
|
{
|
package/lib/configs/ts.js
CHANGED
package/lib/index.js
CHANGED
@@ -26,7 +26,6 @@ module.exports = {
|
|
26
26
|
'./configs/deprecation',
|
27
27
|
'./configs/cspell',
|
28
28
|
'./configs/agilebot',
|
29
|
-
// prettier始终放在最后
|
30
29
|
'./configs/prettier'
|
31
30
|
]
|
32
31
|
},
|
@@ -46,6 +45,12 @@ module.exports = {
|
|
46
45
|
// .d.ts中忽略三斜线引用
|
47
46
|
'@typescript-eslint/triple-slash-reference': 'off'
|
48
47
|
}
|
48
|
+
},
|
49
|
+
{
|
50
|
+
files: ['*.js', '*.jsx', '*.cjs'],
|
51
|
+
rules: {
|
52
|
+
'@typescript-eslint/no-var-requires': 'off'
|
53
|
+
}
|
49
54
|
}
|
50
55
|
]
|
51
56
|
};
|
package/package.json
CHANGED
@@ -1,14 +1,24 @@
|
|
1
1
|
{
|
2
2
|
"name": "@agilebot/eslint-config",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.4",
|
4
4
|
"description": "Agilebot's ESLint config",
|
5
|
+
"bin": {
|
6
|
+
"eslint-agilebot": "bin/eslint-agilebot"
|
7
|
+
},
|
5
8
|
"main": "lib",
|
6
9
|
"license": "MIT",
|
10
|
+
"keywords": [
|
11
|
+
"eslint",
|
12
|
+
"eslint-config"
|
13
|
+
],
|
7
14
|
"repository": {
|
8
15
|
"url": "sh-agilebot/frontend-toolkit",
|
9
16
|
"directory": "packages/eslint-config"
|
10
17
|
},
|
11
18
|
"homepage": "https://github.com/sh-agilebot/frontend-toolkit/tree/master/packages/eslint-config#readme",
|
19
|
+
"engines": {
|
20
|
+
"node": "^18.0.0"
|
21
|
+
},
|
12
22
|
"dependencies": {
|
13
23
|
"@cspell/eslint-plugin": "^8.6.0",
|
14
24
|
"@stylistic/eslint-plugin": "^1.7.0",
|
@@ -37,10 +47,11 @@
|
|
37
47
|
"peerDependencies": {
|
38
48
|
"@agilebot/eslint-plugin": "*",
|
39
49
|
"@agilebot/eslint-utils": "*",
|
40
|
-
"eslint": "^8.0.0"
|
50
|
+
"eslint": "^7.0.0 || ^8.0.0"
|
41
51
|
},
|
42
52
|
"files": [
|
43
|
-
"lib"
|
53
|
+
"lib",
|
54
|
+
"bin"
|
44
55
|
],
|
45
56
|
"scripts": {
|
46
57
|
"lint": "eslint lib --fix"
|