@nx/eslint 23.0.0-beta.17 → 23.0.0-beta.19
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.
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#### Update TypeScript ESLint to v8.13.0
|
|
2
|
+
|
|
3
|
+
Update TypeScript ESLint packages to v8.13.0 if they are already on v8
|
|
4
|
+
|
|
5
|
+
#### Sample Code Changes
|
|
6
|
+
|
|
7
|
+
This migration will update `typescript-eslint`, `@typescript-eslint/eslint-plugin`, `@typescript-eslint/parser` and `@typescript-eslint/utils` to `8.13.0` if they are between version `8.0.0` and `8.13.0`.
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```json title="package.json"
|
|
12
|
+
{
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"typescript-eslint": "^8.0.0",
|
|
15
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
16
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
17
|
+
"@typescript-eslint/utils": "^8.0.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
##### After
|
|
23
|
+
|
|
24
|
+
```json title="package.json"
|
|
25
|
+
{
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript-eslint": "^8.13.0",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
|
29
|
+
"@typescript-eslint/parser": "^8.13.0",
|
|
30
|
+
"@typescript-eslint/utils": "^8.13.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#### Update ESLint Config File Extensions in Overrides
|
|
2
|
+
|
|
3
|
+
Update ESLint flat config to include .cjs, .mjs, .cts, and .mts files in overrides (if needed)
|
|
4
|
+
|
|
5
|
+
#### Sample Code Changes
|
|
6
|
+
|
|
7
|
+
Add `.cjs`, `.mjs`, `.cts`, `.mts` file extensions to overrides converted using `convert-to-flat-config`
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```js title="eslint.config.js"
|
|
12
|
+
const { FlatCompat } = require('@eslint/eslintrc');
|
|
13
|
+
const js = require('@eslint/js');
|
|
14
|
+
const nxEslintPlugin = require('@nx/eslint-plugin');
|
|
15
|
+
|
|
16
|
+
const compat = new FlatCompat({
|
|
17
|
+
baseDirectory: __dirname,
|
|
18
|
+
recommendedConfig: js.configs.recommended,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = [
|
|
22
|
+
...compat
|
|
23
|
+
.config({
|
|
24
|
+
extends: ['plugin:@nx/typescript'],
|
|
25
|
+
})
|
|
26
|
+
.map((config) => ({
|
|
27
|
+
...config,
|
|
28
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
29
|
+
rules: {
|
|
30
|
+
...config.rules,
|
|
31
|
+
},
|
|
32
|
+
})),
|
|
33
|
+
...compat
|
|
34
|
+
.config({
|
|
35
|
+
extends: ['plugin:@nx/javascript'],
|
|
36
|
+
})
|
|
37
|
+
.map((config) => ({
|
|
38
|
+
...config,
|
|
39
|
+
files: ['**/*.js', '**/*.jsx'],
|
|
40
|
+
rules: {
|
|
41
|
+
...config.rules,
|
|
42
|
+
},
|
|
43
|
+
})),
|
|
44
|
+
];
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
##### After
|
|
48
|
+
|
|
49
|
+
```js title="eslint.config.js" {17,28}
|
|
50
|
+
const { FlatCompat } = require('@eslint/eslintrc');
|
|
51
|
+
const js = require('@eslint/js');
|
|
52
|
+
const nxEslintPlugin = require('@nx/eslint-plugin');
|
|
53
|
+
|
|
54
|
+
const compat = new FlatCompat({
|
|
55
|
+
baseDirectory: __dirname,
|
|
56
|
+
recommendedConfig: js.configs.recommended,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
module.exports = [
|
|
60
|
+
...compat
|
|
61
|
+
.config({
|
|
62
|
+
extends: ['plugin:@nx/typescript'],
|
|
63
|
+
})
|
|
64
|
+
.map((config) => ({
|
|
65
|
+
...config,
|
|
66
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
|
|
67
|
+
rules: {
|
|
68
|
+
...config.rules,
|
|
69
|
+
},
|
|
70
|
+
})),
|
|
71
|
+
...compat
|
|
72
|
+
.config({
|
|
73
|
+
extends: ['plugin:@nx/javascript'],
|
|
74
|
+
})
|
|
75
|
+
.map((config) => ({
|
|
76
|
+
...config,
|
|
77
|
+
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
|
|
78
|
+
rules: {
|
|
79
|
+
...config.rules,
|
|
80
|
+
},
|
|
81
|
+
})),
|
|
82
|
+
];
|
|
83
|
+
```
|
|
@@ -145,19 +145,34 @@ function collectCallExpressionRewrites(sourceFile, changes) {
|
|
|
145
145
|
// internal entry.
|
|
146
146
|
replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
|
|
147
147
|
}
|
|
148
|
+
else if (ts.isImportTypeNode(node)) {
|
|
149
|
+
// `typeof import('...')` parses as an `ImportTypeNode`, not a
|
|
150
|
+
// CallExpression — its argument is `LiteralTypeNode<StringLiteral>`.
|
|
151
|
+
// The whole module is referenced, so it can't be symbol-split.
|
|
152
|
+
const literal = getImportTypeStringLiteral(node);
|
|
153
|
+
if (literal && literal.text.startsWith(FROM_PREFIX)) {
|
|
154
|
+
replaceSpecifier(sourceFile, literal, TO_INTERNAL, changes);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
148
157
|
ts.forEachChild(node, visit);
|
|
149
158
|
};
|
|
150
159
|
visit(sourceFile);
|
|
151
160
|
}
|
|
161
|
+
function getImportTypeStringLiteral(node) {
|
|
162
|
+
const arg = node.argument;
|
|
163
|
+
if (arg && ts.isLiteralTypeNode(arg) && ts.isStringLiteral(arg.literal)) {
|
|
164
|
+
return arg.literal;
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
152
168
|
function shouldRewriteCallExpression(call) {
|
|
153
169
|
const callee = call.expression;
|
|
154
170
|
// `require('...')`
|
|
155
171
|
if (ts.isIdentifier(callee) && callee.text === 'require')
|
|
156
172
|
return true;
|
|
157
173
|
// dynamic `import('...')` (runtime form parses as a CallExpression whose
|
|
158
|
-
// callee is the `import` keyword). The type-position
|
|
159
|
-
//
|
|
160
|
-
// we don't touch it.
|
|
174
|
+
// callee is the `import` keyword). The `typeof import('...')` type-position
|
|
175
|
+
// form is an `ImportTypeNode` (handled in `collectCallExpressionRewrites`).
|
|
161
176
|
if (callee.kind === ts.SyntaxKind.ImportKeyword)
|
|
162
177
|
return true;
|
|
163
178
|
// `jest.mock(...)` / `vi.mock(...)` and friends.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.0-beta.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -73,17 +73,17 @@
|
|
|
73
73
|
"peerDependencies": {
|
|
74
74
|
"@zkochan/js-yaml": "0.0.7",
|
|
75
75
|
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
76
|
-
"@nx/jest": "23.0.0-beta.
|
|
76
|
+
"@nx/jest": "23.0.0-beta.19"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"semver": "^7.6.3",
|
|
80
80
|
"tslib": "^2.3.0",
|
|
81
81
|
"typescript": "~5.9.2",
|
|
82
|
-
"@nx/
|
|
83
|
-
"@nx/
|
|
82
|
+
"@nx/js": "23.0.0-beta.19",
|
|
83
|
+
"@nx/devkit": "23.0.0-beta.19"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"nx": "23.0.0-beta.
|
|
86
|
+
"nx": "23.0.0-beta.19"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@nx/jest": {
|