@automattic/eslint-plugin-wpvip 0.4.8 → 0.4.9
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/configs/base.js +0 -1
- package/configs/formatting.js +9 -0
- package/configs/index.js +1 -0
- package/configs/javascript.js +69 -121
- package/package.json +1 -1
package/configs/base.js
CHANGED
package/configs/index.js
CHANGED
package/configs/javascript.js
CHANGED
|
@@ -29,6 +29,71 @@ module.exports = {
|
|
|
29
29
|
* disable errors, include a brief justification or reasoning.
|
|
30
30
|
*/
|
|
31
31
|
rules: {
|
|
32
|
+
// These rules are from eslint:recommended, but are enumerated here for
|
|
33
|
+
// visibility:
|
|
34
|
+
// https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js
|
|
35
|
+
'constructor-super': 'error',
|
|
36
|
+
'for-direction': 'error',
|
|
37
|
+
'getter-return': 'error',
|
|
38
|
+
'no-async-promise-executor': 'error',
|
|
39
|
+
'no-case-declarations': 'error',
|
|
40
|
+
'no-class-assign': 'error',
|
|
41
|
+
'no-compare-neg-zero': 'error',
|
|
42
|
+
// 'no-cond-assign': 'error', // overridden below
|
|
43
|
+
'no-const-assign': 'error',
|
|
44
|
+
'no-constant-condition': 'error',
|
|
45
|
+
'no-control-regex': 'error',
|
|
46
|
+
'no-debugger': 'error',
|
|
47
|
+
'no-delete-var': 'error',
|
|
48
|
+
'no-dupe-args': 'error',
|
|
49
|
+
'no-dupe-class-members': 'error',
|
|
50
|
+
'no-dupe-else-if': 'error',
|
|
51
|
+
'no-dupe-keys': 'error',
|
|
52
|
+
'no-duplicate-case': 'error',
|
|
53
|
+
'no-empty': 'error',
|
|
54
|
+
'no-empty-character-class': 'error',
|
|
55
|
+
'no-empty-pattern': 'error',
|
|
56
|
+
'no-ex-assign': 'error',
|
|
57
|
+
'no-extra-boolean-cast': 'error',
|
|
58
|
+
'no-extra-semi': 'error',
|
|
59
|
+
'no-fallthrough': 'error',
|
|
60
|
+
'no-func-assign': 'error',
|
|
61
|
+
'no-global-assign': 'error',
|
|
62
|
+
'no-import-assign': 'error',
|
|
63
|
+
'no-inner-declarations': 'error',
|
|
64
|
+
'no-invalid-regexp': 'error',
|
|
65
|
+
'no-irregular-whitespace': 'error',
|
|
66
|
+
'no-loss-of-precision': 'error',
|
|
67
|
+
'no-misleading-character-class': 'error',
|
|
68
|
+
'no-mixed-spaces-and-tabs': 'error',
|
|
69
|
+
'no-new-symbol': 'error',
|
|
70
|
+
'no-nonoctal-decimal-escape': 'error',
|
|
71
|
+
'no-obj-calls': 'error',
|
|
72
|
+
'no-octal': 'error',
|
|
73
|
+
'no-prototype-builtins': 'error',
|
|
74
|
+
'no-redeclare': 'error',
|
|
75
|
+
'no-regex-spaces': 'error',
|
|
76
|
+
'no-self-assign': 'error',
|
|
77
|
+
'no-setter-return': 'error',
|
|
78
|
+
'no-shadow-restricted-names': 'error',
|
|
79
|
+
'no-sparse-arrays': 'error',
|
|
80
|
+
'no-this-before-super': 'error',
|
|
81
|
+
'no-undef': 'error',
|
|
82
|
+
'no-unexpected-multiline': 'error',
|
|
83
|
+
'no-unreachable': 'error',
|
|
84
|
+
'no-unsafe-finally': 'error',
|
|
85
|
+
'no-unsafe-negation': 'error',
|
|
86
|
+
'no-unsafe-optional-chaining': 'error',
|
|
87
|
+
'no-unused-labels': 'error',
|
|
88
|
+
// 'no-unused-vars': 'error', // overridden below
|
|
89
|
+
'no-useless-backreference': 'error',
|
|
90
|
+
'no-useless-catch': 'error',
|
|
91
|
+
'no-useless-escape': 'error',
|
|
92
|
+
'no-with': 'error',
|
|
93
|
+
'require-yield': 'error',
|
|
94
|
+
'use-isnan': 'error',
|
|
95
|
+
// 'valid-typeof': 'error', // overridden below
|
|
96
|
+
|
|
32
97
|
// Async/await must not be used in a `.forEach` method, because the result
|
|
33
98
|
// will not be awaited in the outer scope.
|
|
34
99
|
'@automattic/wpvip/no-async-foreach': 'error',
|
|
@@ -40,47 +105,13 @@ module.exports = {
|
|
|
40
105
|
// Unguarded getRangeAt calls can throw errors in some browsers.
|
|
41
106
|
'@automattic/wpvip/no-unguarded-get-range-at': 'error',
|
|
42
107
|
|
|
43
|
-
'array-bracket-spacing': [ 'error', 'always' ],
|
|
44
|
-
|
|
45
108
|
'array-callback-return': 'error',
|
|
46
109
|
|
|
47
|
-
'arrow-parens': [ 'error', 'always' ],
|
|
48
|
-
|
|
49
|
-
'arrow-spacing': 'error',
|
|
50
|
-
|
|
51
|
-
'brace-style': [ 'error', '1tbs' ],
|
|
52
|
-
|
|
53
|
-
// Identifiers should be in camelCase. Object properties are excluded
|
|
54
|
-
// (including when destructuring) since they often come from external
|
|
55
|
-
// sources (like APIs).
|
|
56
|
-
camelcase: [
|
|
57
|
-
'error',
|
|
58
|
-
{
|
|
59
|
-
properties: 'never',
|
|
60
|
-
ignoreDestructuring: true,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
|
|
64
|
-
'comma-dangle': [ 'error', 'always-multiline' ],
|
|
65
|
-
|
|
66
|
-
'comma-spacing': 'error',
|
|
67
|
-
|
|
68
|
-
'comma-style': [ 'error', 'last' ],
|
|
69
|
-
|
|
70
110
|
// Maximum cyclomatic complexity must not be above 20.
|
|
71
111
|
complexity: 'error',
|
|
72
112
|
|
|
73
|
-
'computed-property-spacing': [ 'error', 'always' ],
|
|
74
|
-
|
|
75
|
-
'constructor-super': 'error',
|
|
76
|
-
|
|
77
|
-
curly: [ 'error', 'all' ],
|
|
78
|
-
|
|
79
113
|
'dot-notation': 'error',
|
|
80
114
|
|
|
81
|
-
// Files must end in a newline.
|
|
82
|
-
'eol-last': [ 'error', 'always' ],
|
|
83
|
-
|
|
84
115
|
eqeqeq: 'error',
|
|
85
116
|
|
|
86
117
|
'func-call-spacing': 'error',
|
|
@@ -108,22 +139,10 @@ module.exports = {
|
|
|
108
139
|
|
|
109
140
|
'import/no-unresolved': 'error',
|
|
110
141
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
'key-spacing': 'error',
|
|
114
|
-
|
|
115
|
-
'keyword-spacing': 'error',
|
|
116
|
-
|
|
142
|
+
// Enforce Unix linebreaks. Included here and not in "formatting" since it
|
|
143
|
+
// is not controversial and helps with interchange.
|
|
117
144
|
'linebreak-style': [ 'error', 'unix' ],
|
|
118
145
|
|
|
119
|
-
// Lines containing code should be a maximum of 200 characters in length.
|
|
120
|
-
'max-len': [
|
|
121
|
-
'warn',
|
|
122
|
-
{
|
|
123
|
-
code: 200,
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
|
|
127
146
|
'no-alert': 'error',
|
|
128
147
|
|
|
129
148
|
// Async/await must not be used in a loop, because it leads to sequential
|
|
@@ -140,18 +159,6 @@ module.exports = {
|
|
|
140
159
|
// logging function that logs on your behalf (and ignore this rule there).
|
|
141
160
|
'no-console': 'warn',
|
|
142
161
|
|
|
143
|
-
'no-const-assign': 'error',
|
|
144
|
-
|
|
145
|
-
'no-debugger': 'error',
|
|
146
|
-
|
|
147
|
-
'no-dupe-args': 'error',
|
|
148
|
-
|
|
149
|
-
'no-dupe-class-members': 'error',
|
|
150
|
-
|
|
151
|
-
'no-dupe-keys': 'error',
|
|
152
|
-
|
|
153
|
-
'no-duplicate-case': 'error',
|
|
154
|
-
|
|
155
162
|
// A single `import` statement should be used when importing multiple things
|
|
156
163
|
// from a module.
|
|
157
164
|
'no-duplicate-imports': 'error',
|
|
@@ -162,18 +169,10 @@ module.exports = {
|
|
|
162
169
|
|
|
163
170
|
'no-eval': 'error',
|
|
164
171
|
|
|
165
|
-
'no-extra-semi': 'error',
|
|
166
|
-
|
|
167
|
-
'no-fallthrough': 'error',
|
|
168
|
-
|
|
169
|
-
'no-irregular-whitespace': 'error',
|
|
170
|
-
|
|
171
172
|
'no-lonely-if': 'error',
|
|
172
173
|
|
|
173
174
|
'no-mixed-operators': 'error',
|
|
174
175
|
|
|
175
|
-
'no-mixed-spaces-and-tabs': 'error',
|
|
176
|
-
|
|
177
176
|
'no-multi-spaces': 'error',
|
|
178
177
|
|
|
179
178
|
'no-multi-str': 'error',
|
|
@@ -182,22 +181,10 @@ module.exports = {
|
|
|
182
181
|
|
|
183
182
|
'no-nested-ternary': 'error',
|
|
184
183
|
|
|
185
|
-
'no-redeclare': 'error',
|
|
186
|
-
|
|
187
184
|
'no-shadow': 'error',
|
|
188
185
|
|
|
189
|
-
'no-trailing-spaces': 'error',
|
|
190
|
-
|
|
191
|
-
'no-undef': 'error',
|
|
192
|
-
|
|
193
186
|
'no-undef-init': 'error',
|
|
194
187
|
|
|
195
|
-
'no-unreachable': 'error',
|
|
196
|
-
|
|
197
|
-
// Negating the left operand of a statment frequently leads to logical
|
|
198
|
-
// errors. Example: `!key in obj` vs. `!(key in obj)`.
|
|
199
|
-
'no-unsafe-negation': 'error',
|
|
200
|
-
|
|
201
188
|
'no-unused-expressions': 'error',
|
|
202
189
|
|
|
203
190
|
'no-unused-vars': [ 'error', { ignoreRestSiblings: true } ],
|
|
@@ -210,57 +197,18 @@ module.exports = {
|
|
|
210
197
|
|
|
211
198
|
'no-var': 'error',
|
|
212
199
|
|
|
200
|
+
// Non-controversial formatting rule.
|
|
213
201
|
'no-whitespace-before-property': 'error',
|
|
214
202
|
|
|
215
|
-
'no-with': 'error',
|
|
216
|
-
|
|
217
|
-
'object-curly-spacing': [ 'error', 'always' ],
|
|
218
|
-
|
|
219
|
-
'object-shorthand': 'error',
|
|
220
|
-
|
|
221
203
|
'one-var': [ 'error', 'never' ],
|
|
222
204
|
|
|
223
|
-
'operator-linebreak': 'error',
|
|
224
|
-
|
|
225
|
-
'padded-blocks': [ 'error', 'never' ],
|
|
226
|
-
|
|
227
|
-
// Arrow functions should be used for function arguments and callbacks.
|
|
228
|
-
'prefer-arrow-callback': 'warn',
|
|
229
|
-
|
|
230
205
|
'prefer-const': [ 'error', { destructuring: 'all' } ],
|
|
231
206
|
|
|
232
207
|
radix: 'error',
|
|
233
208
|
|
|
234
|
-
|
|
235
|
-
'error',
|
|
236
|
-
'single',
|
|
237
|
-
{ allowTemplateLiterals: true, avoidEscape: true },
|
|
238
|
-
],
|
|
239
|
-
|
|
240
|
-
'quote-props': [ 'error', 'as-needed' ],
|
|
241
|
-
|
|
209
|
+
// Non-controversial formatting rule.
|
|
242
210
|
semi: 'error',
|
|
243
211
|
|
|
244
|
-
'semi-spacing': 'error',
|
|
245
|
-
|
|
246
|
-
'space-before-blocks': [ 'error', 'always' ],
|
|
247
|
-
|
|
248
|
-
'space-before-function-paren': [
|
|
249
|
-
'error',
|
|
250
|
-
{ anonymous: 'never', named: 'never', asyncArrow: 'always' },
|
|
251
|
-
],
|
|
252
|
-
|
|
253
|
-
'space-in-parens': [ 'error', 'always' ],
|
|
254
|
-
|
|
255
|
-
'space-infix-ops': 'error',
|
|
256
|
-
|
|
257
|
-
'space-unary-ops': [ 'error', { overrides: { '!': true, yield: true } } ],
|
|
258
|
-
|
|
259
|
-
// Comments should always include consistent spacing for readability.
|
|
260
|
-
'spaced-comment': 'warn',
|
|
261
|
-
|
|
262
|
-
'template-curly-spacing': [ 'error', 'always' ],
|
|
263
|
-
|
|
264
212
|
// The result of `typeof` must always be compared to a literal string.
|
|
265
213
|
'valid-typeof': [
|
|
266
214
|
'error',
|