@automattic/eslint-plugin-wpvip 0.5.5 → 0.5.7

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.
@@ -24,7 +24,7 @@ module.exports = {
24
24
  /**
25
25
  * Note: We must explicitly add this plugin to use our custom rules.
26
26
  */
27
- plugins: [ '@automattic/wpvip', 'import' ],
27
+ plugins: [ '@automattic/wpvip', 'import', 'promise' ],
28
28
 
29
29
  /**
30
30
  * Please include a short description of the rule. For rules that downgrade or
@@ -202,6 +202,22 @@ module.exports = {
202
202
  ],
203
203
 
204
204
  'wrap-iife': [ 'error', 'any' ],
205
+
206
+ 'promise/always-return': 'off',
207
+ 'promise/avoid-new': 'off',
208
+ 'promise/catch-or-return': 'off',
209
+ 'promise/no-callback-in-promise': 'warn',
210
+ 'promise/no-multiple-resolved': 'error',
211
+ 'promise/no-native': 'off',
212
+ 'promise/no-nesting': 'warn',
213
+ 'promise/no-new-statics': 'error',
214
+ 'promise/no-promise-in-callback': 'warn',
215
+ 'promise/no-return-in-finally': 'error',
216
+ 'promise/no-return-wrap': 'error',
217
+ 'promise/param-names': 'error',
218
+ 'promise/prefer-await-to-callbacks': 'off',
219
+ 'promise/prefer-await-to-then': 'off',
220
+ 'promise/valid-params': 'error',
205
221
  },
206
222
 
207
223
  settings: {
@@ -52,6 +52,13 @@ module.exports = {
52
52
  'one-var': 'warn',
53
53
 
54
54
  radix: 'warn',
55
+
56
+ 'promise/no-multiple-resolved': 'warn',
57
+ 'promise/no-new-statics': 'warn',
58
+ 'promise/no-return-in-finally': 'warn',
59
+ 'promise/no-return-wrap': 'warn',
60
+ 'promise/param-names': 'warn',
61
+ 'promise/valid-params': 'warn',
55
62
  },
56
63
  },
57
64
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/eslint-plugin-wpvip",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "description": "ESLint plugin for internal WordPress VIP projects",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -39,6 +39,7 @@
39
39
  "eslint-plugin-json": "3.1.0",
40
40
  "eslint-plugin-jsx-a11y": "6.7.1",
41
41
  "eslint-plugin-prettier": "4.2.1",
42
+ "eslint-plugin-promise": "6.1.1",
42
43
  "eslint-plugin-react": "7.32.2",
43
44
  "eslint-plugin-react-hooks": "4.6.0",
44
45
  "eslint-plugin-security": "1.7.1",
@@ -1,8 +1,23 @@
1
1
  const debugLog = require( './debug-log' );
2
2
  const findPackageJson = require( 'find-package-json' );
3
3
 
4
+ // Get a list of all package.json files in the current directory tree, ascending
5
+ // up the tree from the current directory. Note that this code behaves differently
6
+ // when it is installed as a package vs. when we are linting the code in this repo.
7
+ //
8
+ // When installed as a package, the current directory is inside node_modules and is
9
+ // not the "package root" as we are thinking about it. In this case, we need to ignore
10
+ // all package.json files that are inside node_modules directories.
11
+ //
12
+ // When we are linting the code in this repo, the current directory is not inside
13
+ // node_modules and the first found "package.json" is the "package root."
14
+ //
15
+ // This problem is basically impossible to solve for all edge cases (like someone who
16
+ // runs `npm run lint` from inside "node_modules") but this code should work for
17
+ // most cases.
4
18
  const packages = [ ...findPackageJson( __dirname ) ];
5
- const parent = packages.pop() || {};
19
+ const parent =
20
+ packages.find( pkg => ! pkg.__path.includes( '/node_modules/' ) ) || packages.pop() || {};
6
21
 
7
22
  debugLog( `Found package.json: ${ parent.__path || 'none' }` );
8
23