@nx/eslint 20.0.0-canary.20240925-6182d20 → 20.0.0-canary.20240928-f221a41

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": "20.0.0-canary.20240925-6182d20",
3
+ "version": "20.0.0-canary.20240928-f221a41",
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,11 @@
35
35
  "eslint": "^8.0.0 || ^9.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "20.0.0-canary.20240925-6182d20",
39
- "@nx/js": "20.0.0-canary.20240925-6182d20",
38
+ "@nx/devkit": "20.0.0-canary.20240928-f221a41",
39
+ "@nx/js": "20.0.0-canary.20240928-f221a41",
40
40
  "semver": "^7.5.3",
41
41
  "tslib": "^2.3.0",
42
- "typescript": "~5.4.2",
43
- "@nx/linter": "20.0.0-canary.20240925-6182d20"
42
+ "typescript": "~5.4.2"
44
43
  },
45
44
  "peerDependenciesMeta": {
46
45
  "@zkochan/js-yaml": {
@@ -85,6 +85,7 @@ const getGlobalFlatEslintConfiguration = (rootProject) => {
85
85
  content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatPredefinedConfig)('flat/base'), { insertAtTheEnd: false });
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
+ content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)({ ignores: ['**/dist'] }));
88
89
  if (!rootProject) {
89
90
  content = (0, ast_utils_1.addBlockToFlatConfigExport)(content, (0, ast_utils_1.generateFlatOverride)({
90
91
  files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
@@ -49,6 +49,7 @@ async function lintProjectGeneratorInternal(tree, options) {
49
49
  if (lintFilePatterns &&
50
50
  lintFilePatterns.length &&
51
51
  lintFilePatterns.some((p) => !['./src', '{projectRoot}', projectConfig.root].includes(p))) {
52
+ projectConfig.targets ??= {};
52
53
  projectConfig.targets['lint'] = {
53
54
  command: `eslint ${lintFilePatterns
54
55
  .join(' ')
@@ -57,6 +58,7 @@ async function lintProjectGeneratorInternal(tree, options) {
57
58
  }
58
59
  }
59
60
  else {
61
+ projectConfig.targets ??= {};
60
62
  projectConfig.targets['lint'] = {
61
63
  executor: '@nx/eslint:lint',
62
64
  };
@@ -62,9 +62,11 @@ export declare function overrideNeedsCompat(override: Partial<Linter.ConfigOverr
62
62
  * Generates an AST object or spread element representing a modern flat config entry,
63
63
  * based on a given legacy eslintrc JSON override object
64
64
  */
65
- export declare function generateFlatOverride(_override: Partial<Linter.ConfigOverride<Linter.RulesRecord>>): ts.ObjectLiteralExpression | ts.SpreadElement;
65
+ export declare function generateFlatOverride(_override: Partial<Linter.ConfigOverride<Linter.RulesRecord>> & {
66
+ ignores?: Linter.FlatConfig['ignores'];
67
+ }): ts.ObjectLiteralExpression | ts.SpreadElement;
66
68
  export declare function generateFlatPredefinedConfig(predefinedConfigName: string, moduleName?: string, spread?: boolean): ts.ObjectLiteralExpression | ts.SpreadElement | ts.ElementAccessExpression;
67
- export declare function mapFilePaths(_override: Partial<Linter.ConfigOverride<Linter.RulesRecord>>): Partial<Linter.ConfigOverride<Linter.RulesRecord>>;
69
+ export declare function mapFilePaths<T extends Partial<Linter.ConfigOverride<Linter.RulesRecord>>>(_override: T): T;
68
70
  /**
69
71
  * Generates an AST from a JSON-type input
70
72
  */
@@ -148,12 +148,16 @@ function replaceOverride(content, root, lookup, update) {
148
148
  changes.push({
149
149
  type: devkit_1.ChangeType.Insert,
150
150
  index: start,
151
- text: JSON.stringify(updatedData, null, 2)
152
- // restore any parser require calls that were stripped during JSON parsing
153
- .replace(/"parser": "([^"]+)"/g, (_, parser) => {
154
- return `"parser": require('${parser}')`;
155
- })
156
- .slice(2, -2), // remove curly braces and start/end line breaks since we are injecting just properties
151
+ // NOTE: Indentation added to format without formatting tools like Prettier.
152
+ text: ' ' +
153
+ JSON.stringify(updatedData, null, 2)
154
+ // restore any parser require calls that were stripped during JSON parsing
155
+ .replace(/"parser": "([^"]+)"/g, (_, parser) => {
156
+ return `"parser": require('${parser}')`;
157
+ })
158
+ .slice(2, -2) // remove curly braces and start/end line breaks since we are injecting just properties
159
+ // Append indentation so file is formatted without Prettier
160
+ .replaceAll(/\n/g, '\n '),
157
161
  });
158
162
  }
159
163
  }
@@ -282,7 +286,10 @@ function addBlockToFlatConfigExport(content, config, options = {
282
286
  // base config was not generated by Nx.
283
287
  if (!exportsArray)
284
288
  return content;
285
- const insert = printer.printNode(ts.EmitHint.Expression, config, source);
289
+ const insert = ' ' +
290
+ printer
291
+ .printNode(ts.EmitHint.Expression, config, source)
292
+ .replaceAll(/\n/g, '\n ');
286
293
  if (options.insertAtTheEnd) {
287
294
  const index = exportsArray.length > 0
288
295
  ? exportsArray.at(exportsArray.length - 1).end
@@ -301,7 +308,7 @@ function addBlockToFlatConfigExport(content, config, options = {
301
308
  {
302
309
  type: devkit_1.ChangeType.Insert,
303
310
  index,
304
- text: `\n${insert},`,
311
+ text: `\n${insert},\n`,
305
312
  },
306
313
  ]);
307
314
  }
@@ -608,6 +615,9 @@ function generateFlatOverride(_override) {
608
615
  const flatConfigOverride = {
609
616
  files,
610
617
  };
618
+ if (override.ignores) {
619
+ flatConfigOverride.ignores = override.ignores;
620
+ }
611
621
  if (override.rules) {
612
622
  flatConfigOverride.rules = override.rules;
613
623
  }