@agilebot/eslint-config 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/cli.js +49 -49
- package/lib/configs/eslint.js +23 -23
- package/lib/index.js +56 -56
- package/package.json +1 -1
package/lib/cli.js
CHANGED
@@ -1,49 +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
|
-
};
|
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/index.js
CHANGED
@@ -1,56 +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
|
-
'./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
|
-
};
|
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
|
+
};
|