@nx/eslint-plugin 17.0.4 → 17.0.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/LICENSE +1 -1
- package/README.md +4 -9
- package/migrations.json +0 -6
- package/package.json +8 -8
- package/src/configs/angular.js +15 -1
- package/src/configs/javascript.d.ts +0 -20
- package/src/configs/javascript.js +0 -20
- package/src/configs/react-base.js +2 -3
- package/src/configs/typescript.d.ts +0 -20
- package/src/configs/typescript.js +0 -20
- package/src/constants.d.ts +2 -3
- package/src/constants.js +4 -5
- package/src/index.js +11 -12
- package/src/resolve-workspace-rules.js +1 -3
- package/src/rules/dependency-checks.d.ts +1 -3
- package/src/rules/dependency-checks.js +6 -11
- package/src/rules/enforce-module-boundaries.d.ts +2 -3
- package/src/rules/enforce-module-boundaries.js +9 -15
- package/src/rules/nx-plugin-checks.js +6 -7
- package/src/utils/ast-utils.js +10 -11
- package/src/utils/create-eslint-rule.d.ts +2 -0
- package/src/utils/create-eslint-rule.js +5 -0
- package/src/utils/package-json-utils.js +3 -6
- package/src/utils/runtime-lint-utils.d.ts +6 -4
- package/src/utils/runtime-lint-utils.js +18 -34
- package/src/migrations/update-17-2-6-rename-workspace-rules/rename-workspace-rules.d.ts +0 -2
- package/src/migrations/update-17-2-6-rename-workspace-rules/rename-workspace-rules.js +0 -29
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
<p style="text-align: center;">
|
|
2
|
-
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
|
|
4
|
-
<img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
|
|
5
|
-
</picture>
|
|
6
|
-
</p>
|
|
1
|
+
<p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
|
|
7
2
|
|
|
8
3
|
<div style="text-align: center;">
|
|
9
4
|
|
|
@@ -20,9 +15,9 @@
|
|
|
20
15
|
|
|
21
16
|
<hr>
|
|
22
17
|
|
|
23
|
-
# Nx: Smart
|
|
18
|
+
# Nx: Smart, Fast and Extensible Build System
|
|
24
19
|
|
|
25
|
-
Nx is a build system with
|
|
20
|
+
Nx is a next generation build system with first class monorepo support and powerful integrations.
|
|
26
21
|
|
|
27
22
|
This package is an ESLint plugin for Nx.
|
|
28
23
|
|
|
@@ -64,5 +59,5 @@ npx nx@latest init
|
|
|
64
59
|
- [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
|
|
65
60
|
|
|
66
61
|
<p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
|
|
67
|
-
width="100%" alt="Nx - Smart
|
|
62
|
+
width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
|
|
68
63
|
|
package/migrations.json
CHANGED
|
@@ -5,12 +5,6 @@
|
|
|
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"
|
|
14
8
|
}
|
|
15
9
|
},
|
|
16
10
|
"packageJsonUpdates": {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "v17.0.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": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://nx.dev",
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@typescript-eslint/parser": "^
|
|
27
|
+
"@typescript-eslint/parser": "^5.60.1",
|
|
28
28
|
"eslint-config-prettier": "^9.0.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependenciesMeta": {
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@nx/devkit": "
|
|
37
|
-
"@nx/js": "
|
|
38
|
-
"@typescript-eslint/type-utils": "^
|
|
39
|
-
"@typescript-eslint/utils": "^
|
|
36
|
+
"@nx/devkit": "v17.0.6",
|
|
37
|
+
"@nx/js": "v17.0.6",
|
|
38
|
+
"@typescript-eslint/type-utils": "^5.60.1",
|
|
39
|
+
"@typescript-eslint/utils": "^5.60.1",
|
|
40
40
|
"chalk": "^4.1.0",
|
|
41
41
|
"confusing-browser-globals": "^1.0.9",
|
|
42
42
|
"jsonc-eslint-parser": "^2.1.0",
|
|
43
|
-
"semver": "
|
|
43
|
+
"semver": "7.5.3",
|
|
44
44
|
"tslib": "^2.3.0",
|
|
45
|
-
"@nrwl/eslint-plugin-nx": "
|
|
45
|
+
"@nrwl/eslint-plugin-nx": "v17.0.6"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
package/src/configs/angular.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
let angularEslintPlugin;
|
|
4
|
+
try {
|
|
5
|
+
angularEslintPlugin = require('@angular-eslint/eslint-plugin');
|
|
6
|
+
}
|
|
7
|
+
catch { }
|
|
3
8
|
/**
|
|
4
9
|
* This configuration is intended to be applied to ALL .ts files in Angular
|
|
5
10
|
* projects within an Nx workspace.
|
|
@@ -18,7 +23,16 @@ exports.default = {
|
|
|
18
23
|
node: true,
|
|
19
24
|
},
|
|
20
25
|
plugins: ['@angular-eslint'],
|
|
21
|
-
extends: [
|
|
26
|
+
extends: [
|
|
27
|
+
'plugin:@angular-eslint/recommended',
|
|
28
|
+
/**
|
|
29
|
+
* TODO: Consider dropping this extends and explicitly carrying over rules we care about
|
|
30
|
+
* into our typescript preset in v13
|
|
31
|
+
*/
|
|
32
|
+
...(angularEslintPlugin?.configs?.['recommended--extra']
|
|
33
|
+
? ['plugin:@angular-eslint/recommended--extra']
|
|
34
|
+
: []),
|
|
35
|
+
],
|
|
22
36
|
parserOptions: {
|
|
23
37
|
// Unset the default value for parserOptions.project that is found in earlier versions of @angular-eslint
|
|
24
38
|
project: [],
|
|
@@ -37,26 +37,6 @@ declare const _default: {
|
|
|
37
37
|
* having to frequently use "eslint-disable-next-line" in their configs.
|
|
38
38
|
*/
|
|
39
39
|
'@typescript-eslint/no-var-requires': string;
|
|
40
|
-
/**
|
|
41
|
-
* From https://typescript-eslint.io/blog/announcing-typescript-eslint-v6/#updated-configuration-rules
|
|
42
|
-
*
|
|
43
|
-
* The following rules were added to preserve the linting rules that were
|
|
44
|
-
* previously defined v5 of `@typescript-eslint`. v6 of `@typescript-eslint`
|
|
45
|
-
* changed how configurations are defined.
|
|
46
|
-
*
|
|
47
|
-
* TODO(v19): re-evalute these deviations from @typescript-eslint/recommended in v19 of Nx
|
|
48
|
-
*/
|
|
49
|
-
'no-extra-semi': string;
|
|
50
|
-
'@typescript-eslint/no-extra-semi': string;
|
|
51
|
-
'@typescript-eslint/no-non-null-assertion': string;
|
|
52
|
-
'@typescript-eslint/adjacent-overload-signatures': string;
|
|
53
|
-
'@typescript-eslint/prefer-namespace-keyword': string;
|
|
54
|
-
'no-empty-function': string;
|
|
55
|
-
'@typescript-eslint/no-empty-function': string;
|
|
56
|
-
'@typescript-eslint/no-inferrable-types': string;
|
|
57
|
-
'@typescript-eslint/no-unused-vars': string;
|
|
58
|
-
'@typescript-eslint/no-empty-interface': string;
|
|
59
|
-
'@typescript-eslint/no-explicit-any': string;
|
|
60
40
|
};
|
|
61
41
|
};
|
|
62
42
|
export default _default;
|
|
@@ -46,25 +46,5 @@ exports.default = {
|
|
|
46
46
|
* having to frequently use "eslint-disable-next-line" in their configs.
|
|
47
47
|
*/
|
|
48
48
|
'@typescript-eslint/no-var-requires': 'off',
|
|
49
|
-
/**
|
|
50
|
-
* From https://typescript-eslint.io/blog/announcing-typescript-eslint-v6/#updated-configuration-rules
|
|
51
|
-
*
|
|
52
|
-
* The following rules were added to preserve the linting rules that were
|
|
53
|
-
* previously defined v5 of `@typescript-eslint`. v6 of `@typescript-eslint`
|
|
54
|
-
* changed how configurations are defined.
|
|
55
|
-
*
|
|
56
|
-
* TODO(v19): re-evalute these deviations from @typescript-eslint/recommended in v19 of Nx
|
|
57
|
-
*/
|
|
58
|
-
'no-extra-semi': 'off',
|
|
59
|
-
'@typescript-eslint/no-extra-semi': 'error',
|
|
60
|
-
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
61
|
-
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
62
|
-
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
63
|
-
'no-empty-function': 'off',
|
|
64
|
-
'@typescript-eslint/no-empty-function': 'error',
|
|
65
|
-
'@typescript-eslint/no-inferrable-types': 'error',
|
|
66
|
-
'@typescript-eslint/no-unused-vars': 'warn',
|
|
67
|
-
'@typescript-eslint/no-empty-interface': 'error',
|
|
68
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
69
49
|
},
|
|
70
50
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
/**
|
|
5
4
|
* This configuration is intended to be applied to ALL files within a React
|
|
6
5
|
* project in an Nx workspace.
|
|
@@ -11,7 +10,7 @@ const tslib_1 = require("tslib");
|
|
|
11
10
|
* This configuration is intended to be combined with other configs from this
|
|
12
11
|
* package.
|
|
13
12
|
*/
|
|
14
|
-
const
|
|
13
|
+
const restrictedGlobals = require("confusing-browser-globals");
|
|
15
14
|
/**
|
|
16
15
|
* Rule set originally adapted from:
|
|
17
16
|
* https://github.com/facebook/create-react-app/blob/567f36c9235f1e1fd4a76dc6d1ae00be754ca047/packages/eslint-config-react-app/index.js
|
|
@@ -92,7 +91,7 @@ exports.default = {
|
|
|
92
91
|
'no-template-curly-in-string': 'warn',
|
|
93
92
|
'no-this-before-super': 'warn',
|
|
94
93
|
'no-throw-literal': 'warn',
|
|
95
|
-
'no-restricted-globals': ['error'].concat(
|
|
94
|
+
'no-restricted-globals': ['error'].concat(restrictedGlobals),
|
|
96
95
|
'no-unexpected-multiline': 'warn',
|
|
97
96
|
'no-unreachable': 'warn',
|
|
98
97
|
'no-unused-expressions': 'off',
|
|
@@ -19,26 +19,6 @@ declare const _default: {
|
|
|
19
19
|
'@typescript-eslint/explicit-module-boundary-types': string;
|
|
20
20
|
'@typescript-eslint/explicit-function-return-type': string;
|
|
21
21
|
'@typescript-eslint/no-parameter-properties': string;
|
|
22
|
-
/**
|
|
23
|
-
* From https://typescript-eslint.io/blog/announcing-typescript-eslint-v6/#updated-configuration-rules
|
|
24
|
-
*
|
|
25
|
-
* The following rules were added to preserve the linting rules that were
|
|
26
|
-
* previously defined v5 of `@typescript-eslint`. v6 of `@typescript-eslint`
|
|
27
|
-
* changed how configurations are defined.
|
|
28
|
-
*
|
|
29
|
-
* TODO(v19): re-evalute these deviations from @typescript-eslint/recommended in v19 of Nx
|
|
30
|
-
*/
|
|
31
|
-
'no-extra-semi': string;
|
|
32
|
-
'@typescript-eslint/no-extra-semi': string;
|
|
33
|
-
'@typescript-eslint/no-non-null-assertion': string;
|
|
34
|
-
'@typescript-eslint/adjacent-overload-signatures': string;
|
|
35
|
-
'@typescript-eslint/prefer-namespace-keyword': string;
|
|
36
|
-
'no-empty-function': string;
|
|
37
|
-
'@typescript-eslint/no-empty-function': string;
|
|
38
|
-
'@typescript-eslint/no-inferrable-types': string;
|
|
39
|
-
'@typescript-eslint/no-unused-vars': string;
|
|
40
|
-
'@typescript-eslint/no-empty-interface': string;
|
|
41
|
-
'@typescript-eslint/no-explicit-any': string;
|
|
42
22
|
};
|
|
43
23
|
};
|
|
44
24
|
export default _default;
|
|
@@ -29,25 +29,5 @@ exports.default = {
|
|
|
29
29
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
30
30
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
31
31
|
'@typescript-eslint/no-parameter-properties': 'off',
|
|
32
|
-
/**
|
|
33
|
-
* From https://typescript-eslint.io/blog/announcing-typescript-eslint-v6/#updated-configuration-rules
|
|
34
|
-
*
|
|
35
|
-
* The following rules were added to preserve the linting rules that were
|
|
36
|
-
* previously defined v5 of `@typescript-eslint`. v6 of `@typescript-eslint`
|
|
37
|
-
* changed how configurations are defined.
|
|
38
|
-
*
|
|
39
|
-
* TODO(v19): re-evalute these deviations from @typescript-eslint/recommended in v19 of Nx
|
|
40
|
-
*/
|
|
41
|
-
'no-extra-semi': 'off',
|
|
42
|
-
'@typescript-eslint/no-extra-semi': 'error',
|
|
43
|
-
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
44
|
-
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
|
45
|
-
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
|
46
|
-
'no-empty-function': 'off',
|
|
47
|
-
'@typescript-eslint/no-empty-function': 'error',
|
|
48
|
-
'@typescript-eslint/no-inferrable-types': 'error',
|
|
49
|
-
'@typescript-eslint/no-unused-vars': 'warn',
|
|
50
|
-
'@typescript-eslint/no-empty-interface': 'error',
|
|
51
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
52
32
|
},
|
|
53
33
|
};
|
package/src/constants.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const WORKSPACE_RULES_PATH = "tools/eslint-rules";
|
|
2
1
|
export declare const WORKSPACE_PLUGIN_DIR: string;
|
|
3
2
|
/**
|
|
4
3
|
* We add a namespace so that we mitigate the risk of rule name collisions as much as
|
|
@@ -8,6 +7,6 @@ export declare const WORKSPACE_PLUGIN_DIR: string;
|
|
|
8
7
|
* E.g. if a user writes a rule called "foo", then they will include it in their ESLint
|
|
9
8
|
* config files as:
|
|
10
9
|
*
|
|
11
|
-
* "@nx/workspace
|
|
10
|
+
* "@nx/workspace/foo": "error"
|
|
12
11
|
*/
|
|
13
|
-
export declare const
|
|
12
|
+
export declare const WORKSPACE_RULE_NAMESPACE = "workspace";
|
package/src/constants.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WORKSPACE_RULE_NAMESPACE = exports.WORKSPACE_PLUGIN_DIR = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
exports.
|
|
7
|
-
exports.WORKSPACE_PLUGIN_DIR = (0, path_1.join)(devkit_1.workspaceRoot, exports.WORKSPACE_RULES_PATH);
|
|
6
|
+
exports.WORKSPACE_PLUGIN_DIR = (0, path_1.join)(devkit_1.workspaceRoot, 'tools/eslint-rules');
|
|
8
7
|
/**
|
|
9
8
|
* We add a namespace so that we mitigate the risk of rule name collisions as much as
|
|
10
9
|
* possible between what users might create in their workspaces and what we might want
|
|
@@ -13,6 +12,6 @@ exports.WORKSPACE_PLUGIN_DIR = (0, path_1.join)(devkit_1.workspaceRoot, exports.
|
|
|
13
12
|
* E.g. if a user writes a rule called "foo", then they will include it in their ESLint
|
|
14
13
|
* config files as:
|
|
15
14
|
*
|
|
16
|
-
* "@nx/workspace
|
|
15
|
+
* "@nx/workspace/foo": "error"
|
|
17
16
|
*/
|
|
18
|
-
exports.
|
|
17
|
+
exports.WORKSPACE_RULE_NAMESPACE = 'workspace';
|
package/src/index.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const dependency_checks_1 = tslib_1.__importStar(require("./rules/dependency-checks"));
|
|
3
|
+
const typescript_1 = require("./configs/typescript");
|
|
4
|
+
const javascript_1 = require("./configs/javascript");
|
|
5
|
+
const react_tmp_1 = require("./configs/react-tmp");
|
|
6
|
+
const react_base_1 = require("./configs/react-base");
|
|
7
|
+
const react_jsx_1 = require("./configs/react-jsx");
|
|
8
|
+
const react_typescript_1 = require("./configs/react-typescript");
|
|
9
|
+
const angular_1 = require("./configs/angular");
|
|
10
|
+
const angular_template_1 = require("./configs/angular-template");
|
|
11
|
+
const enforce_module_boundaries_1 = require("./rules/enforce-module-boundaries");
|
|
12
|
+
const nx_plugin_checks_1 = require("./rules/nx-plugin-checks");
|
|
13
|
+
const dependency_checks_1 = require("./rules/dependency-checks");
|
|
15
14
|
// Resolve any custom rules that might exist in the current workspace
|
|
16
15
|
const resolve_workspace_rules_1 = require("./resolve-workspace-rules");
|
|
17
16
|
module.exports = {
|
|
@@ -21,9 +21,7 @@ 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.
|
|
25
|
-
// keep the old namespaced rules for backwards compatibility
|
|
26
|
-
namespacedRules[`${constants_1.WORKSPACE_RULE_PREFIX}/${ruleName}`] = ruleConfig;
|
|
24
|
+
namespacedRules[`${constants_1.WORKSPACE_RULE_NAMESPACE}/${ruleName}`] = ruleConfig;
|
|
27
25
|
}
|
|
28
26
|
return namespacedRules;
|
|
29
27
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
1
|
export type Options = [
|
|
3
2
|
{
|
|
4
3
|
buildTargets?: string[];
|
|
@@ -8,10 +7,9 @@ export type Options = [
|
|
|
8
7
|
ignoredDependencies?: string[];
|
|
9
8
|
ignoredFiles?: string[];
|
|
10
9
|
includeTransitiveDependencies?: boolean;
|
|
11
|
-
useLocalPathsForWorkspaceDependencies?: boolean;
|
|
12
10
|
}
|
|
13
11
|
];
|
|
14
12
|
export type MessageIds = 'missingDependency' | 'obsoleteDependency' | 'versionMismatch' | 'missingDependencySection';
|
|
15
13
|
export declare const RULE_NAME = "dependency-checks";
|
|
16
|
-
declare const _default:
|
|
14
|
+
declare const _default: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<MessageIds, Options, import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
17
15
|
export default _default;
|
|
@@ -5,18 +5,18 @@ const path_1 = require("path");
|
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
7
|
const find_npm_dependencies_1 = require("@nx/js/src/utils/find-npm-dependencies");
|
|
8
|
+
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
8
9
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
9
10
|
const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
|
|
10
11
|
const package_json_utils_1 = require("../utils/package-json-utils");
|
|
11
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
12
12
|
exports.RULE_NAME = 'dependency-checks';
|
|
13
|
-
exports.default =
|
|
13
|
+
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
14
14
|
name: exports.RULE_NAME,
|
|
15
15
|
meta: {
|
|
16
16
|
type: 'suggestion',
|
|
17
17
|
docs: {
|
|
18
18
|
description: `Checks dependencies in project's package.json for version mismatches`,
|
|
19
|
-
recommended: '
|
|
19
|
+
recommended: 'error',
|
|
20
20
|
},
|
|
21
21
|
fixable: 'code',
|
|
22
22
|
schema: [
|
|
@@ -30,7 +30,6 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
30
30
|
checkObsoleteDependencies: { type: 'boolean' },
|
|
31
31
|
checkVersionMismatches: { type: 'boolean' },
|
|
32
32
|
includeTransitiveDependencies: { type: 'boolean' },
|
|
33
|
-
useLocalPathsForWorkspaceDependencies: { type: 'boolean' },
|
|
34
33
|
},
|
|
35
34
|
additionalProperties: false,
|
|
36
35
|
},
|
|
@@ -51,10 +50,9 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
51
50
|
ignoredDependencies: [],
|
|
52
51
|
ignoredFiles: [],
|
|
53
52
|
includeTransitiveDependencies: false,
|
|
54
|
-
useLocalPathsForWorkspaceDependencies: false,
|
|
55
53
|
},
|
|
56
54
|
],
|
|
57
|
-
create(context, [{ buildTargets, ignoredDependencies, ignoredFiles, checkMissingDependencies, checkObsoleteDependencies, checkVersionMismatches, includeTransitiveDependencies,
|
|
55
|
+
create(context, [{ buildTargets, ignoredDependencies, ignoredFiles, checkMissingDependencies, checkObsoleteDependencies, checkVersionMismatches, includeTransitiveDependencies, },]) {
|
|
58
56
|
if (!context.parserServices.isJSON) {
|
|
59
57
|
return {};
|
|
60
58
|
}
|
|
@@ -83,7 +81,6 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
83
81
|
{
|
|
84
82
|
includeTransitiveDependencies,
|
|
85
83
|
ignoredFiles,
|
|
86
|
-
useLocalPathsForWorkspaceDependencies,
|
|
87
84
|
});
|
|
88
85
|
const expectedDependencyNames = Object.keys(npmDependencies);
|
|
89
86
|
const projPackageJsonPath = (0, path_1.join)(devkit_1.workspaceRoot, sourceProject.data.root, 'package.json');
|
|
@@ -126,9 +123,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
126
123
|
if (!checkVersionMismatches) {
|
|
127
124
|
return;
|
|
128
125
|
}
|
|
129
|
-
if (npmDependencies[packageName]
|
|
130
|
-
packageRange.startsWith('file:') ||
|
|
131
|
-
npmDependencies[packageName] === '*' ||
|
|
126
|
+
if (npmDependencies[packageName] === '*' ||
|
|
132
127
|
packageRange === '*' ||
|
|
133
128
|
(0, semver_1.satisfies)(npmDependencies[packageName], packageRange, {
|
|
134
129
|
includePrerelease: true,
|
|
@@ -199,7 +194,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
199
194
|
},
|
|
200
195
|
fix: (fixer) => {
|
|
201
196
|
expectedDependencyNames.sort().reduce((acc, d) => {
|
|
202
|
-
acc[d] = rootPackageJsonDeps[d] ||
|
|
197
|
+
acc[d] = rootPackageJsonDeps[d] || dependencies[d];
|
|
203
198
|
return acc;
|
|
204
199
|
}, projPackageJsonDeps);
|
|
205
200
|
const dependencies = Object.keys(projPackageJsonDeps)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DepConstraint } from '../utils/runtime-lint-utils';
|
|
2
|
-
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
3
2
|
type Options = [
|
|
4
3
|
{
|
|
5
4
|
allow: string[];
|
|
@@ -12,7 +11,7 @@ type Options = [
|
|
|
12
11
|
checkNestedExternalImports: boolean;
|
|
13
12
|
}
|
|
14
13
|
];
|
|
15
|
-
export type MessageIds = 'noRelativeOrAbsoluteImportsAcrossLibraries' | '
|
|
14
|
+
export type MessageIds = 'noRelativeOrAbsoluteImportsAcrossLibraries' | 'noSelfCircularDependencies' | 'noCircularDependencies' | 'noImportsOfApps' | 'noImportsOfE2e' | 'noImportOfNonBuildableLibraries' | 'noImportsOfLazyLoadedLibraries' | 'projectWithoutTagsCannotHaveDependencies' | 'bannedExternalImportsViolation' | 'nestedBannedExternalImportsViolation' | 'noTransitiveDependencies' | 'onlyTagsConstraintViolation' | 'emptyOnlyTagsConstraintViolation' | 'notTagsConstraintViolation';
|
|
16
15
|
export declare const RULE_NAME = "enforce-module-boundaries";
|
|
17
|
-
declare const _default:
|
|
16
|
+
declare const _default: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<MessageIds, Options, import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
|
|
18
17
|
export default _default;
|
|
@@ -8,16 +8,16 @@ const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
|
|
|
8
8
|
const utils_1 = require("@typescript-eslint/utils");
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
11
|
+
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
11
12
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
12
|
-
const utils_2 = require("@typescript-eslint/utils");
|
|
13
13
|
exports.RULE_NAME = 'enforce-module-boundaries';
|
|
14
|
-
exports.default =
|
|
14
|
+
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
15
15
|
name: exports.RULE_NAME,
|
|
16
16
|
meta: {
|
|
17
17
|
type: 'suggestion',
|
|
18
18
|
docs: {
|
|
19
19
|
description: `Ensure that module boundaries are respected within the monorepo`,
|
|
20
|
-
recommended: '
|
|
20
|
+
recommended: 'error',
|
|
21
21
|
},
|
|
22
22
|
fixable: 'code',
|
|
23
23
|
schema: [
|
|
@@ -97,7 +97,6 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
97
97
|
],
|
|
98
98
|
messages: {
|
|
99
99
|
noRelativeOrAbsoluteImportsAcrossLibraries: `Projects cannot be imported by a relative or absolute path, and must begin with a npm scope`,
|
|
100
|
-
noRelativeOrAbsoluteExternals: `External resources cannot be imported using a relative or absolute path`,
|
|
101
100
|
noCircularDependencies: `Circular dependency between "{{sourceProjectName}}" and "{{targetProjectName}}" detected: {{path}}\n\nCircular file chain:\n{{filePaths}}`,
|
|
102
101
|
noSelfCircularDependencies: `Projects should use relative imports to import from other files within the same project. Use "./path/to/file" instead of import from "{{imp}}"`,
|
|
103
102
|
noImportsOfApps: 'Imports of apps are forbidden',
|
|
@@ -209,15 +208,8 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
209
208
|
targetProject =
|
|
210
209
|
targetProject ||
|
|
211
210
|
(0, runtime_lint_utils_1.findProjectUsingImport)(projectGraph, targetProjectLocator, sourceFilePath, imp);
|
|
211
|
+
// If target is not part of an nx workspace, return.
|
|
212
212
|
if (!targetProject) {
|
|
213
|
-
// non-project imports cannot use relative or absolute paths
|
|
214
|
-
if ((0, fileutils_1.isRelativePath)(imp) || imp.startsWith('/')) {
|
|
215
|
-
context.report({
|
|
216
|
-
node,
|
|
217
|
-
messageId: 'noRelativeOrAbsoluteExternals',
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
// If target is not found (including node internals) we bail early
|
|
221
213
|
return;
|
|
222
214
|
}
|
|
223
215
|
// we only allow relative paths within the same project
|
|
@@ -225,7 +217,7 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
225
217
|
if (sourceProject === targetProject) {
|
|
226
218
|
if (!allowCircularSelfDependency &&
|
|
227
219
|
!(0, fileutils_1.isRelativePath)(imp) &&
|
|
228
|
-
!(0, runtime_lint_utils_1.
|
|
220
|
+
!(0, runtime_lint_utils_1.isAngularSecondaryEntrypoint)(imp, sourceFilePath, sourceProject.data.root)) {
|
|
229
221
|
context.report({
|
|
230
222
|
node,
|
|
231
223
|
messageId: 'noSelfCircularDependencies',
|
|
@@ -359,8 +351,10 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
359
351
|
}
|
|
360
352
|
}
|
|
361
353
|
// if we import a library using loadChildren, we should not import it using es6imports
|
|
362
|
-
if (
|
|
363
|
-
|
|
354
|
+
if (node.type === utils_1.AST_NODE_TYPES.ImportDeclaration &&
|
|
355
|
+
node.importKind !== 'type' &&
|
|
356
|
+
!checkDynamicDependenciesExceptions.some((a) => (0, runtime_lint_utils_1.matchImportWithWildcard)(a, imp)) &&
|
|
357
|
+
(0, runtime_lint_utils_1.onlyLoadChildren)(projectGraph, sourceProject.name, targetProject.name, [])) {
|
|
364
358
|
const filesWithLazyImports = (0, graph_utils_1.findFilesWithDynamicImports)(projectFileMap, sourceProject.name, targetProject.name);
|
|
365
359
|
context.report({
|
|
366
360
|
data: {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateVersionJsonExpression = exports.validatePackageGroup = exports.validateImplemenationNode = exports.validateEntry = exports.checkCollectionNode = exports.checkCollectionFileNode = exports.RULE_NAME = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
6
4
|
const devkit_1 = require("@nx/devkit");
|
|
7
5
|
const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
|
|
8
6
|
const fs_1 = require("fs");
|
|
9
7
|
const internal_1 = require("@nx/js/src/internal");
|
|
10
|
-
const path =
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
11
10
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
12
11
|
const semver_1 = require("semver");
|
|
13
|
-
const
|
|
12
|
+
const path_1 = require("path");
|
|
14
13
|
const DEFAULT_OPTIONS = {
|
|
15
14
|
generatorsJson: 'generators.json',
|
|
16
15
|
executorsJson: 'executors.json',
|
|
@@ -19,12 +18,12 @@ const DEFAULT_OPTIONS = {
|
|
|
19
18
|
allowedVersionStrings: ['*', 'latest', 'next'],
|
|
20
19
|
};
|
|
21
20
|
exports.RULE_NAME = 'nx-plugin-checks';
|
|
22
|
-
exports.default =
|
|
21
|
+
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
23
22
|
name: exports.RULE_NAME,
|
|
24
23
|
meta: {
|
|
25
24
|
docs: {
|
|
26
25
|
description: 'Checks common nx-plugin configuration files for validity',
|
|
27
|
-
recommended: '
|
|
26
|
+
recommended: 'error',
|
|
28
27
|
},
|
|
29
28
|
schema: [
|
|
30
29
|
{
|
|
@@ -90,7 +89,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => ``)({
|
|
|
90
89
|
return {};
|
|
91
90
|
}
|
|
92
91
|
if (!global.tsProjectRegistered) {
|
|
93
|
-
(0, internal_1.registerTsProject)((0,
|
|
92
|
+
(0, internal_1.registerTsProject)((0, path_1.join)(devkit_1.workspaceRoot, 'tsconfig.base.json'));
|
|
94
93
|
global.tsProjectRegistered = true;
|
|
95
94
|
}
|
|
96
95
|
return {
|
package/src/utils/ast-utils.js
CHANGED
|
@@ -79,17 +79,7 @@ function hasMemberExport(exportedMember, filePath) {
|
|
|
79
79
|
return ((0, js_1.findNodes)(sourceFile, ts.SyntaxKind.Identifier).filter((identifier) => identifier.text === exportedMember).length > 0);
|
|
80
80
|
}
|
|
81
81
|
function getRelativeImportPath(exportedMember, filePath, basePath) {
|
|
82
|
-
|
|
83
|
-
throwIfNoEntry: false,
|
|
84
|
-
});
|
|
85
|
-
if (!status /*not existed, but probably not full file with an extension*/) {
|
|
86
|
-
// try to find an extension that exists
|
|
87
|
-
const ext = ['.ts', '.tsx', '.js', '.jsx'].find((ext) => (0, fs_1.lstatSync)(filePath + ext, { throwIfNoEntry: false }));
|
|
88
|
-
if (ext) {
|
|
89
|
-
filePath += ext;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (status.isDirectory()) {
|
|
82
|
+
if ((0, fs_1.lstatSync)(filePath).isDirectory()) {
|
|
93
83
|
const file = (0, fs_1.readdirSync)(filePath).find((file) => /^index\.[jt]sx?$/.exec(file));
|
|
94
84
|
if (file) {
|
|
95
85
|
filePath = (0, devkit_1.joinPathFragments)(filePath, file);
|
|
@@ -98,6 +88,15 @@ function getRelativeImportPath(exportedMember, filePath, basePath) {
|
|
|
98
88
|
return;
|
|
99
89
|
}
|
|
100
90
|
}
|
|
91
|
+
else if (!(0, fs_1.lstatSync)(filePath, {
|
|
92
|
+
throwIfNoEntry: false,
|
|
93
|
+
}) /*not folder, but probably not full file with an extension either*/) {
|
|
94
|
+
// try to find an extension that exists
|
|
95
|
+
const ext = ['.ts', '.tsx', '.js', '.jsx'].find((ext) => (0, fs_1.lstatSync)(filePath + ext, { throwIfNoEntry: false }));
|
|
96
|
+
if (ext) {
|
|
97
|
+
filePath += ext;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
101
100
|
const fileContent = (0, fs_1.readFileSync)(filePath, 'utf8');
|
|
102
101
|
// use the TypeScript AST to find the path to the file where exportedMember is defined
|
|
103
102
|
const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const createESLintRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener = import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<TMessageIds, TOptions, TRuleListener>;
|
|
@@ -14,18 +14,15 @@ function getAllDependencies(packageJson) {
|
|
|
14
14
|
}
|
|
15
15
|
exports.getAllDependencies = getAllDependencies;
|
|
16
16
|
function getProductionDependencies(packageJsonPath) {
|
|
17
|
-
if (!globalThis.projPackageJsonDeps ||
|
|
18
|
-
!globalThis.projPackageJsonDeps[packageJsonPath] ||
|
|
19
|
-
!(0, runtime_lint_utils_1.isTerminalRun)()) {
|
|
17
|
+
if (!globalThis.projPackageJsonDeps || !(0, runtime_lint_utils_1.isTerminalRun)()) {
|
|
20
18
|
const packageJson = getPackageJson(packageJsonPath);
|
|
21
|
-
globalThis.projPackageJsonDeps =
|
|
22
|
-
globalThis.projPackageJsonDeps[packageJsonPath] = {
|
|
19
|
+
globalThis.projPackageJsonDeps = {
|
|
23
20
|
...packageJson.dependencies,
|
|
24
21
|
...packageJson.peerDependencies,
|
|
25
22
|
...packageJson.optionalDependencies,
|
|
26
23
|
};
|
|
27
24
|
}
|
|
28
|
-
return globalThis.projPackageJsonDeps
|
|
25
|
+
return globalThis.projPackageJsonDeps;
|
|
29
26
|
}
|
|
30
27
|
exports.getProductionDependencies = getProductionDependencies;
|
|
31
28
|
function getPackageJson(path) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ProjectGraph, ProjectGraphDependency, ProjectGraphExternalNode, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
2
|
import { ProjectRootMappings } from 'nx/src/project-graph/utils/find-project-for-path';
|
|
3
3
|
import { TargetProjectLocator } from '@nx/js/src/internal';
|
|
4
|
-
import { TSESTree } from '@typescript-eslint/utils';
|
|
5
4
|
export type Deps = {
|
|
6
5
|
[projectName: string]: ProjectGraphDependency[];
|
|
7
6
|
};
|
|
@@ -40,7 +39,7 @@ export declare function isAbsoluteImportIntoAnotherProject(imp: string, workspac
|
|
|
40
39
|
}): boolean;
|
|
41
40
|
export declare function findProjectUsingImport(projectGraph: ProjectGraph, targetProjectLocator: TargetProjectLocator, filePath: string, imp: string): ProjectGraphProjectNode | ProjectGraphExternalNode;
|
|
42
41
|
export declare function findConstraintsFor(depConstraints: DepConstraint[], sourceProject: ProjectGraphProjectNode): DepConstraint[];
|
|
43
|
-
export declare function
|
|
42
|
+
export declare function onlyLoadChildren(graph: ProjectGraph, sourceProjectName: string, targetProjectName: string, visited: string[]): any;
|
|
44
43
|
export declare function getSourceFilePath(sourceFileName: string, projectPath: string): string;
|
|
45
44
|
export declare function hasBannedImport(source: ProjectGraphProjectNode, target: ProjectGraphExternalNode, depConstraints: DepConstraint[], imp: string): DepConstraint | undefined;
|
|
46
45
|
/**
|
|
@@ -78,9 +77,12 @@ export declare function groupImports(importsToRemap: {
|
|
|
78
77
|
importPath: string;
|
|
79
78
|
}[]): string;
|
|
80
79
|
/**
|
|
81
|
-
* Checks if
|
|
80
|
+
* Checks if import points to a secondary entry point in Angular project
|
|
81
|
+
* @param targetProjectLocator
|
|
82
|
+
* @param importExpr
|
|
83
|
+
* @returns
|
|
82
84
|
*/
|
|
83
|
-
export declare function
|
|
85
|
+
export declare function isAngularSecondaryEntrypoint(importExpr: string, filePath: string, projectRoot: string): boolean;
|
|
84
86
|
/**
|
|
85
87
|
* Returns true if the given project contains MFE config with "exposes:" section
|
|
86
88
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.appIsMFERemote = exports.
|
|
4
|
-
const
|
|
5
|
-
const path = tslib_1.__importStar(require("path"));
|
|
3
|
+
exports.appIsMFERemote = exports.isAngularSecondaryEntrypoint = exports.groupImports = exports.isTerminalRun = exports.hasBuildExecutor = exports.isDirectDependency = exports.hasBannedDependencies = exports.findTransitiveExternalDependencies = exports.hasBannedImport = exports.getSourceFilePath = exports.onlyLoadChildren = exports.findConstraintsFor = exports.findProjectUsingImport = exports.isAbsoluteImportIntoAnotherProject = exports.findProject = exports.getTargetProjectBasedOnRelativeImport = exports.isRelative = exports.matchImportWithWildcard = exports.findDependenciesWithTags = exports.isComboDepConstraint = exports.hasNoneOfTheseTags = exports.stringifyTags = void 0;
|
|
4
|
+
const path = require("path");
|
|
6
5
|
const path_1 = require("path");
|
|
7
6
|
const devkit_1 = require("@nx/devkit");
|
|
8
7
|
const graph_utils_1 = require("./graph-utils");
|
|
@@ -10,7 +9,6 @@ const fileutils_1 = require("nx/src/utils/fileutils");
|
|
|
10
9
|
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
11
10
|
const js_1 = require("@nx/js");
|
|
12
11
|
const internal_1 = require("@nx/js/src/internal");
|
|
13
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
14
12
|
function stringifyTags(tags) {
|
|
15
13
|
return tags.map((t) => `"${t}"`).join(', ');
|
|
16
14
|
}
|
|
@@ -125,31 +123,21 @@ function findConstraintsFor(depConstraints, sourceProject) {
|
|
|
125
123
|
});
|
|
126
124
|
}
|
|
127
125
|
exports.findConstraintsFor = findConstraintsFor;
|
|
128
|
-
function hasStaticImportOfDynamicResource(node, graph, sourceProjectName, targetProjectName) {
|
|
129
|
-
if (node.type !== utils_1.AST_NODE_TYPES.ImportDeclaration ||
|
|
130
|
-
node.importKind === 'type') {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
return onlyLoadChildren(graph, sourceProjectName, targetProjectName, []);
|
|
134
|
-
}
|
|
135
|
-
exports.hasStaticImportOfDynamicResource = hasStaticImportOfDynamicResource;
|
|
136
126
|
function onlyLoadChildren(graph, sourceProjectName, targetProjectName, visited) {
|
|
137
|
-
if (visited.indexOf(sourceProjectName) > -1)
|
|
127
|
+
if (visited.indexOf(sourceProjectName) > -1)
|
|
138
128
|
return false;
|
|
139
|
-
}
|
|
140
129
|
return ((graph.dependencies[sourceProjectName] || []).filter((d) => {
|
|
141
|
-
if (d.type !== devkit_1.DependencyType.dynamic)
|
|
130
|
+
if (d.type !== devkit_1.DependencyType.dynamic)
|
|
142
131
|
return false;
|
|
143
|
-
|
|
144
|
-
if (d.target === targetProjectName) {
|
|
132
|
+
if (d.target === targetProjectName)
|
|
145
133
|
return true;
|
|
146
|
-
}
|
|
147
134
|
return onlyLoadChildren(graph, d.target, targetProjectName, [
|
|
148
135
|
...visited,
|
|
149
136
|
sourceProjectName,
|
|
150
137
|
]);
|
|
151
138
|
}).length > 0);
|
|
152
139
|
}
|
|
140
|
+
exports.onlyLoadChildren = onlyLoadChildren;
|
|
153
141
|
function getSourceFilePath(sourceFileName, projectPath) {
|
|
154
142
|
const normalizedProjectPath = (0, devkit_1.normalizePath)(projectPath);
|
|
155
143
|
const normalizedSourceFileName = (0, devkit_1.normalizePath)(sourceFileName);
|
|
@@ -282,7 +270,7 @@ function hasBuildExecutor(projectGraph, buildTargets = ['build']) {
|
|
|
282
270
|
projectGraph.data.targets[target].executor !== ''));
|
|
283
271
|
}
|
|
284
272
|
exports.hasBuildExecutor = hasBuildExecutor;
|
|
285
|
-
const ESLINT_REGEX = /node_modules.*[\/\\]eslint
|
|
273
|
+
const ESLINT_REGEX = /node_modules.*[\/\\]eslint$/;
|
|
286
274
|
const JEST_REGEX = /node_modules\/.bin\/jest$/; // when we run unit tests in jest
|
|
287
275
|
const NRWL_CLI_REGEX = /nx[\/\\]bin[\/\\]run-executor\.js$/;
|
|
288
276
|
function isTerminalRun() {
|
|
@@ -322,21 +310,17 @@ function groupImports(importsToRemap) {
|
|
|
322
310
|
}
|
|
323
311
|
exports.groupImports = groupImports;
|
|
324
312
|
/**
|
|
325
|
-
* Checks if
|
|
313
|
+
* Checks if import points to a secondary entry point in Angular project
|
|
314
|
+
* @param targetProjectLocator
|
|
315
|
+
* @param importExpr
|
|
316
|
+
* @returns
|
|
326
317
|
*/
|
|
327
|
-
function
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
if (!resolvedImportFile) {
|
|
331
|
-
return false;
|
|
332
|
-
}
|
|
333
|
-
const importEntryPoint = getAngularEntryPoint(resolvedImportFile, projectRoot);
|
|
334
|
-
const srcEntryPoint = getAngularEntryPoint(filePath, projectRoot);
|
|
335
|
-
// check if the entry point of import expression is different than the source file's entry point
|
|
336
|
-
return importEntryPoint !== srcEntryPoint;
|
|
318
|
+
function isAngularSecondaryEntrypoint(importExpr, filePath, projectRoot) {
|
|
319
|
+
const resolvedModule = (0, internal_1.resolveModuleByImport)(importExpr, filePath, (0, path_1.join)(devkit_1.workspaceRoot, (0, js_1.getRootTsConfigFileName)()));
|
|
320
|
+
return (!!resolvedModule && fileIsSecondaryEntryPoint(resolvedModule, projectRoot));
|
|
337
321
|
}
|
|
338
|
-
exports.
|
|
339
|
-
function
|
|
322
|
+
exports.isAngularSecondaryEntrypoint = isAngularSecondaryEntrypoint;
|
|
323
|
+
function fileIsSecondaryEntryPoint(file, projectRoot) {
|
|
340
324
|
let parent = (0, devkit_1.joinPathFragments)(file, '../');
|
|
341
325
|
while (parent !== `${projectRoot}/`) {
|
|
342
326
|
// we need to find closest existing ng-package.json
|
|
@@ -345,11 +329,11 @@ function getAngularEntryPoint(file, projectRoot) {
|
|
|
345
329
|
if (ngPackageContent) {
|
|
346
330
|
// https://github.com/ng-packagr/ng-packagr/blob/23c718d04eea85e015b4c261310b7bd0c39e5311/src/ng-package.schema.json#L54
|
|
347
331
|
const entryFile = (0, devkit_1.parseJson)(ngPackageContent)?.lib?.entryFile;
|
|
348
|
-
return (0, devkit_1.joinPathFragments)(parent, entryFile);
|
|
332
|
+
return entryFile && file === (0, devkit_1.joinPathFragments)(parent, entryFile);
|
|
349
333
|
}
|
|
350
334
|
parent = (0, devkit_1.joinPathFragments)(parent, '../');
|
|
351
335
|
}
|
|
352
|
-
return
|
|
336
|
+
return false;
|
|
353
337
|
}
|
|
354
338
|
/**
|
|
355
339
|
* Returns true if the given project contains MFE config with "exposes:" section
|
|
@@ -1,29 +0,0 @@
|
|
|
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;
|