@automattic/eslint-plugin-wpvip 0.13.1 → 1.1.0
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/cli.js +14 -11
- package/configs/formatting.js +69 -66
- package/configs/index.js +4 -1
- package/configs/javascript.js +235 -217
- package/configs/jsdoc.js +66 -62
- package/configs/prettier.js +10 -6
- package/configs/react.js +47 -45
- package/configs/recommended.js +7 -13
- package/configs/testing.js +19 -18
- package/configs/typescript.js +95 -73
- package/configs/weak-javascript.js +41 -59
- package/configs/weak-testing.js +14 -13
- package/configs/weak-typescript.js +25 -27
- package/eslint.config.js +13 -0
- package/index.js +6 -4
- package/package.json +28 -29
- package/plugin.js +12 -0
- package/rules/nestjs-route-prefix.js +15 -2
- package/rules/no-async-foreach.js +12 -1
- package/rules/no-unguarded-get-range-at.js +1 -0
- package/init.js +0 -1
package/configs/javascript.js
CHANGED
|
@@ -6,257 +6,275 @@
|
|
|
6
6
|
* - https://github.com/WordPress/gutenberg/blob/%40wordpress/eslint-plugin%4014.1.0/packages/eslint-plugin/configs/recommended-with-formatting.js
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
const babelParser = require( '@babel/eslint-parser' );
|
|
10
|
+
const ImportPlugin = require( 'eslint-plugin-import' );
|
|
11
|
+
const JsonPlugin = require( 'eslint-plugin-json' );
|
|
12
|
+
const PromisePlugin = require( 'eslint-plugin-promise' );
|
|
13
|
+
const SecurityPluginConfigs = require( 'eslint-plugin-security' );
|
|
14
|
+
const UnusedImportsPlugin = require( 'eslint-plugin-unused-imports' );
|
|
15
|
+
const globals = require( 'globals' );
|
|
16
|
+
|
|
17
|
+
/** @type import('eslint').Linter.Config[] */
|
|
18
|
+
module.exports = [
|
|
19
|
+
JsonPlugin.configs.recommended,
|
|
20
|
+
{
|
|
21
|
+
files: [ '**/tsconfig*.json' ],
|
|
22
|
+
rules: {
|
|
23
|
+
'json/*': [ 'error', { allowComments: true } ],
|
|
24
|
+
},
|
|
22
25
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* Please include a short description of the rule. For rules that downgrade or
|
|
31
|
-
* disable errors, include a brief justification or reasoning.
|
|
32
|
-
*/
|
|
33
|
-
rules: {
|
|
34
|
-
// BEGIN eslint:recommended, enumerated here for visibility:
|
|
35
|
-
// https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js
|
|
36
|
-
'constructor-super': 'error',
|
|
37
|
-
'for-direction': 'error',
|
|
38
|
-
'getter-return': 'error',
|
|
39
|
-
'no-async-promise-executor': 'error',
|
|
40
|
-
'no-case-declarations': 'error',
|
|
41
|
-
'no-class-assign': 'error',
|
|
42
|
-
'no-compare-neg-zero': 'error',
|
|
43
|
-
// 'no-cond-assign': 'error', // extended below
|
|
44
|
-
'no-const-assign': 'error',
|
|
45
|
-
'no-constant-binary-expression': 'error',
|
|
46
|
-
'no-constant-condition': 'error',
|
|
47
|
-
'no-control-regex': 'error',
|
|
48
|
-
'no-debugger': 'error',
|
|
49
|
-
'no-delete-var': 'error',
|
|
50
|
-
'no-dupe-args': 'error',
|
|
51
|
-
'no-dupe-class-members': 'error',
|
|
52
|
-
'no-dupe-else-if': 'error',
|
|
53
|
-
'no-dupe-keys': 'error',
|
|
54
|
-
'no-duplicate-case': 'error',
|
|
55
|
-
// 'no-empty': 'error', // extended below
|
|
56
|
-
'no-empty-character-class': 'error',
|
|
57
|
-
'no-empty-pattern': 'error',
|
|
58
|
-
'no-ex-assign': 'error',
|
|
59
|
-
'no-extra-boolean-cast': 'error',
|
|
60
|
-
'no-extra-semi': 'error',
|
|
61
|
-
'no-fallthrough': 'error',
|
|
62
|
-
'no-func-assign': 'error',
|
|
63
|
-
'no-global-assign': 'error',
|
|
64
|
-
'no-import-assign': 'error',
|
|
65
|
-
'no-inner-declarations': 'error',
|
|
66
|
-
'no-invalid-regexp': 'error',
|
|
67
|
-
'no-irregular-whitespace': 'error',
|
|
68
|
-
'no-loss-of-precision': 'error',
|
|
69
|
-
'no-misleading-character-class': 'error',
|
|
70
|
-
'no-mixed-spaces-and-tabs': 'error',
|
|
71
|
-
'no-new-symbol': 'error',
|
|
72
|
-
'no-nonoctal-decimal-escape': 'error',
|
|
73
|
-
'no-obj-calls': 'error',
|
|
74
|
-
'no-octal': 'error',
|
|
75
|
-
'no-prototype-builtins': 'error',
|
|
76
|
-
'no-redeclare': 'error',
|
|
77
|
-
'no-regex-spaces': 'error',
|
|
78
|
-
'no-self-assign': 'error',
|
|
79
|
-
'no-setter-return': 'error',
|
|
80
|
-
'no-shadow-restricted-names': 'error',
|
|
81
|
-
'no-sparse-arrays': 'error',
|
|
82
|
-
'no-this-before-super': 'error',
|
|
83
|
-
'no-undef': 'error',
|
|
84
|
-
'no-unexpected-multiline': 'error',
|
|
85
|
-
'no-unreachable': 'error',
|
|
86
|
-
'no-unsafe-finally': 'error',
|
|
87
|
-
'no-unsafe-negation': 'error',
|
|
88
|
-
'no-unsafe-optional-chaining': 'error',
|
|
89
|
-
'no-unused-labels': 'error',
|
|
90
|
-
// 'no-unused-vars': 'error', // extended below
|
|
91
|
-
'no-useless-backreference': 'error',
|
|
92
|
-
'no-useless-catch': 'error',
|
|
93
|
-
'no-useless-escape': 'error',
|
|
94
|
-
'no-with': 'error',
|
|
95
|
-
'require-yield': 'error',
|
|
96
|
-
'use-isnan': 'error',
|
|
97
|
-
// 'valid-typeof': 'error', // extended below
|
|
98
|
-
// END eslint:recommended
|
|
99
|
-
|
|
100
|
-
// Async/await must not be used in a `.forEach` method, because the result
|
|
101
|
-
// will not be awaited in the outer scope.
|
|
102
|
-
'@automattic/wpvip/no-async-foreach': 'error',
|
|
103
|
-
|
|
104
|
-
// Unguarded getRangeAt calls can throw errors in some browsers.
|
|
105
|
-
'@automattic/wpvip/no-unguarded-get-range-at': 'error',
|
|
106
|
-
|
|
107
|
-
'array-callback-return': 'error',
|
|
108
|
-
|
|
109
|
-
// Maximum cyclomatic complexity must not be above 20.
|
|
110
|
-
complexity: 'error',
|
|
111
|
-
|
|
112
|
-
eqeqeq: 'error',
|
|
113
|
-
|
|
114
|
-
// Identifiers should be between 2 and 40 characters in length in order to
|
|
115
|
-
// provide a concise semantic meaning.
|
|
116
|
-
'id-length': [
|
|
117
|
-
'warn',
|
|
118
|
-
{
|
|
119
|
-
min: 2,
|
|
120
|
-
max: 40,
|
|
26
|
+
SecurityPluginConfigs.configs.recommended,
|
|
27
|
+
{
|
|
28
|
+
languageOptions: {
|
|
29
|
+
ecmaVersion: 2022,
|
|
30
|
+
globals: {
|
|
31
|
+
...globals.node,
|
|
32
|
+
...globals.nodeBuiltin,
|
|
121
33
|
},
|
|
122
|
-
|
|
34
|
+
parser: babelParser,
|
|
35
|
+
parserOptions: {
|
|
36
|
+
requireConfigFile: false,
|
|
37
|
+
sourceType: 'module',
|
|
38
|
+
ecmaVersion: 2022,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
plugins: {
|
|
42
|
+
'@automattic/wpvip': require( '../plugin' ),
|
|
43
|
+
import: ImportPlugin,
|
|
44
|
+
promise: PromisePlugin,
|
|
45
|
+
'unused-imports': UnusedImportsPlugin,
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Please include a short description of the rule. For rules that downgrade or
|
|
49
|
+
* disable errors, include a brief justification or reasoning.
|
|
50
|
+
*/
|
|
51
|
+
rules: {
|
|
52
|
+
// BEGIN eslint:recommended, enumerated here for visibility:
|
|
53
|
+
// https://github.com/eslint/eslint/blob/main/packages/js/src/configs/eslint-recommended.js
|
|
54
|
+
'constructor-super': 'error',
|
|
55
|
+
'for-direction': 'error',
|
|
56
|
+
'getter-return': 'error',
|
|
57
|
+
'no-async-promise-executor': 'error',
|
|
58
|
+
'no-case-declarations': 'error',
|
|
59
|
+
'no-class-assign': 'error',
|
|
60
|
+
'no-compare-neg-zero': 'error',
|
|
61
|
+
// 'no-cond-assign': 'error', // extended below
|
|
62
|
+
'no-const-assign': 'error',
|
|
63
|
+
'no-constant-binary-expression': 'error',
|
|
64
|
+
'no-constant-condition': 'error',
|
|
65
|
+
'no-control-regex': 'error',
|
|
66
|
+
'no-debugger': 'error',
|
|
67
|
+
'no-delete-var': 'error',
|
|
68
|
+
'no-dupe-args': 'error',
|
|
69
|
+
'no-dupe-class-members': 'error',
|
|
70
|
+
'no-dupe-else-if': 'error',
|
|
71
|
+
'no-dupe-keys': 'error',
|
|
72
|
+
'no-duplicate-case': 'error',
|
|
73
|
+
// 'no-empty': 'error', // extended below
|
|
74
|
+
'no-empty-character-class': 'error',
|
|
75
|
+
'no-empty-pattern': 'error',
|
|
76
|
+
'no-ex-assign': 'error',
|
|
77
|
+
'no-extra-boolean-cast': 'error',
|
|
78
|
+
'no-extra-semi': 'error',
|
|
79
|
+
'no-fallthrough': 'error',
|
|
80
|
+
'no-func-assign': 'error',
|
|
81
|
+
'no-global-assign': 'error',
|
|
82
|
+
'no-import-assign': 'error',
|
|
83
|
+
'no-inner-declarations': 'error',
|
|
84
|
+
'no-invalid-regexp': 'error',
|
|
85
|
+
'no-irregular-whitespace': 'error',
|
|
86
|
+
'no-loss-of-precision': 'error',
|
|
87
|
+
'no-misleading-character-class': 'error',
|
|
88
|
+
'no-mixed-spaces-and-tabs': 'error',
|
|
89
|
+
'no-new-symbol': 'error',
|
|
90
|
+
'no-nonoctal-decimal-escape': 'error',
|
|
91
|
+
'no-obj-calls': 'error',
|
|
92
|
+
'no-octal': 'error',
|
|
93
|
+
'no-prototype-builtins': 'error',
|
|
94
|
+
'no-redeclare': 'error',
|
|
95
|
+
'no-regex-spaces': 'error',
|
|
96
|
+
'no-self-assign': 'error',
|
|
97
|
+
'no-setter-return': 'error',
|
|
98
|
+
'no-shadow-restricted-names': 'error',
|
|
99
|
+
'no-sparse-arrays': 'error',
|
|
100
|
+
'no-this-before-super': 'error',
|
|
101
|
+
'no-undef': 'error',
|
|
102
|
+
'no-unexpected-multiline': 'error',
|
|
103
|
+
'no-unreachable': 'error',
|
|
104
|
+
'no-unsafe-finally': 'error',
|
|
105
|
+
'no-unsafe-negation': 'error',
|
|
106
|
+
'no-unsafe-optional-chaining': 'error',
|
|
107
|
+
'no-unused-labels': 'error',
|
|
108
|
+
// 'no-unused-vars': 'error', // extended below
|
|
109
|
+
'no-useless-backreference': 'error',
|
|
110
|
+
'no-useless-catch': 'error',
|
|
111
|
+
'no-useless-escape': 'error',
|
|
112
|
+
'no-with': 'error',
|
|
113
|
+
'require-yield': 'error',
|
|
114
|
+
'use-isnan': 'error',
|
|
115
|
+
// 'valid-typeof': 'error', // extended below
|
|
116
|
+
// END eslint:recommended
|
|
117
|
+
|
|
118
|
+
// Async/await must not be used in a `.forEach` method, because the result
|
|
119
|
+
// will not be awaited in the outer scope.
|
|
120
|
+
'@automattic/wpvip/no-async-foreach': 'error',
|
|
121
|
+
|
|
122
|
+
// Unguarded getRangeAt calls can throw errors in some browsers.
|
|
123
|
+
'@automattic/wpvip/no-unguarded-get-range-at': 'error',
|
|
124
|
+
|
|
125
|
+
'array-callback-return': 'error',
|
|
126
|
+
|
|
127
|
+
// Maximum cyclomatic complexity must not be above 20.
|
|
128
|
+
complexity: 'error',
|
|
129
|
+
|
|
130
|
+
eqeqeq: 'error',
|
|
131
|
+
|
|
132
|
+
// Identifiers should be between 2 and 40 characters in length in order to
|
|
133
|
+
// provide a concise semantic meaning.
|
|
134
|
+
'id-length': [
|
|
135
|
+
'warn',
|
|
136
|
+
{
|
|
137
|
+
min: 2,
|
|
138
|
+
max: 40,
|
|
139
|
+
},
|
|
140
|
+
],
|
|
123
141
|
|
|
124
|
-
|
|
142
|
+
'import/default': 'warn',
|
|
125
143
|
|
|
126
|
-
|
|
144
|
+
'import/named': 'warn',
|
|
127
145
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
|
|
135
|
-
'import/no-unresolved': 'error',
|
|
136
|
-
'unused-imports/no-unused-imports': 'warn',
|
|
137
|
-
|
|
138
|
-
// Enforce external / internal import groups and alphabetical ordering.
|
|
139
|
-
'import/order': [
|
|
140
|
-
'error',
|
|
141
|
-
{
|
|
142
|
-
'newlines-between': 'always',
|
|
143
|
-
alphabetize: {
|
|
144
|
-
order: 'asc',
|
|
146
|
+
'import/no-extraneous-dependencies': [
|
|
147
|
+
'error',
|
|
148
|
+
{
|
|
149
|
+
peerDependencies: true,
|
|
145
150
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
],
|
|
152
|
+
|
|
153
|
+
'import/no-unresolved': 'error',
|
|
154
|
+
'unused-imports/no-unused-imports': 'warn',
|
|
155
|
+
|
|
156
|
+
// Enforce external / internal import groups and alphabetical ordering.
|
|
157
|
+
'import/order': [
|
|
158
|
+
'error',
|
|
159
|
+
{
|
|
160
|
+
'newlines-between': 'always',
|
|
161
|
+
alphabetize: {
|
|
162
|
+
order: 'asc',
|
|
163
|
+
},
|
|
164
|
+
groups: [
|
|
165
|
+
[ 'builtin', 'external' ],
|
|
166
|
+
[ 'index', 'internal', 'object', 'parent', 'sibling' ],
|
|
167
|
+
[ 'type' ],
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
],
|
|
153
171
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
172
|
+
// Enforce Unix linebreaks. Included here and not in "formatting" since it
|
|
173
|
+
// is not controversial and helps with interchange.
|
|
174
|
+
'linebreak-style': [ 'error', 'unix' ],
|
|
157
175
|
|
|
158
|
-
|
|
176
|
+
'no-alert': 'error',
|
|
159
177
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
178
|
+
// Async/await must not be used in a loop, because it leads to sequential
|
|
179
|
+
// execution, when parallel execution is almost always preferred.
|
|
180
|
+
'no-await-in-loop': 'error',
|
|
163
181
|
|
|
164
|
-
|
|
182
|
+
'no-bitwise': 'error',
|
|
165
183
|
|
|
166
|
-
|
|
184
|
+
'no-caller': 'error',
|
|
167
185
|
|
|
168
|
-
|
|
186
|
+
'no-cond-assign': [ 'error', 'except-parens' ],
|
|
169
187
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
188
|
+
// `console.log` should not be used directly in code. Ideally, delegate to a
|
|
189
|
+
// logging function that logs on your behalf (and ignore this rule there).
|
|
190
|
+
'no-console': 'warn',
|
|
173
191
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
192
|
+
// A single `import` statement should be used when importing multiple things
|
|
193
|
+
// from a module.
|
|
194
|
+
'no-duplicate-imports': 'error',
|
|
177
195
|
|
|
178
|
-
|
|
196
|
+
'no-else-return': 'error',
|
|
179
197
|
|
|
180
|
-
|
|
198
|
+
'no-empty': [ 'error', { allowEmptyCatch: true } ],
|
|
181
199
|
|
|
182
|
-
|
|
200
|
+
'no-eq-null': 'error',
|
|
183
201
|
|
|
184
|
-
|
|
202
|
+
'no-eval': 'error',
|
|
185
203
|
|
|
186
|
-
|
|
204
|
+
'no-lonely-if': 'error',
|
|
187
205
|
|
|
188
|
-
|
|
206
|
+
'no-implicit-coercion': 'error',
|
|
189
207
|
|
|
190
|
-
|
|
208
|
+
'no-mixed-operators': 'error',
|
|
191
209
|
|
|
192
|
-
|
|
210
|
+
'no-nested-ternary': 'error',
|
|
193
211
|
|
|
194
|
-
|
|
212
|
+
'no-shadow': 'error',
|
|
195
213
|
|
|
196
|
-
|
|
214
|
+
'no-undef-init': 'error',
|
|
197
215
|
|
|
198
|
-
|
|
216
|
+
'no-unused-expressions': 'error',
|
|
199
217
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
'no-useless-computed-key': 'error',
|
|
218
|
+
'no-unused-vars': [
|
|
219
|
+
'error',
|
|
220
|
+
{
|
|
221
|
+
argsIgnorePattern: '^_',
|
|
222
|
+
destructuredArrayIgnorePattern: '^_',
|
|
223
|
+
ignoreRestSiblings: true,
|
|
224
|
+
},
|
|
225
|
+
],
|
|
210
226
|
|
|
211
|
-
|
|
227
|
+
'no-useless-computed-key': 'error',
|
|
212
228
|
|
|
213
|
-
|
|
229
|
+
'no-useless-constructor': 'error',
|
|
214
230
|
|
|
215
|
-
|
|
231
|
+
'no-useless-return': 'error',
|
|
216
232
|
|
|
217
|
-
|
|
233
|
+
'no-var': 'error',
|
|
218
234
|
|
|
219
|
-
|
|
235
|
+
'one-var': [ 'error', 'never' ],
|
|
220
236
|
|
|
221
|
-
|
|
237
|
+
'prefer-const': [ 'error', { destructuring: 'all' } ],
|
|
222
238
|
|
|
223
|
-
|
|
224
|
-
'valid-typeof': [
|
|
225
|
-
'error',
|
|
226
|
-
{
|
|
227
|
-
requireStringLiterals: true,
|
|
228
|
-
},
|
|
229
|
-
],
|
|
230
|
-
|
|
231
|
-
'wrap-iife': [ 'error', 'any' ],
|
|
232
|
-
|
|
233
|
-
'promise/always-return': 'off',
|
|
234
|
-
'promise/avoid-new': 'off',
|
|
235
|
-
'promise/catch-or-return': 'off',
|
|
236
|
-
'promise/no-callback-in-promise': 'warn',
|
|
237
|
-
'promise/no-native': 'off',
|
|
238
|
-
'promise/no-nesting': 'warn',
|
|
239
|
-
'promise/no-new-statics': 'error',
|
|
240
|
-
'promise/no-promise-in-callback': 'warn',
|
|
241
|
-
'promise/no-return-in-finally': 'error',
|
|
242
|
-
'promise/no-return-wrap': 'error',
|
|
243
|
-
'promise/param-names': 'error',
|
|
244
|
-
'promise/prefer-await-to-callbacks': 'off',
|
|
245
|
-
'promise/prefer-await-to-then': 'off',
|
|
246
|
-
'promise/valid-params': 'error',
|
|
247
|
-
|
|
248
|
-
// This rule has been disabled because it is extremely slow:
|
|
249
|
-
// https://github.com/Automattic/vip-cli/pull/1534
|
|
250
|
-
//
|
|
251
|
-
// 'promise/no-multiple-resolved': 'error',
|
|
252
|
-
},
|
|
239
|
+
radix: 'error',
|
|
253
240
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
241
|
+
// The result of `typeof` must always be compared to a literal string.
|
|
242
|
+
'valid-typeof': [
|
|
243
|
+
'error',
|
|
244
|
+
{
|
|
245
|
+
requireStringLiterals: true,
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
|
|
249
|
+
'wrap-iife': [ 'error', 'any' ],
|
|
250
|
+
|
|
251
|
+
'promise/always-return': 'off',
|
|
252
|
+
'promise/avoid-new': 'off',
|
|
253
|
+
'promise/catch-or-return': 'off',
|
|
254
|
+
'promise/no-callback-in-promise': 'warn',
|
|
255
|
+
'promise/no-native': 'off',
|
|
256
|
+
'promise/no-nesting': 'warn',
|
|
257
|
+
'promise/no-new-statics': 'error',
|
|
258
|
+
'promise/no-promise-in-callback': 'warn',
|
|
259
|
+
'promise/no-return-in-finally': 'error',
|
|
260
|
+
'promise/no-return-wrap': 'error',
|
|
261
|
+
'promise/param-names': 'error',
|
|
262
|
+
'promise/prefer-await-to-callbacks': 'off',
|
|
263
|
+
'promise/prefer-await-to-then': 'off',
|
|
264
|
+
'promise/valid-params': 'error',
|
|
265
|
+
|
|
266
|
+
// This rule has been disabled because it is extremely slow:
|
|
267
|
+
// https://github.com/Automattic/vip-cli/pull/1534
|
|
268
|
+
//
|
|
269
|
+
// 'promise/no-multiple-resolved': 'error',
|
|
270
|
+
},
|
|
271
|
+
settings: {
|
|
272
|
+
'import/resolver': {
|
|
273
|
+
node: {
|
|
274
|
+
extensions: [ '.js', '.jsx', '.ts', '.tsx', '.cjs', '.mjs', '.cts', '.mts' ],
|
|
275
|
+
},
|
|
276
|
+
typescript: 'eslint-import-resolver-typescript',
|
|
258
277
|
},
|
|
259
|
-
typescript: 'eslint-import-resolver-typescript',
|
|
260
278
|
},
|
|
261
279
|
},
|
|
262
|
-
|
|
280
|
+
];
|
package/configs/jsdoc.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* https://github.com/WordPress/gutenberg/blob/%40wordpress/eslint-plugin%4014.1.0/packages/eslint-plugin/configs/jsdoc.js
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
const JsDoc = require( 'eslint-plugin-jsdoc' );
|
|
6
7
|
const globals = require( 'globals' );
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -40,68 +41,71 @@ const typescriptUtilityTypes = [
|
|
|
40
41
|
'false',
|
|
41
42
|
];
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
/** @type import('eslint').Linter.Config[] */
|
|
45
|
+
module.exports = [
|
|
46
|
+
JsDoc.configs[ 'flat/recommended' ],
|
|
47
|
+
{
|
|
48
|
+
settings: {
|
|
49
|
+
jsdoc: {
|
|
50
|
+
preferredTypes: {
|
|
51
|
+
object: 'Object',
|
|
52
|
+
},
|
|
53
|
+
tagNamePreference: {
|
|
54
|
+
returns: 'return',
|
|
55
|
+
yields: 'yield',
|
|
56
|
+
},
|
|
53
57
|
},
|
|
54
58
|
},
|
|
59
|
+
rules: {
|
|
60
|
+
'jsdoc/no-undefined-types': [
|
|
61
|
+
'error',
|
|
62
|
+
{
|
|
63
|
+
definedTypes: [
|
|
64
|
+
// Required to reference browser types because we don't have the `browser` environment enabled for the project.
|
|
65
|
+
// Here we filter out all browser globals that don't begin with an uppercase letter because those
|
|
66
|
+
// generally refer to window-level event listeners and are not a valid type to reference (e.g. `onclick`).
|
|
67
|
+
...Object.keys( globals.browser ).filter( key => /^[A-Z]/.test( key ) ),
|
|
68
|
+
...typescriptUtilityTypes,
|
|
69
|
+
'void',
|
|
70
|
+
'JSX',
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
'jsdoc/require-jsdoc': 'off',
|
|
75
|
+
'jsdoc/require-param-description': 'off',
|
|
76
|
+
'jsdoc/require-returns': 'off',
|
|
77
|
+
'jsdoc/require-yields': 'off',
|
|
78
|
+
'jsdoc/tag-lines': 'off',
|
|
79
|
+
'jsdoc/no-multi-asterisks': [ 'error', { preventAtMiddleLines: false } ],
|
|
80
|
+
'jsdoc/check-access': 'error',
|
|
81
|
+
'jsdoc/check-alignment': 'error',
|
|
82
|
+
'jsdoc/check-line-alignment': [
|
|
83
|
+
'error',
|
|
84
|
+
'always',
|
|
85
|
+
{
|
|
86
|
+
tags: [ 'param', 'arg', 'argument', 'property', 'prop' ],
|
|
87
|
+
preserveMainDescriptionPostDelimiter: true,
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
'jsdoc/check-param-names': 'error',
|
|
91
|
+
'jsdoc/check-property-names': 'error',
|
|
92
|
+
'jsdoc/check-tag-names': 'error',
|
|
93
|
+
'jsdoc/check-types': 'error',
|
|
94
|
+
'jsdoc/check-values': 'off',
|
|
95
|
+
'jsdoc/empty-tags': 'error',
|
|
96
|
+
'jsdoc/implements-on-classes': 'error',
|
|
97
|
+
'jsdoc/newline-after-description': 'error',
|
|
98
|
+
'jsdoc/require-param': 'error',
|
|
99
|
+
'jsdoc/require-param-name': 'error',
|
|
100
|
+
'jsdoc/require-param-type': 'error',
|
|
101
|
+
'jsdoc/require-property': 'error',
|
|
102
|
+
'jsdoc/require-property-description': 'error',
|
|
103
|
+
'jsdoc/require-property-name': 'error',
|
|
104
|
+
'jsdoc/require-property-type': 'error',
|
|
105
|
+
'jsdoc/require-returns-check': 'error',
|
|
106
|
+
'jsdoc/require-returns-description': 'error',
|
|
107
|
+
'jsdoc/require-returns-type': 'error',
|
|
108
|
+
'jsdoc/valid-types': 'error',
|
|
109
|
+
},
|
|
55
110
|
},
|
|
56
|
-
|
|
57
|
-
'jsdoc/no-undefined-types': [
|
|
58
|
-
'error',
|
|
59
|
-
{
|
|
60
|
-
definedTypes: [
|
|
61
|
-
// Required to reference browser types because we don't have the `browser` environment enabled for the project.
|
|
62
|
-
// Here we filter out all browser globals that don't begin with an uppercase letter because those
|
|
63
|
-
// generally refer to window-level event listeners and are not a valid type to reference (e.g. `onclick`).
|
|
64
|
-
...Object.keys( globals.browser ).filter( key => /^[A-Z]/.test( key ) ),
|
|
65
|
-
...typescriptUtilityTypes,
|
|
66
|
-
'void',
|
|
67
|
-
'JSX',
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
'jsdoc/require-jsdoc': 'off',
|
|
72
|
-
'jsdoc/require-param-description': 'off',
|
|
73
|
-
'jsdoc/require-returns': 'off',
|
|
74
|
-
'jsdoc/require-yields': 'off',
|
|
75
|
-
'jsdoc/tag-lines': 'off',
|
|
76
|
-
'jsdoc/no-multi-asterisks': [ 'error', { preventAtMiddleLines: false } ],
|
|
77
|
-
'jsdoc/check-access': 'error',
|
|
78
|
-
'jsdoc/check-alignment': 'error',
|
|
79
|
-
'jsdoc/check-line-alignment': [
|
|
80
|
-
'error',
|
|
81
|
-
'always',
|
|
82
|
-
{
|
|
83
|
-
tags: [ 'param', 'arg', 'argument', 'property', 'prop' ],
|
|
84
|
-
preserveMainDescriptionPostDelimiter: true,
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
'jsdoc/check-param-names': 'error',
|
|
88
|
-
'jsdoc/check-property-names': 'error',
|
|
89
|
-
'jsdoc/check-tag-names': 'error',
|
|
90
|
-
'jsdoc/check-types': 'error',
|
|
91
|
-
'jsdoc/check-values': 'off',
|
|
92
|
-
'jsdoc/empty-tags': 'error',
|
|
93
|
-
'jsdoc/implements-on-classes': 'error',
|
|
94
|
-
'jsdoc/newline-after-description': 'error',
|
|
95
|
-
'jsdoc/require-param': 'error',
|
|
96
|
-
'jsdoc/require-param-name': 'error',
|
|
97
|
-
'jsdoc/require-param-type': 'error',
|
|
98
|
-
'jsdoc/require-property': 'error',
|
|
99
|
-
'jsdoc/require-property-description': 'error',
|
|
100
|
-
'jsdoc/require-property-name': 'error',
|
|
101
|
-
'jsdoc/require-property-type': 'error',
|
|
102
|
-
'jsdoc/require-returns-check': 'error',
|
|
103
|
-
'jsdoc/require-returns-description': 'error',
|
|
104
|
-
'jsdoc/require-returns-type': 'error',
|
|
105
|
-
'jsdoc/valid-types': 'error',
|
|
106
|
-
},
|
|
107
|
-
};
|
|
111
|
+
];
|
package/configs/prettier.js
CHANGED
|
@@ -3,10 +3,14 @@
|
|
|
3
3
|
* https://github.com/WordPress/gutenberg/blob/%40wordpress/eslint-plugin%4014.1.0/packages/eslint-plugin/configs/recommended.js
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const eslintPluginPrettierRecommended = require( 'eslint-plugin-prettier/recommended' );
|
|
7
|
+
|
|
8
|
+
/** @type import('eslint').Linter.Config[] */
|
|
9
|
+
module.exports = [
|
|
10
|
+
eslintPluginPrettierRecommended,
|
|
11
|
+
{
|
|
12
|
+
rules: {
|
|
13
|
+
'prettier/prettier': 'error',
|
|
14
|
+
},
|
|
11
15
|
},
|
|
12
|
-
|
|
16
|
+
];
|