@nx/eslint-plugin 16.4.0-beta.10 → 16.4.0-beta.13
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "16.4.0-beta.
|
|
3
|
+
"version": "16.4.0-beta.13",
|
|
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,9 +33,9 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@nrwl/eslint-plugin-nx": "16.4.0-beta.
|
|
37
|
-
"@nx/devkit": "16.4.0-beta.
|
|
38
|
-
"@nx/js": "16.4.0-beta.
|
|
36
|
+
"@nrwl/eslint-plugin-nx": "16.4.0-beta.13",
|
|
37
|
+
"@nx/devkit": "16.4.0-beta.13",
|
|
38
|
+
"@nx/js": "16.4.0-beta.13",
|
|
39
39
|
"@typescript-eslint/type-utils": "^5.58.0",
|
|
40
40
|
"@typescript-eslint/utils": "^5.58.0",
|
|
41
41
|
"chalk": "^4.1.0",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"migrations": "./migrations.json"
|
|
50
50
|
},
|
|
51
51
|
"types": "./src/index.d.ts",
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "d81afedfcc8d07db8cdb9b0e9286de0321ee184e"
|
|
53
53
|
}
|
|
@@ -64,7 +64,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
64
64
|
noImportsOfApps: 'Imports of apps are forbidden',
|
|
65
65
|
noImportsOfE2e: 'Imports of e2e projects are forbidden',
|
|
66
66
|
noImportOfNonBuildableLibraries: 'Buildable libraries cannot import or export from non-buildable libraries',
|
|
67
|
-
noImportsOfLazyLoadedLibraries: `
|
|
67
|
+
noImportsOfLazyLoadedLibraries: `Static imports of lazy-loaded libraries are forbidden.\n\nLibrary "{{targetProjectName}}" is lazy-loaded in these files:\n{{filePaths}}`,
|
|
68
68
|
projectWithoutTagsCannotHaveDependencies: `A project without tags matching at least one constraint cannot depend on any libraries`,
|
|
69
69
|
bannedExternalImportsViolation: `A project tagged with "{{sourceTag}}" is not allowed to import the "{{package}}" package`,
|
|
70
70
|
nestedBannedExternalImportsViolation: `A project tagged with "{{sourceTag}}" is not allowed to import the "{{package}}" package. Nested import found at {{childProjectName}}`,
|
|
@@ -312,7 +312,14 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
312
312
|
node.importKind !== 'type' &&
|
|
313
313
|
!checkDynamicDependenciesExceptions.some((a) => (0, runtime_lint_utils_1.matchImportWithWildcard)(a, imp)) &&
|
|
314
314
|
(0, runtime_lint_utils_1.onlyLoadChildren)(projectGraph, sourceProject.name, targetProject.name, [])) {
|
|
315
|
+
const filesWithLazyImports = (0, graph_utils_1.findFilesWithDynamicImports)(projectFileMap, sourceProject.name, targetProject.name);
|
|
315
316
|
context.report({
|
|
317
|
+
data: {
|
|
318
|
+
filePaths: filesWithLazyImports
|
|
319
|
+
.map(({ file }) => `- ${file}`)
|
|
320
|
+
.join('\n'),
|
|
321
|
+
targetProjectName: targetProject.name,
|
|
322
|
+
},
|
|
316
323
|
node,
|
|
317
324
|
messageId: 'noImportsOfLazyLoadedLibraries',
|
|
318
325
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ProjectFileMap, ProjectGraph, ProjectGraphProjectNode } from '@nx/devkit';
|
|
1
|
+
import type { FileData, ProjectFileMap, ProjectGraph, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
2
|
export declare function getPath(graph: ProjectGraph, sourceProjectName: string, targetProjectName: string): Array<ProjectGraphProjectNode>;
|
|
3
3
|
export declare function pathExists(graph: ProjectGraph, sourceProjectName: string, targetProjectName: string): boolean;
|
|
4
4
|
export declare function checkCircularPath(graph: ProjectGraph, sourceProject: ProjectGraphProjectNode, targetProject: ProjectGraphProjectNode): ProjectGraphProjectNode[];
|
|
5
5
|
export declare function findFilesInCircularPath(projectFileMap: ProjectFileMap, circularPath: ProjectGraphProjectNode[]): Array<string[]>;
|
|
6
|
+
export declare function findFilesWithDynamicImports(projectFileMap: ProjectFileMap, sourceProjectName: string, targetProjectName: string): FileData[];
|
package/src/utils/graph-utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findFilesInCircularPath = exports.checkCircularPath = exports.pathExists = exports.getPath = void 0;
|
|
3
|
+
exports.findFilesWithDynamicImports = exports.findFilesInCircularPath = exports.checkCircularPath = exports.pathExists = exports.getPath = void 0;
|
|
4
4
|
const project_graph_1 = require("nx/src/config/project-graph");
|
|
5
5
|
const reach = {
|
|
6
6
|
graph: null,
|
|
@@ -114,3 +114,16 @@ function findFilesInCircularPath(projectFileMap, circularPath) {
|
|
|
114
114
|
return filePathChain;
|
|
115
115
|
}
|
|
116
116
|
exports.findFilesInCircularPath = findFilesInCircularPath;
|
|
117
|
+
function findFilesWithDynamicImports(projectFileMap, sourceProjectName, targetProjectName) {
|
|
118
|
+
const files = [];
|
|
119
|
+
projectFileMap[sourceProjectName].forEach((file) => {
|
|
120
|
+
if (!file.deps)
|
|
121
|
+
return;
|
|
122
|
+
if (file.deps.some((d) => (0, project_graph_1.fileDataDepTarget)(d) === targetProjectName &&
|
|
123
|
+
(0, project_graph_1.fileDataDepType)(d) === project_graph_1.DependencyType.dynamic)) {
|
|
124
|
+
files.push(file);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return files;
|
|
128
|
+
}
|
|
129
|
+
exports.findFilesWithDynamicImports = findFilesWithDynamicImports;
|