@automattic/eslint-plugin-wpvip 0.4.12 → 0.5.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/README.md +1 -0
- package/configs/typescript.js +14 -3
- package/configs/weak-typescript.js +25 -1
- package/package.json +2 -1
- package/utils/is-package-installed.js +2 -22
package/README.md
CHANGED
package/configs/typescript.js
CHANGED
|
@@ -18,11 +18,21 @@ module.exports = {
|
|
|
18
18
|
|
|
19
19
|
parser: '@typescript-eslint/parser',
|
|
20
20
|
|
|
21
|
+
parserOptions: {
|
|
22
|
+
project: './tsconfig.json',
|
|
23
|
+
},
|
|
24
|
+
|
|
21
25
|
rules: {
|
|
22
26
|
// TypeScript `any` type must not be used. This is a warning in the base
|
|
23
27
|
// config, and is elevated to an error here.
|
|
24
28
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
25
29
|
|
|
30
|
+
// Disable some rules that TypeScript handles and are also a Performance
|
|
31
|
+
// issue. See:
|
|
32
|
+
// https://github.com/typescript-eslint/typescript-eslint/blob/main/docs/linting/troubleshooting/Performance.md#eslint-plugin-import
|
|
33
|
+
'import/default': 'off',
|
|
34
|
+
'import/named': 'off',
|
|
35
|
+
|
|
26
36
|
// Don't require redundant JSDoc types in TypeScript files.
|
|
27
37
|
'jsdoc/require-param-type': 'off',
|
|
28
38
|
'jsdoc/require-returns-type': 'off',
|
|
@@ -42,10 +52,11 @@ module.exports = {
|
|
|
42
52
|
plugins: ['@typescript-eslint', 'jsdoc'],
|
|
43
53
|
|
|
44
54
|
settings: {
|
|
55
|
+
'import/parsers': {
|
|
56
|
+
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
57
|
+
},
|
|
45
58
|
'import/resolver': {
|
|
46
|
-
|
|
47
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
|
48
|
-
},
|
|
59
|
+
typescript: {},
|
|
49
60
|
},
|
|
50
61
|
},
|
|
51
62
|
};
|
|
@@ -13,7 +13,31 @@ module.exports = {
|
|
|
13
13
|
* Downgrade rules from the base preset to "warn". Do not disable rules (set
|
|
14
14
|
* to "off"). If a rule is already set to a warning, do not disable it.
|
|
15
15
|
*/
|
|
16
|
-
rules: {
|
|
16
|
+
rules: {
|
|
17
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
18
|
+
|
|
19
|
+
'@typescript-eslint/no-floating-promises': 'warn',
|
|
20
|
+
|
|
21
|
+
'@typescript-eslint/no-misused-promises': 'warn',
|
|
22
|
+
|
|
23
|
+
'@typescript-eslint/no-unsafe-argument': 'warn',
|
|
24
|
+
|
|
25
|
+
'@typescript-eslint/no-unsafe-assignment': 'warn',
|
|
26
|
+
|
|
27
|
+
'@typescript-eslint/no-unsafe-call': 'warn',
|
|
28
|
+
|
|
29
|
+
'@typescript-eslint/no-unsafe-member-access': 'warn',
|
|
30
|
+
|
|
31
|
+
'@typescript-eslint/no-unsafe-return': 'warn',
|
|
32
|
+
|
|
33
|
+
'@typescript-eslint/require-await': 'warn',
|
|
34
|
+
|
|
35
|
+
'@typescript-eslint/restrict-plus-operands': 'warn',
|
|
36
|
+
|
|
37
|
+
'@typescript-eslint/restrict-template-expressions': 'warn',
|
|
38
|
+
|
|
39
|
+
'@typescript-eslint/unbound-method': 'warn',
|
|
40
|
+
},
|
|
17
41
|
},
|
|
18
42
|
],
|
|
19
43
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/eslint-plugin-wpvip",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "ESLint plugin for internal WordPress VIP projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "5.55.0",
|
|
31
31
|
"@typescript-eslint/parser": "5.55.0",
|
|
32
32
|
"eslint-config-prettier": "8.7.0",
|
|
33
|
+
"eslint-import-resolver-typescript": "3.5.3",
|
|
33
34
|
"eslint-plugin-import": "2.27.5",
|
|
34
35
|
"eslint-plugin-jest": "27.2.1",
|
|
35
36
|
"eslint-plugin-jsdoc": "40.0.2",
|
|
@@ -1,28 +1,8 @@
|
|
|
1
|
-
const fs = require('node:fs');
|
|
2
1
|
const debugLog = require('./debug-log');
|
|
3
2
|
const findPackageJson = require('find-package-json');
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const firstPackage = packages.shift();
|
|
8
|
-
|
|
9
|
-
// A little hack to help us use this plugin to lint itself: When installed via
|
|
10
|
-
// NPM, .eslintrc.js will be missing (due to .npmignore).
|
|
11
|
-
if ('@automattic/eslint-plugin-wpvip' === firstPackage.name) {
|
|
12
|
-
const eslintRc = firstPackage.__path.replace(
|
|
13
|
-
/package\.json$/,
|
|
14
|
-
'.eslintrc.js'
|
|
15
|
-
);
|
|
16
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
17
|
-
if (fs.statSync(eslintRc)) {
|
|
18
|
-
return firstPackage;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return packages.pop() || {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const parent = findParent();
|
|
4
|
+
const packages = [...findPackageJson(__dirname)];
|
|
5
|
+
const parent = packages.pop() || {};
|
|
26
6
|
|
|
27
7
|
debugLog(`Found package.json: ${parent.__path || 'none'}`);
|
|
28
8
|
|