@nx/eslint 21.0.4-beta.0 → 21.0.4
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 +3 -3
- package/src/generators/workspace-rule/files/__name__.spec.ts__tmpl__ +11 -2
- package/src/generators/workspace-rule/workspace-rule.d.ts +2 -2
- package/src/generators/workspace-rule/workspace-rule.js +11 -3
- package/src/generators/workspace-rules-project/workspace-rules-project.js +1 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/eslint",
|
3
|
-
"version": "21.0.4
|
3
|
+
"version": "21.0.4",
|
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,8 +35,8 @@
|
|
35
35
|
"eslint": "^8.0.0 || ^9.0.0"
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
|
-
"@nx/devkit": "21.0.4
|
39
|
-
"@nx/js": "21.0.4
|
38
|
+
"@nx/devkit": "21.0.4",
|
39
|
+
"@nx/js": "21.0.4",
|
40
40
|
"semver": "^7.5.3",
|
41
41
|
"tslib": "^2.3.0",
|
42
42
|
"typescript": "~5.7.2"
|
@@ -1,10 +1,19 @@
|
|
1
|
-
import {
|
1
|
+
<% if (flatConfig) { %>import { RuleTester } from '@typescript-eslint/rule-tester';
|
2
|
+
import type { RuleTesterConfig } from '@typescript-eslint/rule-tester';
|
3
|
+
import { rule, RULE_NAME } from './<%= name %>';
|
4
|
+
|
5
|
+
const ruleTester = new RuleTester({
|
6
|
+
languageOptions: {
|
7
|
+
parser: require('@typescript-eslint/parser'),
|
8
|
+
},
|
9
|
+
} as RuleTesterConfig);
|
10
|
+
<% } else { %>import { TSESLint } from '@typescript-eslint/utils';
|
2
11
|
import { rule, RULE_NAME } from './<%= name %>';
|
3
12
|
|
4
13
|
const ruleTester = new TSESLint.RuleTester({
|
5
14
|
parser: require.resolve('@typescript-eslint/parser'),
|
6
15
|
});
|
7
|
-
|
16
|
+
<% } %>
|
8
17
|
ruleTester.run(RULE_NAME, rule, {
|
9
18
|
valid: [`const example = true;`],
|
10
19
|
invalid: [],
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { Tree } from '@nx/devkit';
|
1
|
+
import { GeneratorCallback, Tree } from '@nx/devkit';
|
2
2
|
export interface LintWorkspaceRuleGeneratorOptions {
|
3
3
|
name: string;
|
4
4
|
directory: string;
|
5
5
|
}
|
6
|
-
export declare function lintWorkspaceRuleGenerator(tree: Tree, options: LintWorkspaceRuleGeneratorOptions): Promise<
|
6
|
+
export declare function lintWorkspaceRuleGenerator(tree: Tree, options: LintWorkspaceRuleGeneratorOptions): Promise<GeneratorCallback>;
|
@@ -7,19 +7,27 @@ const path_1 = require("path");
|
|
7
7
|
const ts = require("typescript");
|
8
8
|
const workspace_lint_rules_1 = require("../../utils/workspace-lint-rules");
|
9
9
|
const workspace_rules_project_1 = require("../workspace-rules-project/workspace-rules-project");
|
10
|
+
const flat_config_1 = require("../../utils/flat-config");
|
11
|
+
const versions_1 = require("../../utils/versions");
|
10
12
|
async function lintWorkspaceRuleGenerator(tree, options) {
|
13
|
+
const tasks = [];
|
14
|
+
const flatConfig = (0, flat_config_1.useFlatConfig)(tree);
|
11
15
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
12
16
|
// Ensure that the workspace rules project has been created
|
13
|
-
|
17
|
+
tasks.push(await (0, workspace_rules_project_1.lintWorkspaceRulesProjectGenerator)(tree, {
|
14
18
|
skipFormat: true,
|
15
19
|
addPlugin: process.env.NX_ADD_PLUGINS !== 'false' &&
|
16
20
|
nxJson.useInferencePlugins !== false,
|
17
|
-
});
|
21
|
+
}));
|
22
|
+
if (flatConfig) {
|
23
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@typescript-eslint/rule-tester': versions_1.eslint9__typescriptESLintVersion }));
|
24
|
+
}
|
18
25
|
const ruleDir = (0, devkit_1.joinPathFragments)(workspace_lint_rules_1.workspaceLintPluginDir, options.directory ?? '');
|
19
26
|
// Generate the required files for the new rule
|
20
27
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files'), ruleDir, {
|
21
28
|
tmpl: '',
|
22
29
|
name: options.name,
|
30
|
+
flatConfig,
|
23
31
|
});
|
24
32
|
const nameCamelCase = (0, string_utils_1.camelize)(options.name);
|
25
33
|
/**
|
@@ -73,5 +81,5 @@ async function lintWorkspaceRuleGenerator(tree, options) {
|
|
73
81
|
"@nx/workspace-${options.name}": "error"
|
74
82
|
}
|
75
83
|
`);
|
76
|
-
return
|
84
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
77
85
|
}
|
@@ -50,6 +50,7 @@ async function lintWorkspaceRulesProjectGenerator(tree, options = {}) {
|
|
50
50
|
setupFile: 'none',
|
51
51
|
compiler: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree) ? 'swc' : 'tsc',
|
52
52
|
skipFormat: true,
|
53
|
+
testEnvironment: 'node',
|
53
54
|
}));
|
54
55
|
(0, devkit_1.updateJson)(tree, (0, path_1.join)(workspace_lint_rules_1.workspaceLintPluginDir, 'tsconfig.spec.json'), (json) => {
|
55
56
|
delete json.compilerOptions?.module;
|