eslint-config-next 12.1.1 → 12.1.2

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.
Files changed (2) hide show
  1. package/index.js +45 -0
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -4,6 +4,51 @@
4
4
  *
5
5
  * https://www.npmjs.com/package/@rushstack/eslint-patch
6
6
  */
7
+ const keptPaths = []
8
+ const sortedPaths = []
9
+ const cwd = process.cwd().replace(/\\/g, '/')
10
+ const originalPaths = require.resolve.paths('eslint-plugin-import')
11
+
12
+ // eslint throws a conflict error when plugins resolve to different
13
+ // locations, since we want to lock our dependencies by default
14
+ // but also need to allow using user dependencies this updates
15
+ // our resolve paths to first check the cwd and iterate to
16
+ // eslint-config-next's dependencies if needed
17
+
18
+ for (let i = originalPaths.length - 1; i >= 0; i--) {
19
+ const currentPath = originalPaths[i]
20
+
21
+ if (currentPath.replace(/\\/g, '/').startsWith(cwd)) {
22
+ sortedPaths.push(currentPath)
23
+ } else {
24
+ keptPaths.unshift(currentPath)
25
+ }
26
+ }
27
+
28
+ // maintain order of node_modules outside of cwd
29
+ sortedPaths.push(...keptPaths)
30
+
31
+ const hookPropertyMap = new Map(
32
+ [
33
+ ['eslint-plugin-import', 'eslint-plugin-import'],
34
+ ['eslint-plugin-react', 'eslint-plugin-react'],
35
+ ['eslint-plugin-jsx-a11y', 'eslint-plugin-jsx-a11y'],
36
+ ].map(([request, replacement]) => [
37
+ request,
38
+ require.resolve(replacement, { paths: sortedPaths }),
39
+ ])
40
+ )
41
+
42
+ const mod = require('module')
43
+ const resolveFilename = mod._resolveFilename
44
+ mod._resolveFilename = function (request, parent, isMain, options) {
45
+ const hookResolved = hookPropertyMap.get(request)
46
+ if (hookResolved) {
47
+ request = hookResolved
48
+ }
49
+ return resolveFilename.call(mod, request, parent, isMain, options)
50
+ }
51
+
7
52
  require('@rushstack/eslint-patch/modern-module-resolution')
8
53
 
9
54
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-next",
3
- "version": "12.1.1",
3
+ "version": "12.1.2",
4
4
  "description": "ESLint configuration used by NextJS.",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -9,7 +9,7 @@
9
9
  "directory": "packages/eslint-config-next"
10
10
  },
11
11
  "dependencies": {
12
- "@next/eslint-plugin-next": "12.1.1",
12
+ "@next/eslint-plugin-next": "12.1.2",
13
13
  "@rushstack/eslint-patch": "1.0.8",
14
14
  "@typescript-eslint/parser": "5.10.1",
15
15
  "eslint-import-resolver-node": "0.3.4",
@@ -29,5 +29,5 @@
29
29
  "optional": true
30
30
  }
31
31
  },
32
- "gitHead": "79a8651bc454c0d2be6e805237bbe93ad6bf02ab"
32
+ "gitHead": "50be7cc17d192084613ead62fbb5f4026bd96cee"
33
33
  }