@nx/eslint 0.0.0-pr-30715-a5f5e3b → 0.0.0-pr-31222-862e973
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/LICENSE +1 -1
- package/README.md +1 -1
- package/migrations.json +98 -119
- package/package.json +7 -6
- package/src/executors/lint/utility/eslint-utils.js +0 -6
- package/src/generators/convert-to-flat-config/converters/json-converter.d.ts +1 -1
- package/src/generators/convert-to-flat-config/converters/json-converter.js +18 -10
- package/src/generators/convert-to-flat-config/generator.js +17 -18
- package/src/generators/convert-to-flat-config/schema.d.ts +0 -2
- package/src/generators/convert-to-inferred/convert-to-inferred.js +1 -2
- package/src/generators/init/global-eslint-config.d.ts +1 -1
- package/src/generators/init/global-eslint-config.js +6 -17
- package/src/generators/init/init-migration.d.ts +1 -1
- package/src/generators/init/init-migration.js +13 -18
- package/src/generators/init/init.d.ts +0 -1
- package/src/generators/init/init.js +6 -31
- package/src/generators/lint-project/lint-project.d.ts +0 -1
- package/src/generators/lint-project/lint-project.js +15 -37
- package/src/generators/lint-project/setup-root-eslint.d.ts +0 -1
- package/src/generators/lint-project/setup-root-eslint.js +1 -2
- package/src/generators/utils/eslint-file.d.ts +2 -3
- package/src/generators/utils/eslint-file.js +28 -160
- package/src/generators/utils/flat-config/ast-utils.d.ts +4 -12
- package/src/generators/utils/flat-config/ast-utils.js +63 -412
- package/src/generators/utils/linter.d.ts +0 -3
- package/src/generators/utils/linter.js +2 -2
- package/src/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +2 -11
- package/src/generators/workspace-rule/workspace-rule.d.ts +2 -2
- package/src/generators/workspace-rule/workspace-rule.js +3 -11
- package/src/generators/workspace-rules-project/workspace-rules-project.js +1 -4
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.d.ts +2 -0
- package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.js +44 -0
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.d.ts +2 -0
- package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.js +47 -0
- package/src/migrations/update-17-1-0/update-typescript-eslint.d.ts +2 -0
- package/src/migrations/update-17-1-0/update-typescript-eslint.js +74 -0
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.d.ts +2 -0
- package/src/migrations/update-17-2-0/simplify-eslint-patterns.js +46 -0
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.d.ts +2 -0
- package/src/migrations/update-17-2-9/move-options-to-target-defaults.js +107 -0
- package/src/plugins/plugin.js +10 -21
- package/src/utils/config-file.d.ts +1 -3
- package/src/utils/config-file.js +2 -5
- package/src/utils/flat-config.d.ts +0 -1
- package/src/utils/flat-config.js +3 -9
- package/src/utils/version-utils.d.ts +0 -1
- package/src/utils/version-utils.js +9 -13
- package/src/utils/versions.d.ts +2 -3
- package/src/utils/versions.js +3 -4
- package/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.d.ts +0 -2
- package/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.js +0 -23
- package/src/migrations/update-20-3-0/add-file-extensions-to-overrides.d.ts +0 -2
- package/src/migrations/update-20-3-0/add-file-extensions-to-overrides.js +0 -49
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
[](https://circleci.com/gh/nrwl/nx)
|
|
11
11
|
[]()
|
|
12
|
-
[](https://www.npmjs.com/@nx/workspace)
|
|
13
13
|
[]()
|
|
14
14
|
[](http://commitizen.github.io/cz-cli/)
|
|
15
15
|
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
package/migrations.json
CHANGED
|
@@ -1,176 +1,155 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"update-
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"update-16-0-0-add-nx-packages": {
|
|
4
|
+
"cli": "nx",
|
|
5
|
+
"version": "16.0.0-beta.1",
|
|
6
|
+
"description": "Replace @nrwl/linter with @nx/linter",
|
|
7
|
+
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
7
8
|
},
|
|
8
|
-
"
|
|
9
|
-
"version": "
|
|
10
|
-
"description": "
|
|
11
|
-
"implementation": "./src/migrations/update-
|
|
9
|
+
"update-16-8-0-add-ignored-files": {
|
|
10
|
+
"version": "16.8.0",
|
|
11
|
+
"description": "update-16-8-0-add-ignored-files",
|
|
12
|
+
"implementation": "./src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files"
|
|
13
|
+
},
|
|
14
|
+
"update-17-0-0-rename-to-eslint": {
|
|
15
|
+
"version": "17.0.0-beta.7",
|
|
16
|
+
"description": "update-17-0-0-rename-to-eslint",
|
|
17
|
+
"implementation": "./src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint"
|
|
18
|
+
},
|
|
19
|
+
"update-typescript-eslint": {
|
|
20
|
+
"version": "17.1.0-beta.1",
|
|
21
|
+
"description": "Updates for @typescript-utils/utils v6.9.1+",
|
|
22
|
+
"implementation": "./src/migrations/update-17-1-0/update-typescript-eslint"
|
|
23
|
+
},
|
|
24
|
+
"simplify-eslint-patterns": {
|
|
25
|
+
"version": "17.2.0-beta.0",
|
|
26
|
+
"description": "Simplify eslintFilePatterns",
|
|
27
|
+
"implementation": "./src/migrations/update-17-2-0/simplify-eslint-patterns"
|
|
28
|
+
},
|
|
29
|
+
"move-options-to-target-defaults": {
|
|
30
|
+
"version": "17.2.9",
|
|
31
|
+
"description": "Move executor options to target defaults",
|
|
32
|
+
"implementation": "./src/migrations/update-17-2-9/move-options-to-target-defaults"
|
|
12
33
|
}
|
|
13
34
|
},
|
|
14
35
|
"packageJsonUpdates": {
|
|
15
|
-
"
|
|
16
|
-
"version": "
|
|
36
|
+
"16.0.0": {
|
|
37
|
+
"version": "16.0.0-beta.0",
|
|
17
38
|
"packages": {
|
|
18
39
|
"@typescript-eslint/parser": {
|
|
19
|
-
"version": "^
|
|
40
|
+
"version": "^5.58.0"
|
|
20
41
|
},
|
|
21
42
|
"@typescript-eslint/eslint-plugin": {
|
|
22
|
-
"version": "^
|
|
43
|
+
"version": "^5.58.0"
|
|
23
44
|
},
|
|
24
45
|
"@typescript-eslint/utils": {
|
|
25
|
-
"version": "^
|
|
26
|
-
},
|
|
27
|
-
"@typescript-eslint/rule-tester": {
|
|
28
|
-
"version": "^7.16.0",
|
|
29
|
-
"alwaysAddToPackageJson": false
|
|
30
|
-
},
|
|
31
|
-
"@typescript-eslint/scope-manager": {
|
|
32
|
-
"version": "^7.16.0",
|
|
33
|
-
"alwaysAddToPackageJson": false
|
|
34
|
-
},
|
|
35
|
-
"@typescript-eslint/typescript-estree": {
|
|
36
|
-
"version": "^7.16.0",
|
|
37
|
-
"alwaysAddToPackageJson": false
|
|
46
|
+
"version": "^5.58.0"
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
},
|
|
41
|
-
"
|
|
42
|
-
"version": "
|
|
43
|
-
"requires": {
|
|
44
|
-
"typescript-eslint": ">8.0.0 <8.19.0"
|
|
45
|
-
},
|
|
50
|
+
"16.5.0": {
|
|
51
|
+
"version": "16.5.0-beta.2",
|
|
46
52
|
"packages": {
|
|
47
|
-
"typescript-eslint": {
|
|
48
|
-
"version": "^
|
|
53
|
+
"@typescript-eslint/parser": {
|
|
54
|
+
"version": "^5.60.1"
|
|
49
55
|
},
|
|
50
56
|
"@typescript-eslint/eslint-plugin": {
|
|
51
|
-
"version": "^
|
|
52
|
-
},
|
|
53
|
-
"@typescript-eslint/parser": {
|
|
54
|
-
"version": "^8.19.0"
|
|
57
|
+
"version": "^5.60.1"
|
|
55
58
|
},
|
|
56
59
|
"@typescript-eslint/utils": {
|
|
57
|
-
"version": "^
|
|
58
|
-
},
|
|
59
|
-
"@typescript-eslint/rule-tester": {
|
|
60
|
-
"version": "^8.19.0",
|
|
61
|
-
"alwaysAddToPackageJson": false
|
|
62
|
-
},
|
|
63
|
-
"@typescript-eslint/scope-manager": {
|
|
64
|
-
"version": "^8.19.0",
|
|
65
|
-
"alwaysAddToPackageJson": false
|
|
66
|
-
},
|
|
67
|
-
"@typescript-eslint/typescript-estree": {
|
|
68
|
-
"version": "^8.19.0",
|
|
69
|
-
"alwaysAddToPackageJson": false
|
|
60
|
+
"version": "^5.60.1"
|
|
70
61
|
}
|
|
71
62
|
}
|
|
72
63
|
},
|
|
73
|
-
"
|
|
74
|
-
"version": "
|
|
75
|
-
"requires": {
|
|
76
|
-
"@typescript-eslint/eslint-plugin": ">8.0.0 <8.19.0"
|
|
77
|
-
},
|
|
64
|
+
"16.7.0": {
|
|
65
|
+
"version": "16.7.0-beta.2",
|
|
78
66
|
"packages": {
|
|
79
|
-
"
|
|
80
|
-
"version": "
|
|
81
|
-
},
|
|
82
|
-
"@typescript-eslint/eslint-plugin": {
|
|
83
|
-
"version": "^8.19.0"
|
|
67
|
+
"eslint": {
|
|
68
|
+
"version": "~8.46.0"
|
|
84
69
|
},
|
|
85
70
|
"@typescript-eslint/parser": {
|
|
86
|
-
"version": "^
|
|
87
|
-
},
|
|
88
|
-
"@typescript-eslint/utils": {
|
|
89
|
-
"version": "^8.19.0"
|
|
90
|
-
},
|
|
91
|
-
"@typescript-eslint/rule-tester": {
|
|
92
|
-
"version": "^8.19.0",
|
|
93
|
-
"alwaysAddToPackageJson": false
|
|
71
|
+
"version": "^5.60.1"
|
|
94
72
|
},
|
|
95
|
-
"@typescript-eslint/
|
|
96
|
-
"version": "^
|
|
97
|
-
"alwaysAddToPackageJson": false
|
|
73
|
+
"@typescript-eslint/eslint-plugin": {
|
|
74
|
+
"version": "^5.60.1"
|
|
98
75
|
},
|
|
99
|
-
"@typescript-eslint/
|
|
100
|
-
"version": "^
|
|
101
|
-
"alwaysAddToPackageJson": false
|
|
76
|
+
"@typescript-eslint/utils": {
|
|
77
|
+
"version": "^5.60.1"
|
|
102
78
|
}
|
|
103
79
|
}
|
|
104
80
|
},
|
|
105
|
-
"
|
|
106
|
-
"version": "
|
|
81
|
+
"17.0.0": {
|
|
82
|
+
"version": "17.0.0-rc.2",
|
|
107
83
|
"packages": {
|
|
108
84
|
"eslint-config-prettier": {
|
|
109
|
-
"version": "^
|
|
85
|
+
"version": "^9.0.0"
|
|
110
86
|
}
|
|
111
87
|
}
|
|
112
88
|
},
|
|
113
|
-
"
|
|
114
|
-
"version": "
|
|
115
|
-
"requires": {
|
|
116
|
-
"typescript-eslint": ">8.0.0 <8.29.0"
|
|
117
|
-
},
|
|
89
|
+
"17.1.0": {
|
|
90
|
+
"version": "17.1.0-beta.1",
|
|
118
91
|
"packages": {
|
|
119
|
-
"typescript-eslint": {
|
|
120
|
-
"version": "^
|
|
92
|
+
"@typescript-eslint/parser": {
|
|
93
|
+
"version": "^6.9.1"
|
|
121
94
|
},
|
|
122
95
|
"@typescript-eslint/eslint-plugin": {
|
|
123
|
-
"version": "^
|
|
124
|
-
},
|
|
125
|
-
"@typescript-eslint/parser": {
|
|
126
|
-
"version": "^8.29.0"
|
|
96
|
+
"version": "^6.9.1"
|
|
127
97
|
},
|
|
128
98
|
"@typescript-eslint/utils": {
|
|
129
|
-
"version": "^
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
"
|
|
138
|
-
},
|
|
139
|
-
"@typescript-eslint/typescript-estree": {
|
|
140
|
-
"version": "^8.29.0",
|
|
141
|
-
"alwaysAddToPackageJson": false
|
|
99
|
+
"version": "^6.9.1"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"17.2.0": {
|
|
104
|
+
"version": "17.2.0-beta.2",
|
|
105
|
+
"packages": {
|
|
106
|
+
"eslint": {
|
|
107
|
+
"version": "~8.48.0"
|
|
142
108
|
}
|
|
143
109
|
}
|
|
144
110
|
},
|
|
145
|
-
"
|
|
146
|
-
"version": "
|
|
147
|
-
"requires": {
|
|
148
|
-
"@typescript-eslint/eslint-plugin": ">8.0.0 <8.29.0"
|
|
149
|
-
},
|
|
111
|
+
"17.3.0": {
|
|
112
|
+
"version": "17.3.0-beta.0",
|
|
150
113
|
"packages": {
|
|
151
|
-
"typescript-eslint": {
|
|
152
|
-
"version": "^
|
|
114
|
+
"@typescript-eslint/parser": {
|
|
115
|
+
"version": "^6.13.2"
|
|
153
116
|
},
|
|
154
117
|
"@typescript-eslint/eslint-plugin": {
|
|
155
|
-
"version": "^
|
|
118
|
+
"version": "^6.13.2"
|
|
156
119
|
},
|
|
120
|
+
"@typescript-eslint/utils": {
|
|
121
|
+
"version": "^6.13.2"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"18.2.0": {
|
|
126
|
+
"version": "18.2.0-beta.0",
|
|
127
|
+
"packages": {
|
|
157
128
|
"@typescript-eslint/parser": {
|
|
158
|
-
"version": "^
|
|
129
|
+
"version": "^7.3.0"
|
|
130
|
+
},
|
|
131
|
+
"@typescript-eslint/eslint-plugin": {
|
|
132
|
+
"version": "^7.3.0"
|
|
159
133
|
},
|
|
160
134
|
"@typescript-eslint/utils": {
|
|
161
|
-
"version": "^
|
|
135
|
+
"version": "^7.3.0"
|
|
162
136
|
},
|
|
163
|
-
"
|
|
164
|
-
"version": "
|
|
165
|
-
|
|
137
|
+
"eslint": {
|
|
138
|
+
"version": "~8.57.0"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"19.5.0": {
|
|
143
|
+
"version": "19.5.0-beta.1",
|
|
144
|
+
"packages": {
|
|
145
|
+
"@typescript-eslint/parser": {
|
|
146
|
+
"version": "^7.16.0"
|
|
166
147
|
},
|
|
167
|
-
"@typescript-eslint/
|
|
168
|
-
"version": "^
|
|
169
|
-
"alwaysAddToPackageJson": false
|
|
148
|
+
"@typescript-eslint/eslint-plugin": {
|
|
149
|
+
"version": "^7.16.0"
|
|
170
150
|
},
|
|
171
|
-
"@typescript-eslint/
|
|
172
|
-
"version": "^
|
|
173
|
-
"alwaysAddToPackageJson": false
|
|
151
|
+
"@typescript-eslint/utils": {
|
|
152
|
+
"version": "^7.16.0"
|
|
174
153
|
}
|
|
175
154
|
}
|
|
176
155
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-31222-862e973",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The ESLint plugin for Nx contains executors, generators and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.",
|
|
6
6
|
"repository": {
|
|
@@ -35,11 +35,12 @@
|
|
|
35
35
|
"eslint": "^8.0.0 || ^9.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@nx/devkit": "0.0.0-pr-
|
|
39
|
-
"@nx/js": "0.0.0-pr-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-31222-862e973",
|
|
39
|
+
"@nx/js": "0.0.0-pr-31222-862e973",
|
|
40
40
|
"semver": "^7.5.3",
|
|
41
41
|
"tslib": "^2.3.0",
|
|
42
|
-
"typescript": "~5.
|
|
42
|
+
"typescript": "~5.4.2",
|
|
43
|
+
"@nx/linter": "0.0.0-pr-31222-862e973"
|
|
43
44
|
},
|
|
44
45
|
"peerDependenciesMeta": {
|
|
45
46
|
"@zkochan/js-yaml": {
|
|
@@ -49,6 +50,6 @@
|
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
|
51
52
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
53
|
+
"type": "commonjs",
|
|
54
|
+
"types": "./index.d.ts"
|
|
54
55
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveAndInstantiateESLint = resolveAndInstantiateESLint;
|
|
4
|
-
const semver_1 = require("semver");
|
|
5
4
|
const config_file_1 = require("../../../utils/config-file");
|
|
6
5
|
const resolve_eslint_class_1 = require("../../../utils/resolve-eslint-class");
|
|
7
6
|
async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatConfig = false) {
|
|
@@ -13,7 +12,6 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
|
13
12
|
const ESLint = await (0, resolve_eslint_class_1.resolveESLintClass)({
|
|
14
13
|
useFlatConfigOverrideVal: useFlatConfig,
|
|
15
14
|
});
|
|
16
|
-
// ruleFilter exist only in eslint 9+, remove this type when eslint 8 support dropped
|
|
17
15
|
const eslintOptions = {
|
|
18
16
|
overrideConfigFile: eslintConfigPath,
|
|
19
17
|
fix: !!options.fix,
|
|
@@ -59,10 +57,6 @@ async function resolveAndInstantiateESLint(eslintConfigPath, options, useFlatCon
|
|
|
59
57
|
eslintOptions.reportUnusedDisableDirectives =
|
|
60
58
|
options.reportUnusedDisableDirectives || undefined;
|
|
61
59
|
}
|
|
62
|
-
// pass --quiet to eslint 9+ directly: filter only errors
|
|
63
|
-
if (options.quiet && (0, semver_1.gte)(ESLint.version, '9.0.0')) {
|
|
64
|
-
eslintOptions.ruleFilter = (rule) => rule.severity === 2;
|
|
65
|
-
}
|
|
66
60
|
const eslint = new ESLint(eslintOptions);
|
|
67
61
|
return {
|
|
68
62
|
ESLint,
|
|
@@ -4,7 +4,7 @@ import { ESLint } from 'eslint';
|
|
|
4
4
|
* Converts an ESLint JSON config to a flat config.
|
|
5
5
|
* Deletes the original file along with .eslintignore if it exists.
|
|
6
6
|
*/
|
|
7
|
-
export declare function convertEslintJsonToFlatConfig(tree: Tree, root: string, config: ESLint.ConfigData, ignorePaths: string[]
|
|
7
|
+
export declare function convertEslintJsonToFlatConfig(tree: Tree, root: string, config: ESLint.ConfigData, ignorePaths: string[]): {
|
|
8
8
|
content: string;
|
|
9
9
|
addESLintRC: boolean;
|
|
10
10
|
addESLintJS: boolean;
|
|
@@ -10,19 +10,15 @@ const path_utils_1 = require("../../utils/flat-config/path-utils");
|
|
|
10
10
|
* Converts an ESLint JSON config to a flat config.
|
|
11
11
|
* Deletes the original file along with .eslintignore if it exists.
|
|
12
12
|
*/
|
|
13
|
-
function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths
|
|
13
|
+
function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths) {
|
|
14
14
|
const importsMap = new Map();
|
|
15
15
|
const exportElements = [];
|
|
16
16
|
let isFlatCompatNeeded = false;
|
|
17
17
|
let isESLintJSNeeded = false;
|
|
18
18
|
let combinedConfig = [];
|
|
19
19
|
let languageOptions = [];
|
|
20
|
-
// exclude dist and eslint config from being linted, which matches the default for new workspaces
|
|
21
|
-
exportElements.push((0, ast_utils_1.generateAst)({
|
|
22
|
-
ignores: ['**/dist'],
|
|
23
|
-
}));
|
|
24
20
|
if (config.extends) {
|
|
25
|
-
const extendsResult = addExtends(importsMap, exportElements, config
|
|
21
|
+
const extendsResult = addExtends(importsMap, exportElements, config);
|
|
26
22
|
isFlatCompatNeeded = extendsResult.isFlatCompatNeeded;
|
|
27
23
|
isESLintJSNeeded = extendsResult.isESLintJSNeeded;
|
|
28
24
|
}
|
|
@@ -74,7 +70,19 @@ function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths, format)
|
|
|
74
70
|
override.parser) {
|
|
75
71
|
isFlatCompatNeeded = true;
|
|
76
72
|
}
|
|
77
|
-
exportElements.push((0, ast_utils_1.generateFlatOverride)(override
|
|
73
|
+
exportElements.push((0, ast_utils_1.generateFlatOverride)(override));
|
|
74
|
+
// eslint-plugin-import cannot be used with ESLint v9 yet
|
|
75
|
+
// TODO(jack): Once v9 support is released, remove this block.
|
|
76
|
+
// See: https://github.com/import-js/eslint-plugin-import/pull/2996
|
|
77
|
+
if (override.extends === 'plugin:@nx/react') {
|
|
78
|
+
exportElements.push((0, ast_utils_1.generateFlatOverride)({
|
|
79
|
+
rules: {
|
|
80
|
+
'import/first': 'off',
|
|
81
|
+
'import/no-amd': 'off',
|
|
82
|
+
'import/no-webpack-loader-syntax': 'off',
|
|
83
|
+
},
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
78
86
|
});
|
|
79
87
|
}
|
|
80
88
|
if (config.ignorePatterns) {
|
|
@@ -100,7 +108,7 @@ function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths, format)
|
|
|
100
108
|
}
|
|
101
109
|
}
|
|
102
110
|
// create the node list and print it to new file
|
|
103
|
-
const nodeList = (0, ast_utils_1.createNodeList)(importsMap, exportElements
|
|
111
|
+
const nodeList = (0, ast_utils_1.createNodeList)(importsMap, exportElements);
|
|
104
112
|
let content = (0, ast_utils_1.stringifyNodeList)(nodeList);
|
|
105
113
|
if (isFlatCompatNeeded) {
|
|
106
114
|
content = (0, ast_utils_1.addFlatCompatToFlatConfig)(content);
|
|
@@ -112,7 +120,7 @@ function convertEslintJsonToFlatConfig(tree, root, config, ignorePaths, format)
|
|
|
112
120
|
};
|
|
113
121
|
}
|
|
114
122
|
// add parsed extends to export blocks and add import statements
|
|
115
|
-
function addExtends(importsMap, configBlocks, config
|
|
123
|
+
function addExtends(importsMap, configBlocks, config) {
|
|
116
124
|
let isFlatCompatNeeded = false;
|
|
117
125
|
let isESLintJSNeeded = false;
|
|
118
126
|
const extendsConfig = Array.isArray(config.extends)
|
|
@@ -126,7 +134,7 @@ function addExtends(importsMap, configBlocks, config, format) {
|
|
|
126
134
|
if (imp.match(/\.eslintrc(.base)?\.json$/)) {
|
|
127
135
|
const localName = index ? `baseConfig${index}` : 'baseConfig';
|
|
128
136
|
configBlocks.push((0, ast_utils_1.generateSpreadElement)(localName));
|
|
129
|
-
const newImport = imp.replace(/^(.*)\.eslintrc(.base)?\.json$/,
|
|
137
|
+
const newImport = imp.replace(/^(.*)\.eslintrc(.base)?\.json$/, '$1eslint$2.config.js');
|
|
130
138
|
importsMap.set(newImport, localName);
|
|
131
139
|
}
|
|
132
140
|
else {
|
|
@@ -14,21 +14,20 @@ async function convertToFlatConfigGenerator(tree, options) {
|
|
|
14
14
|
if (eslintFile.endsWith('.js')) {
|
|
15
15
|
throw new Error('Only json and yaml eslint config files are supported for conversion');
|
|
16
16
|
}
|
|
17
|
-
options.eslintConfigFormat ??= 'mjs';
|
|
18
17
|
const eslintIgnoreFiles = new Set(['.eslintignore']);
|
|
19
|
-
// convert root eslint config to eslint.config.
|
|
20
|
-
convertRootToFlatConfig(tree, eslintFile
|
|
21
|
-
// convert project eslint files to eslint.config.
|
|
18
|
+
// convert root eslint config to eslint.config.js
|
|
19
|
+
convertRootToFlatConfig(tree, eslintFile);
|
|
20
|
+
// convert project eslint files to eslint.config.js
|
|
22
21
|
const projects = (0, devkit_1.getProjects)(tree);
|
|
23
22
|
for (const [project, projectConfig] of projects) {
|
|
24
|
-
convertProjectToFlatConfig(tree, project, projectConfig, (0, devkit_1.readNxJson)(tree), eslintIgnoreFiles
|
|
23
|
+
convertProjectToFlatConfig(tree, project, projectConfig, (0, devkit_1.readNxJson)(tree), eslintIgnoreFiles);
|
|
25
24
|
}
|
|
26
25
|
// delete all .eslintignore files
|
|
27
26
|
for (const ignoreFile of eslintIgnoreFiles) {
|
|
28
27
|
tree.delete(ignoreFile);
|
|
29
28
|
}
|
|
30
29
|
// replace references in nx.json
|
|
31
|
-
updateNxJsonConfig(tree
|
|
30
|
+
updateNxJsonConfig(tree);
|
|
32
31
|
// install missing packages
|
|
33
32
|
if (!options.skipFormat) {
|
|
34
33
|
await (0, devkit_1.formatFiles)(tree);
|
|
@@ -36,13 +35,13 @@ async function convertToFlatConfigGenerator(tree, options) {
|
|
|
36
35
|
return () => (0, devkit_1.installPackagesTask)(tree);
|
|
37
36
|
}
|
|
38
37
|
exports.default = convertToFlatConfigGenerator;
|
|
39
|
-
function convertRootToFlatConfig(tree, eslintFile
|
|
38
|
+
function convertRootToFlatConfig(tree, eslintFile) {
|
|
40
39
|
if (/\.base\.(js|json|yml|yaml)$/.test(eslintFile)) {
|
|
41
|
-
convertConfigToFlatConfig(tree, '', eslintFile,
|
|
40
|
+
convertConfigToFlatConfig(tree, '', eslintFile, 'eslint.base.config.js');
|
|
42
41
|
}
|
|
43
|
-
convertConfigToFlatConfig(tree, '', eslintFile.replace('.base.', '.'),
|
|
42
|
+
convertConfigToFlatConfig(tree, '', eslintFile.replace('.base.', '.'), 'eslint.config.js');
|
|
44
43
|
}
|
|
45
|
-
function convertProjectToFlatConfig(tree, project, projectConfig, nxJson, eslintIgnoreFiles
|
|
44
|
+
function convertProjectToFlatConfig(tree, project, projectConfig, nxJson, eslintIgnoreFiles) {
|
|
46
45
|
const eslintFile = (0, eslint_file_1.findEslintFile)(tree, projectConfig.root);
|
|
47
46
|
if (eslintFile && !eslintFile.endsWith('.js')) {
|
|
48
47
|
if (projectConfig.targets) {
|
|
@@ -68,7 +67,7 @@ function convertProjectToFlatConfig(tree, project, projectConfig, nxJson, eslint
|
|
|
68
67
|
? p === '@nx/eslint/plugin'
|
|
69
68
|
: p.plugin === '@nx/eslint/plugin');
|
|
70
69
|
if (nxHasEsLintTargets || nxHasEsLintPlugin || eslintTargets.length > 0) {
|
|
71
|
-
convertConfigToFlatConfig(tree, projectConfig.root, eslintFile,
|
|
70
|
+
convertConfigToFlatConfig(tree, projectConfig.root, eslintFile, 'eslint.config.js', ignorePath);
|
|
72
71
|
eslintIgnoreFiles.add(`${projectConfig.root}/.eslintignore`);
|
|
73
72
|
if (ignorePath) {
|
|
74
73
|
eslintIgnoreFiles.add(ignorePath);
|
|
@@ -79,35 +78,35 @@ function convertProjectToFlatConfig(tree, project, projectConfig, nxJson, eslint
|
|
|
79
78
|
}
|
|
80
79
|
// update names of eslint files in nx.json
|
|
81
80
|
// and remove eslintignore
|
|
82
|
-
function updateNxJsonConfig(tree
|
|
81
|
+
function updateNxJsonConfig(tree) {
|
|
83
82
|
if (tree.exists('nx.json')) {
|
|
84
83
|
(0, devkit_1.updateJson)(tree, 'nx.json', (json) => {
|
|
85
84
|
if (json.targetDefaults?.lint?.inputs) {
|
|
86
85
|
const inputSet = new Set(json.targetDefaults.lint.inputs);
|
|
87
|
-
inputSet.add(
|
|
86
|
+
inputSet.add('{workspaceRoot}/eslint.config.js');
|
|
88
87
|
json.targetDefaults.lint.inputs = Array.from(inputSet);
|
|
89
88
|
}
|
|
90
89
|
if (json.targetDefaults?.['@nx/eslint:lint']?.inputs) {
|
|
91
90
|
const inputSet = new Set(json.targetDefaults['@nx/eslint:lint'].inputs);
|
|
92
|
-
inputSet.add(
|
|
91
|
+
inputSet.add('{workspaceRoot}/eslint.config.js');
|
|
93
92
|
json.targetDefaults['@nx/eslint:lint'].inputs = Array.from(inputSet);
|
|
94
93
|
}
|
|
95
94
|
if (json.namedInputs?.production) {
|
|
96
95
|
const inputSet = new Set(json.namedInputs.production);
|
|
97
|
-
inputSet.add(
|
|
96
|
+
inputSet.add('!{projectRoot}/eslint.config.js');
|
|
98
97
|
json.namedInputs.production = Array.from(inputSet);
|
|
99
98
|
}
|
|
100
99
|
return json;
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
|
-
function convertConfigToFlatConfig(tree, root, source, target,
|
|
103
|
+
function convertConfigToFlatConfig(tree, root, source, target, ignorePath) {
|
|
105
104
|
const ignorePaths = ignorePath
|
|
106
105
|
? [ignorePath, `${root}/.eslintignore`]
|
|
107
106
|
: [`${root}/.eslintignore`];
|
|
108
107
|
if (source.endsWith('.json')) {
|
|
109
108
|
const config = (0, devkit_1.readJson)(tree, `${root}/${source}`);
|
|
110
|
-
const conversionResult = (0, json_converter_1.convertEslintJsonToFlatConfig)(tree, root, config, ignorePaths
|
|
109
|
+
const conversionResult = (0, json_converter_1.convertEslintJsonToFlatConfig)(tree, root, config, ignorePaths);
|
|
111
110
|
return processConvertedConfig(tree, root, source, target, conversionResult);
|
|
112
111
|
}
|
|
113
112
|
if (source.endsWith('.yaml') || source.endsWith('.yml')) {
|
|
@@ -117,7 +116,7 @@ function convertConfigToFlatConfig(tree, root, source, target, format, ignorePat
|
|
|
117
116
|
json: true,
|
|
118
117
|
filename: source,
|
|
119
118
|
});
|
|
120
|
-
const conversionResult = (0, json_converter_1.convertEslintJsonToFlatConfig)(tree, root, config, ignorePaths
|
|
119
|
+
const conversionResult = (0, json_converter_1.convertEslintJsonToFlatConfig)(tree, root, config, ignorePaths);
|
|
121
120
|
return processConvertedConfig(tree, root, source, target, conversionResult);
|
|
122
121
|
}
|
|
123
122
|
}
|
|
@@ -33,8 +33,7 @@ function postTargetTransformer(target, tree, projectDetails, inferredTargetConfi
|
|
|
33
33
|
'default',
|
|
34
34
|
'{workspaceRoot}/.eslintrc.json',
|
|
35
35
|
'{workspaceRoot}/.eslintignore',
|
|
36
|
-
'{workspaceRoot}/eslint.config.
|
|
37
|
-
'{workspaceRoot}/eslint.config.mjs',
|
|
36
|
+
'{workspaceRoot}/eslint.config.js',
|
|
38
37
|
].includes(input));
|
|
39
38
|
if (inputs.length === 0) {
|
|
40
39
|
delete target.inputs;
|
|
@@ -26,4 +26,4 @@ export declare const javaScriptOverride: {
|
|
|
26
26
|
rules: {};
|
|
27
27
|
};
|
|
28
28
|
export declare const getGlobalEsLintConfiguration: (unitTestRunner?: string, rootProject?: boolean) => Linter.Config;
|
|
29
|
-
export declare const getGlobalFlatEslintConfiguration: (
|
|
29
|
+
export declare const getGlobalFlatEslintConfiguration: (rootProject?: boolean) => string;
|
|
@@ -78,16 +78,14 @@ const getGlobalEsLintConfiguration = (unitTestRunner, rootProject) => {
|
|
|
78
78
|
return config;
|
|
79
79
|
};
|
|
80
80
|
exports.getGlobalEsLintConfiguration = getGlobalEsLintConfiguration;
|
|
81
|
-
const getGlobalFlatEslintConfiguration = (
|
|
82
|
-
const nodeList = (0, ast_utils_1.createNodeList)(new Map(), []
|
|
81
|
+
const getGlobalFlatEslintConfiguration = (rootProject) => {
|
|
82
|
+
const nodeList = (0, ast_utils_1.createNodeList)(new Map(), []);
|
|
83
83
|
let content = (0, ast_utils_1.stringifyNodeList)(nodeList);
|
|
84
84
|
content = (0, ast_utils_1.addImportToFlatConfig)(content, 'nx', '@nx/eslint-plugin');
|
|
85
85
|
content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatPredefinedConfig)('flat/base'), { insertAtTheEnd: false });
|
|
86
86
|
content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatPredefinedConfig)('flat/typescript'));
|
|
87
87
|
content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatPredefinedConfig)('flat/javascript'));
|
|
88
|
-
content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)({
|
|
89
|
-
ignores: ['**/dist'],
|
|
90
|
-
}, format));
|
|
88
|
+
content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)({ ignores: ['**/dist'] }));
|
|
91
89
|
if (!rootProject) {
|
|
92
90
|
content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)({
|
|
93
91
|
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
|
|
@@ -107,21 +105,12 @@ const getGlobalFlatEslintConfiguration = (format, rootProject) => {
|
|
|
107
105
|
},
|
|
108
106
|
],
|
|
109
107
|
},
|
|
110
|
-
}
|
|
108
|
+
}));
|
|
111
109
|
}
|
|
112
110
|
content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)({
|
|
113
|
-
files: [
|
|
114
|
-
'**/*.ts',
|
|
115
|
-
'**/*.tsx',
|
|
116
|
-
'**/*.cts',
|
|
117
|
-
'**/*.mts',
|
|
118
|
-
'**/*.js',
|
|
119
|
-
'**/*.jsx',
|
|
120
|
-
'**/*.cjs',
|
|
121
|
-
'**/*.mjs',
|
|
122
|
-
],
|
|
111
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
|
|
123
112
|
rules: {},
|
|
124
|
-
}
|
|
113
|
+
}));
|
|
125
114
|
return content;
|
|
126
115
|
};
|
|
127
116
|
exports.getGlobalFlatEslintConfiguration = getGlobalFlatEslintConfiguration;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { GeneratorCallback, ProjectConfiguration, TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
|
-
export declare function migrateConfigToMonorepoStyle(projects: ProjectConfiguration[], tree: Tree, unitTestRunner: string,
|
|
2
|
+
export declare function migrateConfigToMonorepoStyle(projects: ProjectConfiguration[], tree: Tree, unitTestRunner: string, keepExistingVersions?: boolean): GeneratorCallback;
|
|
3
3
|
export declare function findLintTarget(project: ProjectConfiguration): TargetConfiguration;
|