@nx/eslint 0.0.0-pr-31231-180f614 → 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.
Files changed (52) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/migrations.json +112 -69
  4. package/package.json +7 -6
  5. package/src/executors/lint/utility/eslint-utils.js +0 -6
  6. package/src/generators/convert-to-flat-config/converters/json-converter.d.ts +1 -1
  7. package/src/generators/convert-to-flat-config/converters/json-converter.js +18 -10
  8. package/src/generators/convert-to-flat-config/generator.js +17 -18
  9. package/src/generators/convert-to-flat-config/schema.d.ts +0 -2
  10. package/src/generators/convert-to-inferred/convert-to-inferred.js +1 -2
  11. package/src/generators/init/global-eslint-config.d.ts +1 -1
  12. package/src/generators/init/global-eslint-config.js +6 -17
  13. package/src/generators/init/init-migration.d.ts +1 -1
  14. package/src/generators/init/init-migration.js +13 -18
  15. package/src/generators/init/init.d.ts +0 -1
  16. package/src/generators/init/init.js +6 -31
  17. package/src/generators/lint-project/lint-project.d.ts +0 -1
  18. package/src/generators/lint-project/lint-project.js +15 -37
  19. package/src/generators/lint-project/setup-root-eslint.d.ts +0 -1
  20. package/src/generators/lint-project/setup-root-eslint.js +1 -2
  21. package/src/generators/utils/eslint-file.d.ts +2 -3
  22. package/src/generators/utils/eslint-file.js +28 -160
  23. package/src/generators/utils/flat-config/ast-utils.d.ts +4 -12
  24. package/src/generators/utils/flat-config/ast-utils.js +63 -412
  25. package/src/generators/utils/linter.d.ts +0 -3
  26. package/src/generators/utils/linter.js +2 -2
  27. package/src/generators/workspace-rules-project/workspace-rules-project.js +1 -3
  28. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  29. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  30. package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.d.ts +2 -0
  31. package/src/migrations/update-16-8-0-add-ignored-files/update-16-8-0-add-ignored-files.js +44 -0
  32. package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.d.ts +2 -0
  33. package/src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint.js +47 -0
  34. package/src/migrations/update-17-1-0/update-typescript-eslint.d.ts +2 -0
  35. package/src/migrations/update-17-1-0/update-typescript-eslint.js +74 -0
  36. package/src/migrations/update-17-2-0/simplify-eslint-patterns.d.ts +2 -0
  37. package/src/migrations/update-17-2-0/simplify-eslint-patterns.js +46 -0
  38. package/src/migrations/update-17-2-9/move-options-to-target-defaults.d.ts +2 -0
  39. package/src/migrations/update-17-2-9/move-options-to-target-defaults.js +107 -0
  40. package/src/plugins/plugin.js +10 -21
  41. package/src/utils/config-file.d.ts +1 -3
  42. package/src/utils/config-file.js +2 -5
  43. package/src/utils/flat-config.d.ts +0 -1
  44. package/src/utils/flat-config.js +3 -9
  45. package/src/utils/version-utils.d.ts +0 -1
  46. package/src/utils/version-utils.js +9 -13
  47. package/src/utils/versions.d.ts +2 -3
  48. package/src/utils/versions.js +3 -4
  49. package/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.d.ts +0 -2
  50. package/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.js +0 -23
  51. package/src/migrations/update-20-3-0/add-file-extensions-to-overrides.d.ts +0 -2
  52. package/src/migrations/update-20-3-0/add-file-extensions-to-overrides.js +0 -49
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2025 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
11
  [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
- [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
12
+ [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
13
13
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
14
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
15
  [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
package/migrations.json CHANGED
@@ -1,112 +1,155 @@
1
1
  {
2
2
  "generators": {
3
- "update-typescript-eslint-v8.13.0": {
4
- "version": "20.2.0-beta.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"
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
- "add-file-extensions-to-overrides": {
9
- "version": "20.3.0-beta.1",
10
- "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"
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
- "19.5.0": {
16
- "version": "19.5.0-beta.1",
36
+ "16.0.0": {
37
+ "version": "16.0.0-beta.0",
17
38
  "packages": {
18
39
  "@typescript-eslint/parser": {
19
- "version": "^7.16.0"
40
+ "version": "^5.58.0"
20
41
  },
21
42
  "@typescript-eslint/eslint-plugin": {
22
- "version": "^7.16.0"
43
+ "version": "^5.58.0"
23
44
  },
24
45
  "@typescript-eslint/utils": {
25
- "version": "^7.16.0"
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
- "20.4.0-typescript-eslint": {
42
- "version": "20.4.0-beta.1",
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": "^8.19.0"
53
+ "@typescript-eslint/parser": {
54
+ "version": "^5.60.1"
49
55
  },
50
56
  "@typescript-eslint/eslint-plugin": {
51
- "version": "^8.19.0"
52
- },
53
- "@typescript-eslint/parser": {
54
- "version": "^8.19.0"
57
+ "version": "^5.60.1"
55
58
  },
56
59
  "@typescript-eslint/utils": {
57
- "version": "^8.19.0"
60
+ "version": "^5.60.1"
61
+ }
62
+ }
63
+ },
64
+ "16.7.0": {
65
+ "version": "16.7.0-beta.2",
66
+ "packages": {
67
+ "eslint": {
68
+ "version": "~8.46.0"
58
69
  },
59
- "@typescript-eslint/rule-tester": {
60
- "version": "^8.19.0",
61
- "alwaysAddToPackageJson": false
70
+ "@typescript-eslint/parser": {
71
+ "version": "^5.60.1"
62
72
  },
63
- "@typescript-eslint/scope-manager": {
64
- "version": "^8.19.0",
65
- "alwaysAddToPackageJson": false
73
+ "@typescript-eslint/eslint-plugin": {
74
+ "version": "^5.60.1"
66
75
  },
67
- "@typescript-eslint/typescript-estree": {
68
- "version": "^8.19.0",
69
- "alwaysAddToPackageJson": false
76
+ "@typescript-eslint/utils": {
77
+ "version": "^5.60.1"
70
78
  }
71
79
  }
72
80
  },
73
- "20.4.0-@typescript-eslint": {
74
- "version": "20.4.0-beta.1",
75
- "requires": {
76
- "@typescript-eslint/eslint-plugin": ">8.0.0 <8.19.0"
77
- },
81
+ "17.0.0": {
82
+ "version": "17.0.0-rc.2",
78
83
  "packages": {
79
- "typescript-eslint": {
80
- "version": "^8.19.0"
84
+ "eslint-config-prettier": {
85
+ "version": "^9.0.0"
86
+ }
87
+ }
88
+ },
89
+ "17.1.0": {
90
+ "version": "17.1.0-beta.1",
91
+ "packages": {
92
+ "@typescript-eslint/parser": {
93
+ "version": "^6.9.1"
81
94
  },
82
95
  "@typescript-eslint/eslint-plugin": {
83
- "version": "^8.19.0"
96
+ "version": "^6.9.1"
84
97
  },
98
+ "@typescript-eslint/utils": {
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"
108
+ }
109
+ }
110
+ },
111
+ "17.3.0": {
112
+ "version": "17.3.0-beta.0",
113
+ "packages": {
85
114
  "@typescript-eslint/parser": {
86
- "version": "^8.19.0"
115
+ "version": "^6.13.2"
116
+ },
117
+ "@typescript-eslint/eslint-plugin": {
118
+ "version": "^6.13.2"
87
119
  },
88
120
  "@typescript-eslint/utils": {
89
- "version": "^8.19.0"
121
+ "version": "^6.13.2"
122
+ }
123
+ }
124
+ },
125
+ "18.2.0": {
126
+ "version": "18.2.0-beta.0",
127
+ "packages": {
128
+ "@typescript-eslint/parser": {
129
+ "version": "^7.3.0"
90
130
  },
91
- "@typescript-eslint/rule-tester": {
92
- "version": "^8.19.0",
93
- "alwaysAddToPackageJson": false
131
+ "@typescript-eslint/eslint-plugin": {
132
+ "version": "^7.3.0"
94
133
  },
95
- "@typescript-eslint/scope-manager": {
96
- "version": "^8.19.0",
97
- "alwaysAddToPackageJson": false
134
+ "@typescript-eslint/utils": {
135
+ "version": "^7.3.0"
98
136
  },
99
- "@typescript-eslint/typescript-estree": {
100
- "version": "^8.19.0",
101
- "alwaysAddToPackageJson": false
137
+ "eslint": {
138
+ "version": "~8.57.0"
102
139
  }
103
140
  }
104
141
  },
105
- "20.7.0": {
106
- "version": "20.7.0-beta.4",
142
+ "19.5.0": {
143
+ "version": "19.5.0-beta.1",
107
144
  "packages": {
108
- "eslint-config-prettier": {
109
- "version": "^10.0.0"
145
+ "@typescript-eslint/parser": {
146
+ "version": "^7.16.0"
147
+ },
148
+ "@typescript-eslint/eslint-plugin": {
149
+ "version": "^7.16.0"
150
+ },
151
+ "@typescript-eslint/utils": {
152
+ "version": "^7.16.0"
110
153
  }
111
154
  }
112
155
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/eslint",
3
- "version": "0.0.0-pr-31231-180f614",
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-31231-180f614",
39
- "@nx/js": "0.0.0-pr-31231-180f614",
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.7.2"
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
- "types": "./index.d.ts",
53
- "type": "commonjs"
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[], format: 'cjs' | 'mjs'): {
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, format) {
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, format);
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, format));
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, format);
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, format) {
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$/, `$1eslint$2.config.${format}`);
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.cjs or eslint.base.config.mjs based on eslintConfigFormat
20
- convertRootToFlatConfig(tree, eslintFile, options.eslintConfigFormat);
21
- // convert project eslint files to eslint.config.cjs
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, options.eslintConfigFormat);
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, options.eslintConfigFormat);
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, format) {
38
+ function convertRootToFlatConfig(tree, eslintFile) {
40
39
  if (/\.base\.(js|json|yml|yaml)$/.test(eslintFile)) {
41
- convertConfigToFlatConfig(tree, '', eslintFile, `eslint.base.config.${format}`, format);
40
+ convertConfigToFlatConfig(tree, '', eslintFile, 'eslint.base.config.js');
42
41
  }
43
- convertConfigToFlatConfig(tree, '', eslintFile.replace('.base.', '.'), `eslint.config.${format}`, format);
42
+ convertConfigToFlatConfig(tree, '', eslintFile.replace('.base.', '.'), 'eslint.config.js');
44
43
  }
45
- function convertProjectToFlatConfig(tree, project, projectConfig, nxJson, eslintIgnoreFiles, format) {
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, `eslint.config.${format}`, format, ignorePath);
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, format) {
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(`{workspaceRoot}/eslint.config.${format}`);
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(`{workspaceRoot}/eslint.config.${format}`);
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(`!{projectRoot}/eslint.config.${format}`);
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, format, ignorePath) {
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, format);
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, format);
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
  }
@@ -1,5 +1,3 @@
1
1
  export interface ConvertToFlatConfigGeneratorSchema {
2
2
  skipFormat?: boolean;
3
- // Internal option
4
- eslintConfigFormat?: 'mjs' | 'cjs';
5
3
  }
@@ -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.cjs',
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: (format: "cjs" | "mjs", rootProject?: boolean) => string;
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 = (format, rootProject) => {
82
- const nodeList = (0, ast_utils_1.createNodeList)(new Map(), [], format);
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
- }, format));
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
- }, format));
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, eslintConfigFormat: 'mjs' | 'cjs', keepExistingVersions?: boolean): GeneratorCallback;
2
+ export declare function migrateConfigToMonorepoStyle(projects: ProjectConfiguration[], tree: Tree, unitTestRunner: string, keepExistingVersions?: boolean): GeneratorCallback;
3
3
  export declare function findLintTarget(project: ProjectConfiguration): TargetConfiguration;
@@ -11,19 +11,9 @@ const versions_1 = require("../../utils/versions");
11
11
  const ast_utils_1 = require("../utils/flat-config/ast-utils");
12
12
  const plugin_1 = require("../utils/plugin");
13
13
  const config_file_1 = require("../../utils/config-file");
14
- function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner, eslintConfigFormat, keepExistingVersions) {
14
+ function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner, keepExistingVersions) {
15
15
  const rootEslintConfig = (0, eslint_file_1.findEslintFile)(tree);
16
16
  let skipCleanup = false;
17
- if (rootEslintConfig) {
18
- // We do not want to mix the formats
19
- const fileExtension = (0, path_1.extname)(rootEslintConfig);
20
- if (fileExtension === '.mjs' || fileExtension === '.cjs') {
21
- eslintConfigFormat = fileExtension.slice(1);
22
- }
23
- else {
24
- eslintConfigFormat = (0, eslint_file_1.determineEslintConfigFormat)(tree.read(rootEslintConfig, 'utf-8'));
25
- }
26
- }
27
17
  if (rootEslintConfig?.match(/\.base\./) &&
28
18
  !projects.some((p) => p.root === '.')) {
29
19
  // if the migration has been run already, we need to rename the base config
@@ -37,9 +27,9 @@ function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner, eslintConf
37
27
  (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
38
28
  '@eslint/js': versions_1.eslintVersion,
39
29
  }, undefined, keepExistingVersions);
40
- tree.write(tree.exists(`eslint.config.${eslintConfigFormat}`)
41
- ? `eslint.base.config.${eslintConfigFormat}`
42
- : `eslint.config.${eslintConfigFormat}`, (0, global_eslint_config_1.getGlobalFlatEslintConfiguration)(eslintConfigFormat));
30
+ tree.write(tree.exists('eslint.config.js')
31
+ ? 'eslint.base.config.js'
32
+ : 'eslint.config.js', (0, global_eslint_config_1.getGlobalFlatEslintConfiguration)());
43
33
  }
44
34
  else {
45
35
  const eslintFile = (0, eslint_file_1.findEslintFile)(tree, '.');
@@ -81,7 +71,8 @@ function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner, eslintConf
81
71
  }
82
72
  function findLintTarget(project) {
83
73
  return Object.values(project.targets ?? {}).find((target) => target.executor === '@nx/eslint:lint' ||
84
- target.executor === '@nx/linter:eslint');
74
+ target.executor === '@nx/linter:eslint' ||
75
+ target.executor === '@nrwl/linter:eslint');
85
76
  }
86
77
  function migrateEslintFile(projectEslintPath, tree) {
87
78
  const baseFile = (0, eslint_file_1.findEslintFile)(tree);
@@ -90,13 +81,15 @@ function migrateEslintFile(projectEslintPath, tree) {
90
81
  let config = tree.read(projectEslintPath, 'utf-8');
91
82
  // remove @nx plugin
92
83
  config = (0, ast_utils_1.removePlugin)(config, '@nx', '@nx/eslint-plugin-nx');
93
- // if base config is cjs, we will need to import it using async import
84
+ // extend eslint.base.config.js
94
85
  config = (0, ast_utils_1.addImportToFlatConfig)(config, 'baseConfig', `${(0, devkit_1.offsetFromRoot)((0, path_1.dirname)(projectEslintPath))}${baseFile}`);
95
86
  config = (0, ast_utils_1.addBlockToFlatConfigExport)(config, (0, ast_utils_1.generateSpreadElement)('baseConfig'), { insertAtTheEnd: false });
96
87
  // cleanup file extends
97
88
  config = (0, ast_utils_1.removeCompatExtends)(config, [
98
89
  'plugin:@nx/typescript',
99
90
  'plugin:@nx/javascript',
91
+ 'plugin:@nrwl/typescript',
92
+ 'plugin:@nrwl/javascript',
100
93
  ]);
101
94
  config = (0, ast_utils_1.removePredefinedConfigs)(config, '@nx/eslint-plugin', 'nx', [
102
95
  'flat/base',
@@ -111,7 +104,7 @@ function migrateEslintFile(projectEslintPath, tree) {
111
104
  delete json.root;
112
105
  // remove nrwl/nx plugins
113
106
  if (json.plugins) {
114
- json.plugins = json.plugins.filter((p) => p !== '@nx');
107
+ json.plugins = json.plugins.filter((p) => p !== '@nx' && p !== '@nrwl/nx');
115
108
  if (json.plugins.length === 0) {
116
109
  delete json.plugins;
117
110
  }
@@ -131,7 +124,9 @@ function migrateEslintFile(projectEslintPath, tree) {
131
124
  json.overrides.forEach((override) => {
132
125
  if (override.extends) {
133
126
  override.extends = override.extends.filter((ext) => ext !== 'plugin:@nx/typescript' &&
134
- ext !== 'plugin:@nx/javascript');
127
+ ext !== 'plugin:@nrwl/nx/typescript' &&
128
+ ext !== 'plugin:@nx/javascript' &&
129
+ ext !== 'plugin:@nrwl/nx/javascript');
135
130
  if (override.extends.length === 0) {
136
131
  delete override.extends;
137
132
  }