@nx/eslint-plugin 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/migrations.json CHANGED
@@ -11,6 +11,12 @@
11
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
+ },
15
+ "update-19-1-0-rename-no-extra-semi": {
16
+ "cli": "nx",
17
+ "version": "19.1.0-beta.6",
18
+ "description": "Migrate no-extra-semi rules into user config, out of nx extendable configs",
19
+ "implementation": "./src/migrations/update-19-1-0-migrate-no-extra-semi/migrate-no-extra-semi"
14
20
  }
15
21
  },
16
22
  "packageJsonUpdates": {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/eslint-plugin",
3
- "version": "0.0.0-pr-22179-271588f",
3
+ "version": "0.0.0-pr-26482-ebe2dba",
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,7 +13,8 @@
13
13
  "Web",
14
14
  "Lint",
15
15
  "ESLint",
16
- "CLI"
16
+ "CLI",
17
+ "Testing"
17
18
  ],
18
19
  "main": "./src/index.js",
19
20
  "typings": "./src/index.d.ts",
@@ -33,16 +34,16 @@
33
34
  }
34
35
  },
35
36
  "dependencies": {
36
- "@nx/devkit": "0.0.0-pr-22179-271588f",
37
- "@nx/js": "0.0.0-pr-22179-271588f",
38
- "@typescript-eslint/type-utils": "^6.13.2",
39
- "@typescript-eslint/utils": "^6.13.2",
37
+ "@nx/devkit": "0.0.0-pr-26482-ebe2dba",
38
+ "@nx/js": "0.0.0-pr-26482-ebe2dba",
39
+ "@typescript-eslint/type-utils": "^7.3.0",
40
+ "@typescript-eslint/utils": "^7.3.0",
40
41
  "chalk": "^4.1.0",
41
42
  "confusing-browser-globals": "^1.0.9",
42
43
  "jsonc-eslint-parser": "^2.1.0",
43
44
  "semver": "^7.5.3",
44
45
  "tslib": "^2.3.0",
45
- "@nrwl/eslint-plugin-nx": "0.0.0-pr-22179-271588f"
46
+ "@nrwl/eslint-plugin-nx": "0.0.0-pr-26482-ebe2dba"
46
47
  },
47
48
  "publishConfig": {
48
49
  "access": "public"
@@ -44,10 +44,8 @@ declare const _default: {
44
44
  * previously defined v5 of `@typescript-eslint`. v6 of `@typescript-eslint`
45
45
  * changed how configurations are defined.
46
46
  *
47
- * TODO(v19): re-evalute these deviations from @typescript-eslint/recommended in v19 of Nx
47
+ * TODO(v20): re-evalute these deviations from @typescript-eslint/recommended in v20 of Nx
48
48
  */
49
- 'no-extra-semi': string;
50
- '@typescript-eslint/no-extra-semi': string;
51
49
  '@typescript-eslint/no-non-null-assertion': string;
52
50
  '@typescript-eslint/adjacent-overload-signatures': string;
53
51
  '@typescript-eslint/prefer-namespace-keyword': string;
@@ -53,10 +53,8 @@ exports.default = {
53
53
  * previously defined v5 of `@typescript-eslint`. v6 of `@typescript-eslint`
54
54
  * changed how configurations are defined.
55
55
  *
56
- * TODO(v19): re-evalute these deviations from @typescript-eslint/recommended in v19 of Nx
56
+ * TODO(v20): re-evalute these deviations from @typescript-eslint/recommended in v20 of Nx
57
57
  */
58
- 'no-extra-semi': 'off',
59
- '@typescript-eslint/no-extra-semi': 'error',
60
58
  '@typescript-eslint/no-non-null-assertion': 'warn',
61
59
  '@typescript-eslint/adjacent-overload-signatures': 'error',
62
60
  '@typescript-eslint/prefer-namespace-keyword': 'error',
@@ -1,3 +1,13 @@
1
+ /**
2
+ * This configuration is intended to be applied to ALL files within a React
3
+ * project in an Nx workspace.
4
+ *
5
+ * It should therefore NOT contain any rules or plugins which are specific
6
+ * to one particular variant, e.g. TypeScript vs JavaScript, .js vs .jsx etc
7
+ *
8
+ * This configuration is intended to be combined with other configs from this
9
+ * package.
10
+ */
1
11
  /**
2
12
  * Rule set originally adapted from:
3
13
  * https://github.com/facebook/create-react-app/blob/567f36c9235f1e1fd4a76dc6d1ae00be754ca047/packages/eslint-config-react-app/index.js
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
2
  /**
5
3
  * This configuration is intended to be applied to ALL files within a React
6
4
  * project in an Nx workspace.
@@ -11,7 +9,7 @@ const tslib_1 = require("tslib");
11
9
  * This configuration is intended to be combined with other configs from this
12
10
  * package.
13
11
  */
14
- const confusing_browser_globals_1 = tslib_1.__importDefault(require("confusing-browser-globals"));
12
+ Object.defineProperty(exports, "__esModule", { value: true });
15
13
  /**
16
14
  * Rule set originally adapted from:
17
15
  * https://github.com/facebook/create-react-app/blob/567f36c9235f1e1fd4a76dc6d1ae00be754ca047/packages/eslint-config-react-app/index.js
@@ -92,7 +90,7 @@ exports.default = {
92
90
  'no-template-curly-in-string': 'warn',
93
91
  'no-this-before-super': 'warn',
94
92
  'no-throw-literal': 'warn',
95
- 'no-restricted-globals': ['error'].concat(confusing_browser_globals_1.default),
93
+ 'no-restricted-globals': ['error'].concat(require('confusing-browser-globals')),
96
94
  'no-unexpected-multiline': 'warn',
97
95
  'no-unreachable': 'warn',
98
96
  'no-unused-expressions': 'off',
@@ -26,10 +26,8 @@ declare const _default: {
26
26
  * previously defined v5 of `@typescript-eslint`. v6 of `@typescript-eslint`
27
27
  * changed how configurations are defined.
28
28
  *
29
- * TODO(v19): re-evalute these deviations from @typescript-eslint/recommended in v19 of Nx
29
+ * TODO(v20): re-evalute these deviations from @typescript-eslint/recommended in v20 of Nx
30
30
  */
31
- 'no-extra-semi': string;
32
- '@typescript-eslint/no-extra-semi': string;
33
31
  '@typescript-eslint/no-non-null-assertion': string;
34
32
  '@typescript-eslint/adjacent-overload-signatures': string;
35
33
  '@typescript-eslint/prefer-namespace-keyword': string;
@@ -36,10 +36,8 @@ exports.default = {
36
36
  * previously defined v5 of `@typescript-eslint`. v6 of `@typescript-eslint`
37
37
  * changed how configurations are defined.
38
38
  *
39
- * TODO(v19): re-evalute these deviations from @typescript-eslint/recommended in v19 of Nx
39
+ * TODO(v20): re-evalute these deviations from @typescript-eslint/recommended in v20 of Nx
40
40
  */
41
- 'no-extra-semi': 'off',
42
- '@typescript-eslint/no-extra-semi': 'error',
43
41
  '@typescript-eslint/no-non-null-assertion': 'warn',
44
42
  '@typescript-eslint/adjacent-overload-signatures': 'error',
45
43
  '@typescript-eslint/prefer-namespace-keyword': 'error',
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function migrate(tree: Tree): Promise<void>;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const devkit_1 = require("@nx/devkit");
4
+ async function migrate(tree) {
5
+ (0, devkit_1.visitNotIgnoredFiles)(tree, '.', (path) => {
6
+ if (!path.endsWith('.eslintrc.json')) {
7
+ return;
8
+ }
9
+ // Cheap check to see if the file contains references to the nx TS or JS eslint configs
10
+ const fileContents = tree.read(path, 'utf-8');
11
+ if (!fileContents.includes('@nx/typescript') &&
12
+ !fileContents.includes('@nx/javascript')) {
13
+ return;
14
+ }
15
+ let wasUpdated = false;
16
+ (0, devkit_1.updateJson)(tree, path, (json) => {
17
+ // Update top level config
18
+ wasUpdated = addNoExtraSemiExplicitly(json);
19
+ // Update overrides
20
+ if (json.overrides) {
21
+ for (const override of json.overrides) {
22
+ const overrideUpdated = addNoExtraSemiExplicitly(override);
23
+ wasUpdated = wasUpdated || overrideUpdated;
24
+ }
25
+ }
26
+ return json;
27
+ });
28
+ if (wasUpdated) {
29
+ console.warn(`NOTE: The configuration for @typescript-eslint/no-extra-semi and no-extra-semi that you were previously inheriting from the Nx eslint-plugin has been explicitly added to your ${path} file.
30
+
31
+ This is because those rules have been migrated to the https://eslint.style/ project (for stylistic only rules) and will no longer work in v8 of typescript-eslint. Having them explicitly in your config will make it easier for you to handle the transition, either by starting to use the ESLint Stylistic plugin, or removing the rules from your config.`);
32
+ }
33
+ });
34
+ await (0, devkit_1.formatFiles)(tree);
35
+ }
36
+ exports.default = migrate;
37
+ /**
38
+ * @returns {boolean} whether the json was updated
39
+ */
40
+ function addNoExtraSemiExplicitly(json) {
41
+ let wasUpdated = false;
42
+ if (!json.extends?.includes('@nx/typescript') &&
43
+ !json.extends?.includes('plugin:@nx/typescript') &&
44
+ !json.extends?.includes('@nx/javascript') &&
45
+ !json.extends?.includes('plugin:@nx/javascript')) {
46
+ return wasUpdated;
47
+ }
48
+ if (!json.rules?.['@typescript-eslint/no-extra-semi']) {
49
+ json.rules ??= {};
50
+ json.rules['@typescript-eslint/no-extra-semi'] = 'error';
51
+ wasUpdated = true;
52
+ }
53
+ if (!json.rules?.['no-extra-semi']) {
54
+ json.rules ??= {};
55
+ json.rules['no-extra-semi'] = 'off';
56
+ wasUpdated = true;
57
+ }
58
+ return wasUpdated;
59
+ }
@@ -28,6 +28,7 @@ exports.workspaceRules = (() => {
28
28
  return namespacedRules;
29
29
  }
30
30
  catch (err) {
31
+ console.error(err);
31
32
  return {};
32
33
  }
33
34
  finally {
@@ -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.parserServices.isJSON) {
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 {};
@@ -1,5 +1,5 @@
1
- import { DepConstraint } from '../utils/runtime-lint-utils';
2
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
+ import { DepConstraint } from '../utils/runtime-lint-utils';
3
3
  type Options = [
4
4
  {
5
5
  allow: string[];
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RULE_NAME = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const fileutils_1 = require("nx/src/utils/fileutils");
6
- const graph_utils_1 = require("../utils/graph-utils");
7
- const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
8
5
  const utils_1 = require("@typescript-eslint/utils");
6
+ const internal_1 = require("@nx/js/src/internal");
7
+ const fileutils_1 = require("nx/src/utils/fileutils");
9
8
  const path_1 = require("path");
10
9
  const ast_utils_1 = require("../utils/ast-utils");
10
+ const graph_utils_1 = require("../utils/graph-utils");
11
11
  const project_graph_utils_1 = require("../utils/project-graph-utils");
12
- const utils_2 = require("@typescript-eslint/utils");
12
+ const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
13
13
  exports.RULE_NAME = 'enforce-module-boundaries';
14
- exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl/nx/blob/${devkit_1.NX_VERSION}/docs/generated/packages/eslint-plugin/documents/enforce-module-boundaries.md`)({
14
+ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl/nx/blob/${devkit_1.NX_VERSION}/docs/generated/packages/eslint-plugin/documents/enforce-module-boundaries.md`)({
15
15
  name: exports.RULE_NAME,
16
16
  meta: {
17
17
  type: 'suggestion',
@@ -107,7 +107,7 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
107
107
  projectWithoutTagsCannotHaveDependencies: `A project without tags matching at least one constraint cannot depend on any libraries`,
108
108
  bannedExternalImportsViolation: `A project tagged with "{{sourceTag}}" is not allowed to import "{{imp}}"`,
109
109
  nestedBannedExternalImportsViolation: `A project tagged with "{{sourceTag}}" is not allowed to import "{{imp}}". Nested import found at {{childProjectName}}`,
110
- noTransitiveDependencies: `Transitive dependencies are not allowed. Only packages defined in the "package.json" can be imported`,
110
+ noTransitiveDependencies: `Only packages defined in the "package.json" can be imported. Transitive or unresolvable dependencies are not allowed.`,
111
111
  onlyTagsConstraintViolation: `A project tagged with "{{sourceTag}}" can only depend on libs tagged with {{tags}}`,
112
112
  emptyOnlyTagsConstraintViolation: 'A project tagged with "{{sourceTag}}" cannot depend on any libs with tags',
113
113
  notTagsConstraintViolation: `A project tagged with "{{sourceTag}}" can not depend on libs tagged with {{tags}}\n\nViolation detected in:\n{{projects}}`,
@@ -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 {};
@@ -186,7 +186,7 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
186
186
  const importsToRemap = [];
187
187
  for (const entryPointPath of indexTsPaths) {
188
188
  for (const importMember of imports) {
189
- const importPath = (0, ast_utils_1.getRelativeImportPath)(importMember, (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, entryPointPath.path), sourceProject.data.sourceRoot);
189
+ const importPath = (0, ast_utils_1.getRelativeImportPath)(importMember, (0, path_1.join)(devkit_1.workspaceRoot, entryPointPath.path), sourceProject.data.sourceRoot);
190
190
  // we cannot remap, so leave it as is
191
191
  if (importPath) {
192
192
  importsToRemap.push({
@@ -217,6 +217,20 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
217
217
  messageId: 'noRelativeOrAbsoluteExternals',
218
218
  });
219
219
  }
220
+ else if (banTransitiveDependencies && !(0, internal_1.isBuiltinModuleImport)(imp)) {
221
+ /**
222
+ * At this point, the target project could not be found in the project graph, and it is not a relative or absolute import.
223
+ * Therefore it could be an external/npm package dependency (but not a node built in module) which has not yet been installed
224
+ * in the workspace.
225
+ *
226
+ * If the banTransitiveDependencies option is enabled, we should flag this case as an error because the user is trying to
227
+ * depend on something which is not explicitly defined/resolvable on disk for their project.
228
+ */
229
+ context.report({
230
+ node,
231
+ messageId: 'noTransitiveDependencies',
232
+ });
233
+ }
220
234
  // If target is not found (including node internals) we bail early
221
235
  return;
222
236
  }
@@ -248,7 +262,7 @@ exports.default = utils_2.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
248
262
  const importsToRemap = [];
249
263
  for (const entryPointPath of indexTsPaths) {
250
264
  for (const importMember of imports) {
251
- const importPath = (0, ast_utils_1.getRelativeImportPath)(importMember, (0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, entryPointPath), sourceProject.data.sourceRoot);
265
+ const importPath = (0, ast_utils_1.getRelativeImportPath)(importMember, (0, path_1.join)(devkit_1.workspaceRoot, entryPointPath), sourceProject.data.sourceRoot);
252
266
  if (importPath) {
253
267
  // resolve the import path
254
268
  const relativePath = (0, path_1.relative)((0, path_1.dirname)(fileName), (0, path_1.dirname)(importPath));
@@ -1,5 +1,5 @@
1
- import type { AST } from 'jsonc-eslint-parser';
2
1
  import type { TSESLint } from '@typescript-eslint/utils';
2
+ import type { AST } from 'jsonc-eslint-parser';
3
3
  type Options = [
4
4
  {
5
5
  generatorsJson?: string;
@@ -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 runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
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 path_1 = require("path");
12
- const project_graph_utils_1 = require("../utils/project-graph-utils");
13
11
  const semver_1 = require("semver");
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.parserServices.isJSON) {
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) {
@@ -90,7 +90,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => ``)({
90
90
  return {};
91
91
  }
92
92
  if (!global.tsProjectRegistered) {
93
- (0, internal_1.registerTsProject)((0, path_1.join)(devkit_1.workspaceRoot, 'tsconfig.base.json'));
93
+ (0, internal_1.registerTsProject)((0, js_1.getRootTsConfigPath)());
94
94
  global.tsProjectRegistered = true;
95
95
  }
96
96
  return {
@@ -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
  }
@@ -9,7 +9,7 @@ const path_1 = require("path");
9
9
  const ts = require("typescript");
10
10
  function tryReadBaseJson() {
11
11
  try {
12
- return (0, devkit_1.readJsonFile)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, 'tsconfig.base.json'));
12
+ return (0, devkit_1.readJsonFile)((0, path_1.join)(devkit_1.workspaceRoot, 'tsconfig.base.json'));
13
13
  }
14
14
  catch (e) {
15
15
  devkit_1.logger.warn(`Error reading "tsconfig.base.json": \n${JSON.stringify(e)}`);
@@ -92,7 +92,7 @@ function getRelativeImportPath(exportedMember, filePath, basePath) {
92
92
  else if (status.isDirectory()) {
93
93
  const file = (0, fs_1.readdirSync)(filePath).find((file) => /^index\.[jt]sx?$/.exec(file));
94
94
  if (file) {
95
- filePath = (0, devkit_1.joinPathFragments)(filePath, file);
95
+ filePath = (0, path_1.join)(filePath, file);
96
96
  }
97
97
  else {
98
98
  return;
@@ -187,25 +187,25 @@ function getRelativeImportPath(exportedMember, filePath, basePath) {
187
187
  const modulePath = exportDeclaration.moduleSpecifier.text;
188
188
  let moduleFilePath;
189
189
  if (modulePath.endsWith('.js') || modulePath.endsWith('.jsx')) {
190
- moduleFilePath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(filePath), modulePath);
190
+ moduleFilePath = (0, path_1.join)((0, path_1.dirname)(filePath), modulePath);
191
191
  if (!(0, fs_1.existsSync)(moduleFilePath)) {
192
192
  const tsifiedModulePath = modulePath.replace(/\.js(x?)$/, '.ts$1');
193
- moduleFilePath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(filePath), `${tsifiedModulePath}`);
193
+ moduleFilePath = (0, path_1.join)((0, path_1.dirname)(filePath), `${tsifiedModulePath}`);
194
194
  }
195
195
  }
196
196
  else if (modulePath.endsWith('.ts') || modulePath.endsWith('.tsx')) {
197
- moduleFilePath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(filePath), modulePath);
197
+ moduleFilePath = (0, path_1.join)((0, path_1.dirname)(filePath), modulePath);
198
198
  }
199
199
  else {
200
- moduleFilePath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(filePath), `${modulePath}.ts`);
200
+ moduleFilePath = (0, path_1.join)((0, path_1.dirname)(filePath), `${modulePath}.ts`);
201
201
  if (!(0, fs_1.existsSync)(moduleFilePath)) {
202
202
  // might be a tsx file
203
- moduleFilePath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(filePath), `${modulePath}.tsx`);
203
+ moduleFilePath = (0, path_1.join)((0, path_1.dirname)(filePath), `${modulePath}.tsx`);
204
204
  }
205
205
  }
206
206
  if (!(0, fs_1.existsSync)(moduleFilePath)) {
207
207
  // might be an index.ts
208
- moduleFilePath = (0, devkit_1.joinPathFragments)((0, path_1.dirname)(filePath), `${modulePath}/index.ts`);
208
+ moduleFilePath = (0, path_1.join)((0, path_1.dirname)(filePath), `${modulePath}/index.ts`);
209
209
  }
210
210
  if (hasMemberExport(exportedMember, moduleFilePath)) {
211
211
  const foundFilePath = getRelativeImportPath(exportedMember, moduleFilePath, basePath);
@@ -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
  }
@@ -110,7 +109,7 @@ function isAbsoluteImportIntoAnotherProject(imp, workspaceLayout = { libsDir: 'l
110
109
  }
111
110
  exports.isAbsoluteImportIntoAnotherProject = isAbsoluteImportIntoAnotherProject;
112
111
  function findProjectUsingImport(projectGraph, targetProjectLocator, filePath, imp) {
113
- const target = targetProjectLocator.findProjectWithImport(imp, filePath);
112
+ const target = targetProjectLocator.findProjectFromImport(imp, filePath);
114
113
  return projectGraph.nodes[target] || projectGraph.externalNodes?.[target];
115
114
  }
116
115
  exports.findProjectUsingImport = findProjectUsingImport;
@@ -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)((0, path_1.join)(devkit_1.workspaceRoot, projectRoot, 'package.json'));
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
- (0, path_1.join)(devkit_1.workspaceRoot, (0, js_1.getRootTsConfigFileName)()));
328
+ path.join(devkit_1.workspaceRoot, (0, js_1.getRootTsConfigFileName)()));
330
329
  if (!resolvedImportFile) {
331
330
  return false;
332
331
  }
@@ -341,7 +340,7 @@ function getAngularEntryPoint(file, projectRoot) {
341
340
  while (parent !== `${projectRoot}/`) {
342
341
  // we need to find closest existing ng-package.json
343
342
  // in order to determine if the file matches the secondary entry point
344
- const ngPackageContent = (0, fileutils_1.readFileIfExisting)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, parent, 'ng-package.json'));
343
+ const ngPackageContent = (0, fileutils_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, parent, 'ng-package.json'));
345
344
  if (ngPackageContent) {
346
345
  // https://github.com/ng-packagr/ng-packagr/blob/23c718d04eea85e015b4c261310b7bd0c39e5311/src/ng-package.schema.json#L54
347
346
  const entryFile = (0, devkit_1.parseJson)(ngPackageContent)?.lib?.entryFile;
@@ -355,11 +354,26 @@ function getAngularEntryPoint(file, projectRoot) {
355
354
  * Returns true if the given project contains MFE config with "exposes:" section
356
355
  */
357
356
  function appIsMFERemote(project) {
358
- const mfeConfig = (0, fileutils_1.readFileIfExisting)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, project.data.root, 'module-federation.config.js')) ||
359
- (0, fileutils_1.readFileIfExisting)((0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, project.data.root, 'module-federation.config.ts'));
357
+ const mfeConfig = (0, fileutils_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, project.data.root, 'module-federation.config.js')) ||
358
+ (0, fileutils_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, project.data.root, 'module-federation.config.ts'));
360
359
  if (mfeConfig) {
361
360
  return !!mfeConfig.match(/('|")?exposes('|")?:/);
362
361
  }
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;