@nx/eslint 23.0.0-beta.2 → 23.0.0-beta.21

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 (129) hide show
  1. package/{index.d.ts → dist/index.d.ts} +0 -1
  2. package/dist/internal.d.ts +7 -0
  3. package/dist/internal.js +33 -0
  4. package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
  5. package/{src → dist/src}/executors/lint/lint.impl.d.ts +0 -1
  6. package/{src → dist/src}/executors/lint/lint.impl.js +5 -7
  7. package/{src → dist/src}/executors/lint/schema.json +1 -0
  8. package/{src → dist/src}/executors/lint/utility/eslint-utils.d.ts +0 -1
  9. package/{src → dist/src}/generators/convert-to-flat-config/converters/json-converter.d.ts +1 -1
  10. package/{src → dist/src}/generators/convert-to-flat-config/converters/json-converter.js +76 -16
  11. package/{src → dist/src}/generators/convert-to-flat-config/generator.d.ts +0 -1
  12. package/dist/src/generators/convert-to-flat-config/generator.js +262 -0
  13. package/{src → dist/src}/generators/convert-to-flat-config/schema.json +7 -0
  14. package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
  15. package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +6 -5
  16. package/{src → dist/src}/generators/convert-to-inferred/lib/target-options-map.d.ts +0 -1
  17. package/{src → dist/src}/generators/init/global-eslint-config.d.ts +0 -1
  18. package/{src → dist/src}/generators/init/init-migration.d.ts +0 -1
  19. package/{src → dist/src}/generators/init/init-migration.js +4 -3
  20. package/{src → dist/src}/generators/init/init.d.ts +0 -1
  21. package/{src → dist/src}/generators/init/init.js +34 -18
  22. package/{src → dist/src}/generators/init/schema.json +1 -1
  23. package/{src → dist/src}/generators/lint-project/lint-project.d.ts +0 -1
  24. package/{src → dist/src}/generators/lint-project/lint-project.js +4 -2
  25. package/{src → dist/src}/generators/lint-project/setup-root-eslint.d.ts +0 -1
  26. package/{src → dist/src}/generators/lint-project/setup-root-eslint.js +21 -17
  27. package/{src → dist/src}/generators/utils/eslint-file.d.ts +0 -1
  28. package/{src → dist/src}/generators/utils/eslint-file.js +3 -5
  29. package/{src → dist/src}/generators/utils/eslint-targets.d.ts +0 -1
  30. package/dist/src/generators/utils/eslint-targets.js +17 -0
  31. package/{src → dist/src}/generators/utils/flat-config/ast-utils.d.ts +1 -2
  32. package/{src → dist/src}/generators/utils/flat-config/ast-utils.js +19 -16
  33. package/{src → dist/src}/generators/utils/flat-config/path-utils.d.ts +0 -1
  34. package/{src → dist/src}/generators/utils/linter.d.ts +0 -1
  35. package/{src → dist/src}/generators/utils/plugin.d.ts +0 -1
  36. package/{src → dist/src}/generators/workspace-rule/workspace-rule.d.ts +0 -1
  37. package/{src → dist/src}/generators/workspace-rule/workspace-rule.js +6 -3
  38. package/{src → dist/src}/generators/workspace-rules-project/workspace-rules-project.d.ts +0 -1
  39. package/{src → dist/src}/generators/workspace-rules-project/workspace-rules-project.js +21 -10
  40. package/{src → dist/src}/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.d.ts +0 -1
  41. package/{src → dist/src}/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.js +6 -2
  42. package/dist/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.md +33 -0
  43. package/{src → dist/src}/migrations/update-20-3-0/add-file-extensions-to-overrides.d.ts +0 -1
  44. package/dist/src/migrations/update-20-3-0/add-file-extensions-to-overrides.md +83 -0
  45. package/{src → dist/src}/migrations/update-21-6-0/update-executor-lint-inputs.d.ts +0 -1
  46. package/{src → dist/src}/migrations/update-21-6-0/update-executor-lint-inputs.js +9 -3
  47. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
  48. package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +198 -0
  49. package/{src → dist/src}/plugins/plugin.d.ts +0 -1
  50. package/{src → dist/src}/plugins/plugin.js +30 -28
  51. package/dist/src/utils/assert-supported-eslint-version.d.ts +2 -0
  52. package/dist/src/utils/assert-supported-eslint-version.js +8 -0
  53. package/{src → dist/src}/utils/config-file.d.ts +0 -1
  54. package/dist/src/utils/deprecation.d.ts +3 -0
  55. package/dist/src/utils/deprecation.js +15 -0
  56. package/{src → dist/src}/utils/flat-config.d.ts +0 -1
  57. package/{src → dist/src}/utils/resolve-eslint-class.d.ts +0 -1
  58. package/dist/src/utils/resolve-eslint-class.js +28 -0
  59. package/{src → dist/src}/utils/rules-requiring-type-checking.d.ts +0 -1
  60. package/dist/src/utils/versions.d.ts +17 -0
  61. package/dist/src/utils/versions.js +50 -0
  62. package/{src → dist/src}/utils/workspace-lint-rules.d.ts +0 -1
  63. package/executors.json +2 -2
  64. package/generators.json +10 -10
  65. package/migrations.json +14 -3
  66. package/package.json +49 -10
  67. package/index.d.ts.map +0 -1
  68. package/plugin.d.ts.map +0 -1
  69. package/src/executors/lint/lint.impl.d.ts.map +0 -1
  70. package/src/executors/lint/utility/eslint-utils.d.ts.map +0 -1
  71. package/src/generators/convert-to-flat-config/converters/json-converter.d.ts.map +0 -1
  72. package/src/generators/convert-to-flat-config/generator.d.ts.map +0 -1
  73. package/src/generators/convert-to-flat-config/generator.js +0 -162
  74. package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
  75. package/src/generators/convert-to-inferred/lib/target-options-map.d.ts.map +0 -1
  76. package/src/generators/init/global-eslint-config.d.ts.map +0 -1
  77. package/src/generators/init/init-migration.d.ts.map +0 -1
  78. package/src/generators/init/init.d.ts.map +0 -1
  79. package/src/generators/lint-project/lint-project.d.ts.map +0 -1
  80. package/src/generators/lint-project/setup-root-eslint.d.ts.map +0 -1
  81. package/src/generators/utils/eslint-file.d.ts.map +0 -1
  82. package/src/generators/utils/eslint-targets.d.ts.map +0 -1
  83. package/src/generators/utils/eslint-targets.js +0 -17
  84. package/src/generators/utils/flat-config/ast-utils.d.ts.map +0 -1
  85. package/src/generators/utils/flat-config/path-utils.d.ts.map +0 -1
  86. package/src/generators/utils/linter.d.ts.map +0 -1
  87. package/src/generators/utils/plugin.d.ts.map +0 -1
  88. package/src/generators/workspace-rule/workspace-rule.d.ts.map +0 -1
  89. package/src/generators/workspace-rules-project/workspace-rules-project.d.ts.map +0 -1
  90. package/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.d.ts.map +0 -1
  91. package/src/migrations/update-20-3-0/add-file-extensions-to-overrides.d.ts.map +0 -1
  92. package/src/migrations/update-21-6-0/update-executor-lint-inputs.d.ts.map +0 -1
  93. package/src/plugins/plugin.d.ts.map +0 -1
  94. package/src/utils/config-file.d.ts.map +0 -1
  95. package/src/utils/flat-config.d.ts.map +0 -1
  96. package/src/utils/resolve-eslint-class.d.ts.map +0 -1
  97. package/src/utils/resolve-eslint-class.js +0 -61
  98. package/src/utils/rules-requiring-type-checking.d.ts.map +0 -1
  99. package/src/utils/version-utils.d.ts +0 -5
  100. package/src/utils/version-utils.d.ts.map +0 -1
  101. package/src/utils/version-utils.js +0 -49
  102. package/src/utils/versions.d.ts +0 -10
  103. package/src/utils/versions.d.ts.map +0 -1
  104. package/src/utils/versions.js +0 -13
  105. package/src/utils/workspace-lint-rules.d.ts.map +0 -1
  106. /package/{LICENSE → dist/LICENSE} +0 -0
  107. /package/{index.js → dist/index.js} +0 -0
  108. /package/{plugin.js → dist/plugin.js} +0 -0
  109. /package/{src → dist/src}/executors/lint/schema.d.ts +0 -0
  110. /package/{src → dist/src}/executors/lint/utility/eslint-utils.js +0 -0
  111. /package/{src → dist/src}/generators/convert-to-flat-config/schema.d.ts +0 -0
  112. /package/{src → dist/src}/generators/convert-to-inferred/lib/target-options-map.js +0 -0
  113. /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
  114. /package/{src → dist/src}/generators/init/global-eslint-config.js +0 -0
  115. /package/{src → dist/src}/generators/utils/flat-config/path-utils.js +0 -0
  116. /package/{src → dist/src}/generators/utils/linter.js +0 -0
  117. /package/{src → dist/src}/generators/utils/plugin.js +0 -0
  118. /package/{src → dist/src}/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +0 -0
  119. /package/{src → dist/src}/generators/workspace-rule/files/__name__.ts__tmpl__ +0 -0
  120. /package/{src → dist/src}/generators/workspace-rule/schema.json +0 -0
  121. /package/{src → dist/src}/generators/workspace-rules-project/files/index.ts__tmpl__ +0 -0
  122. /package/{src → dist/src}/generators/workspace-rules-project/files/tsconfig.json__tmpl__ +0 -0
  123. /package/{src → dist/src}/generators/workspace-rules-project/files/tsconfig.lint.json__tmpl__ +0 -0
  124. /package/{src → dist/src}/generators/workspace-rules-project/schema.json +0 -0
  125. /package/{src → dist/src}/migrations/update-20-3-0/add-file-extensions-to-overrides.js +0 -0
  126. /package/{src → dist/src}/utils/config-file.js +0 -0
  127. /package/{src → dist/src}/utils/flat-config.js +0 -0
  128. /package/{src → dist/src}/utils/rules-requiring-type-checking.js +0 -0
  129. /package/{src → dist/src}/utils/workspace-lint-rules.js +0 -0
@@ -2,13 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = default_1;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const internal_1 = require("@nx/devkit/internal");
5
6
  async function default_1(tree) {
6
- const nxJson = (0, devkit_1.readNxJson)(tree);
7
+ const nxJson = (0, devkit_1.readNxJson)(tree) ?? {};
7
8
  const executor = '@nx/eslint:lint';
8
- if (!nxJson.targetDefaults?.[executor]?.inputs) {
9
+ const existing = (0, internal_1.normalizeTargetDefaults)(nxJson.targetDefaults).find((e) => e.executor === executor &&
10
+ e.target === undefined &&
11
+ e.projects === undefined &&
12
+ e.plugin === undefined);
13
+ if (!existing?.inputs) {
9
14
  return;
10
15
  }
11
- const inputs = nxJson.targetDefaults[executor].inputs;
16
+ const inputs = [...existing.inputs];
12
17
  if (!inputs.includes('^default')) {
13
18
  // Add after 'default' if present, otherwise at the beginning
14
19
  const defaultIndex = inputs.indexOf('default');
@@ -22,6 +27,7 @@ async function default_1(tree) {
22
27
  if (!inputs.includes('{workspaceRoot}/tools/eslint-rules/**/*')) {
23
28
  inputs.push('{workspaceRoot}/tools/eslint-rules/**/*');
24
29
  }
30
+ (0, internal_1.upsertTargetDefault)(tree, nxJson, { executor, inputs });
25
31
  (0, devkit_1.updateNxJson)(tree, nxJson);
26
32
  await (0, devkit_1.formatFiles)(tree);
27
33
  }
@@ -0,0 +1,3 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export default function rewriteInternalSubpathImports(tree: Tree): Promise<void>;
3
+ export declare function rewriteSubpathImports(source: string): string;
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = rewriteInternalSubpathImports;
4
+ exports.rewriteSubpathImports = rewriteSubpathImports;
5
+ const devkit_1 = require("@nx/devkit");
6
+ const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
7
+ const FROM_PREFIX = '@nx/eslint/src/';
8
+ const TO_PUBLIC = '@nx/eslint';
9
+ const TO_INTERNAL = '@nx/eslint/internal';
10
+ // Symbols exported from `@nx/eslint`'s public entry (packages/eslint/index.ts).
11
+ // A named import/export of one of these from `@nx/eslint/src/*` is routed to
12
+ // the public `@nx/eslint` entry; everything else goes to `@nx/eslint/internal`.
13
+ const PUBLIC_SYMBOLS = new Set([
14
+ 'lintProjectGenerator',
15
+ 'lintInitGenerator',
16
+ 'Linter',
17
+ 'LinterType',
18
+ ]);
19
+ // Methods on `jest` and `vi` that take a module specifier as their first arg.
20
+ const MOCK_HELPER_METHODS = new Set([
21
+ 'mock',
22
+ 'unmock',
23
+ 'doMock',
24
+ 'dontMock',
25
+ 'requireActual',
26
+ 'requireMock',
27
+ 'importActual',
28
+ 'importMock',
29
+ ]);
30
+ let ts;
31
+ async function rewriteInternalSubpathImports(tree) {
32
+ let touchedCount = 0;
33
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
34
+ if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
35
+ return;
36
+ }
37
+ const original = tree.read(filePath, 'utf-8');
38
+ if (!original || !original.includes(FROM_PREFIX)) {
39
+ return;
40
+ }
41
+ const updated = rewriteSubpathImports(original);
42
+ if (updated !== original) {
43
+ tree.write(filePath, updated);
44
+ touchedCount += 1;
45
+ }
46
+ });
47
+ if (touchedCount > 0) {
48
+ devkit_1.logger.info(`Rewrote @nx/eslint/src/* imports in ${touchedCount} file(s) ` +
49
+ `(public symbols to @nx/eslint, internals to @nx/eslint/internal).`);
50
+ }
51
+ await (0, devkit_1.formatFiles)(tree);
52
+ }
53
+ function rewriteSubpathImports(source) {
54
+ ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
55
+ const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
56
+ /* setParentNodes */ true, ts.ScriptKind.TSX);
57
+ const changes = [];
58
+ for (const stmt of sourceFile.statements) {
59
+ if (ts.isImportDeclaration(stmt)) {
60
+ collectImportRewrite(sourceFile, stmt, changes);
61
+ }
62
+ else if (ts.isExportDeclaration(stmt)) {
63
+ collectExportRewrite(sourceFile, stmt, changes);
64
+ }
65
+ }
66
+ collectCallExpressionRewrites(sourceFile, changes);
67
+ return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
68
+ }
69
+ function isSubpathSpecifier(node) {
70
+ return ts.isStringLiteral(node) && node.text.startsWith(FROM_PREFIX);
71
+ }
72
+ function collectImportRewrite(sourceFile, stmt, changes) {
73
+ if (!isSubpathSpecifier(stmt.moduleSpecifier)) {
74
+ return;
75
+ }
76
+ const clause = stmt.importClause;
77
+ // Pure named imports (`import { a, b } from '...'`) can be split by symbol.
78
+ // A default or namespace import grabs the whole module, so it can't be
79
+ // split — route it wholesale to the internal entry.
80
+ if (clause &&
81
+ !clause.name &&
82
+ clause.namedBindings &&
83
+ ts.isNamedImports(clause.namedBindings)) {
84
+ rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, clause.isTypeOnly, clause.namedBindings.elements, 'import', changes);
85
+ return;
86
+ }
87
+ replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
88
+ }
89
+ function collectExportRewrite(sourceFile, stmt, changes) {
90
+ if (!stmt.moduleSpecifier || !isSubpathSpecifier(stmt.moduleSpecifier)) {
91
+ return;
92
+ }
93
+ // `export { a, b } from '...'` can be split; `export * from '...'` cannot.
94
+ if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
95
+ rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, stmt.isTypeOnly, stmt.exportClause.elements, 'export', changes);
96
+ return;
97
+ }
98
+ replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
99
+ }
100
+ /**
101
+ * Partition the named bindings of an import/export declaration into the ones
102
+ * that resolve to `@nx/eslint`'s public entry and the ones that don't. If both
103
+ * groups are non-empty, the single declaration is split into two.
104
+ */
105
+ function rewriteNamedDeclaration(sourceFile, decl, specifier, isTypeOnly, elements, keyword, changes) {
106
+ const publicEls = [];
107
+ const internalEls = [];
108
+ for (const el of elements) {
109
+ // `propertyName` is the original name in `orig as alias`; fall back to
110
+ // `name` for the plain `orig` form.
111
+ const importedName = (el.propertyName ?? el.name).text;
112
+ (PUBLIC_SYMBOLS.has(importedName) ? publicEls : internalEls).push(el);
113
+ }
114
+ if (publicEls.length === 0) {
115
+ replaceSpecifier(sourceFile, specifier, TO_INTERNAL, changes);
116
+ return;
117
+ }
118
+ if (internalEls.length === 0) {
119
+ replaceSpecifier(sourceFile, specifier, TO_PUBLIC, changes);
120
+ return;
121
+ }
122
+ // Mixed — replace the whole declaration with one statement per target.
123
+ const quote = sourceFile.text.charAt(specifier.getStart(sourceFile));
124
+ const start = decl.getStart(sourceFile);
125
+ const end = decl.getEnd();
126
+ const semicolon = sourceFile.text.charAt(end - 1) === ';' ? ';' : '';
127
+ const prefix = isTypeOnly ? `${keyword} type` : keyword;
128
+ const render = (els, target) => `${prefix} { ${els
129
+ .map((el) => el.getText(sourceFile))
130
+ .join(', ')} } from ${quote}${target}${quote}${semicolon}`;
131
+ changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
132
+ type: devkit_1.ChangeType.Insert,
133
+ index: start,
134
+ text: `${render(publicEls, TO_PUBLIC)}\n${render(internalEls, TO_INTERNAL)}`,
135
+ });
136
+ }
137
+ function collectCallExpressionRewrites(sourceFile, changes) {
138
+ const visit = (node) => {
139
+ if (ts.isCallExpression(node) &&
140
+ shouldRewriteCallExpression(node) &&
141
+ node.arguments.length >= 1 &&
142
+ isSubpathSpecifier(node.arguments[0])) {
143
+ // `require(...)`, dynamic `import(...)` and `jest.mock(...)` reference
144
+ // the module as a whole and can't be symbol-split, so they go to the
145
+ // internal entry.
146
+ replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
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
+ }
157
+ ts.forEachChild(node, visit);
158
+ };
159
+ visit(sourceFile);
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
+ }
168
+ function shouldRewriteCallExpression(call) {
169
+ const callee = call.expression;
170
+ // `require('...')`
171
+ if (ts.isIdentifier(callee) && callee.text === 'require')
172
+ return true;
173
+ // dynamic `import('...')` (runtime form parses as a CallExpression whose
174
+ // callee is the `import` keyword). The `typeof import('...')` type-position
175
+ // form is an `ImportTypeNode` (handled in `collectCallExpressionRewrites`).
176
+ if (callee.kind === ts.SyntaxKind.ImportKeyword)
177
+ return true;
178
+ // `jest.mock(...)` / `vi.mock(...)` and friends.
179
+ if (ts.isPropertyAccessExpression(callee)) {
180
+ const obj = callee.expression;
181
+ if (ts.isIdentifier(obj) &&
182
+ (obj.text === 'jest' || obj.text === 'vi') &&
183
+ MOCK_HELPER_METHODS.has(callee.name.text)) {
184
+ return true;
185
+ }
186
+ }
187
+ return false;
188
+ }
189
+ function replaceSpecifier(sourceFile, literal, target, changes) {
190
+ const start = literal.getStart(sourceFile);
191
+ const end = literal.getEnd();
192
+ const quote = sourceFile.text.charAt(start);
193
+ changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
194
+ type: devkit_1.ChangeType.Insert,
195
+ index: start,
196
+ text: `${quote}${target}${quote}`,
197
+ });
198
+ }
@@ -5,4 +5,3 @@ export interface EslintPluginOptions {
5
5
  }
6
6
  export declare const createNodes: CreateNodesV2<EslintPluginOptions>;
7
7
  export declare const createNodesV2: CreateNodesV2<EslintPluginOptions>;
8
- //# sourceMappingURL=plugin.d.ts.map
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNodesV2 = exports.createNodes = void 0;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
6
6
  const js_1 = require("@nx/js");
7
- const internal_1 = require("@nx/js/src/internal");
7
+ const internal_2 = require("@nx/js/internal");
8
8
  const node_fs_1 = require("node:fs");
9
9
  const node_path_1 = require("node:path");
10
10
  const posix_1 = require("node:path/posix");
@@ -32,14 +32,6 @@ const ESLINT_CONFIG_GLOB_V2 = (0, globs_1.combineGlobPatterns)([
32
32
  ...config_file_1.ESLINT_CONFIG_FILENAMES.map((f) => `**/${f}`),
33
33
  ...PROJECT_CONFIG_FILENAMES.map((f) => `**/${f}`),
34
34
  ]);
35
- function readTargetsCache(cachePath) {
36
- return process.env.NX_CACHE_PROJECT_GRAPH !== 'false' && (0, node_fs_1.existsSync)(cachePath)
37
- ? (0, devkit_1.readJsonFile)(cachePath)
38
- : {};
39
- }
40
- function writeTargetsToCache(cachePath, results) {
41
- (0, devkit_1.writeJsonFile)(cachePath, results);
42
- }
43
35
  const internalCreateNodesV2 = async (ESLint, configFilePath, options, context, projectRootsByEslintRoots, lintableFilesPerProjectRoot, tsconfigChainsByProjectRoot, projectsCache, hashByRoot, pmc) => {
44
36
  const configDir = (0, posix_1.dirname)(configFilePath);
45
37
  const eslintVersion = ESLint.version;
@@ -53,13 +45,17 @@ const internalCreateNodesV2 = async (ESLint, configFilePath, options, context, p
53
45
  });
54
46
  return sharedEslint;
55
47
  };
56
- const projects = {};
57
- await Promise.all(projectRootsByEslintRoots.get(configDir).map(async (projectRoot) => {
48
+ // Collect each project root's contribution in parallel, but write
49
+ // them into `projects` afterwards in input order so insertion order
50
+ // (and therefore downstream merge order) is deterministic. Mutating
51
+ // `projects` from inside `Promise.all` would order keys by which
52
+ // async branch resolves first.
53
+ const orderedProjectRoots = projectRootsByEslintRoots.get(configDir) ?? [];
54
+ const contributions = await Promise.all(orderedProjectRoots.map(async (projectRoot) => {
58
55
  const hash = hashByRoot.get(projectRoot);
59
- if (projectsCache[hash]) {
60
- // We can reuse the projects in the cache.
61
- Object.assign(projects, projectsCache[hash]);
62
- return;
56
+ const cached = projectsCache.get(hash);
57
+ if (cached) {
58
+ return cached;
63
59
  }
64
60
  let hasNonIgnoredLintableFiles = false;
65
61
  if (configDir !== projectRoot || projectRoot === '.') {
@@ -76,20 +72,26 @@ const internalCreateNodesV2 = async (ESLint, configFilePath, options, context, p
76
72
  }
77
73
  if (!hasNonIgnoredLintableFiles) {
78
74
  // No lintable files in the project, store in the cache and skip further processing
79
- projectsCache[hash] = {};
80
- return;
75
+ projectsCache.set(hash, {});
76
+ return null;
81
77
  }
82
78
  const project = getProjectUsingESLintConfig(configFilePath, projectRoot, eslintVersion, options, context, pmc, tsconfigChainsByProjectRoot.get(projectRoot) ?? []);
83
79
  if (project) {
84
- projects[projectRoot] = project;
80
+ const entry = { [projectRoot]: project };
85
81
  // Store project into the cache
86
- projectsCache[hash] = { [projectRoot]: project };
87
- }
88
- else {
89
- // No project found, store in the cache
90
- projectsCache[hash] = {};
82
+ projectsCache.set(hash, entry);
83
+ return entry;
91
84
  }
85
+ // No project found, store in the cache
86
+ projectsCache.set(hash, {});
87
+ return null;
92
88
  }));
89
+ const projects = {};
90
+ for (const contribution of contributions) {
91
+ if (contribution) {
92
+ Object.assign(projects, contribution);
93
+ }
94
+ }
93
95
  return {
94
96
  projects,
95
97
  };
@@ -101,12 +103,12 @@ exports.createNodes = [
101
103
  const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
102
104
  const optionsHash = (0, file_hasher_1.hashObject)(options);
103
105
  const cachePath = (0, posix_1.join)(cache_directory_1.workspaceDataDirectory, `eslint-${optionsHash}.hash`);
104
- const targetsCache = readTargetsCache(cachePath);
106
+ const targetsCache = new internal_1.PluginCache(cachePath);
105
107
  const { eslintConfigFiles, projectRoots, projectRootsByEslintRoots } = splitConfigFiles(configFiles);
106
108
  const lintableFilesPerProjectRoot = await collectLintableFilesByProjectRoot(projectRoots, options, context);
107
109
  const tsconfigChainsByProjectRoot = collectTsconfigChainsByProjectRoot(projectRoots, context.workspaceRoot);
108
110
  const lockFilePattern = (0, js_1.getLockFileName)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
109
- const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, options, context, projectRoots.map((root) => {
111
+ const hashes = await (0, internal_1.calculateHashesForCreateNodes)(projectRoots, options, context, projectRoots.map((root) => {
110
112
  const parentConfigs = eslintConfigFiles.filter((eslintConfig) => isSubDir(root, (0, posix_1.dirname)(eslintConfig)));
111
113
  return [
112
114
  ...parentConfigs,
@@ -132,7 +134,7 @@ exports.createNodes = [
132
134
  return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => internalCreateNodesV2(ESLint, configFile, options, context, projectRootsByEslintRoots, lintableFilesPerProjectRoot, tsconfigChainsByProjectRoot, targetsCache, hashByRoot, pmc), eslintConfigFiles, options, context);
133
135
  }
134
136
  finally {
135
- writeTargetsToCache(cachePath, targetsCache);
137
+ targetsCache.writeToDisk();
136
138
  }
137
139
  },
138
140
  ];
@@ -197,7 +199,7 @@ function collectTsconfigChainsByProjectRoot(projectRoots, workspaceRoot) {
197
199
  continue;
198
200
  const outside = [];
199
201
  const projectPrefix = `${projectRoot}/`;
200
- (0, internal_1.walkTsconfigExtendsChain)((0, posix_1.join)(workspaceRoot, tsconfigPath), (absolutePath) => {
202
+ (0, internal_2.walkTsconfigExtendsChain)((0, posix_1.join)(workspaceRoot, tsconfigPath), (absolutePath) => {
201
203
  const wsRelative = (0, node_path_1.relative)(workspaceRoot, absolutePath)
202
204
  .split(node_path_1.sep)
203
205
  .join('/');
@@ -0,0 +1,2 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare function assertSupportedEslintVersion(tree: Tree): void;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertSupportedEslintVersion = assertSupportedEslintVersion;
4
+ const internal_1 = require("@nx/devkit/internal");
5
+ const versions_1 = require("./versions");
6
+ function assertSupportedEslintVersion(tree) {
7
+ (0, internal_1.assertSupportedPackageVersion)(tree, 'eslint', versions_1.minSupportedEslintVersion);
8
+ }
@@ -8,4 +8,3 @@ export declare const legacyBaseEsLintFlatConfigFile = "eslint.base.config.js";
8
8
  export declare function isFlatConfig(configFilePath: string): boolean;
9
9
  export declare function findFlatConfigFile(directory: string, workspaceRoot: string): string | null;
10
10
  export declare function findOldConfigFile(filePathOrDirectory: string, workspaceRoot: string): string | null;
11
- //# sourceMappingURL=config-file.d.ts.map
@@ -0,0 +1,3 @@
1
+ export declare const ESLINT_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/eslint:lint` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/eslint:convert-to-inferred` to migrate to the `@nx/eslint/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
2
+ export declare function warnEslintExecutorDeprecation(): void;
3
+ export declare function warnEslintExecutorGenerating(): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ESLINT_EXECUTOR_DEPRECATION_MESSAGE = void 0;
4
+ exports.warnEslintExecutorDeprecation = warnEslintExecutorDeprecation;
5
+ exports.warnEslintExecutorGenerating = warnEslintExecutorGenerating;
6
+ const devkit_1 = require("@nx/devkit");
7
+ // TODO(v24): Remove the @nx/eslint:lint executor. The inferred plugin
8
+ // (@nx/eslint/plugin) and the convert-to-inferred generator stay supported.
9
+ exports.ESLINT_EXECUTOR_DEPRECATION_MESSAGE = 'The `@nx/eslint:lint` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/eslint:convert-to-inferred` to migrate to the `@nx/eslint/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.';
10
+ function warnEslintExecutorDeprecation() {
11
+ devkit_1.logger.warn(exports.ESLINT_EXECUTOR_DEPRECATION_MESSAGE);
12
+ }
13
+ function warnEslintExecutorGenerating() {
14
+ devkit_1.logger.warn('Generating a target that uses the deprecated `@nx/eslint:lint` executor. The executor will be removed in Nx v24. Run `nx g @nx/eslint:convert-to-inferred` next to migrate this target to the `@nx/eslint/plugin` inferred plugin and prevent future generators from emitting executor targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.');
15
+ }
@@ -3,4 +3,3 @@ export declare const eslintFlatConfigFilenames: string[];
3
3
  export declare const baseEslintConfigFilenames: string[];
4
4
  export declare function getRootESLintFlatConfigFilename(tree: Tree): string;
5
5
  export declare function useFlatConfig(tree?: Tree): boolean;
6
- //# sourceMappingURL=flat-config.d.ts.map
@@ -2,4 +2,3 @@ import type { ESLint } from 'eslint';
2
2
  export declare function resolveESLintClass(opts?: {
3
3
  useFlatConfigOverrideVal: boolean;
4
4
  }): Promise<typeof ESLint>;
5
- //# sourceMappingURL=resolve-eslint-class.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveESLintClass = resolveESLintClass;
4
+ const flat_config_1 = require("../utils/flat-config");
5
+ async function resolveESLintClass(opts) {
6
+ try {
7
+ const shouldESLintUseFlatConfig = typeof opts?.useFlatConfigOverrideVal === 'boolean'
8
+ ? opts.useFlatConfigOverrideVal
9
+ : (0, flat_config_1.useFlatConfig)();
10
+ // In eslint 8.57.0 (the final v8 version), a dedicated API was added for resolving the correct ESLint class.
11
+ const eslintModule = (await import('eslint'));
12
+ if (typeof eslintModule.loadESLint === 'function') {
13
+ return (await eslintModule.loadESLint({
14
+ useFlatConfig: shouldESLintUseFlatConfig,
15
+ }));
16
+ }
17
+ // Explicitly use the FlatESLint and LegacyESLint classes here because the ESLint class points at a different one based on ESLint v8 vs ESLint v9
18
+ // But the decision on which one to use is not just based on the major version of ESLint.
19
+ const { LegacyESLint, FlatESLint } = await import('eslint/use-at-your-own-risk');
20
+ // LegacyESLint's type no longer structurally matches the flat ESLint class
21
+ // in v9 type defs (new static members like defaultConfig, fromOptionsModule),
22
+ // but at runtime either class is an appropriate return value here.
23
+ return (shouldESLintUseFlatConfig ? FlatESLint : LegacyESLint);
24
+ }
25
+ catch {
26
+ throw new Error('Unable to find `eslint`. Ensure a valid `eslint` version is installed.');
27
+ }
28
+ }
@@ -1,4 +1,3 @@
1
1
  import type { Linter } from 'eslint';
2
2
  export declare function hasRulesRequiringTypeChecking(eslintConfig: Linter.LegacyConfig): boolean;
3
3
  export declare function removeParserOptionsProjectIfNotRequired(json: Linter.LegacyConfig): Linter.LegacyConfig;
4
- //# sourceMappingURL=rules-requiring-type-checking.d.ts.map
@@ -0,0 +1,17 @@
1
+ import { type Tree } from '@nx/devkit';
2
+ export declare const nxVersion: any;
3
+ export declare const minSupportedEslintVersion = "8.0.0";
4
+ export declare const eslintConfigPrettierVersion = "^10.0.0";
5
+ export declare const eslintrcVersion = "^2.1.1";
6
+ export declare const jsoncEslintParserVersion = "^2.1.0";
7
+ export declare const eslintCompat = "^1.1.1";
8
+ export declare const eslintVersion = "^9.8.0";
9
+ export declare const typescriptESLintVersion = "^8.40.0";
10
+ type EslintVersions = {
11
+ eslintVersion: string;
12
+ typescriptESLintVersion: string;
13
+ };
14
+ export declare function versions(tree: Tree): EslintVersions;
15
+ export declare function getInstalledEslintVersion(tree?: Tree): string | null;
16
+ export declare function getInstalledEslintMajorVersion(tree?: Tree): number | null;
17
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.typescriptESLintVersion = exports.eslintVersion = exports.eslintCompat = exports.jsoncEslintParserVersion = exports.eslintrcVersion = exports.eslintConfigPrettierVersion = exports.minSupportedEslintVersion = exports.nxVersion = void 0;
4
+ exports.versions = versions;
5
+ exports.getInstalledEslintVersion = getInstalledEslintVersion;
6
+ exports.getInstalledEslintMajorVersion = getInstalledEslintMajorVersion;
7
+ const internal_1 = require("@nx/devkit/internal");
8
+ const path_1 = require("path");
9
+ const semver_1 = require("semver");
10
+ const flat_config_1 = require("./flat-config");
11
+ exports.nxVersion = require((0, path_1.join)('@nx/eslint', 'package.json')).version;
12
+ exports.minSupportedEslintVersion = '8.0.0';
13
+ exports.eslintConfigPrettierVersion = '^10.0.0';
14
+ exports.eslintrcVersion = '^2.1.1';
15
+ exports.jsoncEslintParserVersion = '^2.1.0';
16
+ exports.eslintCompat = '^1.1.1';
17
+ exports.eslintVersion = '^9.8.0';
18
+ exports.typescriptESLintVersion = '^8.40.0';
19
+ const latestVersions = {
20
+ eslintVersion: exports.eslintVersion,
21
+ typescriptESLintVersion: exports.typescriptESLintVersion,
22
+ };
23
+ const versionMap = {
24
+ 8: {
25
+ eslintVersion: '~8.57.0',
26
+ typescriptESLintVersion: '^8.40.0',
27
+ },
28
+ };
29
+ function versions(tree) {
30
+ const installedEslintVersion = getInstalledEslintVersion(tree);
31
+ if (installedEslintVersion) {
32
+ const eslintMajorVersion = (0, semver_1.major)(installedEslintVersion);
33
+ return versionMap[eslintMajorVersion] ?? latestVersions;
34
+ }
35
+ // No ESLint declared yet — fresh installs honor the user's flat-config
36
+ // preference. Without flat config, install ESLint v8 (eslintrc lane); with
37
+ // flat config, install ESLint v9. Both lanes ship typescript-eslint v8 to
38
+ // match the `@nx/eslint-plugin` `@typescript-eslint/parser` peer.
39
+ return (0, flat_config_1.useFlatConfig)(tree) ? latestVersions : versionMap[8];
40
+ }
41
+ function getInstalledEslintVersion(tree) {
42
+ if (!tree) {
43
+ return (0, internal_1.getInstalledPackageVersion)('eslint');
44
+ }
45
+ return (0, internal_1.getDeclaredPackageVersion)(tree, 'eslint');
46
+ }
47
+ function getInstalledEslintMajorVersion(tree) {
48
+ const installedEslintVersion = getInstalledEslintVersion(tree);
49
+ return installedEslintVersion ? (0, semver_1.major)(installedEslintVersion) : null;
50
+ }
@@ -1,2 +1 @@
1
1
  export declare const workspaceLintPluginDir: string;
2
- //# sourceMappingURL=workspace-lint-rules.d.ts.map
package/executors.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "executors": {
3
3
  "lint": {
4
- "implementation": "./src/executors/lint/lint.impl",
5
- "schema": "./src/executors/lint/schema.json",
4
+ "implementation": "./dist/src/executors/lint/lint.impl",
5
+ "schema": "./dist/src/executors/lint/schema.json",
6
6
  "description": "Run ESLint on a project."
7
7
  }
8
8
  }
package/generators.json CHANGED
@@ -3,30 +3,30 @@
3
3
  "version": "0.1",
4
4
  "generators": {
5
5
  "init": {
6
- "factory": "./src/generators/init/init#initEsLint",
7
- "schema": "./src/generators/init/schema.json",
6
+ "factory": "./dist/src/generators/init/init#initEsLint",
7
+ "schema": "./dist/src/generators/init/schema.json",
8
8
  "description": "Set up the ESLint plugin.",
9
9
  "hidden": true
10
10
  },
11
11
  "workspace-rules-project": {
12
- "factory": "./src/generators/workspace-rules-project/workspace-rules-project#lintWorkspaceRulesProjectGenerator",
13
- "schema": "./src/generators/workspace-rules-project/schema.json",
12
+ "factory": "./dist/src/generators/workspace-rules-project/workspace-rules-project#lintWorkspaceRulesProjectGenerator",
13
+ "schema": "./dist/src/generators/workspace-rules-project/schema.json",
14
14
  "description": "Create the Workspace Lint Rules Project.",
15
15
  "hidden": true
16
16
  },
17
17
  "workspace-rule": {
18
- "factory": "./src/generators/workspace-rule/workspace-rule#lintWorkspaceRuleGenerator",
19
- "schema": "./src/generators/workspace-rule/schema.json",
18
+ "factory": "./dist/src/generators/workspace-rule/workspace-rule#lintWorkspaceRuleGenerator",
19
+ "schema": "./dist/src/generators/workspace-rule/schema.json",
20
20
  "description": "Create a new Workspace ESLint rule."
21
21
  },
22
22
  "convert-to-flat-config": {
23
- "factory": "./src/generators/convert-to-flat-config/generator",
24
- "schema": "./src/generators/convert-to-flat-config/schema.json",
23
+ "factory": "./dist/src/generators/convert-to-flat-config/generator",
24
+ "schema": "./dist/src/generators/convert-to-flat-config/schema.json",
25
25
  "description": "Convert an Nx workspace's ESLint configs to use Flat Config."
26
26
  },
27
27
  "convert-to-inferred": {
28
- "factory": "./src/generators/convert-to-inferred/convert-to-inferred",
29
- "schema": "./src/generators/convert-to-inferred/schema.json",
28
+ "factory": "./dist/src/generators/convert-to-inferred/convert-to-inferred",
29
+ "schema": "./dist/src/generators/convert-to-inferred/schema.json",
30
30
  "description": "Convert existing ESLint project(s) using `@nx/eslint:lint` executor to use `@nx/eslint/plugin`."
31
31
  }
32
32
  }
package/migrations.json CHANGED
@@ -3,17 +3,28 @@
3
3
  "update-typescript-eslint-v8.13.0": {
4
4
  "version": "20.2.0-beta.5",
5
5
  "description": "Update TypeScript ESLint packages to v8.13.0 if they are already on v8",
6
- "implementation": "./src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0"
6
+ "implementation": "./dist/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0",
7
+ "requires": {
8
+ "@typescript-eslint/parser": ">=8.0.0"
9
+ }
7
10
  },
8
11
  "add-file-extensions-to-overrides": {
9
12
  "version": "20.3.0-beta.1",
10
13
  "description": "Update ESLint flat config to include .cjs, .mjs, .cts, and .mts files in overrides (if needed)",
11
- "implementation": "./src/migrations/update-20-3-0/add-file-extensions-to-overrides"
14
+ "implementation": "./dist/src/migrations/update-20-3-0/add-file-extensions-to-overrides",
15
+ "requires": {
16
+ "eslint": ">=8.57.0"
17
+ }
12
18
  },
13
19
  "update-executor-lint-inputs": {
14
20
  "version": "22.7.0-beta.12",
15
21
  "description": "Add missing inputs to @nx/eslint:lint executor target defaults",
16
- "implementation": "./src/migrations/update-21-6-0/update-executor-lint-inputs"
22
+ "implementation": "./dist/src/migrations/update-21-6-0/update-executor-lint-inputs"
23
+ },
24
+ "rewrite-eslint-internal-subpath-imports": {
25
+ "version": "23.0.0-beta.17",
26
+ "description": "Rewrites `@nx/eslint/src/*` subpath imports now that the `./src/*` subpath is no longer exposed by `@nx/eslint`'s exports map. Named imports/exports of public symbols are routed to `@nx/eslint` and the rest to the new `@nx/eslint/internal` entry; `require`, dynamic `import` and `jest.mock` calls reference the whole module and are routed to `@nx/eslint/internal`.",
27
+ "implementation": "./dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports"
17
28
  }
18
29
  },
19
30
  "packageJsonUpdates": {