@nx/eslint-plugin 18.1.0-beta.1 → 18.1.0-beta.3
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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"update-17-2-6-rename-workspace-rules": {
|
|
10
10
|
"cli": "nx",
|
|
11
|
-
"version": "17
|
|
11
|
+
"version": "17.2.6-beta.1",
|
|
12
12
|
"description": "Rename workspace rules from @nx/workspace/name to @nx/workspace-name",
|
|
13
13
|
"implementation": "./src/migrations/update-17-2-6-rename-workspace-rules/rename-workspace-rules"
|
|
14
14
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "18.1.0-beta.
|
|
3
|
+
"version": "18.1.0-beta.3",
|
|
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": "18.1.0-beta.
|
|
37
|
-
"@nx/js": "18.1.0-beta.
|
|
36
|
+
"@nx/devkit": "18.1.0-beta.3",
|
|
37
|
+
"@nx/js": "18.1.0-beta.3",
|
|
38
38
|
"@typescript-eslint/type-utils": "^6.13.2",
|
|
39
39
|
"@typescript-eslint/utils": "^6.13.2",
|
|
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": "18.1.0-beta.
|
|
45
|
+
"@nrwl/eslint-plugin-nx": "18.1.0-beta.3"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
@@ -359,10 +359,8 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
// if we import a library using loadChildren, we should not import it using es6imports
|
|
362
|
-
if (
|
|
363
|
-
node.
|
|
364
|
-
!checkDynamicDependenciesExceptions.some((a) => (0, runtime_lint_utils_1.matchImportWithWildcard)(a, imp)) &&
|
|
365
|
-
(0, runtime_lint_utils_1.onlyLoadChildren)(projectGraph, sourceProject.name, targetProject.name, [])) {
|
|
362
|
+
if (!checkDynamicDependenciesExceptions.some((a) => (0, runtime_lint_utils_1.matchImportWithWildcard)(a, imp)) &&
|
|
363
|
+
(0, runtime_lint_utils_1.hasStaticImportOfDynamicResource)(node, projectGraph, sourceProject.name, targetProject.name)) {
|
|
366
364
|
const filesWithLazyImports = (0, graph_utils_1.findFilesWithDynamicImports)(projectFileMap, sourceProject.name, targetProject.name);
|
|
367
365
|
context.report({
|
|
368
366
|
data: {
|
|
@@ -1,6 +1,7 @@
|
|
|
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';
|
|
4
5
|
export type Deps = {
|
|
5
6
|
[projectName: string]: ProjectGraphDependency[];
|
|
6
7
|
};
|
|
@@ -39,7 +40,7 @@ export declare function isAbsoluteImportIntoAnotherProject(imp: string, workspac
|
|
|
39
40
|
}): boolean;
|
|
40
41
|
export declare function findProjectUsingImport(projectGraph: ProjectGraph, targetProjectLocator: TargetProjectLocator, filePath: string, imp: string): ProjectGraphProjectNode | ProjectGraphExternalNode;
|
|
41
42
|
export declare function findConstraintsFor(depConstraints: DepConstraint[], sourceProject: ProjectGraphProjectNode): DepConstraint[];
|
|
42
|
-
export declare function
|
|
43
|
+
export declare function hasStaticImportOfDynamicResource(node: TSESTree.ImportDeclaration | TSESTree.ImportExpression | TSESTree.ExportAllDeclaration | TSESTree.ExportNamedDeclaration, graph: ProjectGraph, sourceProjectName: string, targetProjectName: string): boolean;
|
|
43
44
|
export declare function getSourceFilePath(sourceFileName: string, projectPath: string): string;
|
|
44
45
|
export declare function hasBannedImport(source: ProjectGraphProjectNode, target: ProjectGraphExternalNode, depConstraints: DepConstraint[], imp: string): DepConstraint | undefined;
|
|
45
46
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.appIsMFERemote = exports.belongsToDifferentNgEntryPoint = exports.groupImports = exports.isTerminalRun = exports.hasBuildExecutor = exports.isDirectDependency = exports.hasBannedDependencies = exports.findTransitiveExternalDependencies = exports.hasBannedImport = exports.getSourceFilePath = exports.
|
|
3
|
+
exports.appIsMFERemote = exports.belongsToDifferentNgEntryPoint = exports.groupImports = exports.isTerminalRun = exports.hasBuildExecutor = exports.isDirectDependency = exports.hasBannedDependencies = exports.findTransitiveExternalDependencies = exports.hasBannedImport = exports.getSourceFilePath = exports.hasStaticImportOfDynamicResource = 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
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -10,6 +10,7 @@ const fileutils_1 = require("nx/src/utils/fileutils");
|
|
|
10
10
|
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
11
11
|
const js_1 = require("@nx/js");
|
|
12
12
|
const internal_1 = require("@nx/js/src/internal");
|
|
13
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
13
14
|
function stringifyTags(tags) {
|
|
14
15
|
return tags.map((t) => `"${t}"`).join(', ');
|
|
15
16
|
}
|
|
@@ -124,21 +125,31 @@ function findConstraintsFor(depConstraints, sourceProject) {
|
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
127
|
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;
|
|
127
136
|
function onlyLoadChildren(graph, sourceProjectName, targetProjectName, visited) {
|
|
128
|
-
if (visited.indexOf(sourceProjectName) > -1)
|
|
137
|
+
if (visited.indexOf(sourceProjectName) > -1) {
|
|
129
138
|
return false;
|
|
139
|
+
}
|
|
130
140
|
return ((graph.dependencies[sourceProjectName] || []).filter((d) => {
|
|
131
|
-
if (d.type !== devkit_1.DependencyType.dynamic)
|
|
141
|
+
if (d.type !== devkit_1.DependencyType.dynamic) {
|
|
132
142
|
return false;
|
|
133
|
-
|
|
143
|
+
}
|
|
144
|
+
if (d.target === targetProjectName) {
|
|
134
145
|
return true;
|
|
146
|
+
}
|
|
135
147
|
return onlyLoadChildren(graph, d.target, targetProjectName, [
|
|
136
148
|
...visited,
|
|
137
149
|
sourceProjectName,
|
|
138
150
|
]);
|
|
139
151
|
}).length > 0);
|
|
140
152
|
}
|
|
141
|
-
exports.onlyLoadChildren = onlyLoadChildren;
|
|
142
153
|
function getSourceFilePath(sourceFileName, projectPath) {
|
|
143
154
|
const normalizedProjectPath = (0, devkit_1.normalizePath)(projectPath);
|
|
144
155
|
const normalizedSourceFileName = (0, devkit_1.normalizePath)(sourceFileName);
|