@automattic/eslint-plugin-wpvip 0.6.0 → 0.8.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/javascript.js +31 -2
- package/configs/typescript.js +10 -3
- package/configs/weak-javascript.js +5 -1
- package/package.json +18 -18
- package/utils/is-package-installed.js +10 -3
package/configs/javascript.js
CHANGED
|
@@ -134,6 +134,22 @@ module.exports = {
|
|
|
134
134
|
'import/no-unresolved': 'error',
|
|
135
135
|
'unused-imports/no-unused-imports': 'warn',
|
|
136
136
|
|
|
137
|
+
// Enforce external / internal import groups and alphabetical ordering.
|
|
138
|
+
'import/order': [
|
|
139
|
+
'error',
|
|
140
|
+
{
|
|
141
|
+
'newlines-between': 'always',
|
|
142
|
+
alphabetize: {
|
|
143
|
+
order: 'asc',
|
|
144
|
+
},
|
|
145
|
+
groups: [
|
|
146
|
+
[ 'builtin', 'external' ],
|
|
147
|
+
[ 'index', 'internal', 'object', 'parent', 'sibling' ],
|
|
148
|
+
[ 'type' ],
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
|
|
137
153
|
// Enforce Unix linebreaks. Included here and not in "formatting" since it
|
|
138
154
|
// is not controversial and helps with interchange.
|
|
139
155
|
'linebreak-style': [ 'error', 'unix' ],
|
|
@@ -168,6 +184,8 @@ module.exports = {
|
|
|
168
184
|
|
|
169
185
|
'no-lonely-if': 'error',
|
|
170
186
|
|
|
187
|
+
'no-implicit-coercion': 'error',
|
|
188
|
+
|
|
171
189
|
'no-mixed-operators': 'error',
|
|
172
190
|
|
|
173
191
|
'no-nested-ternary': 'error',
|
|
@@ -178,7 +196,14 @@ module.exports = {
|
|
|
178
196
|
|
|
179
197
|
'no-unused-expressions': 'error',
|
|
180
198
|
|
|
181
|
-
'no-unused-vars': [
|
|
199
|
+
'no-unused-vars': [
|
|
200
|
+
'error',
|
|
201
|
+
{
|
|
202
|
+
argsIgnorePattern: '^_',
|
|
203
|
+
destructuredArrayIgnorePattern: '^_',
|
|
204
|
+
ignoreRestSiblings: true,
|
|
205
|
+
},
|
|
206
|
+
],
|
|
182
207
|
|
|
183
208
|
'no-useless-computed-key': 'error',
|
|
184
209
|
|
|
@@ -208,7 +233,6 @@ module.exports = {
|
|
|
208
233
|
'promise/avoid-new': 'off',
|
|
209
234
|
'promise/catch-or-return': 'off',
|
|
210
235
|
'promise/no-callback-in-promise': 'warn',
|
|
211
|
-
'promise/no-multiple-resolved': 'error',
|
|
212
236
|
'promise/no-native': 'off',
|
|
213
237
|
'promise/no-nesting': 'warn',
|
|
214
238
|
'promise/no-new-statics': 'error',
|
|
@@ -219,6 +243,11 @@ module.exports = {
|
|
|
219
243
|
'promise/prefer-await-to-callbacks': 'off',
|
|
220
244
|
'promise/prefer-await-to-then': 'off',
|
|
221
245
|
'promise/valid-params': 'error',
|
|
246
|
+
|
|
247
|
+
// This rule has been disabled because it is extremely slow:
|
|
248
|
+
// https://github.com/Automattic/vip-cli/pull/1534
|
|
249
|
+
//
|
|
250
|
+
// 'promise/no-multiple-resolved': 'error',
|
|
222
251
|
},
|
|
223
252
|
|
|
224
253
|
settings: {
|
package/configs/typescript.js
CHANGED
|
@@ -27,6 +27,16 @@ module.exports = {
|
|
|
27
27
|
// config, and is elevated to an error here.
|
|
28
28
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
29
29
|
|
|
30
|
+
// Provide escape hatches around destructuring and arguments.
|
|
31
|
+
'@typescript-eslint/no-unused-vars': [
|
|
32
|
+
'error',
|
|
33
|
+
{
|
|
34
|
+
argsIgnorePattern: '^_',
|
|
35
|
+
destructuredArrayIgnorePattern: '^_',
|
|
36
|
+
ignoreRestSiblings: true,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
|
|
30
40
|
// Disable some rules that TypeScript handles and are also a Performance
|
|
31
41
|
// issue. See:
|
|
32
42
|
// https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/troubleshooting/Performance.md#eslint-plugin-import
|
|
@@ -43,9 +53,6 @@ module.exports = {
|
|
|
43
53
|
'@typescript-eslint/no-shadow': 'error',
|
|
44
54
|
'import/no-duplicates': 'error',
|
|
45
55
|
|
|
46
|
-
// Handled by TS itself.
|
|
47
|
-
'no-unused-vars': 'off',
|
|
48
|
-
|
|
49
56
|
// Empty classes are allowed if they are accompanied by a decorator.
|
|
50
57
|
// This is common in frameworks such as Angular / nest.js.
|
|
51
58
|
'@typescript-eslint/no-extraneous-class': [
|
|
@@ -53,12 +53,16 @@ module.exports = {
|
|
|
53
53
|
|
|
54
54
|
radix: 'warn',
|
|
55
55
|
|
|
56
|
-
'promise/no-multiple-resolved': 'warn',
|
|
57
56
|
'promise/no-new-statics': 'warn',
|
|
58
57
|
'promise/no-return-in-finally': 'warn',
|
|
59
58
|
'promise/no-return-wrap': 'warn',
|
|
60
59
|
'promise/param-names': 'warn',
|
|
61
60
|
'promise/valid-params': 'warn',
|
|
61
|
+
|
|
62
|
+
// This rule has been disabled because it is extremely slow:
|
|
63
|
+
// https://github.com/Automattic/vip-cli/pull/1534
|
|
64
|
+
//
|
|
65
|
+
// 'promise/no-multiple-resolved': 'warn',
|
|
62
66
|
},
|
|
63
67
|
},
|
|
64
68
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/eslint-plugin-wpvip",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "ESLint plugin for internal WordPress VIP projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,37 +32,37 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/Automattic/eslint-config-wpvip#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@babel/eslint-parser": "7.22.
|
|
36
|
-
"@rushstack/eslint-patch": "1.
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "
|
|
38
|
-
"@typescript-eslint/parser": "
|
|
35
|
+
"@babel/eslint-parser": "7.22.15",
|
|
36
|
+
"@rushstack/eslint-patch": "1.5.1",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "6.9.1",
|
|
38
|
+
"@typescript-eslint/parser": "6.9.1",
|
|
39
39
|
"eslint-config-prettier": "8.7.0",
|
|
40
|
-
"eslint-import-resolver-typescript": "3.
|
|
41
|
-
"eslint-plugin-import": "2.
|
|
42
|
-
"eslint-plugin-jest": "27.
|
|
43
|
-
"eslint-plugin-jsdoc": "
|
|
40
|
+
"eslint-import-resolver-typescript": "3.6.1",
|
|
41
|
+
"eslint-plugin-import": "2.29.0",
|
|
42
|
+
"eslint-plugin-jest": "27.6.0",
|
|
43
|
+
"eslint-plugin-jsdoc": "46.8.2",
|
|
44
44
|
"eslint-plugin-json": "3.1.0",
|
|
45
45
|
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
46
46
|
"eslint-plugin-prettier": "4.2.1",
|
|
47
47
|
"eslint-plugin-promise": "6.1.1",
|
|
48
|
-
"eslint-plugin-react": "7.
|
|
48
|
+
"eslint-plugin-react": "7.33.2",
|
|
49
49
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
50
50
|
"eslint-plugin-security": "1.7.1",
|
|
51
51
|
"eslint-plugin-unused-imports": "3.0.0",
|
|
52
52
|
"find-package-json": "1.2.0",
|
|
53
|
-
"globals": "13.
|
|
53
|
+
"globals": "13.23.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"eslint": ">=8"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@tsconfig/node18": "
|
|
60
|
-
"@types/eslint": "8.44.
|
|
61
|
-
"@types/jest": "29.5.
|
|
62
|
-
"eslint": "8.
|
|
63
|
-
"jest": "29.
|
|
59
|
+
"@tsconfig/node18": "18.2.2",
|
|
60
|
+
"@types/eslint": "8.44.6",
|
|
61
|
+
"@types/jest": "29.5.7",
|
|
62
|
+
"eslint": "8.52.0",
|
|
63
|
+
"jest": "29.7.0",
|
|
64
64
|
"prettier": "npm:wp-prettier@2.8.5",
|
|
65
|
-
"ts-jest": "29.
|
|
66
|
-
"typescript": "
|
|
65
|
+
"ts-jest": "29.1.1",
|
|
66
|
+
"typescript": "5.2.2"
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
2
4
|
const findPackageJson = require( 'find-package-json' );
|
|
3
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
const debugLog = require( './debug-log' );
|
|
10
|
+
|
|
4
11
|
// Get a list of all package.json files in the current directory tree, ascending
|
|
5
12
|
// up the tree from the current directory. Note that this code behaves differently
|
|
6
13
|
// when it is installed as a package vs. when we are linting the code in this repo.
|
|
@@ -22,8 +29,8 @@ const parent =
|
|
|
22
29
|
debugLog( `Found package.json: ${ parent.__path || 'none' }` );
|
|
23
30
|
|
|
24
31
|
module.exports = function isPackageInstalled( packageName ) {
|
|
25
|
-
const isDevDependency =
|
|
26
|
-
const isProdDependency =
|
|
32
|
+
const isDevDependency = Boolean( parent.devDependencies?.[ `${ packageName }` ] );
|
|
33
|
+
const isProdDependency = Boolean( parent.dependencies?.[ `${ packageName }` ] );
|
|
27
34
|
|
|
28
35
|
return isDevDependency || isProdDependency;
|
|
29
36
|
};
|