@nx/eslint-plugin 17.2.4 → 17.2.6
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 +6 -0
- package/package.json +4 -4
- package/src/constants.d.ts +3 -2
- package/src/constants.js +5 -4
- package/src/migrations/update-17-2-6-rename-workspace-rules/rename-workspace-rules.d.ts +2 -0
- package/src/migrations/update-17-2-6-rename-workspace-rules/rename-workspace-rules.js +29 -0
- package/src/resolve-workspace-rules.js +3 -1
package/migrations.json
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
"version": "16.0.0-beta.1",
|
|
6
6
|
"description": "Replace @nrwl/eslint-plugin-nx with @nx/eslint-plugin",
|
|
7
7
|
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
8
|
+
},
|
|
9
|
+
"update-17-2-6-rename-workspace-rules": {
|
|
10
|
+
"cli": "nx",
|
|
11
|
+
"version": "17-2-6-beta.1",
|
|
12
|
+
"description": "Rename workspace rules from @nx/workspace/name to @nx/workspace-name",
|
|
13
|
+
"implementation": "./src/migrations/update-17-2-6-rename-workspace-rules/rename-workspace-rules"
|
|
8
14
|
}
|
|
9
15
|
},
|
|
10
16
|
"packageJsonUpdates": {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "17.2.
|
|
3
|
+
"version": "17.2.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The eslint-plugin package is an ESLint plugin that contains a collection of recommended ESLint rule configurations which you can extend from in your own ESLint configs, as well as an Nx-specific lint rule called enforce-module-boundaries.",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@nx/devkit": "17.2.
|
|
37
|
-
"@nx/js": "17.2.
|
|
36
|
+
"@nx/devkit": "17.2.6",
|
|
37
|
+
"@nx/js": "17.2.6",
|
|
38
38
|
"@typescript-eslint/type-utils": "^6.9.1",
|
|
39
39
|
"@typescript-eslint/utils": "^6.9.1",
|
|
40
40
|
"chalk": "^4.1.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"jsonc-eslint-parser": "^2.1.0",
|
|
43
43
|
"semver": "7.5.3",
|
|
44
44
|
"tslib": "^2.3.0",
|
|
45
|
-
"@nrwl/eslint-plugin-nx": "17.2.
|
|
45
|
+
"@nrwl/eslint-plugin-nx": "17.2.6"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
package/src/constants.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const WORKSPACE_RULES_PATH = "tools/eslint-rules";
|
|
1
2
|
export declare const WORKSPACE_PLUGIN_DIR: string;
|
|
2
3
|
/**
|
|
3
4
|
* We add a namespace so that we mitigate the risk of rule name collisions as much as
|
|
@@ -7,6 +8,6 @@ export declare const WORKSPACE_PLUGIN_DIR: string;
|
|
|
7
8
|
* E.g. if a user writes a rule called "foo", then they will include it in their ESLint
|
|
8
9
|
* config files as:
|
|
9
10
|
*
|
|
10
|
-
* "@nx/workspace
|
|
11
|
+
* "@nx/workspace-foo": "error"
|
|
11
12
|
*/
|
|
12
|
-
export declare const
|
|
13
|
+
export declare const WORKSPACE_RULE_PREFIX = "workspace";
|
package/src/constants.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WORKSPACE_RULE_PREFIX = exports.WORKSPACE_PLUGIN_DIR = exports.WORKSPACE_RULES_PATH = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
exports.
|
|
6
|
+
exports.WORKSPACE_RULES_PATH = 'tools/eslint-rules';
|
|
7
|
+
exports.WORKSPACE_PLUGIN_DIR = (0, path_1.join)(devkit_1.workspaceRoot, exports.WORKSPACE_RULES_PATH);
|
|
7
8
|
/**
|
|
8
9
|
* We add a namespace so that we mitigate the risk of rule name collisions as much as
|
|
9
10
|
* possible between what users might create in their workspaces and what we might want
|
|
@@ -12,6 +13,6 @@ exports.WORKSPACE_PLUGIN_DIR = (0, path_1.join)(devkit_1.workspaceRoot, 'tools/e
|
|
|
12
13
|
* E.g. if a user writes a rule called "foo", then they will include it in their ESLint
|
|
13
14
|
* config files as:
|
|
14
15
|
*
|
|
15
|
-
* "@nx/workspace
|
|
16
|
+
* "@nx/workspace-foo": "error"
|
|
16
17
|
*/
|
|
17
|
-
exports.
|
|
18
|
+
exports.WORKSPACE_RULE_PREFIX = 'workspace';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const binary_extensions_1 = require("@nx/devkit/src/utils/binary-extensions");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
async function renameWorkspaceRule(tree) {
|
|
7
|
+
if (!tree.exists(constants_1.WORKSPACE_RULES_PATH)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
let ruleNames = [];
|
|
11
|
+
try {
|
|
12
|
+
ruleNames = Object.keys(require(constants_1.WORKSPACE_PLUGIN_DIR).rules);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, '.', (path) => {
|
|
18
|
+
if ((0, binary_extensions_1.isBinaryPath)(path)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let contents = tree.read(path, 'utf-8');
|
|
22
|
+
ruleNames.forEach((ruleName) => {
|
|
23
|
+
contents = contents.replace(new RegExp(`@nx/workspace/${ruleName}`, 'g'), `@nx/workspace-${ruleName}`);
|
|
24
|
+
});
|
|
25
|
+
tree.write(path, contents);
|
|
26
|
+
});
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
}
|
|
29
|
+
exports.default = renameWorkspaceRule;
|
|
@@ -21,7 +21,9 @@ exports.workspaceRules = (() => {
|
|
|
21
21
|
// Apply the namespace to the resolved rules
|
|
22
22
|
const namespacedRules = {};
|
|
23
23
|
for (const [ruleName, ruleConfig] of Object.entries(rules)) {
|
|
24
|
-
namespacedRules[`${constants_1.
|
|
24
|
+
namespacedRules[`${constants_1.WORKSPACE_RULE_PREFIX}-${ruleName}`] = ruleConfig;
|
|
25
|
+
// keep the old namespaced rules for backwards compatibility
|
|
26
|
+
namespacedRules[`${constants_1.WORKSPACE_RULE_PREFIX}/${ruleName}`] = ruleConfig;
|
|
25
27
|
}
|
|
26
28
|
return namespacedRules;
|
|
27
29
|
}
|