eslint 8.46.0 → 8.47.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
@@ -249,6 +249,11 @@ Bryan Mishkin
249
249
  <img src="https://github.com/fasttime.png?s=75" width="75" height="75"><br />
250
250
  Francesco Trotta
251
251
  </a>
252
+ </td><td align="center" valign="top" width="11%">
253
+ <a href="https://github.com/ota-meshi">
254
+ <img src="https://github.com/ota-meshi.png?s=75" width="75" height="75"><br />
255
+ Yosuke Ota
256
+ </a>
252
257
  </td></tr></tbody></table>
253
258
 
254
259
  ### Website Team
@@ -284,7 +289,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
284
289
  <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
290
  <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
291
  <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://iboysoft.com/"><img src="https://images.opencollective.com/iboysoft-software/7f9d60e/avatar.png" alt="iBoysoft" height="32"></a> <a href="https://www.bairesdev.com/sponsoring-open-source-projects/"><img src="https://images.opencollective.com/bairesdev/48bb773/logo.png" alt="BairesDev" height="32"></a> <a href="https://github.com/about"><img src="https://avatars.githubusercontent.com/u/9919?v=4" alt="GitHub" 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://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>
292
+ <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://github.com/about"><img src="https://avatars.githubusercontent.com/u/9919?v=4" alt="GitHub" 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://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
293
  <!--sponsorsend-->
289
294
 
290
295
  ## Technology Sponsors
@@ -5,6 +5,12 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const { getVariableByName } = require("./utils/ast-utils");
13
+
8
14
  //------------------------------------------------------------------------------
9
15
  // Rule Definition
10
16
  //------------------------------------------------------------------------------
@@ -28,18 +34,24 @@ module.exports = {
28
34
  },
29
35
 
30
36
  create(context) {
37
+ const { sourceCode } = context;
31
38
 
32
39
  return {
33
40
 
34
41
  NewExpression(node) {
35
42
  const wrapperObjects = ["String", "Number", "Boolean"];
36
-
37
- if (wrapperObjects.includes(node.callee.name)) {
38
- context.report({
39
- node,
40
- messageId: "noConstructor",
41
- data: { fn: node.callee.name }
42
- });
43
+ const { name } = node.callee;
44
+
45
+ if (wrapperObjects.includes(name)) {
46
+ const variable = getVariableByName(sourceCode.getScope(node), name);
47
+
48
+ if (variable && variable.identifiers.length === 0) {
49
+ context.report({
50
+ node,
51
+ messageId: "noConstructor",
52
+ data: { fn: name }
53
+ });
54
+ }
43
55
  }
44
56
  }
45
57
  };
@@ -26,8 +26,8 @@ const {
26
26
 
27
27
  const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
28
28
  const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u;
29
+ const arrayMethodWithThisArgPattern = /^(?:every|filter|find(?:Last)?(?:Index)?|flatMap|forEach|map|some)$/u;
29
30
  const arrayOrTypedArrayPattern = /Array$/u;
30
- const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/u;
31
31
  const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u;
32
32
  const thisTagPattern = /^[\s*]*@this/mu;
33
33
 
@@ -467,12 +467,12 @@ function isArrayFromMethod(node) {
467
467
  }
468
468
 
469
469
  /**
470
- * Checks whether or not a node is a method which has `thisArg`.
470
+ * Checks whether or not a node is a method which expects a function as a first argument, and `thisArg` as a second argument.
471
471
  * @param {ASTNode} node A node to check.
472
- * @returns {boolean} Whether or not the node is a method which has `thisArg`.
472
+ * @returns {boolean} Whether or not the node is a method which expects a function as a first argument, and `thisArg` as a second argument.
473
473
  */
474
474
  function isMethodWhichHasThisArg(node) {
475
- return isSpecificMemberAccess(node, null, arrayMethodPattern);
475
+ return isSpecificMemberAccess(node, null, arrayMethodWithThisArgPattern);
476
476
  }
477
477
 
478
478
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "8.46.0",
3
+ "version": "8.47.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -62,8 +62,8 @@
62
62
  "dependencies": {
63
63
  "@eslint-community/eslint-utils": "^4.2.0",
64
64
  "@eslint-community/regexpp": "^4.6.1",
65
- "@eslint/eslintrc": "^2.1.1",
66
- "@eslint/js": "^8.46.0",
65
+ "@eslint/eslintrc": "^2.1.2",
66
+ "@eslint/js": "^8.47.0",
67
67
  "@humanwhocodes/config-array": "^0.11.10",
68
68
  "@humanwhocodes/module-importer": "^1.0.1",
69
69
  "@nodelib/fs.walk": "^1.2.8",
@@ -74,7 +74,7 @@
74
74
  "doctrine": "^3.0.0",
75
75
  "escape-string-regexp": "^4.0.0",
76
76
  "eslint-scope": "^7.2.2",
77
- "eslint-visitor-keys": "^3.4.2",
77
+ "eslint-visitor-keys": "^3.4.3",
78
78
  "espree": "^9.6.1",
79
79
  "esquery": "^1.4.2",
80
80
  "esutils": "^2.0.2",