@nx/eslint 19.1.0-canary.20240511-f7dcf43 → 19.1.0-canary.20240514-cc9b7f3

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": "19.1.0-canary.20240511-f7dcf43",
3
+ "version": "19.1.0-canary.20240514-cc9b7f3",
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": {
@@ -33,12 +33,12 @@
33
33
  "js-yaml": "4.1.0"
34
34
  },
35
35
  "dependencies": {
36
- "@nx/devkit": "19.1.0-canary.20240511-f7dcf43",
37
- "@nx/js": "19.1.0-canary.20240511-f7dcf43",
36
+ "@nx/devkit": "19.1.0-canary.20240514-cc9b7f3",
37
+ "@nx/js": "19.1.0-canary.20240514-cc9b7f3",
38
38
  "eslint": "^8.0.0",
39
39
  "tslib": "^2.3.0",
40
40
  "typescript": "~5.4.2",
41
- "@nx/linter": "19.1.0-canary.20240511-f7dcf43"
41
+ "@nx/linter": "19.1.0-canary.20240514-cc9b7f3"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "js-yaml": {
@@ -38,7 +38,6 @@ async function initEsLint(tree, options) {
38
38
  options.addPlugin ??= addPluginDefault;
39
39
  const hasPlugin = (0, plugin_2.hasEslintPlugin)(tree);
40
40
  const rootEslintFile = (0, eslint_file_1.findEslintFile)(tree);
41
- const graph = await (0, devkit_1.createProjectGraphAsync)();
42
41
  const lintTargetNames = [
43
42
  'lint',
44
43
  'eslint:lint',
@@ -48,7 +47,7 @@ async function initEsLint(tree, options) {
48
47
  '_eslint-lint',
49
48
  ];
50
49
  if (rootEslintFile && options.addPlugin && !hasPlugin) {
51
- await (0, add_plugin_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodes, {
50
+ await (0, add_plugin_1.addPlugin)(tree, '@nx/eslint/plugin', plugin_1.createNodes, {
52
51
  targetName: lintTargetNames,
53
52
  }, options.updatePackageScripts);
54
53
  return () => { };
@@ -58,7 +57,7 @@ async function initEsLint(tree, options) {
58
57
  }
59
58
  updateProductionFileset(tree);
60
59
  if (options.addPlugin) {
61
- await (0, add_plugin_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodes, {
60
+ await (0, add_plugin_1.addPlugin)(tree, '@nx/eslint/plugin', plugin_1.createNodes, {
62
61
  targetName: lintTargetNames,
63
62
  }, options.updatePackageScripts);
64
63
  }
@@ -1,4 +1,4 @@
1
- import type { GeneratorCallback, Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import { Linter as LinterEnum } from '../utils/linter';
3
3
  interface LintProjectOptions {
4
4
  project: string;
@@ -73,7 +73,8 @@ async function lintProjectGeneratorInternal(tree, options) {
73
73
  if (!options.rootProject) {
74
74
  const projects = {};
75
75
  (0, project_configuration_1.getProjects)(tree).forEach((v, k) => (projects[k] = v));
76
- if (isMigrationToMonorepoNeeded(projects, tree)) {
76
+ const graph = await (0, devkit_1.createProjectGraphAsync)();
77
+ if (isMigrationToMonorepoNeeded(tree, graph)) {
77
78
  // we only migrate project configurations that have been created
78
79
  const filteredProjects = [];
79
80
  Object.entries(projects).forEach(([name, project]) => {
@@ -198,30 +199,24 @@ function isBuildableLibraryProject(projectConfig) {
198
199
  * Detect based on the state of lint target configuration of the root project
199
200
  * if we should migrate eslint configs to monorepo style
200
201
  */
201
- function isMigrationToMonorepoNeeded(projects, tree) {
202
+ function isMigrationToMonorepoNeeded(tree, graph) {
202
203
  // the base config is already created, migration has been done
203
204
  if (tree.exists(config_file_1.baseEsLintConfigFile) ||
204
205
  tree.exists(config_file_1.baseEsLintFlatConfigFile)) {
205
206
  return false;
206
207
  }
207
- const configs = Object.values(projects);
208
- if (configs.length === 1) {
209
- return false;
210
- }
208
+ const nodes = Object.values(graph.nodes);
211
209
  // get root project
212
- const rootProject = configs.find((p) => p.root === '.');
213
- if (!rootProject || !rootProject.targets) {
210
+ const rootProject = nodes.find((p) => p.data.root === '.');
211
+ if (!rootProject || !rootProject.data.targets) {
214
212
  return false;
215
213
  }
216
- // check if we're inferring lint target from `@nx/eslint/plugin`
217
- if ((0, plugin_1.hasEslintPlugin)(tree)) {
218
- for (const f of config_file_1.ESLINT_CONFIG_FILENAMES) {
219
- if (tree.exists(f)) {
220
- return true;
221
- }
214
+ for (const targetConfig of Object.values(rootProject.data.targets ?? {})) {
215
+ if (['@nx/eslint:lint', '@nrwl/linter:eslint', '@nx/linter:eslint'].includes(targetConfig.executor) ||
216
+ (targetConfig.executor === 'nx:run-commands' &&
217
+ targetConfig.options?.command.startsWith('eslint '))) {
218
+ return true;
222
219
  }
223
220
  }
224
- // find if root project has lint target
225
- const lintTarget = (0, init_migration_1.findLintTarget)(rootProject);
226
- return !!lintTarget;
221
+ return false;
227
222
  }
@@ -510,7 +510,7 @@ function generateFlatOverride(override) {
510
510
  !override.parser) {
511
511
  if (override.parserOptions) {
512
512
  const { parserOptions, ...rest } = override;
513
- return generateAst({ ...rest, languageSettings: { parserOptions } });
513
+ return generateAst({ ...rest, languageOptions: { parserOptions } });
514
514
  }
515
515
  return generateAst(override);
516
516
  }
@@ -531,7 +531,7 @@ function generateFlatOverride(override) {
531
531
  ];
532
532
  objectLiteralElements.push(ts.factory.createPropertyAssignment('rules', ts.factory.createObjectLiteralExpression(updatedRulesProperties, true)));
533
533
  if (parserOptions) {
534
- addTSObjectProperty(objectLiteralElements, 'languageSettings', {
534
+ addTSObjectProperty(objectLiteralElements, 'languageOptions', {
535
535
  parserOptions,
536
536
  });
537
537
  }