eslint 8.44.0 → 8.45.0

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/README.md CHANGED
@@ -284,7 +284,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
284
284
  <p><a href="#"><img src="https://images.opencollective.com/2021-frameworks-fund/logo.png" alt="Chrome Frameworks Fund" height="undefined"></a> <a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
285
285
  <p><a href="https://engineering.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a></p><h3>Silver Sponsors</h3>
286
286
  <p><a href="https://sentry.io"><img src="https://avatars.githubusercontent.com/u/1396951?v=4" alt="Sentry" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a></p><h3>Bronze Sponsors</h3>
287
- <p><a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://transloadit.com/"><img src="https://avatars.githubusercontent.com/u/125754?v=4" alt="Transloadit" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465?v=4" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://quickbookstoolhub.com"><img src="https://avatars.githubusercontent.com/u/95090305?u=e5bc398ef775c9ed19f955c675cdc1fb6abf01df&v=4" alt="QuickBooks Tool hub" height="32"></a></p>
287
+ <p><a href="https://iboysoft.com/"><img src="https://images.opencollective.com/iboysoft-software/7f9d60e/avatar.png" alt="iBoysoft" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://transloadit.com/"><img src="https://avatars.githubusercontent.com/u/125754?v=4" alt="Transloadit" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465?v=4" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://quickbookstoolhub.com"><img src="https://avatars.githubusercontent.com/u/95090305?u=e5bc398ef775c9ed19f955c675cdc1fb6abf01df&v=4" alt="QuickBooks Tool hub" height="32"></a></p>
288
288
  <!--sponsorsend-->
289
289
 
290
290
  ## Technology Sponsors
@@ -576,7 +576,6 @@ class FlatESLint {
576
576
  cacheFilePath,
577
577
  lintResultCache,
578
578
  defaultConfigs,
579
- defaultIgnores: () => false,
580
579
  configs: null
581
580
  });
582
581
 
@@ -100,6 +100,22 @@ function normalizeReportLoc(descriptor) {
100
100
  return descriptor.node.loc;
101
101
  }
102
102
 
103
+ /**
104
+ * Clones the given fix object.
105
+ * @param {Fix|null} fix The fix to clone.
106
+ * @returns {Fix|null} Deep cloned fix object or `null` if `null` or `undefined` was passed in.
107
+ */
108
+ function cloneFix(fix) {
109
+ if (!fix) {
110
+ return null;
111
+ }
112
+
113
+ return {
114
+ range: [fix.range[0], fix.range[1]],
115
+ text: fix.text
116
+ };
117
+ }
118
+
103
119
  /**
104
120
  * Check that a fix has a valid range.
105
121
  * @param {Fix|null} fix The fix to validate.
@@ -137,7 +153,7 @@ function mergeFixes(fixes, sourceCode) {
137
153
  return null;
138
154
  }
139
155
  if (fixes.length === 1) {
140
- return fixes[0];
156
+ return cloneFix(fixes[0]);
141
157
  }
142
158
 
143
159
  fixes.sort(compareFixesByRange);
@@ -183,7 +199,7 @@ function normalizeFixes(descriptor, sourceCode) {
183
199
  }
184
200
 
185
201
  assertValidFix(fix);
186
- return fix;
202
+ return cloneFix(fix);
187
203
  }
188
204
 
189
205
  /**
@@ -1250,7 +1250,7 @@ module.exports = {
1250
1250
 
1251
1251
  IfStatement(node) {
1252
1252
  addBlocklessNodeIndent(node.consequent);
1253
- if (node.alternate && node.alternate.type !== "IfStatement") {
1253
+ if (node.alternate) {
1254
1254
  addBlocklessNodeIndent(node.alternate);
1255
1255
  }
1256
1256
  },
@@ -94,6 +94,7 @@ module.exports = {
94
94
  messages: {
95
95
  unnecessaryEscape: "Unnecessary escape character: \\{{character}}.",
96
96
  removeEscape: "Remove the `\\`. This maintains the current functionality.",
97
+ removeEscapeDoNotKeepSemantics: "Remove the `\\` if it was inserted by mistake.",
97
98
  escapeBackslash: "Replace the `\\` with `\\\\` to include the actual backslash character."
98
99
  },
99
100
 
@@ -125,7 +126,10 @@ module.exports = {
125
126
  data: { character },
126
127
  suggest: [
127
128
  {
128
- messageId: "removeEscape",
129
+
130
+ // Removing unnecessary `\` characters in a directive is not guaranteed to maintain functionality.
131
+ messageId: astUtils.isDirective(node.parent)
132
+ ? "removeEscapeDoNotKeepSemantics" : "removeEscape",
129
133
  fix(fixer) {
130
134
  return fixer.removeRange(range);
131
135
  }
@@ -130,42 +130,6 @@ function isBlockLikeStatement(sourceCode, node) {
130
130
  );
131
131
  }
132
132
 
133
- /**
134
- * Check whether the given node is a directive or not.
135
- * @param {ASTNode} node The node to check.
136
- * @param {SourceCode} sourceCode The source code object to get tokens.
137
- * @returns {boolean} `true` if the node is a directive.
138
- */
139
- function isDirective(node, sourceCode) {
140
- return (
141
- astUtils.isTopLevelExpressionStatement(node) &&
142
- node.expression.type === "Literal" &&
143
- typeof node.expression.value === "string" &&
144
- !astUtils.isParenthesised(sourceCode, node.expression)
145
- );
146
- }
147
-
148
- /**
149
- * Check whether the given node is a part of directive prologue or not.
150
- * @param {ASTNode} node The node to check.
151
- * @param {SourceCode} sourceCode The source code object to get tokens.
152
- * @returns {boolean} `true` if the node is a part of directive prologue.
153
- */
154
- function isDirectivePrologue(node, sourceCode) {
155
- if (isDirective(node, sourceCode)) {
156
- for (const sibling of node.parent.body) {
157
- if (sibling === node) {
158
- break;
159
- }
160
- if (!isDirective(sibling, sourceCode)) {
161
- return false;
162
- }
163
- }
164
- return true;
165
- }
166
- return false;
167
- }
168
-
169
133
  /**
170
134
  * Gets the actual last token.
171
135
  *
@@ -359,12 +323,10 @@ const StatementTypes = {
359
323
  CJS_IMPORT.test(sourceCode.getText(node.declarations[0].init))
360
324
  },
361
325
  directive: {
362
- test: isDirectivePrologue
326
+ test: astUtils.isDirective
363
327
  },
364
328
  expression: {
365
- test: (node, sourceCode) =>
366
- node.type === "ExpressionStatement" &&
367
- !isDirectivePrologue(node, sourceCode)
329
+ test: node => node.type === "ExpressionStatement" && !astUtils.isDirective(node)
368
330
  },
369
331
  iife: {
370
332
  test: isIIFEStatement
@@ -375,10 +337,10 @@ const StatementTypes = {
375
337
  isBlockLikeStatement(sourceCode, node)
376
338
  },
377
339
  "multiline-expression": {
378
- test: (node, sourceCode) =>
340
+ test: node =>
379
341
  node.loc.start.line !== node.loc.end.line &&
380
342
  node.type === "ExpressionStatement" &&
381
- !isDirectivePrologue(node, sourceCode)
343
+ !astUtils.isDirective(node)
382
344
  },
383
345
 
384
346
  "multiline-const": newMultilineKeywordTester("const"),
@@ -1006,6 +1006,15 @@ function isTopLevelExpressionStatement(node) {
1006
1006
 
1007
1007
  }
1008
1008
 
1009
+ /**
1010
+ * Check whether the given node is a part of a directive prologue or not.
1011
+ * @param {ASTNode} node The node to check.
1012
+ * @returns {boolean} `true` if the node is a part of directive prologue.
1013
+ */
1014
+ function isDirective(node) {
1015
+ return node.type === "ExpressionStatement" && typeof node.directive === "string";
1016
+ }
1017
+
1009
1018
  //------------------------------------------------------------------------------
1010
1019
  // Public Interface
1011
1020
  //------------------------------------------------------------------------------
@@ -2158,5 +2167,6 @@ module.exports = {
2158
2167
  getSwitchCaseColonToken,
2159
2168
  getModuleExportName,
2160
2169
  isConstant,
2161
- isTopLevelExpressionStatement
2170
+ isTopLevelExpressionStatement,
2171
+ isDirective
2162
2172
  };
@@ -14,6 +14,7 @@
14
14
  const { FileEnumerator } = require("./cli-engine/file-enumerator");
15
15
  const { FlatESLint, shouldUseFlatConfig } = require("./eslint/flat-eslint");
16
16
  const FlatRuleTester = require("./rule-tester/flat-rule-tester");
17
+ const { ESLint } = require("./eslint/eslint");
17
18
 
18
19
  //-----------------------------------------------------------------------------
19
20
  // Exports
@@ -24,5 +25,6 @@ module.exports = {
24
25
  FlatESLint,
25
26
  shouldUseFlatConfig,
26
27
  FlatRuleTester,
27
- FileEnumerator
28
+ FileEnumerator,
29
+ LegacyESLint: ESLint
28
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "8.44.0",
3
+ "version": "8.45.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -85,7 +85,6 @@
85
85
  "globals": "^13.19.0",
86
86
  "graphemer": "^1.4.0",
87
87
  "ignore": "^5.2.0",
88
- "import-fresh": "^3.0.0",
89
88
  "imurmurhash": "^0.1.4",
90
89
  "is-glob": "^4.0.0",
91
90
  "is-path-inside": "^3.0.3",
@@ -97,7 +96,6 @@
97
96
  "natural-compare": "^1.4.0",
98
97
  "optionator": "^0.9.3",
99
98
  "strip-ansi": "^6.0.1",
100
- "strip-json-comments": "^3.1.0",
101
99
  "text-table": "^0.2.0"
102
100
  },
103
101
  "devDependencies": {
@@ -156,7 +154,6 @@
156
154
  "semver": "^7.5.3",
157
155
  "shelljs": "^0.8.2",
158
156
  "sinon": "^11.0.0",
159
- "temp": "^0.9.0",
160
157
  "webpack": "^5.23.0",
161
158
  "webpack-cli": "^4.5.0",
162
159
  "yorkie": "^2.0.0"