@darksheep/eslint 5.2.1 → 5.3.1
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/CHANGELOG.md +30 -0
- package/package.json +8 -6
- package/src/configs/eslint-base.js +103 -103
- package/src/configs/eslint-complexity.js +24 -24
- package/src/configs/eslint-ignores.js +32 -32
- package/src/configs/eslint-recommended.js +4 -4
- package/src/configs/eslint-style.js +12 -12
- package/src/custom/index.js +5 -5
- package/src/custom/instance-of-array.js +44 -44
- package/src/custom/loose-types.js +128 -128
- package/src/custom/no-useless-expression.js +19 -19
- package/src/custom/sequence-expression.js +15 -15
- package/src/index.js +39 -37
- package/src/plugins/eslint-comments.js +19 -19
- package/src/plugins/jsdoc.js +57 -57
- package/src/plugins/json.js +43 -27
- package/src/plugins/node.js +108 -108
- package/src/plugins/package-json.js +25 -25
- package/src/plugins/perfectionist.js +200 -200
- package/src/plugins/promise.js +9 -9
- package/src/plugins/react.js +111 -111
- package/src/plugins/regexp.js +6 -6
- package/src/plugins/sca.js +32 -32
- package/src/plugins/security.js +14 -14
- package/src/plugins/sonarjs.js +11 -20
- package/src/plugins/style.js +236 -236
- package/src/plugins/typescript.js +65 -65
- package/src/plugins/unicorn.js +40 -40
- package/src/plugins/unused-imports.js +25 -25
- package/src/plugins/yml.js +41 -0
- package/src/types.d.ts +80 -80
- package/src/utilities/editorconfig.js +151 -141
- package/src/utilities/eslint-files.js +20 -20
- package/src/utilities/expand-glob.js +34 -34
- package/src/utilities/filesystem.js +30 -30
- package/src/utilities/make-compat.js +6 -6
- package/src/utilities/package.js +29 -29
- package/types/src/plugins/yml.d.ts +5 -0
- package/types/src/utilities/editorconfig.d.ts +7 -0
package/src/plugins/react.js
CHANGED
|
@@ -4,88 +4,88 @@ import { getPackageJson } from '../utilities/package.js';
|
|
|
4
4
|
|
|
5
5
|
/** @type {import('eslint').Linter.RulesRecord} */
|
|
6
6
|
const rules = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
'react/display-name': 2,
|
|
8
|
+
'react/jsx-key': 2,
|
|
9
|
+
'react/jsx-no-comment-textnodes': 2,
|
|
10
|
+
'react/jsx-no-duplicate-props': 2,
|
|
11
|
+
'react/jsx-no-target-blank': 2,
|
|
12
|
+
'react/jsx-no-undef': 2,
|
|
13
|
+
'react/jsx-uses-react': 2,
|
|
14
|
+
'react/jsx-uses-vars': 2,
|
|
15
|
+
'react/no-children-prop': 2,
|
|
16
|
+
'react/no-danger-with-children': 2,
|
|
17
|
+
'react/no-deprecated': 2,
|
|
18
|
+
'react/no-direct-mutation-state': 2,
|
|
19
|
+
'react/no-find-dom-node': 2,
|
|
20
|
+
'react/no-is-mounted': 2,
|
|
21
|
+
'react/no-render-return-value': 2,
|
|
22
|
+
'react/no-string-refs': 2,
|
|
23
|
+
'react/no-unescaped-entities': 2,
|
|
24
|
+
'react/no-unknown-property': 2,
|
|
25
|
+
'react/no-unsafe': 0,
|
|
26
|
+
'react/prop-types': 2,
|
|
27
|
+
'react/react-in-jsx-scope': 2,
|
|
28
|
+
'react/require-render-return': 2,
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
30
|
+
'react/boolean-prop-naming': 0,
|
|
31
|
+
'react/button-has-type': 0,
|
|
32
|
+
'react/default-props-match-prop-types': 0,
|
|
33
|
+
'react/destructuring-assignment': 0,
|
|
34
|
+
'react/forbid-component-props': 0,
|
|
35
|
+
'react/forbid-dom-props': 0,
|
|
36
|
+
'react/forbid-elements': 0,
|
|
37
|
+
'react/forbid-foreign-prop-types': 0,
|
|
38
|
+
'react/forbid-prop-types': 0,
|
|
39
|
+
'react/function-component-definition': 0,
|
|
40
|
+
'react/hook-use-state': 0,
|
|
41
|
+
'react/iframe-missing-sandbox': 0,
|
|
42
|
+
'react/jsx-boolean-value': 0,
|
|
43
|
+
'react/jsx-filename-extension': 0,
|
|
44
|
+
'react/jsx-handler-names': 0,
|
|
45
|
+
'react/jsx-max-depth': 0,
|
|
46
|
+
'react/jsx-no-bind': 0,
|
|
47
|
+
'react/jsx-no-constructed-context-values': 0,
|
|
48
|
+
'react/jsx-no-leaked-render': 0,
|
|
49
|
+
'react/jsx-no-literals': 0,
|
|
50
|
+
'react/jsx-no-script-url': 0,
|
|
51
|
+
'react/jsx-no-useless-fragment': 0,
|
|
52
|
+
'react/jsx-pascal-case': 0,
|
|
53
|
+
'react/jsx-fragments': 0,
|
|
54
|
+
'react/jsx-props-no-spreading': 0,
|
|
55
|
+
'react/no-invalid-html-attribute': 0,
|
|
56
|
+
'react/no-access-state-in-setstate': 0,
|
|
57
|
+
'react/no-adjacent-inline-elements': 0,
|
|
58
|
+
'react/no-array-index-key': 0,
|
|
59
|
+
'react/no-arrow-function-lifecycle': 0,
|
|
60
|
+
'react/no-danger': 0,
|
|
61
|
+
'react/no-did-mount-set-state': 0,
|
|
62
|
+
'react/no-did-update-set-state': 0,
|
|
63
|
+
'react/no-multi-comp': 0,
|
|
64
|
+
'react/no-namespace': 0,
|
|
65
|
+
'react/no-set-state': 0,
|
|
66
|
+
'react/no-redundant-should-component-update': 0,
|
|
67
|
+
'react/no-this-in-sfc': 0,
|
|
68
|
+
'react/no-typos': 0,
|
|
69
|
+
'react/no-unstable-nested-components': 0,
|
|
70
|
+
'react/no-unused-class-component-methods': 0,
|
|
71
|
+
'react/no-unused-prop-types': 0,
|
|
72
|
+
'react/no-unused-state': 0,
|
|
73
|
+
'react/no-object-type-as-default-prop': 0,
|
|
74
|
+
'react/no-will-update-set-state': 0,
|
|
75
|
+
'react/prefer-es6-class': 0,
|
|
76
|
+
'react/prefer-exact-props': 0,
|
|
77
|
+
'react/prefer-read-only-props': 0,
|
|
78
|
+
'react/prefer-stateless-function': 0,
|
|
79
|
+
'react/require-default-props': 0,
|
|
80
|
+
'react/require-optimization': 0,
|
|
81
|
+
'react/self-closing-comp': 0,
|
|
82
|
+
'react/sort-comp': 0,
|
|
83
|
+
'react/sort-default-props': 0,
|
|
84
|
+
'react/sort-prop-types': 0,
|
|
85
|
+
'react/state-in-constructor': 0,
|
|
86
|
+
'react/static-property-placement': 0,
|
|
87
|
+
'react/style-prop-object': 0,
|
|
88
|
+
'react/void-dom-elements-no-children': 0,
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
/**
|
|
@@ -94,37 +94,37 @@ const rules = {
|
|
|
94
94
|
* @returns {Promise<import('eslint').Linter.FlatConfig[]>}
|
|
95
95
|
*/
|
|
96
96
|
export async function createEslintReactConfig(root) {
|
|
97
|
-
|
|
97
|
+
const packageJson = await getPackageJson(root, 'react');
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
settings: {
|
|
109
|
-
react: { version: packageJson?.version },
|
|
110
|
-
},
|
|
111
|
-
plugins: { react },
|
|
112
|
-
rules: rules,
|
|
99
|
+
return [
|
|
100
|
+
{
|
|
101
|
+
name: 'react/jsx',
|
|
102
|
+
files: [ '**/*.jsx' ],
|
|
103
|
+
languageOptions: {
|
|
104
|
+
parserOptions: {
|
|
105
|
+
ecmaFeatures: { jsx: true },
|
|
113
106
|
},
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
107
|
+
},
|
|
108
|
+
settings: {
|
|
109
|
+
react: { version: packageJson?.version },
|
|
110
|
+
},
|
|
111
|
+
plugins: { react },
|
|
112
|
+
rules: rules,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'react/tsx',
|
|
116
|
+
files: [ '**/*.tsx' ],
|
|
117
|
+
languageOptions: {
|
|
118
|
+
parserOptions: {
|
|
119
|
+
ecmaFeatures: { jsx: true },
|
|
120
|
+
jsxPragma: null,
|
|
128
121
|
},
|
|
129
|
-
|
|
122
|
+
},
|
|
123
|
+
settings: {
|
|
124
|
+
react: { version: packageJson?.version },
|
|
125
|
+
},
|
|
126
|
+
plugins: { react },
|
|
127
|
+
rules: rules,
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
130
|
}
|
package/src/plugins/regexp.js
CHANGED
|
@@ -5,10 +5,10 @@ import regexp from 'eslint-plugin-regexp';
|
|
|
5
5
|
* @returns {import('eslint').Linter.FlatConfig[]}
|
|
6
6
|
*/
|
|
7
7
|
export function createEslintRegexpConfig() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
name: 'regexp/recommended',
|
|
11
|
+
...regexp.configs['flat/recommended'],
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
14
|
}
|
package/src/plugins/sca.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import sca from '../custom/index.js';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
getCommonFiles,
|
|
4
|
+
getModuleFiles,
|
|
5
|
+
getTypescriptFiles,
|
|
6
6
|
} from '../utilities/eslint-files.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -11,33 +11,33 @@ import {
|
|
|
11
11
|
* @returns {Promise<import('eslint').Linter.FlatConfig[]>}
|
|
12
12
|
*/
|
|
13
13
|
export async function createEslintSCAConfig(root) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
name: 'sca/javascript',
|
|
17
|
+
files: [
|
|
18
|
+
...await getCommonFiles(root),
|
|
19
|
+
...await getModuleFiles(root),
|
|
20
|
+
],
|
|
21
|
+
plugins: { sca },
|
|
22
|
+
rules: {
|
|
23
|
+
'sca/loose-types': [
|
|
24
|
+
'error',
|
|
25
|
+
{
|
|
26
|
+
allowConditionalExpressionCallExpression: true,
|
|
27
|
+
allowLogicalExpressionCallExpression: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
'sca/no-useless-expression': 'error',
|
|
31
|
+
'sca/sequence-expression': 'error',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'sca/typescript',
|
|
36
|
+
files: getTypescriptFiles(),
|
|
37
|
+
plugins: { sca },
|
|
38
|
+
rules: {
|
|
39
|
+
'sca/sequence-expression': 'error',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
43
|
}
|
package/src/plugins/security.js
CHANGED
|
@@ -5,20 +5,20 @@ import security from 'eslint-plugin-security';
|
|
|
5
5
|
* @returns {import('eslint').Linter.FlatConfig[]}
|
|
6
6
|
*/
|
|
7
7
|
export function createEslintSecurityConfig() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
return [ {
|
|
9
|
+
name: 'security/recommended',
|
|
10
|
+
plugins: { security },
|
|
11
|
+
rules: {
|
|
12
|
+
...security.configs.recommended.rules,
|
|
13
|
+
'security/detect-object-injection': 0,
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
// I dont particularly care here..
|
|
16
|
+
'security/detect-non-literal-fs-filename': 0,
|
|
17
|
+
'security/detect-non-literal-require': 0,
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
// eslint-plugin-regexp does this better...
|
|
20
|
+
'security/detect-non-literal-regexp': 0,
|
|
21
|
+
'security/detect-unsafe-regex': 0,
|
|
22
|
+
},
|
|
23
|
+
} ];
|
|
24
24
|
}
|
package/src/plugins/sonarjs.js
CHANGED
|
@@ -5,24 +5,15 @@ import sonarjs from 'eslint-plugin-sonarjs';
|
|
|
5
5
|
* @returns {import('eslint').Linter.FlatConfig[]}
|
|
6
6
|
*/
|
|
7
7
|
export function createEslintSonarJSConfig() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
files: [
|
|
20
|
-
'**/*.test.*',
|
|
21
|
-
'*.test.*',
|
|
22
|
-
],
|
|
23
|
-
rules: {
|
|
24
|
-
'sonarjs/no-duplicate-string': 'off',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
];
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
name: 'sonarjs/recommended',
|
|
11
|
+
plugins: { sonarjs },
|
|
12
|
+
rules: {
|
|
13
|
+
...sonarjs.configs.recommended.rules,
|
|
14
|
+
'sonarjs/cognitive-complexity': 'error',
|
|
15
|
+
'sonarjs/no-duplicate-string': 'off',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
];
|
|
28
19
|
}
|