@nx/eslint-plugin 19.0.7 → 19.1.0-beta.1
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 +5 -6
- package/src/rules/dependency-checks.js +6 -6
- package/src/rules/enforce-module-boundaries.js +1 -1
- package/src/rules/nx-plugin-checks.d.ts +1 -1
- package/src/rules/nx-plugin-checks.js +8 -8
- package/src/utils/runtime-lint-utils.d.ts +2 -7
- package/src/utils/runtime-lint-utils.js +8 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.1.0-beta.1",
|
|
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": {
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"Web",
|
|
14
14
|
"Lint",
|
|
15
15
|
"ESLint",
|
|
16
|
-
"CLI"
|
|
17
|
-
"Testing"
|
|
16
|
+
"CLI"
|
|
18
17
|
],
|
|
19
18
|
"main": "./src/index.js",
|
|
20
19
|
"typings": "./src/index.d.ts",
|
|
@@ -34,8 +33,8 @@
|
|
|
34
33
|
}
|
|
35
34
|
},
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "19.0.
|
|
38
|
-
"@nx/js": "19.0.
|
|
36
|
+
"@nx/devkit": "19.1.0-beta.1",
|
|
37
|
+
"@nx/js": "19.1.0-beta.1",
|
|
39
38
|
"@typescript-eslint/type-utils": "^7.3.0",
|
|
40
39
|
"@typescript-eslint/utils": "^7.3.0",
|
|
41
40
|
"chalk": "^4.1.0",
|
|
@@ -43,7 +42,7 @@
|
|
|
43
42
|
"jsonc-eslint-parser": "^2.1.0",
|
|
44
43
|
"semver": "^7.5.3",
|
|
45
44
|
"tslib": "^2.3.0",
|
|
46
|
-
"@nrwl/eslint-plugin-nx": "19.0.
|
|
45
|
+
"@nrwl/eslint-plugin-nx": "19.1.0-beta.1"
|
|
47
46
|
},
|
|
48
47
|
"publishConfig": {
|
|
49
48
|
"access": "public"
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RULE_NAME = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const find_npm_dependencies_1 = require("@nx/js/src/utils/find-npm-dependencies");
|
|
6
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
7
4
|
const path_1 = require("path");
|
|
8
5
|
const semver_1 = require("semver");
|
|
9
|
-
const
|
|
6
|
+
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const find_npm_dependencies_1 = require("@nx/js/src/utils/find-npm-dependencies");
|
|
10
8
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
11
9
|
const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
|
|
10
|
+
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
13
|
exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl/nx/blob/${devkit_1.NX_VERSION}/docs/generated/packages/eslint-plugin/documents/dependency-checks.md`)({
|
|
14
14
|
name: exports.RULE_NAME,
|
|
@@ -55,10 +55,10 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
55
55
|
},
|
|
56
56
|
],
|
|
57
57
|
create(context, [{ buildTargets, ignoredDependencies, ignoredFiles, checkMissingDependencies, checkObsoleteDependencies, checkVersionMismatches, includeTransitiveDependencies, useLocalPathsForWorkspaceDependencies, },]) {
|
|
58
|
-
if (!
|
|
58
|
+
if (!context.parserServices.isJSON) {
|
|
59
59
|
return {};
|
|
60
60
|
}
|
|
61
|
-
const fileName = (0, devkit_1.normalizePath)(context.
|
|
61
|
+
const fileName = (0, devkit_1.normalizePath)(context.getFilename());
|
|
62
62
|
// support only package.json
|
|
63
63
|
if (!fileName.endsWith('/package.json')) {
|
|
64
64
|
return {};
|
|
@@ -130,7 +130,7 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
130
130
|
* Globally cached info about workspace
|
|
131
131
|
*/
|
|
132
132
|
const projectPath = (0, devkit_1.normalizePath)(global.projectPath || devkit_1.workspaceRoot);
|
|
133
|
-
const fileName = (0, devkit_1.normalizePath)(context.
|
|
133
|
+
const fileName = (0, devkit_1.normalizePath)(context.getFilename());
|
|
134
134
|
const { projectGraph, projectRootMappings, projectFileMap, targetProjectLocator, } = (0, project_graph_utils_1.readProjectGraph)(exports.RULE_NAME);
|
|
135
135
|
if (!projectGraph) {
|
|
136
136
|
return {};
|
|
@@ -4,13 +4,13 @@ exports.validateVersionJsonExpression = exports.validatePackageGroup = exports.v
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const utils_1 = require("@typescript-eslint/utils");
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const
|
|
8
|
-
const internal_1 = require("@nx/js/src/internal");
|
|
7
|
+
const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
|
|
9
8
|
const fs_1 = require("fs");
|
|
9
|
+
const internal_1 = require("@nx/js/src/internal");
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
|
-
const semver_1 = require("semver");
|
|
12
11
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
13
|
-
const
|
|
12
|
+
const semver_1 = require("semver");
|
|
13
|
+
const js_1 = require("@nx/js");
|
|
14
14
|
const DEFAULT_OPTIONS = {
|
|
15
15
|
generatorsJson: 'generators.json',
|
|
16
16
|
executorsJson: 'executors.json',
|
|
@@ -73,11 +73,11 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => ``)({
|
|
|
73
73
|
defaultOptions: [DEFAULT_OPTIONS],
|
|
74
74
|
create(context) {
|
|
75
75
|
// jsonc-eslint-parser adds this property to parserServices where appropriate
|
|
76
|
-
if (!
|
|
76
|
+
if (!context.parserServices.isJSON) {
|
|
77
77
|
return {};
|
|
78
78
|
}
|
|
79
79
|
const { projectGraph, projectRootMappings } = (0, project_graph_utils_1.readProjectGraph)(exports.RULE_NAME);
|
|
80
|
-
const sourceFilePath = (0, runtime_lint_utils_1.getSourceFilePath)(context.
|
|
80
|
+
const sourceFilePath = (0, runtime_lint_utils_1.getSourceFilePath)(context.getFilename(), devkit_1.workspaceRoot);
|
|
81
81
|
const sourceProject = (0, runtime_lint_utils_1.findProject)(projectGraph, projectRootMappings, sourceFilePath);
|
|
82
82
|
// If source is not part of an nx workspace, return.
|
|
83
83
|
if (!sourceProject) {
|
|
@@ -205,7 +205,7 @@ function validateEntry(baseNode, key, mode, context) {
|
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
else {
|
|
208
|
-
const schemaFilePath = path.join(path.dirname(context.
|
|
208
|
+
const schemaFilePath = path.join(path.dirname(context.getFilename()), schemaNode.value.value);
|
|
209
209
|
if (!(0, fs_1.existsSync)(schemaFilePath)) {
|
|
210
210
|
context.report({
|
|
211
211
|
messageId: 'invalidSchemaPath',
|
|
@@ -289,7 +289,7 @@ function validateImplemenationNode(implementationNode, key, context) {
|
|
|
289
289
|
else {
|
|
290
290
|
const [implementationPath, identifier] = implementationNode.value.value.split('#');
|
|
291
291
|
let resolvedPath;
|
|
292
|
-
const modulePath = path.join(path.dirname(context.
|
|
292
|
+
const modulePath = path.join(path.dirname(context.getFilename()), implementationPath);
|
|
293
293
|
try {
|
|
294
294
|
resolvedPath = require.resolve(modulePath);
|
|
295
295
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProjectGraph, ProjectGraphDependency, ProjectGraphExternalNode, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
-
import { TargetProjectLocator } from '@nx/js/src/internal';
|
|
3
|
-
import { TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
4
2
|
import { ProjectRootMappings } from 'nx/src/project-graph/utils/find-project-for-path';
|
|
3
|
+
import { TargetProjectLocator } from '@nx/js/src/internal';
|
|
4
|
+
import { TSESTree } from '@typescript-eslint/utils';
|
|
5
5
|
export type Deps = {
|
|
6
6
|
[projectName: string]: ProjectGraphDependency[];
|
|
7
7
|
};
|
|
@@ -85,9 +85,4 @@ export declare function belongsToDifferentNgEntryPoint(importExpr: string, fileP
|
|
|
85
85
|
* Returns true if the given project contains MFE config with "exposes:" section
|
|
86
86
|
*/
|
|
87
87
|
export declare function appIsMFERemote(project: ProjectGraphProjectNode): boolean;
|
|
88
|
-
/**
|
|
89
|
-
* parserServices moved from the context object to the nested sourceCode object in v8,
|
|
90
|
-
* and was removed from its original location in v9.
|
|
91
|
-
*/
|
|
92
|
-
export declare function getParserServices(context: Readonly<TSESLint.RuleContext<any, any>>): any;
|
|
93
88
|
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const path_1 = require("path");
|
|
5
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
+
const graph_utils_1 = require("./graph-utils");
|
|
9
|
+
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
10
|
+
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
6
11
|
const js_1 = require("@nx/js");
|
|
7
12
|
const internal_1 = require("@nx/js/src/internal");
|
|
8
13
|
const utils_1 = require("@typescript-eslint/utils");
|
|
9
|
-
const path = tslib_1.__importStar(require("node:path"));
|
|
10
|
-
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
11
|
-
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
12
|
-
const graph_utils_1 = require("./graph-utils");
|
|
13
14
|
function stringifyTags(tags) {
|
|
14
15
|
return tags.map((t) => `"${t}"`).join(', ');
|
|
15
16
|
}
|
|
@@ -245,7 +246,7 @@ function isDirectDependency(source, target) {
|
|
|
245
246
|
}
|
|
246
247
|
exports.isDirectDependency = isDirectDependency;
|
|
247
248
|
function packageExistsInPackageJson(packageName, projectRoot) {
|
|
248
|
-
const content = (0, fileutils_1.readFileIfExisting)(
|
|
249
|
+
const content = (0, fileutils_1.readFileIfExisting)((0, path_1.join)(devkit_1.workspaceRoot, projectRoot, 'package.json'));
|
|
249
250
|
if (content) {
|
|
250
251
|
const { dependencies, devDependencies, peerDependencies } = (0, devkit_1.parseJson)(content);
|
|
251
252
|
if (dependencies && dependencies[packageName]) {
|
|
@@ -325,7 +326,7 @@ exports.groupImports = groupImports;
|
|
|
325
326
|
*/
|
|
326
327
|
function belongsToDifferentNgEntryPoint(importExpr, filePath, projectRoot) {
|
|
327
328
|
const resolvedImportFile = (0, internal_1.resolveModuleByImport)(importExpr, filePath, // not strictly necessary, but speeds up resolution
|
|
328
|
-
|
|
329
|
+
(0, path_1.join)(devkit_1.workspaceRoot, (0, js_1.getRootTsConfigFileName)()));
|
|
329
330
|
if (!resolvedImportFile) {
|
|
330
331
|
return false;
|
|
331
332
|
}
|
|
@@ -362,18 +363,3 @@ function appIsMFERemote(project) {
|
|
|
362
363
|
return false;
|
|
363
364
|
}
|
|
364
365
|
exports.appIsMFERemote = appIsMFERemote;
|
|
365
|
-
/**
|
|
366
|
-
* parserServices moved from the context object to the nested sourceCode object in v8,
|
|
367
|
-
* and was removed from its original location in v9.
|
|
368
|
-
*/
|
|
369
|
-
function getParserServices(context) {
|
|
370
|
-
if (context.sourceCode && context.sourceCode.parserServices) {
|
|
371
|
-
return context.sourceCode.parserServices;
|
|
372
|
-
}
|
|
373
|
-
const parserServices = context.parserServices;
|
|
374
|
-
if (!parserServices) {
|
|
375
|
-
throw new Error('Parser Services are not available, please check your ESLint configuration');
|
|
376
|
-
}
|
|
377
|
-
return parserServices;
|
|
378
|
-
}
|
|
379
|
-
exports.getParserServices = getParserServices;
|