@nx/eslint-plugin 19.0.4 → 19.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/package.json +4 -4
- 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 +7 -2
- package/src/utils/runtime-lint-utils.js +22 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.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": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@nx/devkit": "19.0.
|
|
37
|
-
"@nx/js": "19.0.
|
|
36
|
+
"@nx/devkit": "19.0.6",
|
|
37
|
+
"@nx/js": "19.0.6",
|
|
38
38
|
"@typescript-eslint/type-utils": "^7.3.0",
|
|
39
39
|
"@typescript-eslint/utils": "^7.3.0",
|
|
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": "19.0.
|
|
45
|
+
"@nrwl/eslint-plugin-nx": "19.0.6"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
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 path_1 = require("path");
|
|
5
|
-
const semver_1 = require("semver");
|
|
6
4
|
const devkit_1 = require("@nx/devkit");
|
|
7
5
|
const find_npm_dependencies_1 = require("@nx/js/src/utils/find-npm-dependencies");
|
|
6
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const semver_1 = require("semver");
|
|
9
|
+
const package_json_utils_1 = require("../utils/package-json-utils");
|
|
8
10
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
9
11
|
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 (!context.
|
|
58
|
+
if (!(0, runtime_lint_utils_1.getParserServices)(context).isJSON) {
|
|
59
59
|
return {};
|
|
60
60
|
}
|
|
61
|
-
const fileName = (0, devkit_1.normalizePath)(context.getFilename());
|
|
61
|
+
const fileName = (0, devkit_1.normalizePath)(context.filename ?? 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.getFilename());
|
|
133
|
+
const fileName = (0, devkit_1.normalizePath)(context.filename ?? 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 fs_1 = require("fs");
|
|
7
|
+
const js_1 = require("@nx/js");
|
|
9
8
|
const internal_1 = require("@nx/js/src/internal");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
10
|
const path = tslib_1.__importStar(require("path"));
|
|
11
|
-
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
12
11
|
const semver_1 = require("semver");
|
|
13
|
-
const
|
|
12
|
+
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
13
|
+
const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
|
|
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 (!context.
|
|
76
|
+
if (!(0, runtime_lint_utils_1.getParserServices)(context).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.getFilename(), devkit_1.workspaceRoot);
|
|
80
|
+
const sourceFilePath = (0, runtime_lint_utils_1.getSourceFilePath)(context.filename ?? 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.getFilename()), schemaNode.value.value);
|
|
208
|
+
const schemaFilePath = path.join(path.dirname(context.filename ?? 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.getFilename()), implementationPath);
|
|
292
|
+
const modulePath = path.join(path.dirname(context.filename ?? 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 { ProjectRootMappings } from 'nx/src/project-graph/utils/find-project-for-path';
|
|
3
2
|
import { TargetProjectLocator } from '@nx/js/src/internal';
|
|
4
|
-
import { TSESTree } from '@typescript-eslint/utils';
|
|
3
|
+
import { TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
4
|
+
import { ProjectRootMappings } from 'nx/src/project-graph/utils/find-project-for-path';
|
|
5
5
|
export type Deps = {
|
|
6
6
|
[projectName: string]: ProjectGraphDependency[];
|
|
7
7
|
};
|
|
@@ -85,4 +85,9 @@ 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;
|
|
88
93
|
export {};
|
|
@@ -1,16 +1,15 @@
|
|
|
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.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;
|
|
3
|
+
exports.getParserServices = 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");
|
|
7
5
|
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");
|
|
11
6
|
const js_1 = require("@nx/js");
|
|
12
7
|
const internal_1 = require("@nx/js/src/internal");
|
|
13
8
|
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");
|
|
14
13
|
function stringifyTags(tags) {
|
|
15
14
|
return tags.map((t) => `"${t}"`).join(', ');
|
|
16
15
|
}
|
|
@@ -246,7 +245,7 @@ function isDirectDependency(source, target) {
|
|
|
246
245
|
}
|
|
247
246
|
exports.isDirectDependency = isDirectDependency;
|
|
248
247
|
function packageExistsInPackageJson(packageName, projectRoot) {
|
|
249
|
-
const content = (0, fileutils_1.readFileIfExisting)(
|
|
248
|
+
const content = (0, fileutils_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, projectRoot, 'package.json'));
|
|
250
249
|
if (content) {
|
|
251
250
|
const { dependencies, devDependencies, peerDependencies } = (0, devkit_1.parseJson)(content);
|
|
252
251
|
if (dependencies && dependencies[packageName]) {
|
|
@@ -326,7 +325,7 @@ exports.groupImports = groupImports;
|
|
|
326
325
|
*/
|
|
327
326
|
function belongsToDifferentNgEntryPoint(importExpr, filePath, projectRoot) {
|
|
328
327
|
const resolvedImportFile = (0, internal_1.resolveModuleByImport)(importExpr, filePath, // not strictly necessary, but speeds up resolution
|
|
329
|
-
|
|
328
|
+
path.join(devkit_1.workspaceRoot, (0, js_1.getRootTsConfigFileName)()));
|
|
330
329
|
if (!resolvedImportFile) {
|
|
331
330
|
return false;
|
|
332
331
|
}
|
|
@@ -363,3 +362,18 @@ function appIsMFERemote(project) {
|
|
|
363
362
|
return false;
|
|
364
363
|
}
|
|
365
364
|
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;
|