@nx/eslint-plugin 17.2.0-beta.11 → 17.2.0-beta.14

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": "17.2.0-beta.11",
3
+ "version": "17.2.0-beta.14",
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": "17.2.0-beta.11",
37
- "@nx/js": "17.2.0-beta.11",
36
+ "@nx/devkit": "17.2.0-beta.14",
37
+ "@nx/js": "17.2.0-beta.14",
38
38
  "@typescript-eslint/type-utils": "^6.9.1",
39
39
  "@typescript-eslint/utils": "^6.9.1",
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": "17.2.0-beta.11"
45
+ "@nrwl/eslint-plugin-nx": "17.2.0-beta.14"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public"
@@ -12,7 +12,7 @@ type Options = [
12
12
  checkNestedExternalImports: boolean;
13
13
  }
14
14
  ];
15
- export type MessageIds = 'noRelativeOrAbsoluteImportsAcrossLibraries' | 'noSelfCircularDependencies' | 'noCircularDependencies' | 'noImportsOfApps' | 'noImportsOfE2e' | 'noImportOfNonBuildableLibraries' | 'noImportsOfLazyLoadedLibraries' | 'projectWithoutTagsCannotHaveDependencies' | 'bannedExternalImportsViolation' | 'nestedBannedExternalImportsViolation' | 'noTransitiveDependencies' | 'onlyTagsConstraintViolation' | 'emptyOnlyTagsConstraintViolation' | 'notTagsConstraintViolation';
15
+ export type MessageIds = 'noRelativeOrAbsoluteImportsAcrossLibraries' | 'noRelativeOrAbsoluteExternals' | 'noSelfCircularDependencies' | 'noCircularDependencies' | 'noImportsOfApps' | 'noImportsOfE2e' | 'noImportOfNonBuildableLibraries' | 'noImportsOfLazyLoadedLibraries' | 'projectWithoutTagsCannotHaveDependencies' | 'bannedExternalImportsViolation' | 'nestedBannedExternalImportsViolation' | 'noTransitiveDependencies' | 'onlyTagsConstraintViolation' | 'emptyOnlyTagsConstraintViolation' | 'notTagsConstraintViolation';
16
16
  export declare const RULE_NAME = "enforce-module-boundaries";
17
17
  declare const _default: ESLintUtils.RuleModule<MessageIds, Options, ESLintUtils.RuleListener>;
18
18
  export default _default;
@@ -97,6 +97,7 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => ``)({
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`,
100
101
  noCircularDependencies: `Circular dependency between "{{sourceProjectName}}" and "{{targetProjectName}}" detected: {{path}}\n\nCircular file chain:\n{{filePaths}}`,
101
102
  noSelfCircularDependencies: `Projects should use relative imports to import from other files within the same project. Use "./path/to/file" instead of import from "{{imp}}"`,
102
103
  noImportsOfApps: 'Imports of apps are forbidden',
@@ -208,8 +209,15 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => ``)({
208
209
  targetProject =
209
210
  targetProject ||
210
211
  (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
213
221
  return;
214
222
  }
215
223
  // we only allow relative paths within the same project