@nx/eslint 19.6.0-canary.20240719-83b88a1 → 19.6.0-canary.20240723-c4f9d89

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.6.0-canary.20240719-83b88a1",
3
+ "version": "19.6.0-canary.20240723-c4f9d89",
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,12 +35,12 @@
35
35
  "eslint": "^8.0.0 || ^9.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "19.6.0-canary.20240719-83b88a1",
39
- "@nx/js": "19.6.0-canary.20240719-83b88a1",
38
+ "@nx/devkit": "19.6.0-canary.20240723-c4f9d89",
39
+ "@nx/js": "19.6.0-canary.20240723-c4f9d89",
40
40
  "semver": "^7.5.3",
41
41
  "tslib": "^2.3.0",
42
42
  "typescript": "~5.4.2",
43
- "@nx/linter": "19.6.0-canary.20240719-83b88a1"
43
+ "@nx/linter": "19.6.0-canary.20240723-c4f9d89"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "@zkochan/js-yaml": {
@@ -137,6 +137,9 @@ Please see https://nx.dev/recipes/tips-n-tricks/eslint for full guidance on how
137
137
  if (printInfo) {
138
138
  outputPrintInfo(totals);
139
139
  }
140
+ if (totals.warnings > options.maxWarnings) {
141
+ console.info(`ESLint found too many warnings (maximum: ${options.maxWarnings}).`);
142
+ }
140
143
  return {
141
144
  success: normalizedOptions.force ||
142
145
  (totals.errors === 0 &&
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.convertToInferred = convertToInferred;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const plugin_1 = require("../../plugins/plugin");
6
5
  const executor_to_plugin_migrator_1 = require("@nx/devkit/src/generators/plugin-migrations/executor-to-plugin-migrator");
7
- const target_options_map_1 = require("./lib/target-options-map");
8
- const utils_1 = require("nx/src/tasks-runner/utils");
9
6
  const plugin_migration_utils_1 = require("@nx/devkit/src/generators/plugin-migrations/plugin-migration-utils");
7
+ const posix_1 = require("node:path/posix");
8
+ const utils_1 = require("nx/src/tasks-runner/utils");
9
+ const plugin_1 = require("../../plugins/plugin");
10
+ const config_file_1 = require("../../utils/config-file");
11
+ const target_options_map_1 = require("./lib/target-options-map");
10
12
  async function convertToInferred(tree, options) {
11
13
  const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
12
14
  const migratedProjects = await (0, executor_to_plugin_migrator_1.migrateProjectExecutorsToPlugin)(tree, projectGraph, '@nx/eslint/plugin', plugin_1.createNodesV2, { targetName: 'lint' }, [
@@ -14,6 +16,7 @@ async function convertToInferred(tree, options) {
14
16
  executors: ['@nx/eslint:lint', '@nrwl/linter:eslint'],
15
17
  postTargetTransformer,
16
18
  targetPluginOptionMapper: (targetName) => ({ targetName }),
19
+ skipTargetFilter,
17
20
  },
18
21
  ], options.project);
19
22
  if (migratedProjects.size === 0) {
@@ -64,10 +67,9 @@ function postTargetTransformer(target, tree, projectDetails, inferredTargetConfi
64
67
  return target;
65
68
  }
66
69
  function handlePropertiesInOptions(options, projectDetails, target) {
67
- if ('eslintConfig' in options) {
68
- options.config = (0, plugin_migration_utils_1.toProjectRelativePath)(options.eslintConfig, projectDetails.root);
69
- delete options.eslintConfig;
70
- }
70
+ // inferred targets are only identified after known files that ESLint would
71
+ // pick up, so we can remove the eslintConfig option
72
+ delete options.eslintConfig;
71
73
  if ('force' in options) {
72
74
  delete options.force;
73
75
  }
@@ -96,16 +98,40 @@ function handlePropertiesInOptions(options, projectDetails, target) {
96
98
  }
97
99
  if ('lintFilePatterns' in options) {
98
100
  const normalizedLintFilePatterns = options.lintFilePatterns.map((pattern) => {
99
- return (0, utils_1.interpolate)(pattern, {
101
+ const interpolatedPattern = (0, utils_1.interpolate)(pattern, {
100
102
  workspaceRoot: '',
101
103
  projectRoot: projectDetails.root,
102
104
  projectName: projectDetails.projectName,
103
105
  });
106
+ if (interpolatedPattern === projectDetails.root) {
107
+ return '.';
108
+ }
109
+ return interpolatedPattern.replace(new RegExp(`^(?:\./)?${projectDetails.root}/`), '');
104
110
  });
105
- options.args = normalizedLintFilePatterns.map((pattern) => pattern.startsWith(projectDetails.root)
106
- ? pattern.replace(new RegExp(`^${projectDetails.root}/`), './')
107
- : pattern);
111
+ options.args = normalizedLintFilePatterns
112
+ // the @nx/eslint/plugin automatically infers these, so we don't need to pass them in
113
+ .filter((p) => projectDetails.root === '.'
114
+ ? !['.', 'src', './src', 'lib', './lib'].includes(p)
115
+ : p !== '.');
116
+ if (options.args.length === 0) {
117
+ delete options.args;
118
+ }
108
119
  delete options.lintFilePatterns;
109
120
  }
110
121
  }
111
122
  exports.default = convertToInferred;
123
+ function skipTargetFilter(targetOptions, project) {
124
+ if (targetOptions.eslintConfig) {
125
+ // check that the eslintConfig option is a default config file known by ESLint
126
+ if (!config_file_1.ESLINT_CONFIG_FILENAMES.includes((0, posix_1.basename)(targetOptions.eslintConfig))) {
127
+ return `The "eslintConfig" option value (${targetOptions.eslintConfig}) is not a default config file known by ESLint.`;
128
+ }
129
+ // check that it is at the project root or in a parent directory
130
+ const eslintConfigPath = (0, posix_1.relative)(project.root, targetOptions.eslintConfig);
131
+ if ((0, posix_1.dirname)(eslintConfigPath) !== '.' &&
132
+ !eslintConfigPath.startsWith('../')) {
133
+ return `The "eslintConfig" option value (${targetOptions.eslintConfig}) must point to a file in the project root or a parent directory.`;
134
+ }
135
+ }
136
+ return false;
137
+ }
@@ -32,7 +32,6 @@ function findFlatConfigFile(directory, workspaceRoot) {
32
32
  while (true) {
33
33
  const configFilePath = getConfigFileInDirectory(currentDir, exports.ESLINT_FLAT_CONFIG_FILENAMES);
34
34
  if (configFilePath) {
35
- console.log(`Found eslint flat config file at: ${configFilePath}`);
36
35
  return configFilePath;
37
36
  }
38
37
  if (currentDir === workspaceRoot) {