@nx/eslint 23.0.0-beta.4 → 23.0.0-beta.6

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.4",
3
+ "version": "23.0.0-beta.6",
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.4",
35
+ "@nx/jest": "23.0.0-beta.6",
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.4",
41
- "@nx/js": "23.0.0-beta.4",
40
+ "@nx/devkit": "23.0.0-beta.6",
41
+ "@nx/js": "23.0.0-beta.6",
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.4"
47
+ "nx": "23.0.0-beta.6"
48
48
  },
49
49
  "peerDependenciesMeta": {
50
50
  "@nx/jest": {
@@ -1 +1 @@
1
- {"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAYpB,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,iBA4BlE;AAyJD,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"convert-to-inferred.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/convert-to-inferred/convert-to-inferred.ts"],"names":[],"mappings":"AAKA,OAAO,EAKL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAOpB,UAAU,MAAM;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,iBA4BlE;AAyJD,eAAe,iBAAiB,CAAC"}
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertToInferred = convertToInferred;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
6
- const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
7
6
  const posix_1 = require("node:path/posix");
8
7
  const utils_1 = require("nx/src/tasks-runner/utils");
9
8
  const plugin_1 = require("../../plugins/plugin");
@@ -11,7 +10,7 @@ const config_file_1 = require("../../utils/config-file");
11
10
  const target_options_map_1 = require("./lib/target-options-map");
12
11
  async function convertToInferred(tree, options) {
13
12
  const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
14
- const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/eslint/plugin', plugin_1.createNodesV2, { targetName: 'lint' }, [
13
+ const migratedProjects = await (0, internal_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/eslint/plugin', plugin_1.createNodesV2, { targetName: 'lint' }, [
15
14
  {
16
15
  executors: ['@nx/eslint:lint', '@nrwl/linter:eslint'],
17
16
  postTargetTransformer,
@@ -20,7 +19,7 @@ async function convertToInferred(tree, options) {
20
19
  },
21
20
  ], options.project);
22
21
  if (migratedProjects.size === 0) {
23
- throw new executor_to_plugin_migrator_1.NoTargetsToMigrateError();
22
+ throw new internal_1.NoTargetsToMigrateError();
24
23
  }
25
24
  if (!options.skipFormat) {
26
25
  await (0, devkit_1.formatFiles)(tree);
@@ -75,7 +74,7 @@ function postTargetTransformer(target, tree, projectDetails, inferredTargetConfi
75
74
  }
76
75
  }
77
76
  if (target.outputs) {
78
- (0, plugin_migration_utils_1.processTargetOutputs)(target, [], inferredTargetConfiguration, {
77
+ (0, internal_1.processTargetOutputs)(target, [], inferredTargetConfiguration, {
79
78
  projectName: projectDetails.projectName,
80
79
  projectRoot: projectDetails.root,
81
80
  });
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/init/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAWpB,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,kBAAkB,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CACpC;AA+CD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAwF5B;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iBAAiB,8BAG3B"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,iBAAiB,EAIjB,IAAI,EAGL,MAAM,YAAY,CAAC;AAUpB,MAAM,WAAW,iBAAiB;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,kBAAkB,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CACpC;AA+CD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAwF5B;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iBAAiB,8BAG3B"}
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initEsLint = initEsLint;
4
4
  exports.lintInitGenerator = lintInitGenerator;
5
+ const internal_1 = require("@nx/devkit/internal");
5
6
  const devkit_1 = require("@nx/devkit");
6
- const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
7
7
  const versions_1 = require("../../utils/versions");
8
8
  const eslint_file_1 = require("../utils/eslint-file");
9
9
  const plugin_1 = require("../../plugins/plugin");
@@ -75,7 +75,7 @@ async function initEsLint(tree, options) {
75
75
  '_eslint-lint',
76
76
  ];
77
77
  if (rootEslintFile && options.addPlugin && !hasPlugin) {
78
- await (0, add_plugin_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodesV2, {
78
+ await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodesV2, {
79
79
  targetName: lintTargetNames,
80
80
  }, options.updatePackageScripts);
81
81
  return () => { };
@@ -86,7 +86,7 @@ async function initEsLint(tree, options) {
86
86
  updateProductionFileset(tree, options.eslintConfigFormat);
87
87
  updateVsCodeRecommendedExtensions(tree);
88
88
  if (options.addPlugin) {
89
- await (0, add_plugin_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodesV2, {
89
+ await (0, internal_1.addPlugin)(tree, graph, '@nx/eslint/plugin', plugin_1.createNodesV2, {
90
90
  targetName: lintTargetNames,
91
91
  }, options.updatePackageScripts);
92
92
  }
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEslintTargets = getEslintTargets;
4
- const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
4
+ const internal_1 = require("@nx/devkit/internal");
5
5
  function getEslintTargets(tree) {
6
6
  const eslintTargetNames = new Set();
7
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/eslint:lint', (_, __, target) => {
7
+ (0, internal_1.forEachExecutorOptions)(tree, '@nx/eslint:lint', (_, __, target) => {
8
8
  eslintTargetNames.add(target);
9
9
  });
10
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nx/linter:eslint', (_, __, target) => {
10
+ (0, internal_1.forEachExecutorOptions)(tree, '@nx/linter:eslint', (_, __, target) => {
11
11
  eslintTargetNames.add(target);
12
12
  });
13
- (0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/linter:eslint', (_, __, target) => {
13
+ (0, internal_1.forEachExecutorOptions)(tree, '@nrwl/linter:eslint', (_, __, target) => {
14
14
  eslintTargetNames.add(target);
15
15
  });
16
16
  return eslintTargetNames;
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-rule.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/workspace-rule/workspace-rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAKjB,IAAI,EACL,MAAM,YAAY,CAAC;AASpB,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iCAAiC,8BAiH3C"}
1
+ {"version":3,"file":"workspace-rule.d.ts","sourceRoot":"","sources":["../../../../../../packages/eslint/src/generators/workspace-rule/workspace-rule.ts"],"names":[],"mappings":"AACA,OAAO,EAML,iBAAiB,EAKjB,IAAI,EACL,MAAM,YAAY,CAAC;AAQpB,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,iCAAiC,8BAiH3C"}
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lintWorkspaceRuleGenerator = lintWorkspaceRuleGenerator;
4
4
  const tslib_1 = require("tslib");
5
+ const internal_1 = require("@nx/devkit/internal");
5
6
  const devkit_1 = require("@nx/devkit");
6
- const string_utils_1 = require("@nx/devkit/src/utils/string-utils");
7
7
  const path_1 = require("path");
8
8
  const ts = tslib_1.__importStar(require("typescript"));
9
9
  const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
@@ -30,7 +30,7 @@ async function lintWorkspaceRuleGenerator(tree, options) {
30
30
  name: options.name,
31
31
  flatConfig,
32
32
  });
33
- const nameCamelCase = (0, string_utils_1.camelize)(options.name);
33
+ const nameCamelCase = (0, internal_1.camelize)(options.name);
34
34
  /**
35
35
  * Import the new rule into the workspace plugin index.ts and
36
36
  * register it ready for use in lint configs.
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint/src/plugins/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,EAMd,MAAM,YAAY,CAAC;AAwBpB,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAuHD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CAoF1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint/src/plugins/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,aAAa,EAId,MAAM,YAAY,CAAC;AAuBpB,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AA2GD,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,mBAAmB,CAoF1D,CAAC;AAEF,eAAO,MAAM,aAAa,oCAAc,CAAC"}
@@ -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/src/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;
@@ -56,9 +48,10 @@ const internalCreateNodesV2 = async (ESLint, configFilePath, options, context, p
56
48
  const projects = {};
57
49
  await Promise.all(projectRootsByEslintRoots.get(configDir).map(async (projectRoot) => {
58
50
  const hash = hashByRoot.get(projectRoot);
59
- if (projectsCache[hash]) {
51
+ const cached = projectsCache.get(hash);
52
+ if (cached) {
60
53
  // We can reuse the projects in the cache.
61
- Object.assign(projects, projectsCache[hash]);
54
+ Object.assign(projects, cached);
62
55
  return;
63
56
  }
64
57
  let hasNonIgnoredLintableFiles = false;
@@ -76,18 +69,18 @@ const internalCreateNodesV2 = async (ESLint, configFilePath, options, context, p
76
69
  }
77
70
  if (!hasNonIgnoredLintableFiles) {
78
71
  // No lintable files in the project, store in the cache and skip further processing
79
- projectsCache[hash] = {};
72
+ projectsCache.set(hash, {});
80
73
  return;
81
74
  }
82
75
  const project = getProjectUsingESLintConfig(configFilePath, projectRoot, eslintVersion, options, context, pmc, tsconfigChainsByProjectRoot.get(projectRoot) ?? []);
83
76
  if (project) {
84
77
  projects[projectRoot] = project;
85
78
  // Store project into the cache
86
- projectsCache[hash] = { [projectRoot]: project };
79
+ projectsCache.set(hash, { [projectRoot]: project });
87
80
  }
88
81
  else {
89
82
  // No project found, store in the cache
90
- projectsCache[hash] = {};
83
+ projectsCache.set(hash, {});
91
84
  }
92
85
  }));
93
86
  return {
@@ -101,12 +94,12 @@ exports.createNodes = [
101
94
  const pmc = (0, devkit_1.getPackageManagerCommand)((0, devkit_1.detectPackageManager)(context.workspaceRoot));
102
95
  const optionsHash = (0, file_hasher_1.hashObject)(options);
103
96
  const cachePath = (0, posix_1.join)(cache_directory_1.workspaceDataDirectory, `eslint-${optionsHash}.hash`);
104
- const targetsCache = readTargetsCache(cachePath);
97
+ const targetsCache = new internal_1.PluginCache(cachePath);
105
98
  const { eslintConfigFiles, projectRoots, projectRootsByEslintRoots } = splitConfigFiles(configFiles);
106
99
  const lintableFilesPerProjectRoot = await collectLintableFilesByProjectRoot(projectRoots, options, context);
107
100
  const tsconfigChainsByProjectRoot = collectTsconfigChainsByProjectRoot(projectRoots, context.workspaceRoot);
108
101
  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) => {
102
+ const hashes = await (0, internal_1.calculateHashesForCreateNodes)(projectRoots, options, context, projectRoots.map((root) => {
110
103
  const parentConfigs = eslintConfigFiles.filter((eslintConfig) => isSubDir(root, (0, posix_1.dirname)(eslintConfig)));
111
104
  return [
112
105
  ...parentConfigs,
@@ -132,7 +125,7 @@ exports.createNodes = [
132
125
  return await (0, devkit_1.createNodesFromFiles)((configFile, options, context) => internalCreateNodesV2(ESLint, configFile, options, context, projectRootsByEslintRoots, lintableFilesPerProjectRoot, tsconfigChainsByProjectRoot, targetsCache, hashByRoot, pmc), eslintConfigFiles, options, context);
133
126
  }
134
127
  finally {
135
- writeTargetsToCache(cachePath, targetsCache);
128
+ targetsCache.writeToDisk();
136
129
  }
137
130
  },
138
131
  ];
@@ -197,7 +190,7 @@ function collectTsconfigChainsByProjectRoot(projectRoots, workspaceRoot) {
197
190
  continue;
198
191
  const outside = [];
199
192
  const projectPrefix = `${projectRoot}/`;
200
- (0, internal_1.walkTsconfigExtendsChain)((0, posix_1.join)(workspaceRoot, tsconfigPath), (absolutePath) => {
193
+ (0, internal_2.walkTsconfigExtendsChain)((0, posix_1.join)(workspaceRoot, tsconfigPath), (absolutePath) => {
201
194
  const wsRelative = (0, node_path_1.relative)(workspaceRoot, absolutePath)
202
195
  .split(node_path_1.sep)
203
196
  .join('/');
@@ -4,9 +4,9 @@ exports.getInstalledPackageVersion = getInstalledPackageVersion;
4
4
  exports.getInstalledEslintVersion = getInstalledEslintVersion;
5
5
  exports.getTypeScriptEslintVersionToInstall = getTypeScriptEslintVersionToInstall;
6
6
  const devkit_1 = require("@nx/devkit");
7
- const semver_1 = require("@nx/devkit/src/utils/semver");
7
+ const internal_1 = require("@nx/devkit/internal");
8
8
  const devkit_internals_1 = require("nx/src/devkit-internals");
9
- const semver_2 = require("semver");
9
+ const semver_1 = require("semver");
10
10
  const versions_1 = require("./versions");
11
11
  function getInstalledPackageVersion(pkgName, tree) {
12
12
  try {
@@ -31,8 +31,8 @@ function getInstalledPackageVersion(pkgName, tree) {
31
31
  try {
32
32
  // try to parse and return the version
33
33
  return tree
34
- ? (0, semver_1.checkAndCleanWithSemver)(tree, pkgName, pkgVersionInRootPackageJson)
35
- : (0, semver_1.checkAndCleanWithSemver)(pkgName, pkgVersionInRootPackageJson);
34
+ ? (0, internal_1.checkAndCleanWithSemver)(tree, pkgName, pkgVersionInRootPackageJson)
35
+ : (0, internal_1.checkAndCleanWithSemver)(pkgName, pkgVersionInRootPackageJson);
36
36
  }
37
37
  catch { }
38
38
  // we could not resolve the version
@@ -43,7 +43,7 @@ function getInstalledEslintVersion(tree) {
43
43
  }
44
44
  function getTypeScriptEslintVersionToInstall(tree) {
45
45
  const eslintVersion = getInstalledEslintVersion(tree);
46
- return eslintVersion && (0, semver_2.lt)(eslintVersion, '9.0.0')
46
+ return eslintVersion && (0, semver_1.lt)(eslintVersion, '9.0.0')
47
47
  ? versions_1.typescriptESLintVersion
48
48
  : versions_1.eslint9__typescriptESLintVersion;
49
49
  }