@nx/eslint 0.0.0-pr-27404-ad15a9c → 0.0.0-pr-27404-9b7456c

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",
3
- "version": "0.0.0-pr-27404-ad15a9c",
3
+ "version": "0.0.0-pr-27404-9b7456c",
4
4
  "private": false,
5
5
  "description": "The ESLint plugin for Nx contains executors, generators and utilities used for linting JavaScript/TypeScript projects within an Nx workspace.",
6
6
  "repository": {
@@ -35,12 +35,12 @@
35
35
  "eslint": "^8.0.0 || ^9.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "0.0.0-pr-27404-ad15a9c",
39
- "@nx/js": "0.0.0-pr-27404-ad15a9c",
38
+ "@nx/devkit": "0.0.0-pr-27404-9b7456c",
39
+ "@nx/js": "0.0.0-pr-27404-9b7456c",
40
40
  "semver": "^7.5.3",
41
41
  "tslib": "^2.3.0",
42
42
  "typescript": "~5.4.2",
43
- "@nx/linter": "0.0.0-pr-27404-ad15a9c"
43
+ "@nx/linter": "0.0.0-pr-27404-9b7456c"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "@zkochan/js-yaml": {
@@ -86,7 +86,25 @@ const getGlobalFlatEslintConfiguration = (rootProject) => {
86
86
  content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatPredefinedConfig)('flat/typescript'));
87
87
  content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatPredefinedConfig)('flat/javascript'));
88
88
  if (!rootProject) {
89
- content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)(moduleBoundariesOverride));
89
+ content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)({
90
+ files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
91
+ rules: {
92
+ '@nx/enforce-module-boundaries': [
93
+ 'error',
94
+ {
95
+ enforceBuildableLibDependency: true,
96
+ allow: [
97
+ // This allows a root project to be present without causing lint errors
98
+ // since all projects will depend on this base file.
99
+ '^.*/eslint.base.config.[cm]?js$',
100
+ ],
101
+ depConstraints: [
102
+ { sourceTag: '*', onlyDependOnLibsWithTags: ['*'] },
103
+ ],
104
+ },
105
+ ],
106
+ },
107
+ }));
90
108
  }
91
109
  content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)({
92
110
  files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
@@ -91,7 +91,7 @@ function migrateEslintFile(projectEslintPath, tree) {
91
91
  'plugin:@nrwl/typescript',
92
92
  'plugin:@nrwl/javascript',
93
93
  ]);
94
- config = (0, ast_utils_1.removePredefinedConfigs)(config, 'nx', '@nx/eslint-plugin', [
94
+ config = (0, ast_utils_1.removePredefinedConfigs)(config, '@nx/eslint-plugin', 'nx', [
95
95
  'flat/base',
96
96
  'flat/typescript',
97
97
  'flat/javascript',
@@ -164,7 +164,7 @@ function createEsLintConfiguration(tree, options, projectConfig, setParserOption
164
164
  'error',
165
165
  {
166
166
  // With flat configs, we don't want to include imports in the eslint js/cjs/mjs files to be checked
167
- ignoredFiles: ['**/*/*eslint*'],
167
+ ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
168
168
  },
169
169
  ],
170
170
  },
@@ -26,11 +26,7 @@ export declare function addBlockToFlatConfigExport(content: string, config: ts.E
26
26
  }): string;
27
27
  export declare function removePlugin(content: string, pluginName: string, pluginImport: string): string;
28
28
  export declare function removeCompatExtends(content: string, compatExtends: string[]): string;
29
- /**
30
- * Removes the pre-defined configs that match `configs` array from the config export.
31
- * Also, removes the module matching `moduleImport` from imports if it is unused.
32
- */
33
- export declare function removePredefinedConfigs(content: string, moduleVariable: string, moduleImport: string, configs: string[]): string;
29
+ export declare function removePredefinedConfigs(content: string, moduleImport: string, moduleVariable: string, configs: string[]): string;
34
30
  /**
35
31
  * Add plugins block to the top of the export blocks
36
32
  */
@@ -277,6 +277,11 @@ function addBlockToFlatConfigExport(content, config, options = {
277
277
  return node.expression.right.elements;
278
278
  }
279
279
  });
280
+ // The config is not in the format that we generate with, skip update.
281
+ // This could happen during `init-migration` when extracting config from the base, but
282
+ // base config was not generated by Nx.
283
+ if (!exportsArray)
284
+ return content;
280
285
  const insert = printer.printNode(ts.EmitHint.Expression, config, source);
281
286
  if (options.insertAtTheEnd) {
282
287
  const index = exportsArray.length > 0
@@ -414,7 +419,7 @@ function removePlugin(content, pluginName, pluginImport) {
414
419
  function removeCompatExtends(content, compatExtends) {
415
420
  const source = ts.createSourceFile('', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
416
421
  const changes = [];
417
- findAllBlocks(source).forEach((node) => {
422
+ findAllBlocks(source)?.forEach((node) => {
418
423
  if (ts.isSpreadElement(node) &&
419
424
  ts.isCallExpression(node.expression) &&
420
425
  ts.isArrowFunction(node.expression.arguments[0]) &&
@@ -446,15 +451,11 @@ function removeCompatExtends(content, compatExtends) {
446
451
  });
447
452
  return (0, devkit_1.applyChangesToString)(content, changes);
448
453
  }
449
- /**
450
- * Removes the pre-defined configs that match `configs` array from the config export.
451
- * Also, removes the module matching `moduleImport` from imports if it is unused.
452
- */
453
- function removePredefinedConfigs(content, moduleVariable, moduleImport, configs) {
454
+ function removePredefinedConfigs(content, moduleImport, moduleVariable, configs) {
454
455
  const source = ts.createSourceFile('', content, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
455
456
  const changes = [];
456
457
  let removeImport = true;
457
- findAllBlocks(source).forEach((node) => {
458
+ findAllBlocks(source)?.forEach((node) => {
458
459
  if (ts.isSpreadElement(node) &&
459
460
  ts.isElementAccessExpression(node.expression) &&
460
461
  ts.isPropertyAccessExpression(node.expression.expression) &&