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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/eslint",
3
- "version": "23.0.0-beta.0",
3
+ "version": "23.0.0-beta.2",
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": {
@@ -32,19 +32,19 @@
32
32
  "generators": "./generators.json",
33
33
  "executors": "./executors.json",
34
34
  "peerDependencies": {
35
- "@nx/jest": "23.0.0-beta.0",
35
+ "@nx/jest": "23.0.0-beta.2",
36
36
  "@zkochan/js-yaml": "0.0.7",
37
37
  "eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
38
38
  },
39
39
  "dependencies": {
40
- "@nx/devkit": "23.0.0-beta.0",
41
- "@nx/js": "23.0.0-beta.0",
40
+ "@nx/devkit": "23.0.0-beta.2",
41
+ "@nx/js": "23.0.0-beta.2",
42
42
  "semver": "^7.6.3",
43
43
  "tslib": "^2.3.0",
44
44
  "typescript": "~5.9.2"
45
45
  },
46
46
  "devDependencies": {
47
- "nx": "23.0.0-beta.0"
47
+ "nx": "23.0.0-beta.2"
48
48
  },
49
49
  "peerDependenciesMeta": {
50
50
  "@nx/jest": {
@@ -1 +1 @@
1
- {"version":3,"file":"lint-project.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/lint-project/lint-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EASjB,IAAI,EAIL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA0BnE,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAEnC;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,8BAE3E;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,kBAAkB,8BA8I5B"}
1
+ {"version":3,"file":"lint-project.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/lint-project/lint-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,iBAAiB,EAQjB,IAAI,EAIL,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA0BnE,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAEnC;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,8BAE3E;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,kBAAkB,8BA4I5B"}
@@ -78,13 +78,11 @@ async function lintProjectGeneratorInternal(tree, options) {
78
78
  // companion e2e app so we should check if migration to
79
79
  // monorepo style is needed
80
80
  if (!options.rootProject) {
81
- const projects = {};
82
- (0, project_configuration_1.getProjects)(tree).forEach((v, k) => (projects[k] = v));
83
- const graph = await (0, devkit_1.createProjectGraphAsync)();
84
- if (isMigrationToMonorepoNeeded(tree, graph)) {
81
+ const projectsFromTree = (0, project_configuration_1.getProjects)(tree);
82
+ if (await isMigrationToMonorepoNeeded(tree, projectsFromTree)) {
85
83
  // we only migrate project configurations that have been created
86
84
  const filteredProjects = [];
87
- Object.entries(projects).forEach(([name, project]) => {
85
+ projectsFromTree.forEach((project, name) => {
88
86
  if (name !== options.project) {
89
87
  filteredProjects.push(project);
90
88
  }
@@ -244,20 +242,42 @@ function isBuildableLibraryProject(tree, projectConfig) {
244
242
  }
245
243
  /**
246
244
  * Detect based on the state of lint target configuration of the root project
247
- * if we should migrate eslint configs to monorepo style
245
+ * if we should migrate eslint configs to monorepo style.
246
+ *
247
+ * Checks the tree first so explicit root lint targets written earlier in the
248
+ * same generator run are visible; the project graph is only consulted to
249
+ * surface targets inferred by `@nx/eslint/plugin`, which don't appear on the
250
+ * tree.
248
251
  */
249
- function isMigrationToMonorepoNeeded(tree, graph) {
252
+ async function isMigrationToMonorepoNeeded(tree, projectsFromTree) {
250
253
  // the base config is already created, migration has been done
251
254
  if ([config_file_1.baseEsLintConfigFile, ...config_file_1.BASE_ESLINT_CONFIG_FILENAMES].some((f) => tree.exists(f))) {
252
255
  return false;
253
256
  }
254
- const nodes = Object.values(graph.nodes);
255
- // get root project
256
- const rootProject = nodes.find((p) => p.data.root === '.');
257
- if (!rootProject || !rootProject.data.targets) {
257
+ for (const project of projectsFromTree.values()) {
258
+ if (project.root === '.') {
259
+ if (rootHasEslintLintTarget(project.targets)) {
260
+ return true;
261
+ }
262
+ break;
263
+ }
264
+ }
265
+ if (!(0, plugin_1.hasEslintPlugin)(tree)) {
266
+ return false;
267
+ }
268
+ const graph = await (0, devkit_1.createProjectGraphAsync)();
269
+ for (const node of Object.values(graph.nodes)) {
270
+ if (node.data.root === '.') {
271
+ return rootHasEslintLintTarget(node.data.targets);
272
+ }
273
+ }
274
+ return false;
275
+ }
276
+ function rootHasEslintLintTarget(targets) {
277
+ if (!targets) {
258
278
  return false;
259
279
  }
260
- for (const targetConfig of Object.values(rootProject.data.targets ?? {})) {
280
+ for (const targetConfig of Object.values(targets)) {
261
281
  if (['@nx/eslint:lint', '@nx/linter:eslint'].includes(targetConfig.executor) ||
262
282
  (targetConfig.executor === 'nx:run-commands' &&
263
283
  targetConfig.options?.command &&