@automattic/eslint-plugin-wpvip 0.4.9 → 0.4.11
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/.eslintrc.js +1 -0
- package/configs/formatting.js +101 -0
- package/configs/index.js +1 -0
- package/configs/javascript.js +6 -20
- package/configs/weak-javascript.js +50 -5
- package/configs/weak-testing.js +24 -0
- package/package.json +1 -1
package/.eslintrc.js
CHANGED
package/configs/formatting.js
CHANGED
|
@@ -4,6 +4,107 @@ module.exports = {
|
|
|
4
4
|
* disable errors, include a brief justification or reasoning.
|
|
5
5
|
*/
|
|
6
6
|
rules: {
|
|
7
|
+
'array-bracket-spacing': [ 'error', 'always' ],
|
|
8
|
+
|
|
9
|
+
'arrow-parens': [ 'error', 'always' ],
|
|
10
|
+
|
|
11
|
+
'arrow-spacing': 'error',
|
|
12
|
+
|
|
13
|
+
'brace-style': [ 'error', '1tbs' ],
|
|
14
|
+
|
|
15
|
+
// Identifiers should be in camelCase. Object properties are excluded
|
|
16
|
+
// (including when destructuring) since they often come from external
|
|
17
|
+
// sources (like APIs).
|
|
18
|
+
camelcase: [
|
|
19
|
+
'error',
|
|
20
|
+
{
|
|
21
|
+
properties: 'never',
|
|
22
|
+
ignoreDestructuring: true,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
'comma-dangle': [ 'error', 'always-multiline' ],
|
|
27
|
+
|
|
28
|
+
'comma-spacing': 'error',
|
|
29
|
+
|
|
30
|
+
'comma-style': [ 'error', 'last' ],
|
|
31
|
+
|
|
32
|
+
'computed-property-spacing': [ 'error', 'always' ],
|
|
33
|
+
|
|
34
|
+
curly: [ 'error', 'all' ],
|
|
35
|
+
|
|
36
|
+
'dot-notation': 'error',
|
|
37
|
+
|
|
38
|
+
// Files must end in a newline.
|
|
39
|
+
'eol-last': [ 'error', 'always' ],
|
|
40
|
+
|
|
41
|
+
'func-call-spacing': 'error',
|
|
42
|
+
|
|
43
|
+
indent: [ 'error', 'tab', { SwitchCase: 1 } ],
|
|
44
|
+
|
|
45
|
+
'key-spacing': 'error',
|
|
46
|
+
|
|
47
|
+
'keyword-spacing': 'error',
|
|
48
|
+
|
|
49
|
+
// Lines containing code should be a maximum of 200 characters in length.
|
|
50
|
+
'max-len': [
|
|
51
|
+
'warn',
|
|
52
|
+
{
|
|
53
|
+
code: 200,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
|
|
57
|
+
'no-multi-spaces': 'error',
|
|
58
|
+
|
|
59
|
+
'no-multi-str': 'error',
|
|
60
|
+
|
|
61
|
+
'no-multiple-empty-lines': [ 'error', { max: 1 } ],
|
|
62
|
+
|
|
63
|
+
'no-trailing-spaces': 'error',
|
|
64
|
+
|
|
65
|
+
'no-whitespace-before-property': 'error',
|
|
66
|
+
|
|
67
|
+
'object-curly-spacing': [ 'error', 'always' ],
|
|
68
|
+
|
|
69
|
+
'object-shorthand': 'error',
|
|
70
|
+
|
|
71
|
+
'operator-linebreak': 'error',
|
|
72
|
+
|
|
73
|
+
'padded-blocks': [ 'error', 'never' ],
|
|
74
|
+
|
|
75
|
+
// Arrow functions should be used for function arguments and callbacks.
|
|
76
|
+
'prefer-arrow-callback': 'warn',
|
|
77
|
+
|
|
78
|
+
quotes: [
|
|
79
|
+
'error',
|
|
80
|
+
'single',
|
|
81
|
+
{ allowTemplateLiterals: true, avoidEscape: true },
|
|
82
|
+
],
|
|
83
|
+
|
|
84
|
+
'quote-props': [ 'error', 'as-needed' ],
|
|
85
|
+
|
|
86
|
+
semi: 'error',
|
|
87
|
+
|
|
88
|
+
'semi-spacing': 'error',
|
|
89
|
+
|
|
90
|
+
'space-before-blocks': [ 'error', 'always' ],
|
|
91
|
+
|
|
92
|
+
'space-before-function-paren': [
|
|
93
|
+
'error',
|
|
94
|
+
{ anonymous: 'never', named: 'never', asyncArrow: 'always' },
|
|
95
|
+
],
|
|
96
|
+
|
|
97
|
+
'space-in-parens': [ 'error', 'always' ],
|
|
98
|
+
|
|
99
|
+
'space-infix-ops': 'error',
|
|
100
|
+
|
|
101
|
+
'space-unary-ops': [ 'error', { overrides: { '!': true, yield: true } } ],
|
|
102
|
+
|
|
103
|
+
// Comments should always include consistent spacing for readability.
|
|
104
|
+
'spaced-comment': 'warn',
|
|
105
|
+
|
|
106
|
+
'template-curly-spacing': [ 'error', 'always' ],
|
|
107
|
+
|
|
7
108
|
},
|
|
8
109
|
};
|
|
9
110
|
|
package/configs/index.js
CHANGED
package/configs/javascript.js
CHANGED
|
@@ -39,7 +39,7 @@ module.exports = {
|
|
|
39
39
|
'no-case-declarations': 'error',
|
|
40
40
|
'no-class-assign': 'error',
|
|
41
41
|
'no-compare-neg-zero': 'error',
|
|
42
|
-
// 'no-cond-assign': 'error', //
|
|
42
|
+
// 'no-cond-assign': 'error', // extended below
|
|
43
43
|
'no-const-assign': 'error',
|
|
44
44
|
'no-constant-condition': 'error',
|
|
45
45
|
'no-control-regex': 'error',
|
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
|
50
50
|
'no-dupe-else-if': 'error',
|
|
51
51
|
'no-dupe-keys': 'error',
|
|
52
52
|
'no-duplicate-case': 'error',
|
|
53
|
-
'no-empty': 'error',
|
|
53
|
+
// 'no-empty': 'error', // extended below
|
|
54
54
|
'no-empty-character-class': 'error',
|
|
55
55
|
'no-empty-pattern': 'error',
|
|
56
56
|
'no-ex-assign': 'error',
|
|
@@ -85,14 +85,14 @@ module.exports = {
|
|
|
85
85
|
'no-unsafe-negation': 'error',
|
|
86
86
|
'no-unsafe-optional-chaining': 'error',
|
|
87
87
|
'no-unused-labels': 'error',
|
|
88
|
-
// 'no-unused-vars': 'error', //
|
|
88
|
+
// 'no-unused-vars': 'error', // extended below
|
|
89
89
|
'no-useless-backreference': 'error',
|
|
90
90
|
'no-useless-catch': 'error',
|
|
91
91
|
'no-useless-escape': 'error',
|
|
92
92
|
'no-with': 'error',
|
|
93
93
|
'require-yield': 'error',
|
|
94
94
|
'use-isnan': 'error',
|
|
95
|
-
// 'valid-typeof': 'error', //
|
|
95
|
+
// 'valid-typeof': 'error', // extended below
|
|
96
96
|
|
|
97
97
|
// Async/await must not be used in a `.forEach` method, because the result
|
|
98
98
|
// will not be awaited in the outer scope.
|
|
@@ -110,12 +110,8 @@ module.exports = {
|
|
|
110
110
|
// Maximum cyclomatic complexity must not be above 20.
|
|
111
111
|
complexity: 'error',
|
|
112
112
|
|
|
113
|
-
'dot-notation': 'error',
|
|
114
|
-
|
|
115
113
|
eqeqeq: 'error',
|
|
116
114
|
|
|
117
|
-
'func-call-spacing': 'error',
|
|
118
|
-
|
|
119
115
|
// Identifiers should be between 2 and 40 characters in length in order to
|
|
120
116
|
// provide a concise semantic meaning.
|
|
121
117
|
'id-length': [
|
|
@@ -165,6 +161,8 @@ module.exports = {
|
|
|
165
161
|
|
|
166
162
|
'no-else-return': 'error',
|
|
167
163
|
|
|
164
|
+
'no-empty': [ 'error', { allowEmptyCatch: true } ],
|
|
165
|
+
|
|
168
166
|
'no-eq-null': 'error',
|
|
169
167
|
|
|
170
168
|
'no-eval': 'error',
|
|
@@ -173,12 +171,6 @@ module.exports = {
|
|
|
173
171
|
|
|
174
172
|
'no-mixed-operators': 'error',
|
|
175
173
|
|
|
176
|
-
'no-multi-spaces': 'error',
|
|
177
|
-
|
|
178
|
-
'no-multi-str': 'error',
|
|
179
|
-
|
|
180
|
-
'no-multiple-empty-lines': [ 'error', { max: 1 } ],
|
|
181
|
-
|
|
182
174
|
'no-nested-ternary': 'error',
|
|
183
175
|
|
|
184
176
|
'no-shadow': 'error',
|
|
@@ -197,18 +189,12 @@ module.exports = {
|
|
|
197
189
|
|
|
198
190
|
'no-var': 'error',
|
|
199
191
|
|
|
200
|
-
// Non-controversial formatting rule.
|
|
201
|
-
'no-whitespace-before-property': 'error',
|
|
202
|
-
|
|
203
192
|
'one-var': [ 'error', 'never' ],
|
|
204
193
|
|
|
205
194
|
'prefer-const': [ 'error', { destructuring: 'all' } ],
|
|
206
195
|
|
|
207
196
|
radix: 'error',
|
|
208
197
|
|
|
209
|
-
// Non-controversial formatting rule.
|
|
210
|
-
semi: 'error',
|
|
211
|
-
|
|
212
198
|
// The result of `typeof` must always be compared to a literal string.
|
|
213
199
|
'valid-typeof': [
|
|
214
200
|
'error',
|
|
@@ -7,9 +7,54 @@
|
|
|
7
7
|
* temporary basis.
|
|
8
8
|
*/
|
|
9
9
|
module.exports = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
overrides: [
|
|
11
|
+
{
|
|
12
|
+
// Don't apply weak rules to TypeScript files.
|
|
13
|
+
files: [ '**/*.js', '**/*.jsx' ],
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Downgrade rules from the base preset to "warn". Do not disable rules (set
|
|
17
|
+
* to "off"). If a rule is already set to a warning, do not disable it.
|
|
18
|
+
*/
|
|
19
|
+
rules: {
|
|
20
|
+
'@automattic/wpvip/no-unused-vars-before-return': 'warn',
|
|
21
|
+
|
|
22
|
+
complexity: 'warn',
|
|
23
|
+
|
|
24
|
+
eqeqeq: 'warn',
|
|
25
|
+
|
|
26
|
+
'object-shorthand': 'warn',
|
|
27
|
+
|
|
28
|
+
'no-async-promise-executor': 'warn',
|
|
29
|
+
|
|
30
|
+
'no-await-in-loop': 'warn',
|
|
31
|
+
|
|
32
|
+
'no-case-declarations': 'warn',
|
|
33
|
+
|
|
34
|
+
'no-dupe-else-if': 'warn',
|
|
35
|
+
|
|
36
|
+
'no-else-return': 'warn',
|
|
37
|
+
|
|
38
|
+
'no-eq-null': 'warn',
|
|
39
|
+
|
|
40
|
+
'no-lonely-if': 'warn',
|
|
41
|
+
|
|
42
|
+
'no-mixed-operators': 'warn',
|
|
43
|
+
|
|
44
|
+
'no-prototype-builtins': 'warn',
|
|
45
|
+
|
|
46
|
+
'no-shadow': 'warn',
|
|
47
|
+
|
|
48
|
+
'no-unused-vars': 'warn',
|
|
49
|
+
|
|
50
|
+
'no-useless-escape': 'warn',
|
|
51
|
+
|
|
52
|
+
'no-var': 'warn',
|
|
53
|
+
|
|
54
|
+
'one-var': 'warn',
|
|
55
|
+
|
|
56
|
+
radix: 'warn',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
],
|
|
15
60
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Weak" testing rules
|
|
3
|
+
* ====================
|
|
4
|
+
* These rules are intended for codebases that are transitioning to the stronger
|
|
5
|
+
* testing preset but need weaker rules to prevent a massive number of changes.
|
|
6
|
+
* They do not provide good protection or standardization, but can useful on a
|
|
7
|
+
* temporary basis.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = {
|
|
10
|
+
/**
|
|
11
|
+
* Downgrade rules from the testing preset to "warn". Do not disable rules
|
|
12
|
+
* (set to "off"). If a rule is already set to a warning, do not disable it.
|
|
13
|
+
*/
|
|
14
|
+
rules: {
|
|
15
|
+
'jest/no-alias-methods': 'warn',
|
|
16
|
+
|
|
17
|
+
'jest/no-done-callback': 'warn',
|
|
18
|
+
|
|
19
|
+
'jest/no-conditional-expect': 'warn',
|
|
20
|
+
|
|
21
|
+
'jest/no-standalone-expect': 'warn',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|