@nx/eslint 23.0.0-beta.16 → 23.0.0-beta.18
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/{index.d.ts → dist/index.d.ts} +0 -1
- package/dist/internal.d.ts +8 -0
- package/dist/internal.js +34 -0
- package/{plugin.d.ts → dist/plugin.d.ts} +0 -1
- package/{src → dist/src}/executors/lint/lint.impl.d.ts +0 -1
- package/{src → dist/src}/executors/lint/utility/eslint-utils.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-flat-config/converters/json-converter.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-flat-config/generator.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.d.ts +0 -1
- package/{src → dist/src}/generators/convert-to-inferred/lib/target-options-map.d.ts +0 -1
- package/{src → dist/src}/generators/init/global-eslint-config.d.ts +0 -1
- package/{src → dist/src}/generators/init/init-migration.d.ts +0 -1
- package/{src → dist/src}/generators/init/init.d.ts +0 -1
- package/{src → dist/src}/generators/lint-project/lint-project.d.ts +0 -1
- package/{src → dist/src}/generators/lint-project/setup-root-eslint.d.ts +0 -1
- package/{src → dist/src}/generators/utils/eslint-file.d.ts +0 -1
- package/{src → dist/src}/generators/utils/eslint-targets.d.ts +0 -1
- package/{src → dist/src}/generators/utils/flat-config/ast-utils.d.ts +0 -1
- package/{src → dist/src}/generators/utils/flat-config/path-utils.d.ts +0 -1
- package/{src → dist/src}/generators/utils/linter.d.ts +0 -1
- package/{src → dist/src}/generators/utils/plugin.d.ts +0 -1
- package/{src → dist/src}/generators/workspace-rule/workspace-rule.d.ts +0 -1
- package/{src → dist/src}/generators/workspace-rules-project/workspace-rules-project.d.ts +0 -1
- package/{src → dist/src}/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.d.ts +0 -1
- package/dist/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.md +33 -0
- package/{src → dist/src}/migrations/update-20-3-0/add-file-extensions-to-overrides.d.ts +0 -1
- package/dist/src/migrations/update-20-3-0/add-file-extensions-to-overrides.md +83 -0
- package/{src → dist/src}/migrations/update-21-6-0/update-executor-lint-inputs.d.ts +0 -1
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.d.ts +3 -0
- package/dist/src/migrations/update-23-0-0/rewrite-internal-subpath-imports.js +183 -0
- package/{src → dist/src}/plugins/plugin.d.ts +0 -1
- package/{src → dist/src}/utils/config-file.d.ts +0 -1
- package/{src → dist/src}/utils/deprecation.d.ts +0 -1
- package/{src → dist/src}/utils/flat-config.d.ts +0 -1
- package/{src → dist/src}/utils/resolve-eslint-class.d.ts +0 -1
- package/dist/src/utils/resolve-eslint-class.js +28 -0
- package/{src → dist/src}/utils/rules-requiring-type-checking.d.ts +0 -1
- package/{src → dist/src}/utils/version-utils.d.ts +0 -1
- package/{src → dist/src}/utils/versions.d.ts +0 -1
- package/{src → dist/src}/utils/versions.js +2 -1
- package/{src → dist/src}/utils/workspace-lint-rules.d.ts +0 -1
- package/executors.json +2 -2
- package/generators.json +10 -10
- package/migrations.json +8 -3
- package/package.json +49 -10
- package/index.d.ts.map +0 -1
- package/plugin.d.ts.map +0 -1
- package/src/executors/lint/lint.impl.d.ts.map +0 -1
- package/src/executors/lint/utility/eslint-utils.d.ts.map +0 -1
- package/src/generators/convert-to-flat-config/converters/json-converter.d.ts.map +0 -1
- package/src/generators/convert-to-flat-config/generator.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/convert-to-inferred.d.ts.map +0 -1
- package/src/generators/convert-to-inferred/lib/target-options-map.d.ts.map +0 -1
- package/src/generators/init/global-eslint-config.d.ts.map +0 -1
- package/src/generators/init/init-migration.d.ts.map +0 -1
- package/src/generators/init/init.d.ts.map +0 -1
- package/src/generators/lint-project/lint-project.d.ts.map +0 -1
- package/src/generators/lint-project/setup-root-eslint.d.ts.map +0 -1
- package/src/generators/utils/eslint-file.d.ts.map +0 -1
- package/src/generators/utils/eslint-targets.d.ts.map +0 -1
- package/src/generators/utils/flat-config/ast-utils.d.ts.map +0 -1
- package/src/generators/utils/flat-config/path-utils.d.ts.map +0 -1
- package/src/generators/utils/linter.d.ts.map +0 -1
- package/src/generators/utils/plugin.d.ts.map +0 -1
- package/src/generators/workspace-rule/workspace-rule.d.ts.map +0 -1
- package/src/generators/workspace-rules-project/workspace-rules-project.d.ts.map +0 -1
- package/src/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.d.ts.map +0 -1
- package/src/migrations/update-20-3-0/add-file-extensions-to-overrides.d.ts.map +0 -1
- package/src/migrations/update-21-6-0/update-executor-lint-inputs.d.ts.map +0 -1
- package/src/plugins/plugin.d.ts.map +0 -1
- package/src/utils/config-file.d.ts.map +0 -1
- package/src/utils/deprecation.d.ts.map +0 -1
- package/src/utils/flat-config.d.ts.map +0 -1
- package/src/utils/resolve-eslint-class.d.ts.map +0 -1
- package/src/utils/resolve-eslint-class.js +0 -61
- package/src/utils/rules-requiring-type-checking.d.ts.map +0 -1
- package/src/utils/version-utils.d.ts.map +0 -1
- package/src/utils/versions.d.ts.map +0 -1
- package/src/utils/workspace-lint-rules.d.ts.map +0 -1
- /package/{LICENSE → dist/LICENSE} +0 -0
- /package/{index.js → dist/index.js} +0 -0
- /package/{plugin.js → dist/plugin.js} +0 -0
- /package/{src → dist/src}/executors/lint/lint.impl.js +0 -0
- /package/{src → dist/src}/executors/lint/schema.d.ts +0 -0
- /package/{src → dist/src}/executors/lint/schema.json +0 -0
- /package/{src → dist/src}/executors/lint/utility/eslint-utils.js +0 -0
- /package/{src → dist/src}/generators/convert-to-flat-config/converters/json-converter.js +0 -0
- /package/{src → dist/src}/generators/convert-to-flat-config/generator.js +0 -0
- /package/{src → dist/src}/generators/convert-to-flat-config/schema.d.ts +0 -0
- /package/{src → dist/src}/generators/convert-to-flat-config/schema.json +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/convert-to-inferred.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/lib/target-options-map.js +0 -0
- /package/{src → dist/src}/generators/convert-to-inferred/schema.json +0 -0
- /package/{src → dist/src}/generators/init/global-eslint-config.js +0 -0
- /package/{src → dist/src}/generators/init/init-migration.js +0 -0
- /package/{src → dist/src}/generators/init/init.js +0 -0
- /package/{src → dist/src}/generators/init/schema.json +0 -0
- /package/{src → dist/src}/generators/lint-project/lint-project.js +0 -0
- /package/{src → dist/src}/generators/lint-project/setup-root-eslint.js +0 -0
- /package/{src → dist/src}/generators/utils/eslint-file.js +0 -0
- /package/{src → dist/src}/generators/utils/eslint-targets.js +0 -0
- /package/{src → dist/src}/generators/utils/flat-config/ast-utils.js +0 -0
- /package/{src → dist/src}/generators/utils/flat-config/path-utils.js +0 -0
- /package/{src → dist/src}/generators/utils/linter.js +0 -0
- /package/{src → dist/src}/generators/utils/plugin.js +0 -0
- /package/{src → dist/src}/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/workspace-rule/files/__name__.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/workspace-rule/schema.json +0 -0
- /package/{src → dist/src}/generators/workspace-rule/workspace-rule.js +0 -0
- /package/{src → dist/src}/generators/workspace-rules-project/files/index.ts__tmpl__ +0 -0
- /package/{src → dist/src}/generators/workspace-rules-project/files/tsconfig.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/workspace-rules-project/files/tsconfig.lint.json__tmpl__ +0 -0
- /package/{src → dist/src}/generators/workspace-rules-project/schema.json +0 -0
- /package/{src → dist/src}/generators/workspace-rules-project/workspace-rules-project.js +0 -0
- /package/{src → dist/src}/migrations/update-20-2-0/update-typescript-eslint-v8-13-0.js +0 -0
- /package/{src → dist/src}/migrations/update-20-3-0/add-file-extensions-to-overrides.js +0 -0
- /package/{src → dist/src}/migrations/update-21-6-0/update-executor-lint-inputs.js +0 -0
- /package/{src → dist/src}/plugins/plugin.js +0 -0
- /package/{src → dist/src}/utils/config-file.js +0 -0
- /package/{src → dist/src}/utils/deprecation.js +0 -0
- /package/{src → dist/src}/utils/flat-config.js +0 -0
- /package/{src → dist/src}/utils/rules-requiring-type-checking.js +0 -0
- /package/{src → dist/src}/utils/version-utils.js +0 -0
- /package/{src → dist/src}/utils/workspace-lint-rules.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { addExtendsToLintConfig, addIgnoresToLintConfig, addOverrideToLintConfig, addPluginsToLintConfig, addPredefinedConfigToFlatLintConfig, findEslintFile, isEslintConfigSupported, lintConfigHasOverride, replaceOverridesInLintConfig, updateOverrideInLintConfig, updateRelativePathsInConfig, } from './src/generators/utils/eslint-file';
|
|
2
|
+
export { addImportToFlatConfig } from './src/generators/utils/flat-config/ast-utils';
|
|
3
|
+
export { useFlatConfig } from './src/utils/flat-config';
|
|
4
|
+
export { javaScriptOverride, typeScriptOverride, } from './src/generators/init/global-eslint-config';
|
|
5
|
+
export { setupRootEsLint } from './src/generators/lint-project/setup-root-eslint';
|
|
6
|
+
export { getInstalledEslintVersion, getTypeScriptEslintVersionToInstall, } from './src/utils/version-utils';
|
|
7
|
+
export { eslint9__typescriptESLintVersion } from './src/utils/versions';
|
|
8
|
+
export type { Schema } from './src/executors/lint/schema';
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Semi-private surface for first-party Nx packages.
|
|
3
|
+
//
|
|
4
|
+
// External plugins should NOT import from here — this entry is curated for
|
|
5
|
+
// internal consumers and may change without semver protection. Mirrors
|
|
6
|
+
// `@nx/devkit/internal`.
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.eslint9__typescriptESLintVersion = exports.getTypeScriptEslintVersionToInstall = exports.getInstalledEslintVersion = exports.setupRootEsLint = exports.typeScriptOverride = exports.javaScriptOverride = exports.useFlatConfig = exports.addImportToFlatConfig = exports.updateRelativePathsInConfig = exports.updateOverrideInLintConfig = exports.replaceOverridesInLintConfig = exports.lintConfigHasOverride = exports.isEslintConfigSupported = exports.findEslintFile = exports.addPredefinedConfigToFlatLintConfig = exports.addPluginsToLintConfig = exports.addOverrideToLintConfig = exports.addIgnoresToLintConfig = exports.addExtendsToLintConfig = void 0;
|
|
9
|
+
var eslint_file_1 = require("./src/generators/utils/eslint-file");
|
|
10
|
+
Object.defineProperty(exports, "addExtendsToLintConfig", { enumerable: true, get: function () { return eslint_file_1.addExtendsToLintConfig; } });
|
|
11
|
+
Object.defineProperty(exports, "addIgnoresToLintConfig", { enumerable: true, get: function () { return eslint_file_1.addIgnoresToLintConfig; } });
|
|
12
|
+
Object.defineProperty(exports, "addOverrideToLintConfig", { enumerable: true, get: function () { return eslint_file_1.addOverrideToLintConfig; } });
|
|
13
|
+
Object.defineProperty(exports, "addPluginsToLintConfig", { enumerable: true, get: function () { return eslint_file_1.addPluginsToLintConfig; } });
|
|
14
|
+
Object.defineProperty(exports, "addPredefinedConfigToFlatLintConfig", { enumerable: true, get: function () { return eslint_file_1.addPredefinedConfigToFlatLintConfig; } });
|
|
15
|
+
Object.defineProperty(exports, "findEslintFile", { enumerable: true, get: function () { return eslint_file_1.findEslintFile; } });
|
|
16
|
+
Object.defineProperty(exports, "isEslintConfigSupported", { enumerable: true, get: function () { return eslint_file_1.isEslintConfigSupported; } });
|
|
17
|
+
Object.defineProperty(exports, "lintConfigHasOverride", { enumerable: true, get: function () { return eslint_file_1.lintConfigHasOverride; } });
|
|
18
|
+
Object.defineProperty(exports, "replaceOverridesInLintConfig", { enumerable: true, get: function () { return eslint_file_1.replaceOverridesInLintConfig; } });
|
|
19
|
+
Object.defineProperty(exports, "updateOverrideInLintConfig", { enumerable: true, get: function () { return eslint_file_1.updateOverrideInLintConfig; } });
|
|
20
|
+
Object.defineProperty(exports, "updateRelativePathsInConfig", { enumerable: true, get: function () { return eslint_file_1.updateRelativePathsInConfig; } });
|
|
21
|
+
var ast_utils_1 = require("./src/generators/utils/flat-config/ast-utils");
|
|
22
|
+
Object.defineProperty(exports, "addImportToFlatConfig", { enumerable: true, get: function () { return ast_utils_1.addImportToFlatConfig; } });
|
|
23
|
+
var flat_config_1 = require("./src/utils/flat-config");
|
|
24
|
+
Object.defineProperty(exports, "useFlatConfig", { enumerable: true, get: function () { return flat_config_1.useFlatConfig; } });
|
|
25
|
+
var global_eslint_config_1 = require("./src/generators/init/global-eslint-config");
|
|
26
|
+
Object.defineProperty(exports, "javaScriptOverride", { enumerable: true, get: function () { return global_eslint_config_1.javaScriptOverride; } });
|
|
27
|
+
Object.defineProperty(exports, "typeScriptOverride", { enumerable: true, get: function () { return global_eslint_config_1.typeScriptOverride; } });
|
|
28
|
+
var setup_root_eslint_1 = require("./src/generators/lint-project/setup-root-eslint");
|
|
29
|
+
Object.defineProperty(exports, "setupRootEsLint", { enumerable: true, get: function () { return setup_root_eslint_1.setupRootEsLint; } });
|
|
30
|
+
var version_utils_1 = require("./src/utils/version-utils");
|
|
31
|
+
Object.defineProperty(exports, "getInstalledEslintVersion", { enumerable: true, get: function () { return version_utils_1.getInstalledEslintVersion; } });
|
|
32
|
+
Object.defineProperty(exports, "getTypeScriptEslintVersionToInstall", { enumerable: true, get: function () { return version_utils_1.getTypeScriptEslintVersionToInstall; } });
|
|
33
|
+
var versions_1 = require("./src/utils/versions");
|
|
34
|
+
Object.defineProperty(exports, "eslint9__typescriptESLintVersion", { enumerable: true, get: function () { return versions_1.eslint9__typescriptESLintVersion; } });
|
|
@@ -2,4 +2,3 @@ import { GeneratorCallback, Tree } from '@nx/devkit';
|
|
|
2
2
|
import { ConvertToFlatConfigGeneratorSchema } from './schema';
|
|
3
3
|
export declare function convertToFlatConfigGenerator(tree: Tree, options: ConvertToFlatConfigGeneratorSchema): Promise<void | GeneratorCallback>;
|
|
4
4
|
export default convertToFlatConfigGenerator;
|
|
5
|
-
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -27,4 +27,3 @@ export declare const javaScriptOverride: {
|
|
|
27
27
|
};
|
|
28
28
|
export declare const getGlobalEsLintConfiguration: (unitTestRunner?: string, rootProject?: boolean) => Linter.LegacyConfig;
|
|
29
29
|
export declare const getGlobalFlatEslintConfiguration: (format: "cjs" | "mjs", rootProject?: boolean) => string;
|
|
30
|
-
//# sourceMappingURL=global-eslint-config.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { GeneratorCallback, ProjectConfiguration, TargetConfiguration, Tree } from '@nx/devkit';
|
|
2
2
|
export declare function migrateConfigToMonorepoStyle(projects: ProjectConfiguration[], tree: Tree, unitTestRunner: string, eslintConfigFormat: 'mjs' | 'cjs', keepExistingVersions?: boolean): GeneratorCallback;
|
|
3
3
|
export declare function findLintTarget(project: ProjectConfiguration): TargetConfiguration;
|
|
4
|
-
//# sourceMappingURL=init-migration.d.ts.map
|
|
@@ -8,4 +8,3 @@ export interface LinterInitOptions {
|
|
|
8
8
|
}
|
|
9
9
|
export declare function initEsLint(tree: Tree, options: LinterInitOptions): Promise<GeneratorCallback>;
|
|
10
10
|
export declare function lintInitGenerator(tree: Tree, options: LinterInitOptions): Promise<GeneratorCallback>;
|
|
11
|
-
//# sourceMappingURL=init.d.ts.map
|
|
@@ -22,4 +22,3 @@ interface LintProjectOptions {
|
|
|
22
22
|
export declare function lintProjectGenerator(tree: Tree, options: LintProjectOptions): Promise<GeneratorCallback>;
|
|
23
23
|
export declare function lintProjectGeneratorInternal(tree: Tree, options: LintProjectOptions): Promise<GeneratorCallback>;
|
|
24
24
|
export {};
|
|
25
|
-
//# sourceMappingURL=lint-project.d.ts.map
|
|
@@ -28,4 +28,3 @@ export declare function addPredefinedConfigToFlatLintConfig(tree: Tree, root: st
|
|
|
28
28
|
export declare function addPluginsToLintConfig(tree: Tree, root: string, plugin: string | string[]): void;
|
|
29
29
|
export declare function addIgnoresToLintConfig(tree: Tree, root: string, ignorePatterns: string[]): void;
|
|
30
30
|
export declare function getPluginImport(pluginName: string): string;
|
|
31
|
-
//# sourceMappingURL=eslint-file.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
2
|
export declare function updateFiles(override: Linter.ConfigOverride<Linter.RulesRecord>): Linter.ConfigOverride<Linter.RulesRecord>;
|
|
3
3
|
export declare function mapFilePath(filePath: string): string;
|
|
4
|
-
//# sourceMappingURL=path-utils.d.ts.map
|
|
@@ -6,4 +6,3 @@ export interface LintWorkspaceRulesProjectGeneratorOptions {
|
|
|
6
6
|
addPlugin?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare function lintWorkspaceRulesProjectGenerator(tree: Tree, options?: LintWorkspaceRulesProjectGeneratorOptions): Promise<GeneratorCallback>;
|
|
9
|
-
//# sourceMappingURL=workspace-rules-project.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#### Update TypeScript ESLint to v8.13.0
|
|
2
|
+
|
|
3
|
+
Update TypeScript ESLint packages to v8.13.0 if they are already on v8
|
|
4
|
+
|
|
5
|
+
#### Sample Code Changes
|
|
6
|
+
|
|
7
|
+
This migration will update `typescript-eslint`, `@typescript-eslint/eslint-plugin`, `@typescript-eslint/parser` and `@typescript-eslint/utils` to `8.13.0` if they are between version `8.0.0` and `8.13.0`.
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```json title="package.json"
|
|
12
|
+
{
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"typescript-eslint": "^8.0.0",
|
|
15
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
16
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
17
|
+
"@typescript-eslint/utils": "^8.0.0"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
##### After
|
|
23
|
+
|
|
24
|
+
```json title="package.json"
|
|
25
|
+
{
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"typescript-eslint": "^8.13.0",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^8.13.0",
|
|
29
|
+
"@typescript-eslint/parser": "^8.13.0",
|
|
30
|
+
"@typescript-eslint/utils": "^8.13.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#### Update ESLint Config File Extensions in Overrides
|
|
2
|
+
|
|
3
|
+
Update ESLint flat config to include .cjs, .mjs, .cts, and .mts files in overrides (if needed)
|
|
4
|
+
|
|
5
|
+
#### Sample Code Changes
|
|
6
|
+
|
|
7
|
+
Add `.cjs`, `.mjs`, `.cts`, `.mts` file extensions to overrides converted using `convert-to-flat-config`
|
|
8
|
+
|
|
9
|
+
##### Before
|
|
10
|
+
|
|
11
|
+
```js title="eslint.config.js"
|
|
12
|
+
const { FlatCompat } = require('@eslint/eslintrc');
|
|
13
|
+
const js = require('@eslint/js');
|
|
14
|
+
const nxEslintPlugin = require('@nx/eslint-plugin');
|
|
15
|
+
|
|
16
|
+
const compat = new FlatCompat({
|
|
17
|
+
baseDirectory: __dirname,
|
|
18
|
+
recommendedConfig: js.configs.recommended,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
module.exports = [
|
|
22
|
+
...compat
|
|
23
|
+
.config({
|
|
24
|
+
extends: ['plugin:@nx/typescript'],
|
|
25
|
+
})
|
|
26
|
+
.map((config) => ({
|
|
27
|
+
...config,
|
|
28
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
29
|
+
rules: {
|
|
30
|
+
...config.rules,
|
|
31
|
+
},
|
|
32
|
+
})),
|
|
33
|
+
...compat
|
|
34
|
+
.config({
|
|
35
|
+
extends: ['plugin:@nx/javascript'],
|
|
36
|
+
})
|
|
37
|
+
.map((config) => ({
|
|
38
|
+
...config,
|
|
39
|
+
files: ['**/*.js', '**/*.jsx'],
|
|
40
|
+
rules: {
|
|
41
|
+
...config.rules,
|
|
42
|
+
},
|
|
43
|
+
})),
|
|
44
|
+
];
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
##### After
|
|
48
|
+
|
|
49
|
+
```js title="eslint.config.js" {17,28}
|
|
50
|
+
const { FlatCompat } = require('@eslint/eslintrc');
|
|
51
|
+
const js = require('@eslint/js');
|
|
52
|
+
const nxEslintPlugin = require('@nx/eslint-plugin');
|
|
53
|
+
|
|
54
|
+
const compat = new FlatCompat({
|
|
55
|
+
baseDirectory: __dirname,
|
|
56
|
+
recommendedConfig: js.configs.recommended,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
module.exports = [
|
|
60
|
+
...compat
|
|
61
|
+
.config({
|
|
62
|
+
extends: ['plugin:@nx/typescript'],
|
|
63
|
+
})
|
|
64
|
+
.map((config) => ({
|
|
65
|
+
...config,
|
|
66
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
|
|
67
|
+
rules: {
|
|
68
|
+
...config.rules,
|
|
69
|
+
},
|
|
70
|
+
})),
|
|
71
|
+
...compat
|
|
72
|
+
.config({
|
|
73
|
+
extends: ['plugin:@nx/javascript'],
|
|
74
|
+
})
|
|
75
|
+
.map((config) => ({
|
|
76
|
+
...config,
|
|
77
|
+
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
|
|
78
|
+
rules: {
|
|
79
|
+
...config.rules,
|
|
80
|
+
},
|
|
81
|
+
})),
|
|
82
|
+
];
|
|
83
|
+
```
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = rewriteInternalSubpathImports;
|
|
4
|
+
exports.rewriteSubpathImports = rewriteSubpathImports;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const TS_EXTENSIONS = ['.ts', '.tsx', '.cts', '.mts'];
|
|
7
|
+
const FROM_PREFIX = '@nx/eslint/src/';
|
|
8
|
+
const TO_PUBLIC = '@nx/eslint';
|
|
9
|
+
const TO_INTERNAL = '@nx/eslint/internal';
|
|
10
|
+
// Symbols exported from `@nx/eslint`'s public entry (packages/eslint/index.ts).
|
|
11
|
+
// A named import/export of one of these from `@nx/eslint/src/*` is routed to
|
|
12
|
+
// the public `@nx/eslint` entry; everything else goes to `@nx/eslint/internal`.
|
|
13
|
+
const PUBLIC_SYMBOLS = new Set([
|
|
14
|
+
'lintProjectGenerator',
|
|
15
|
+
'lintInitGenerator',
|
|
16
|
+
'Linter',
|
|
17
|
+
'LinterType',
|
|
18
|
+
]);
|
|
19
|
+
// Methods on `jest` and `vi` that take a module specifier as their first arg.
|
|
20
|
+
const MOCK_HELPER_METHODS = new Set([
|
|
21
|
+
'mock',
|
|
22
|
+
'unmock',
|
|
23
|
+
'doMock',
|
|
24
|
+
'dontMock',
|
|
25
|
+
'requireActual',
|
|
26
|
+
'requireMock',
|
|
27
|
+
'importActual',
|
|
28
|
+
'importMock',
|
|
29
|
+
]);
|
|
30
|
+
let ts;
|
|
31
|
+
async function rewriteInternalSubpathImports(tree) {
|
|
32
|
+
let touchedCount = 0;
|
|
33
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (filePath) => {
|
|
34
|
+
if (!TS_EXTENSIONS.some((ext) => filePath.endsWith(ext))) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const original = tree.read(filePath, 'utf-8');
|
|
38
|
+
if (!original || !original.includes(FROM_PREFIX)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const updated = rewriteSubpathImports(original);
|
|
42
|
+
if (updated !== original) {
|
|
43
|
+
tree.write(filePath, updated);
|
|
44
|
+
touchedCount += 1;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (touchedCount > 0) {
|
|
48
|
+
devkit_1.logger.info(`Rewrote @nx/eslint/src/* imports in ${touchedCount} file(s) ` +
|
|
49
|
+
`(public symbols to @nx/eslint, internals to @nx/eslint/internal).`);
|
|
50
|
+
}
|
|
51
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
52
|
+
}
|
|
53
|
+
function rewriteSubpathImports(source) {
|
|
54
|
+
ts ??= (0, devkit_1.ensurePackage)('typescript', '*');
|
|
55
|
+
const sourceFile = ts.createSourceFile('tmp.ts', source, ts.ScriptTarget.Latest,
|
|
56
|
+
/* setParentNodes */ true, ts.ScriptKind.TSX);
|
|
57
|
+
const changes = [];
|
|
58
|
+
for (const stmt of sourceFile.statements) {
|
|
59
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
60
|
+
collectImportRewrite(sourceFile, stmt, changes);
|
|
61
|
+
}
|
|
62
|
+
else if (ts.isExportDeclaration(stmt)) {
|
|
63
|
+
collectExportRewrite(sourceFile, stmt, changes);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
collectCallExpressionRewrites(sourceFile, changes);
|
|
67
|
+
return changes.length > 0 ? (0, devkit_1.applyChangesToString)(source, changes) : source;
|
|
68
|
+
}
|
|
69
|
+
function isSubpathSpecifier(node) {
|
|
70
|
+
return ts.isStringLiteral(node) && node.text.startsWith(FROM_PREFIX);
|
|
71
|
+
}
|
|
72
|
+
function collectImportRewrite(sourceFile, stmt, changes) {
|
|
73
|
+
if (!isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const clause = stmt.importClause;
|
|
77
|
+
// Pure named imports (`import { a, b } from '...'`) can be split by symbol.
|
|
78
|
+
// A default or namespace import grabs the whole module, so it can't be
|
|
79
|
+
// split — route it wholesale to the internal entry.
|
|
80
|
+
if (clause &&
|
|
81
|
+
!clause.name &&
|
|
82
|
+
clause.namedBindings &&
|
|
83
|
+
ts.isNamedImports(clause.namedBindings)) {
|
|
84
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, clause.isTypeOnly, clause.namedBindings.elements, 'import', changes);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
88
|
+
}
|
|
89
|
+
function collectExportRewrite(sourceFile, stmt, changes) {
|
|
90
|
+
if (!stmt.moduleSpecifier || !isSubpathSpecifier(stmt.moduleSpecifier)) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// `export { a, b } from '...'` can be split; `export * from '...'` cannot.
|
|
94
|
+
if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
|
|
95
|
+
rewriteNamedDeclaration(sourceFile, stmt, stmt.moduleSpecifier, stmt.isTypeOnly, stmt.exportClause.elements, 'export', changes);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
replaceSpecifier(sourceFile, stmt.moduleSpecifier, TO_INTERNAL, changes);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Partition the named bindings of an import/export declaration into the ones
|
|
102
|
+
* that resolve to `@nx/eslint`'s public entry and the ones that don't. If both
|
|
103
|
+
* groups are non-empty, the single declaration is split into two.
|
|
104
|
+
*/
|
|
105
|
+
function rewriteNamedDeclaration(sourceFile, decl, specifier, isTypeOnly, elements, keyword, changes) {
|
|
106
|
+
const publicEls = [];
|
|
107
|
+
const internalEls = [];
|
|
108
|
+
for (const el of elements) {
|
|
109
|
+
// `propertyName` is the original name in `orig as alias`; fall back to
|
|
110
|
+
// `name` for the plain `orig` form.
|
|
111
|
+
const importedName = (el.propertyName ?? el.name).text;
|
|
112
|
+
(PUBLIC_SYMBOLS.has(importedName) ? publicEls : internalEls).push(el);
|
|
113
|
+
}
|
|
114
|
+
if (publicEls.length === 0) {
|
|
115
|
+
replaceSpecifier(sourceFile, specifier, TO_INTERNAL, changes);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (internalEls.length === 0) {
|
|
119
|
+
replaceSpecifier(sourceFile, specifier, TO_PUBLIC, changes);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// Mixed — replace the whole declaration with one statement per target.
|
|
123
|
+
const quote = sourceFile.text.charAt(specifier.getStart(sourceFile));
|
|
124
|
+
const start = decl.getStart(sourceFile);
|
|
125
|
+
const end = decl.getEnd();
|
|
126
|
+
const semicolon = sourceFile.text.charAt(end - 1) === ';' ? ';' : '';
|
|
127
|
+
const prefix = isTypeOnly ? `${keyword} type` : keyword;
|
|
128
|
+
const render = (els, target) => `${prefix} { ${els
|
|
129
|
+
.map((el) => el.getText(sourceFile))
|
|
130
|
+
.join(', ')} } from ${quote}${target}${quote}${semicolon}`;
|
|
131
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
132
|
+
type: devkit_1.ChangeType.Insert,
|
|
133
|
+
index: start,
|
|
134
|
+
text: `${render(publicEls, TO_PUBLIC)}\n${render(internalEls, TO_INTERNAL)}`,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function collectCallExpressionRewrites(sourceFile, changes) {
|
|
138
|
+
const visit = (node) => {
|
|
139
|
+
if (ts.isCallExpression(node) &&
|
|
140
|
+
shouldRewriteCallExpression(node) &&
|
|
141
|
+
node.arguments.length >= 1 &&
|
|
142
|
+
isSubpathSpecifier(node.arguments[0])) {
|
|
143
|
+
// `require(...)`, dynamic `import(...)` and `jest.mock(...)` reference
|
|
144
|
+
// the module as a whole and can't be symbol-split, so they go to the
|
|
145
|
+
// internal entry.
|
|
146
|
+
replaceSpecifier(sourceFile, node.arguments[0], TO_INTERNAL, changes);
|
|
147
|
+
}
|
|
148
|
+
ts.forEachChild(node, visit);
|
|
149
|
+
};
|
|
150
|
+
visit(sourceFile);
|
|
151
|
+
}
|
|
152
|
+
function shouldRewriteCallExpression(call) {
|
|
153
|
+
const callee = call.expression;
|
|
154
|
+
// `require('...')`
|
|
155
|
+
if (ts.isIdentifier(callee) && callee.text === 'require')
|
|
156
|
+
return true;
|
|
157
|
+
// dynamic `import('...')` (runtime form parses as a CallExpression whose
|
|
158
|
+
// callee is the `import` keyword). The type-position form
|
|
159
|
+
// (`typeof import('...')`) is an `ImportTypeNode`, not a CallExpression, so
|
|
160
|
+
// we don't touch it.
|
|
161
|
+
if (callee.kind === ts.SyntaxKind.ImportKeyword)
|
|
162
|
+
return true;
|
|
163
|
+
// `jest.mock(...)` / `vi.mock(...)` and friends.
|
|
164
|
+
if (ts.isPropertyAccessExpression(callee)) {
|
|
165
|
+
const obj = callee.expression;
|
|
166
|
+
if (ts.isIdentifier(obj) &&
|
|
167
|
+
(obj.text === 'jest' || obj.text === 'vi') &&
|
|
168
|
+
MOCK_HELPER_METHODS.has(callee.name.text)) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
function replaceSpecifier(sourceFile, literal, target, changes) {
|
|
175
|
+
const start = literal.getStart(sourceFile);
|
|
176
|
+
const end = literal.getEnd();
|
|
177
|
+
const quote = sourceFile.text.charAt(start);
|
|
178
|
+
changes.push({ type: devkit_1.ChangeType.Delete, start, length: end - start }, {
|
|
179
|
+
type: devkit_1.ChangeType.Insert,
|
|
180
|
+
index: start,
|
|
181
|
+
text: `${quote}${target}${quote}`,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
@@ -8,4 +8,3 @@ export declare const legacyBaseEsLintFlatConfigFile = "eslint.base.config.js";
|
|
|
8
8
|
export declare function isFlatConfig(configFilePath: string): boolean;
|
|
9
9
|
export declare function findFlatConfigFile(directory: string, workspaceRoot: string): string | null;
|
|
10
10
|
export declare function findOldConfigFile(filePathOrDirectory: string, workspaceRoot: string): string | null;
|
|
11
|
-
//# sourceMappingURL=config-file.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export declare const ESLINT_EXECUTOR_DEPRECATION_MESSAGE = "The `@nx/eslint:lint` executor is deprecated and will be removed in Nx v24. Run `nx g @nx/eslint:convert-to-inferred` to migrate to the `@nx/eslint/plugin` inferred targets. See https://nx.dev/docs/guides/tasks--caching/convert-to-inferred for details.";
|
|
2
2
|
export declare function warnEslintExecutorDeprecation(): void;
|
|
3
3
|
export declare function warnEslintExecutorGenerating(): void;
|
|
4
|
-
//# sourceMappingURL=deprecation.d.ts.map
|
|
@@ -3,4 +3,3 @@ export declare const eslintFlatConfigFilenames: string[];
|
|
|
3
3
|
export declare const baseEslintConfigFilenames: string[];
|
|
4
4
|
export declare function getRootESLintFlatConfigFilename(tree: Tree): string;
|
|
5
5
|
export declare function useFlatConfig(tree?: Tree): boolean;
|
|
6
|
-
//# sourceMappingURL=flat-config.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveESLintClass = resolveESLintClass;
|
|
4
|
+
const flat_config_1 = require("../utils/flat-config");
|
|
5
|
+
async function resolveESLintClass(opts) {
|
|
6
|
+
try {
|
|
7
|
+
const shouldESLintUseFlatConfig = typeof opts?.useFlatConfigOverrideVal === 'boolean'
|
|
8
|
+
? opts.useFlatConfigOverrideVal
|
|
9
|
+
: (0, flat_config_1.useFlatConfig)();
|
|
10
|
+
// In eslint 8.57.0 (the final v8 version), a dedicated API was added for resolving the correct ESLint class.
|
|
11
|
+
const eslintModule = (await import('eslint'));
|
|
12
|
+
if (typeof eslintModule.loadESLint === 'function') {
|
|
13
|
+
return (await eslintModule.loadESLint({
|
|
14
|
+
useFlatConfig: shouldESLintUseFlatConfig,
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
// Explicitly use the FlatESLint and LegacyESLint classes here because the ESLint class points at a different one based on ESLint v8 vs ESLint v9
|
|
18
|
+
// But the decision on which one to use is not just based on the major version of ESLint.
|
|
19
|
+
const { LegacyESLint, FlatESLint } = await import('eslint/use-at-your-own-risk');
|
|
20
|
+
// LegacyESLint's type no longer structurally matches the flat ESLint class
|
|
21
|
+
// in v9 type defs (new static members like defaultConfig, fromOptionsModule),
|
|
22
|
+
// but at runtime either class is an appropriate return value here.
|
|
23
|
+
return (shouldESLintUseFlatConfig ? FlatESLint : LegacyESLint);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Error('Unable to find `eslint`. Ensure a valid `eslint` version is installed.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
2
|
export declare function hasRulesRequiringTypeChecking(eslintConfig: Linter.LegacyConfig): boolean;
|
|
3
3
|
export declare function removeParserOptionsProjectIfNotRequired(json: Linter.LegacyConfig): Linter.LegacyConfig;
|
|
4
|
-
//# sourceMappingURL=rules-requiring-type-checking.d.ts.map
|
|
@@ -2,4 +2,3 @@ import { type Tree } from '@nx/devkit';
|
|
|
2
2
|
export declare function getInstalledPackageVersion(pkgName: string, tree?: Tree): string | null;
|
|
3
3
|
export declare function getInstalledEslintVersion(tree?: Tree): string | null;
|
|
4
4
|
export declare function getTypeScriptEslintVersionToInstall(tree: Tree): string | null;
|
|
5
|
-
//# sourceMappingURL=version-utils.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.eslintCompat = exports.eslint9__eslintVersion = exports.eslint9__typescriptESLintVersion = exports.jsoncEslintParserVersion = exports.typescriptESLintVersion = exports.eslintConfigPrettierVersion = exports.eslintrcVersion = exports.eslintVersion = exports.nxVersion = void 0;
|
|
4
|
-
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
exports.nxVersion = require((0, path_1.join)('@nx/eslint', 'package.json')).version;
|
|
5
6
|
exports.eslintVersion = '~8.57.0';
|
|
6
7
|
exports.eslintrcVersion = '^2.1.1';
|
|
7
8
|
exports.eslintConfigPrettierVersion = '^10.0.0';
|
package/executors.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"executors": {
|
|
3
3
|
"lint": {
|
|
4
|
-
"implementation": "./src/executors/lint/lint.impl",
|
|
5
|
-
"schema": "./src/executors/lint/schema.json",
|
|
4
|
+
"implementation": "./dist/src/executors/lint/lint.impl",
|
|
5
|
+
"schema": "./dist/src/executors/lint/schema.json",
|
|
6
6
|
"description": "Run ESLint on a project."
|
|
7
7
|
}
|
|
8
8
|
}
|