@nx/eslint 17.3.0-canary.20231219-9d7a724 → 17.3.0-canary.20231221-2374d8e

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": "17.3.0-canary.20231219-9d7a724",
3
+ "version": "17.3.0-canary.20231221-2374d8e",
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": {
@@ -34,11 +34,11 @@
34
34
  "js-yaml": "4.1.0"
35
35
  },
36
36
  "dependencies": {
37
- "@nx/devkit": "17.3.0-canary.20231219-9d7a724",
38
- "@nx/js": "17.3.0-canary.20231219-9d7a724",
37
+ "@nx/devkit": "17.3.0-canary.20231221-2374d8e",
38
+ "@nx/js": "17.3.0-canary.20231221-2374d8e",
39
39
  "tslib": "^2.3.0",
40
40
  "typescript": "~5.2.2",
41
- "@nx/linter": "17.3.0-canary.20231219-9d7a724"
41
+ "@nx/linter": "17.3.0-canary.20231221-2374d8e"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "eslint": {
@@ -128,7 +128,7 @@ function addOverrideToLintConfig(tree, root, override, options = {
128
128
  }
129
129
  exports.addOverrideToLintConfig = addOverrideToLintConfig;
130
130
  function overrideNeedsCompat(override) {
131
- return (!override.env && !override.extends && !override.plugins && !override.parser);
131
+ return (override.env || override.extends || override.plugins || override.parser);
132
132
  }
133
133
  function updateOverrideInLintConfig(tree, root, lookup, update) {
134
134
  if ((0, flat_config_1.useFlatConfig)(tree)) {
@@ -142,7 +142,13 @@ function updateOverrideInLintConfig(tree, root, lookup, update) {
142
142
  (0, devkit_1.updateJson)(tree, fileName, (json) => {
143
143
  const index = json.overrides.findIndex(lookup);
144
144
  if (index !== -1) {
145
- json.overrides[index] = update(json.overrides[index]);
145
+ const newOverride = update(json.overrides[index]);
146
+ if (newOverride) {
147
+ json.overrides[index] = newOverride;
148
+ }
149
+ else {
150
+ json.overrides.splice(index, 1);
151
+ }
146
152
  }
147
153
  return json;
148
154
  });
@@ -194,7 +200,9 @@ function addExtendsToLintConfig(tree, root, plugin) {
194
200
  if ((0, flat_config_1.useFlatConfig)(tree)) {
195
201
  const fileName = (0, devkit_1.joinPathFragments)(root, 'eslint.config.js');
196
202
  const pluginExtends = (0, ast_utils_1.generatePluginExtendsElement)(plugins);
197
- tree.write(fileName, (0, ast_utils_1.addBlockToFlatConfigExport)(tree.read(fileName, 'utf8'), pluginExtends));
203
+ let content = tree.read(fileName, 'utf8');
204
+ content = (0, ast_utils_1.addCompatToFlatConfig)(content);
205
+ tree.write(fileName, (0, ast_utils_1.addBlockToFlatConfigExport)(content, pluginExtends));
198
206
  }
199
207
  else {
200
208
  const fileName = (0, devkit_1.joinPathFragments)(root, '.eslintrc.json');
@@ -8,7 +8,7 @@ export declare function hasOverride(content: string, lookup: (override: Linter.C
8
8
  /**
9
9
  * Finds an override matching the lookup function and applies the update function to it
10
10
  */
11
- export declare function replaceOverride(content: string, root: string, lookup: (override: Linter.ConfigOverride<Linter.RulesRecord>) => boolean, update: (override: Linter.ConfigOverride<Linter.RulesRecord>) => Linter.ConfigOverride<Linter.RulesRecord>): string;
11
+ export declare function replaceOverride(content: string, root: string, lookup: (override: Linter.ConfigOverride<Linter.RulesRecord>) => boolean, update?: (override: Linter.ConfigOverride<Linter.RulesRecord>) => Linter.ConfigOverride<Linter.RulesRecord>): string;
12
12
  /**
13
13
  * Adding require statement to the top of the file
14
14
  */
@@ -119,12 +119,14 @@ function replaceOverride(content, root, lookup, update) {
119
119
  length: end - start,
120
120
  });
121
121
  const updatedData = update(data);
122
- mapFilePaths(updatedData);
123
- changes.push({
124
- type: devkit_1.ChangeType.Insert,
125
- index: start,
126
- text: JSON.stringify(updatedData, null, 2).slice(2, -2), // remove curly braces and start/end line breaks since we are injecting just properties
127
- });
122
+ if (updatedData) {
123
+ mapFilePaths(updatedData);
124
+ changes.push({
125
+ type: devkit_1.ChangeType.Insert,
126
+ index: start,
127
+ text: JSON.stringify(updatedData, null, 2).slice(2, -2), // remove curly braces and start/end line breaks since we are injecting just properties
128
+ });
129
+ }
128
130
  }
129
131
  }
130
132
  });