eslint 8.43.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.
@@ -9,6 +9,7 @@
9
9
  // Requirements
10
10
  //------------------------------------------------------------------------------
11
11
 
12
+ const { KEYS: eslintVisitorKeys } = require("eslint-visitor-keys");
12
13
  const esutils = require("esutils");
13
14
  const espree = require("espree");
14
15
  const escapeRegExp = require("escape-string-regexp");
@@ -1005,6 +1006,15 @@ function isTopLevelExpressionStatement(node) {
1005
1006
 
1006
1007
  }
1007
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
+
1008
1018
  //------------------------------------------------------------------------------
1009
1019
  // Public Interface
1010
1020
  //------------------------------------------------------------------------------
@@ -1461,7 +1471,16 @@ module.exports = {
1461
1471
  return 19;
1462
1472
 
1463
1473
  default:
1464
- return 20;
1474
+ if (node.type in eslintVisitorKeys) {
1475
+ return 20;
1476
+ }
1477
+
1478
+ /*
1479
+ * if the node is not a standard node that we know about, then assume it has the lowest precedence
1480
+ * this will mean that rules will wrap unknown nodes in parentheses where applicable instead of
1481
+ * unwrapping them and potentially changing the meaning of the code or introducing a syntax error.
1482
+ */
1483
+ return -1;
1465
1484
  }
1466
1485
  },
1467
1486
 
@@ -2123,6 +2142,15 @@ module.exports = {
2123
2142
  return OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN.test(rawString);
2124
2143
  },
2125
2144
 
2145
+ /**
2146
+ * Determines whether the given node is a template literal without expressions.
2147
+ * @param {ASTNode} node Node to check.
2148
+ * @returns {boolean} True if the node is a template literal without expressions.
2149
+ */
2150
+ isStaticTemplateLiteral(node) {
2151
+ return node.type === "TemplateLiteral" && node.expressions.length === 0;
2152
+ },
2153
+
2126
2154
  isReferenceToGlobalVariable,
2127
2155
  isLogicalExpression,
2128
2156
  isCoalesceExpression,
@@ -2139,5 +2167,6 @@ module.exports = {
2139
2167
  getSwitchCaseColonToken,
2140
2168
  getModuleExportName,
2141
2169
  isConstant,
2142
- isTopLevelExpressionStatement
2170
+ isTopLevelExpressionStatement,
2171
+ isDirective
2143
2172
  };
@@ -4,6 +4,12 @@
4
4
  */
5
5
  "use strict";
6
6
 
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const astUtils = require("./utils/ast-utils");
12
+
7
13
  //------------------------------------------------------------------------------
8
14
  // Rule Definition
9
15
  //------------------------------------------------------------------------------
@@ -88,7 +94,7 @@ module.exports = {
88
94
  if (parent.type === "BinaryExpression" && OPERATORS.has(parent.operator)) {
89
95
  const sibling = parent.left === node ? parent.right : parent.left;
90
96
 
91
- if (sibling.type === "Literal" || sibling.type === "TemplateLiteral" && !sibling.expressions.length) {
97
+ if (sibling.type === "Literal" || astUtils.isStaticTemplateLiteral(sibling)) {
92
98
  const value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked;
93
99
 
94
100
  if (!VALID_TYPES.has(value)) {
package/lib/rules/yoda.js CHANGED
@@ -58,22 +58,13 @@ function isNegativeNumericLiteral(node) {
58
58
  );
59
59
  }
60
60
 
61
- /**
62
- * Determines whether a node is a Template Literal which can be determined statically.
63
- * @param {ASTNode} node Node to test
64
- * @returns {boolean} True if the node is a Template Literal without expression.
65
- */
66
- function isStaticTemplateLiteral(node) {
67
- return node.type === "TemplateLiteral" && node.expressions.length === 0;
68
- }
69
-
70
61
  /**
71
62
  * Determines whether a non-Literal node should be treated as a single Literal node.
72
63
  * @param {ASTNode} node Node to test
73
64
  * @returns {boolean} True if the node should be treated as a single Literal node.
74
65
  */
75
66
  function looksLikeLiteral(node) {
76
- return isNegativeNumericLiteral(node) || isStaticTemplateLiteral(node);
67
+ return isNegativeNumericLiteral(node) || astUtils.isStaticTemplateLiteral(node);
77
68
  }
78
69
 
79
70
  /**
@@ -100,7 +91,7 @@ function getNormalizedLiteral(node) {
100
91
  };
101
92
  }
102
93
 
103
- if (isStaticTemplateLiteral(node)) {
94
+ if (astUtils.isStaticTemplateLiteral(node)) {
104
95
  return {
105
96
  type: "Literal",
106
97
  value: node.quasis[0].value.cooked,
@@ -21,7 +21,7 @@ module.exports = {};
21
21
  /**
22
22
  * @typedef {Object} ParserOptions
23
23
  * @property {EcmaFeatures} [ecmaFeatures] The optional features.
24
- * @property {3|5|6|7|8|9|10|11|12|13|14|2015|2016|2017|2018|2019|2020|2021|2022|2023} [ecmaVersion] The ECMAScript version (or revision number).
24
+ * @property {3|5|6|7|8|9|10|11|12|13|14|15|2015|2016|2017|2018|2019|2020|2021|2022|2023|2024} [ecmaVersion] The ECMAScript version (or revision number).
25
25
  * @property {"script"|"module"} [sourceType] The source code type.
26
26
  * @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3.
27
27
  */
@@ -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.43.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": {
@@ -62,8 +62,8 @@
62
62
  "dependencies": {
63
63
  "@eslint-community/eslint-utils": "^4.2.0",
64
64
  "@eslint-community/regexpp": "^4.4.0",
65
- "@eslint/eslintrc": "^2.0.3",
66
- "@eslint/js": "8.43.0",
65
+ "@eslint/eslintrc": "^2.1.0",
66
+ "@eslint/js": "8.44.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",
@@ -75,7 +75,7 @@
75
75
  "escape-string-regexp": "^4.0.0",
76
76
  "eslint-scope": "^7.2.0",
77
77
  "eslint-visitor-keys": "^3.4.1",
78
- "espree": "^9.5.2",
78
+ "espree": "^9.6.0",
79
79
  "esquery": "^1.4.2",
80
80
  "esutils": "^2.0.2",
81
81
  "fast-deep-equal": "^3.1.3",
@@ -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",
@@ -95,9 +94,8 @@
95
94
  "lodash.merge": "^4.6.2",
96
95
  "minimatch": "^3.1.2",
97
96
  "natural-compare": "^1.4.0",
98
- "optionator": "^0.9.1",
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": {
@@ -115,8 +113,8 @@
115
113
  "eslint-plugin-eslint-comments": "^3.2.0",
116
114
  "eslint-plugin-eslint-plugin": "^5.1.0",
117
115
  "eslint-plugin-internal-rules": "file:tools/internal-rules",
118
- "eslint-plugin-jsdoc": "^38.1.6",
119
- "eslint-plugin-n": "^15.2.4",
116
+ "eslint-plugin-jsdoc": "^46.2.5",
117
+ "eslint-plugin-n": "^16.0.0",
120
118
  "eslint-plugin-unicorn": "^42.0.0",
121
119
  "eslint-release": "^3.2.0",
122
120
  "eslump": "^3.0.0",
@@ -153,10 +151,9 @@
153
151
  "puppeteer": "^13.7.0",
154
152
  "recast": "^0.20.4",
155
153
  "regenerator-runtime": "^0.13.2",
156
- "semver": "^7.3.5",
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"