@agilebot/eslint-config 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/eslint-agilebot +2 -0
- package/lib/cli.js +49 -0
- package/lib/configs/eslint.js +23 -23
- package/lib/configs/ts.js +1 -0
- package/lib/index.js +56 -51
- 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
@@ -1,23 +1,23 @@
|
|
1
|
-
const { isCI } = require('@agilebot/eslint-utils');
|
2
|
-
|
3
|
-
module.exports = {
|
4
|
-
plugins: ['eslint-comments', 'file-progress'],
|
5
|
-
rules: {
|
6
|
-
// 禁止未使用的eslint-disable注释
|
7
|
-
'eslint-comments/no-unused-disable': 'error',
|
8
|
-
// 禁止无限制的eslint-disable注释
|
9
|
-
'eslint-comments/no-unlimited-disable': 'error',
|
10
|
-
// 禁止重复的eslint-disable注释
|
11
|
-
'eslint-comments/no-duplicate-disable': 'error',
|
12
|
-
// 禁止聚合的eslint-enable注释
|
13
|
-
'eslint-comments/no-aggregating-enable': 'error',
|
14
|
-
// eslint-disable
|
15
|
-
'eslint-comments/require-description': [
|
16
|
-
'error',
|
17
|
-
{
|
18
|
-
ignore: ['eslint-env', 'exported', 'global', 'globals']
|
19
|
-
}
|
20
|
-
],
|
21
|
-
'file-progress/activate': isCI() ? 'off' : 'warn'
|
22
|
-
}
|
23
|
-
};
|
1
|
+
const { isCI } = require('@agilebot/eslint-utils');
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
plugins: ['eslint-comments', 'file-progress'],
|
5
|
+
rules: {
|
6
|
+
// 禁止未使用的eslint-disable注释
|
7
|
+
'eslint-comments/no-unused-disable': 'error',
|
8
|
+
// 禁止无限制的eslint-disable注释
|
9
|
+
'eslint-comments/no-unlimited-disable': 'error',
|
10
|
+
// 禁止重复的eslint-disable注释
|
11
|
+
'eslint-comments/no-duplicate-disable': 'error',
|
12
|
+
// 禁止聚合的eslint-enable注释
|
13
|
+
'eslint-comments/no-aggregating-enable': 'error',
|
14
|
+
// 须说明原因eslint-disable
|
15
|
+
'eslint-comments/require-description': [
|
16
|
+
'error',
|
17
|
+
{
|
18
|
+
ignore: ['eslint-env', 'exported', 'global', 'globals']
|
19
|
+
}
|
20
|
+
],
|
21
|
+
'file-progress/activate': isCI() ? 'off' : 'warn'
|
22
|
+
}
|
23
|
+
};
|
package/lib/configs/ts.js
CHANGED
package/lib/index.js
CHANGED
@@ -1,51 +1,56 @@
|
|
1
|
-
module.exports = {
|
2
|
-
overrides: [
|
3
|
-
{
|
4
|
-
files: [
|
5
|
-
'*.ts',
|
6
|
-
'*.tsx',
|
7
|
-
'*.cts',
|
8
|
-
'*.mts',
|
9
|
-
'*.js',
|
10
|
-
'*.jsx',
|
11
|
-
'*.cjs',
|
12
|
-
'*.mjs'
|
13
|
-
],
|
14
|
-
parser: '@typescript-eslint/parser',
|
15
|
-
extends: [
|
16
|
-
'./configs/env',
|
17
|
-
'./configs/standard',
|
18
|
-
'./configs/ts',
|
19
|
-
'./configs/promise',
|
20
|
-
'./configs/import',
|
21
|
-
'./configs/unicorn',
|
22
|
-
'./configs/react',
|
23
|
-
'./configs/jsdoc',
|
24
|
-
'./configs/lodash',
|
25
|
-
'./configs/eslint',
|
26
|
-
'./configs/deprecation',
|
27
|
-
'./configs/cspell',
|
28
|
-
'./configs/agilebot',
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
1
|
+
module.exports = {
|
2
|
+
overrides: [
|
3
|
+
{
|
4
|
+
files: [
|
5
|
+
'*.ts',
|
6
|
+
'*.tsx',
|
7
|
+
'*.cts',
|
8
|
+
'*.mts',
|
9
|
+
'*.js',
|
10
|
+
'*.jsx',
|
11
|
+
'*.cjs',
|
12
|
+
'*.mjs'
|
13
|
+
],
|
14
|
+
parser: '@typescript-eslint/parser',
|
15
|
+
extends: [
|
16
|
+
'./configs/env',
|
17
|
+
'./configs/standard',
|
18
|
+
'./configs/ts',
|
19
|
+
'./configs/promise',
|
20
|
+
'./configs/import',
|
21
|
+
'./configs/unicorn',
|
22
|
+
'./configs/react',
|
23
|
+
'./configs/jsdoc',
|
24
|
+
'./configs/lodash',
|
25
|
+
'./configs/eslint',
|
26
|
+
'./configs/deprecation',
|
27
|
+
'./configs/cspell',
|
28
|
+
'./configs/agilebot',
|
29
|
+
'./configs/prettier'
|
30
|
+
]
|
31
|
+
},
|
32
|
+
{
|
33
|
+
files: ['*.ts', '*.tsx'],
|
34
|
+
rules: {
|
35
|
+
'@typescript-eslint/explicit-member-accessibility': 'error'
|
36
|
+
}
|
37
|
+
},
|
38
|
+
{
|
39
|
+
files: ['*.d.ts'],
|
40
|
+
rules: {
|
41
|
+
// .d.ts中支持导入ts文件中的类型
|
42
|
+
'@typescript-eslint/consistent-type-imports': 'off',
|
43
|
+
// .d.ts中忽略属性命名规则
|
44
|
+
'@typescript-eslint/naming-convention': 'off',
|
45
|
+
// .d.ts中忽略三斜线引用
|
46
|
+
'@typescript-eslint/triple-slash-reference': 'off'
|
47
|
+
}
|
48
|
+
},
|
49
|
+
{
|
50
|
+
files: ['*.js', '*.jsx', '*.cjs'],
|
51
|
+
rules: {
|
52
|
+
'@typescript-eslint/no-var-requires': 'off'
|
53
|
+
}
|
54
|
+
}
|
55
|
+
]
|
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.3",
|
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"
|