@nx/eslint 17.3.0-canary.20231212-99ec7d8 → 17.3.0-canary.20231214-dc03c37

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/migrations.json CHANGED
@@ -114,6 +114,20 @@
114
114
  "version": "~8.48.0"
115
115
  }
116
116
  }
117
+ },
118
+ "17.3.0": {
119
+ "version": "17.3.0-beta.0",
120
+ "packages": {
121
+ "@typescript-eslint/parser": {
122
+ "version": "^6.13.2"
123
+ },
124
+ "@typescript-eslint/eslint-plugin": {
125
+ "version": "^6.13.2"
126
+ },
127
+ "@typescript-eslint/utils": {
128
+ "version": "^6.13.2"
129
+ }
130
+ }
117
131
  }
118
132
  }
119
133
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/eslint",
3
- "version": "17.3.0-canary.20231212-99ec7d8",
3
+ "version": "17.3.0-canary.20231214-dc03c37",
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": {
@@ -34,11 +34,11 @@
34
34
  "js-yaml": "4.1.0"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "17.3.0-canary.20231212-99ec7d8",
38
- "@nx/js": "17.3.0-canary.20231212-99ec7d8",
37
+ "@nx/devkit": "17.3.0-canary.20231214-dc03c37",
38
+ "@nx/js": "17.3.0-canary.20231214-dc03c37",
39
39
  "tslib": "^2.3.0",
40
40
  "typescript": "~5.2.2",
41
- "@nx/linter": "17.3.0-canary.20231212-99ec7d8"
41
+ "@nx/linter": "17.3.0-canary.20231214-dc03c37"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "eslint": {
@@ -93,6 +93,10 @@ const getGlobalFlatEslintConfiguration = (unitTestRunner, rootProject) => {
93
93
  if (unitTestRunner === 'jest') {
94
94
  content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)(jestOverride));
95
95
  }
96
+ // add ignore for .nx folder
97
+ content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateAst)({
98
+ ignores: ['.nx'],
99
+ }));
96
100
  return content;
97
101
  };
98
102
  exports.getGlobalFlatEslintConfiguration = getGlobalFlatEslintConfiguration;
@@ -9,24 +9,44 @@ const flat_config_1 = require("../../utils/flat-config");
9
9
  const versions_1 = require("../../utils/versions");
10
10
  const ast_utils_1 = require("../utils/flat-config/ast-utils");
11
11
  function migrateConfigToMonorepoStyle(projects, tree, unitTestRunner) {
12
- if ((0, flat_config_1.useFlatConfig)(tree)) {
13
- // we need this for the compat
14
- (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
15
- '@eslint/js': versions_1.eslintVersion,
16
- });
17
- tree.write('eslint.base.config.js', (0, global_eslint_config_1.getGlobalFlatEslintConfiguration)(unitTestRunner));
12
+ const rootEslintConfig = (0, eslint_file_1.findEslintFile)(tree);
13
+ let skipCleanup = false;
14
+ if (rootEslintConfig?.match(/\.base\./) &&
15
+ !projects.some((p) => p.root === '.')) {
16
+ // if the migration has been run already, we need to rename the base config
17
+ // and only update the extends paths
18
+ tree.rename(rootEslintConfig, rootEslintConfig.replace('.base.', '.'));
19
+ skipCleanup = true;
18
20
  }
19
21
  else {
20
- (0, devkit_1.writeJson)(tree, '.eslintrc.base.json', (0, global_eslint_config_1.getGlobalEsLintConfiguration)(unitTestRunner));
22
+ if ((0, flat_config_1.useFlatConfig)(tree)) {
23
+ // we need this for the compat
24
+ (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
25
+ '@eslint/js': versions_1.eslintVersion,
26
+ });
27
+ tree.write(tree.exists('eslint.config.js')
28
+ ? 'eslint.base.config.js'
29
+ : 'eslint.config.js', (0, global_eslint_config_1.getGlobalFlatEslintConfiguration)(unitTestRunner));
30
+ }
31
+ else {
32
+ const eslintFile = (0, eslint_file_1.findEslintFile)(tree, '.');
33
+ (0, devkit_1.writeJson)(tree, eslintFile ? '.eslintrc.base.json' : '.eslintrc.json', (0, global_eslint_config_1.getGlobalEsLintConfiguration)(unitTestRunner));
34
+ }
21
35
  }
22
- // update extens in all projects' eslint configs
36
+ // update extends in all projects' eslint configs
23
37
  projects.forEach((project) => {
24
38
  const lintTarget = findLintTarget(project);
25
39
  if (lintTarget) {
26
40
  const eslintFile = lintTarget.options?.eslintConfig || (0, eslint_file_1.findEslintFile)(tree, project.root);
27
41
  if (eslintFile) {
28
42
  const projectEslintPath = (0, devkit_1.joinPathFragments)(project.root, eslintFile);
29
- migrateEslintFile(projectEslintPath, tree);
43
+ if (skipCleanup) {
44
+ const content = tree.read(projectEslintPath, 'utf-8');
45
+ tree.write(projectEslintPath, content.replace(rootEslintConfig, rootEslintConfig.replace('.base.', '.')));
46
+ }
47
+ else {
48
+ migrateEslintFile(projectEslintPath, tree);
49
+ }
30
50
  }
31
51
  }
32
52
  });
@@ -39,13 +59,14 @@ function findLintTarget(project) {
39
59
  }
40
60
  exports.findLintTarget = findLintTarget;
41
61
  function migrateEslintFile(projectEslintPath, tree) {
62
+ const baseFile = (0, eslint_file_1.findEslintFile)(tree);
42
63
  if ((0, eslint_file_1.isEslintConfigSupported)(tree)) {
43
64
  if ((0, flat_config_1.useFlatConfig)(tree)) {
44
65
  let config = tree.read(projectEslintPath, 'utf-8');
45
66
  // remove @nx plugin
46
67
  config = (0, ast_utils_1.removePlugin)(config, '@nx', '@nx/eslint-plugin-nx');
47
68
  // extend eslint.base.config.js
48
- config = (0, ast_utils_1.addImportToFlatConfig)(config, 'baseConfig', `${(0, devkit_1.offsetFromRoot)((0, path_1.dirname)(projectEslintPath))}eslint.base.config.js`);
69
+ config = (0, ast_utils_1.addImportToFlatConfig)(config, 'baseConfig', `${(0, devkit_1.offsetFromRoot)((0, path_1.dirname)(projectEslintPath))}${baseFile}`);
49
70
  config = (0, ast_utils_1.addBlockToFlatConfigExport)(config, (0, ast_utils_1.generateSpreadElement)('baseConfig'), { insertAtTheEnd: false });
50
71
  // cleanup file extends
51
72
  config = (0, ast_utils_1.removeCompatExtends)(config, [
@@ -69,7 +90,7 @@ function migrateEslintFile(projectEslintPath, tree) {
69
90
  }
70
91
  // add extends
71
92
  json.extends = json.extends || [];
72
- const pathToRootConfig = `${(0, devkit_1.offsetFromRoot)((0, path_1.dirname)(projectEslintPath))}.eslintrc.base.json`;
93
+ const pathToRootConfig = `${(0, devkit_1.offsetFromRoot)((0, path_1.dirname)(projectEslintPath))}${baseFile}`;
73
94
  if (json.extends.indexOf(pathToRootConfig) === -1) {
74
95
  json.extends.push(pathToRootConfig);
75
96
  }
@@ -1,5 +1,5 @@
1
- import { Tree } from '@nx/devkit';
2
- import { Linter } from 'eslint';
1
+ import type { Tree } from '@nx/devkit';
2
+ import type { Linter } from 'eslint';
3
3
  export declare function findEslintFile(tree: Tree, projectRoot?: string): string | null;
4
4
  export declare function isEslintConfigSupported(tree: Tree, projectRoot?: string): boolean;
5
5
  export declare function updateRelativePathsInConfig(tree: Tree, sourcePath: string, destinationPath: string): void;
@@ -2,4 +2,4 @@ export declare const nxVersion: any;
2
2
  export declare const eslintVersion = "~8.48.0";
3
3
  export declare const eslintrcVersion = "^2.1.1";
4
4
  export declare const eslintConfigPrettierVersion = "^9.0.0";
5
- export declare const typescriptESLintVersion = "^6.9.1";
5
+ export declare const typescriptESLintVersion = "^6.13.2";
@@ -5,4 +5,4 @@ exports.nxVersion = require('../../package.json').version;
5
5
  exports.eslintVersion = '~8.48.0';
6
6
  exports.eslintrcVersion = '^2.1.1';
7
7
  exports.eslintConfigPrettierVersion = '^9.0.0';
8
- exports.typescriptESLintVersion = '^6.9.1';
8
+ exports.typescriptESLintVersion = '^6.13.2';