@nx/eslint 17.0.3 → 17.1.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/migrations.json CHANGED
@@ -27,6 +27,11 @@
27
27
  "version": "17.0.0-beta.7",
28
28
  "description": "update-17-0-0-rename-to-eslint",
29
29
  "implementation": "./src/migrations/update-17-0-0-rename-to-eslint/update-17-0-0-rename-to-eslint"
30
+ },
31
+ "update-typescript-eslint": {
32
+ "version": "17.1.0-beta.1",
33
+ "description": "Updates for @typescript-utils/utils v6.9.1+",
34
+ "implementation": "./src/migrations/update-17-1-0/update-typescript-eslint"
30
35
  }
31
36
  },
32
37
  "packageJsonUpdates": {
@@ -82,6 +87,20 @@
82
87
  "version": "^9.0.0"
83
88
  }
84
89
  }
90
+ },
91
+ "17.1.0": {
92
+ "version": "17.1.0-beta.1",
93
+ "packages": {
94
+ "@typescript-eslint/parser": {
95
+ "version": "^6.9.1"
96
+ },
97
+ "@typescript-eslint/eslint-plugin": {
98
+ "version": "^6.9.1"
99
+ },
100
+ "@typescript-eslint/utils": {
101
+ "version": "^6.9.1"
102
+ }
103
+ }
85
104
  }
86
105
  }
87
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/eslint",
3
- "version": "17.0.3",
3
+ "version": "17.1.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": {
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "tslib": "^2.3.0",
37
- "@nx/devkit": "17.0.3",
38
- "@nx/js": "17.0.3",
37
+ "@nx/devkit": "17.1.0-beta.2",
38
+ "@nx/js": "17.1.0-beta.2",
39
39
  "typescript": "~5.1.3",
40
- "@nx/linter": "17.0.3"
40
+ "@nx/linter": "17.1.0-beta.2"
41
41
  },
42
42
  "peerDependenciesMeta": {
43
43
  "eslint": {
@@ -27,7 +27,7 @@ async function run(options, context) {
27
27
  options.cacheLocation = options.cacheLocation
28
28
  ? (0, devkit_1.joinPathFragments)(options.cacheLocation, projectName)
29
29
  : undefined;
30
- const { printConfig, ...normalizedOptions } = options;
30
+ const { printConfig, errorOnUnmatchedPattern, ...normalizedOptions } = options;
31
31
  /**
32
32
  * Until ESLint v9 is released and the new so called flat config is the default
33
33
  * we only want to support it if the user has explicitly opted into it by converting
@@ -84,7 +84,7 @@ Please see https://nx.dev/guides/eslint for full guidance on how to resolve this
84
84
  // If some unexpected error, rethrow
85
85
  throw err;
86
86
  }
87
- if (lintResults.length === 0) {
87
+ if (lintResults.length === 0 && errorOnUnmatchedPattern) {
88
88
  const ignoredPatterns = (await Promise.all(normalizedOptions.lintFilePatterns.map(async (pattern) => (await eslint.isPathIgnored(pattern)) ? pattern : null)))
89
89
  .filter((pattern) => !!pattern)
90
90
  .map((pattern) => `- '${pattern}'`);
@@ -21,6 +21,7 @@ export interface Schema extends JsonObject {
21
21
  resolvePluginsRelativeTo: string | null;
22
22
  reportUnusedDisableDirectives: Linter.StringSeverity | null;
23
23
  printConfig?: string | null;
24
+ errorOnUnmatchedPattern?: boolean;
24
25
  }
25
26
 
26
27
  type Formatter =
@@ -137,6 +137,11 @@
137
137
  "type": "string",
138
138
  "description": "The equivalent of the `--print-config` flag on the ESLint CLI.",
139
139
  "x-completion-type": "file"
140
+ },
141
+ "errorOnUnmatchedPattern": {
142
+ "type": "boolean",
143
+ "description": "When set to false, equivalent of the `--no-error-on-unmatched-pattern` flag on the ESLint CLI.",
144
+ "default": true
140
145
  }
141
146
  },
142
147
  "required": ["lintFilePatterns"],
@@ -25,7 +25,7 @@ export const rule = ESLintUtils.RuleCreator(() => __filename)({
25
25
  type: 'problem',
26
26
  docs: {
27
27
  description: ``,
28
- recommended: 'error',
28
+ recommended: 'recommended',
29
29
  },
30
30
  schema: [],
31
31
  messages: {},
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "extends": "<%= rootTsConfigPath %>",
3
3
  "compilerOptions": {
4
- "module": "commonjs"
4
+ "moduleResolution": "node16",
5
+ "module": "node16"
5
6
  },
6
7
  "files": [],
7
8
  "include": [],
@@ -1,7 +1,7 @@
1
- import { Tree } from '@nx/devkit';
1
+ import { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  export declare const WORKSPACE_RULES_PROJECT_NAME = "eslint-rules";
3
3
  export declare const WORKSPACE_PLUGIN_DIR = "tools/eslint-rules";
4
4
  export interface LintWorkspaceRulesProjectGeneratorOptions {
5
5
  skipFormat?: boolean;
6
6
  }
7
- export declare function lintWorkspaceRulesProjectGenerator(tree: Tree, options?: LintWorkspaceRulesProjectGeneratorOptions): Promise<import("@nx/devkit").GeneratorCallback>;
7
+ export declare function lintWorkspaceRulesProjectGenerator(tree: Tree, options?: LintWorkspaceRulesProjectGeneratorOptions): Promise<GeneratorCallback>;
@@ -10,7 +10,8 @@ const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
10
10
  exports.WORKSPACE_RULES_PROJECT_NAME = 'eslint-rules';
11
11
  exports.WORKSPACE_PLUGIN_DIR = 'tools/eslint-rules';
12
12
  async function lintWorkspaceRulesProjectGenerator(tree, options = {}) {
13
- const { addPropertyToJestConfig, configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
13
+ const { configurationGenerator } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
14
+ const tasks = [];
14
15
  // Noop if the workspace rules project already exists
15
16
  try {
16
17
  (0, devkit_1.readProjectConfiguration)(tree, exports.WORKSPACE_RULES_PROJECT_NAME);
@@ -39,15 +40,16 @@ async function lintWorkspaceRulesProjectGenerator(tree, options = {}) {
39
40
  (0, devkit_1.updateNxJson)(tree, nxJson);
40
41
  }
41
42
  // Add jest to the project and return installation task
42
- const installTask = await configurationGenerator(tree, {
43
+ tasks.push(await configurationGenerator(tree, {
43
44
  project: exports.WORKSPACE_RULES_PROJECT_NAME,
44
45
  supportTsx: false,
45
46
  skipSerializers: true,
46
47
  setupFile: 'none',
47
48
  compiler: 'tsc',
48
49
  skipFormat: true,
49
- });
50
+ }));
50
51
  (0, devkit_1.updateJson)(tree, (0, path_1.join)(workspace_lint_rules_1.workspaceLintPluginDir, 'tsconfig.spec.json'), (json) => {
52
+ delete json.compilerOptions?.module;
51
53
  if (json.include) {
52
54
  json.include = json.include.map((v) => {
53
55
  if (v.startsWith('src/**')) {
@@ -67,14 +69,13 @@ async function lintWorkspaceRulesProjectGenerator(tree, options = {}) {
67
69
  return json;
68
70
  });
69
71
  // Add swc dependencies
70
- (0, add_swc_dependencies_1.addSwcRegisterDependencies)(tree);
71
- // Add extra config to the jest.config.ts file to allow ESLint 8 exports mapping to work with jest
72
- addPropertyToJestConfig(tree, (0, devkit_1.joinPathFragments)(exports.WORKSPACE_PLUGIN_DIR, 'jest.config.ts'), 'moduleNameMapper', {
73
- '@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs',
74
- });
72
+ tasks.push((0, add_swc_dependencies_1.addSwcRegisterDependencies)(tree));
73
+ tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
74
+ '@typescript-eslint/utils': versions_1.typescriptESLintVersion,
75
+ }));
75
76
  if (!options.skipFormat) {
76
77
  await (0, devkit_1.formatFiles)(tree);
77
78
  }
78
- return installTask;
79
+ return (0, devkit_1.runTasksInSerial)(...tasks);
79
80
  }
80
81
  exports.lintWorkspaceRulesProjectGenerator = lintWorkspaceRulesProjectGenerator;
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<void>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ const versions_1 = require("../../utils/versions");
5
+ const path_1 = require("path");
6
+ const typescript_1 = require("typescript");
7
+ function updateJestConfig(tree) {
8
+ const jestConfigPath = 'tools/eslint-rules/jest.config.ts';
9
+ if (tree.exists(jestConfigPath)) {
10
+ const { removePropertyFromJestConfig } = (0, devkit_1.ensurePackage)('@nx/jest', versions_1.nxVersion);
11
+ removePropertyFromJestConfig(tree, jestConfigPath, [
12
+ 'moduleNameMapper',
13
+ '@eslint/eslintrc',
14
+ ]);
15
+ }
16
+ }
17
+ function updateTsConfigs(tree) {
18
+ const tsConfigPath = 'tools/eslint-rules/tsconfig.json';
19
+ if (tree.exists(tsConfigPath)) {
20
+ (0, devkit_1.updateJson)(tree, tsConfigPath, (tsConfig) => {
21
+ tsConfig.compilerOptions ??= {};
22
+ tsConfig.compilerOptions.moduleResolution = 'node16';
23
+ tsConfig.compilerOptions.module = 'node16';
24
+ return tsConfig;
25
+ });
26
+ }
27
+ const tsConfigSpec = 'tools/eslint-rules/tsconfig.spec.json';
28
+ if (tree.exists(tsConfigSpec)) {
29
+ (0, devkit_1.updateJson)(tree, tsConfigSpec, (tsConfigSpec) => {
30
+ delete tsConfigSpec.compilerOptions?.module;
31
+ delete tsConfigSpec.compilerOptions?.moduleResolution;
32
+ return tsConfigSpec;
33
+ });
34
+ }
35
+ }
36
+ function updateRecommended(tree) {
37
+ (0, devkit_1.visitNotIgnoredFiles)(tree, 'tools/eslint-rules', (path) => {
38
+ if ((0, path_1.extname)(path) !== '.ts') {
39
+ return;
40
+ }
41
+ const contents = tree.read(path, 'utf-8');
42
+ const sourceFile = (0, typescript_1.createSourceFile)(path, contents, typescript_1.ScriptTarget.ESNext, true);
43
+ const changes = [];
44
+ const visit = (node) => {
45
+ if ((0, typescript_1.isPropertyAssignment)(node) &&
46
+ (0, typescript_1.isIdentifier)(node.name) &&
47
+ node.name.text === 'recommended' &&
48
+ (0, typescript_1.isStringLiteral)(node.initializer)) {
49
+ changes.push({
50
+ type: devkit_1.ChangeType.Delete,
51
+ start: node.initializer.getStart(sourceFile),
52
+ length: node.initializer.getWidth(sourceFile),
53
+ });
54
+ changes.push({
55
+ type: devkit_1.ChangeType.Insert,
56
+ index: node.initializer.getStart(sourceFile),
57
+ text: "'recommended'",
58
+ });
59
+ }
60
+ else {
61
+ (0, typescript_1.forEachChild)(node, visit);
62
+ }
63
+ };
64
+ (0, typescript_1.forEachChild)(sourceFile, visit);
65
+ tree.write(path, (0, devkit_1.applyChangesToString)(contents, changes));
66
+ });
67
+ }
68
+ async function update(tree) {
69
+ updateJestConfig(tree);
70
+ updateTsConfigs(tree);
71
+ updateRecommended(tree);
72
+ await (0, devkit_1.formatFiles)(tree);
73
+ }
74
+ exports.default = update;
@@ -2,4 +2,4 @@ export declare const nxVersion: any;
2
2
  export declare const eslintVersion = "~8.46.0";
3
3
  export declare const eslintrcVersion = "^2.1.1";
4
4
  export declare const eslintConfigPrettierVersion = "^9.0.0";
5
- export declare const typescriptESLintVersion = "^5.60.1";
5
+ export declare const typescriptESLintVersion = "^6.9.1";
@@ -5,4 +5,4 @@ exports.nxVersion = require('../../package.json').version;
5
5
  exports.eslintVersion = '~8.46.0';
6
6
  exports.eslintrcVersion = '^2.1.1';
7
7
  exports.eslintConfigPrettierVersion = '^9.0.0';
8
- exports.typescriptESLintVersion = '^5.60.1';
8
+ exports.typescriptESLintVersion = '^6.9.1';