eslint 8.14.0 → 8.17.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.
Files changed (60) hide show
  1. package/README.md +17 -12
  2. package/bin/eslint.js +1 -1
  3. package/lib/cli-engine/cli-engine.js +2 -4
  4. package/lib/cli-engine/lint-result-cache.js +1 -1
  5. package/lib/eslint/eslint.js +3 -3
  6. package/lib/linter/code-path-analysis/code-path-segment.js +1 -1
  7. package/lib/linter/code-path-analysis/code-path-state.js +1 -1
  8. package/lib/linter/code-path-analysis/code-path.js +1 -1
  9. package/lib/rules/accessor-pairs.js +4 -4
  10. package/lib/rules/callback-return.js +2 -2
  11. package/lib/rules/capitalized-comments.js +1 -1
  12. package/lib/rules/consistent-this.js +1 -1
  13. package/lib/rules/dot-notation.js +2 -2
  14. package/lib/rules/function-paren-newline.js +8 -5
  15. package/lib/rules/global-require.js +3 -3
  16. package/lib/rules/indent-legacy.js +2 -2
  17. package/lib/rules/indent.js +45 -13
  18. package/lib/rules/jsx-quotes.js +1 -1
  19. package/lib/rules/lines-around-comment.js +3 -3
  20. package/lib/rules/max-lines.js +2 -2
  21. package/lib/rules/max-statements.js +1 -1
  22. package/lib/rules/newline-before-return.js +1 -1
  23. package/lib/rules/no-bitwise.js +2 -2
  24. package/lib/rules/no-console.js +1 -1
  25. package/lib/rules/no-constant-binary-expression.js +3 -3
  26. package/lib/rules/no-control-regex.js +23 -10
  27. package/lib/rules/no-empty-function.js +1 -1
  28. package/lib/rules/no-extra-boolean-cast.js +3 -3
  29. package/lib/rules/no-extra-semi.js +1 -1
  30. package/lib/rules/no-global-assign.js +1 -1
  31. package/lib/rules/no-implicit-coercion.js +8 -8
  32. package/lib/rules/no-loop-func.js +1 -1
  33. package/lib/rules/no-magic-numbers.js +3 -3
  34. package/lib/rules/no-misleading-character-class.js +90 -17
  35. package/lib/rules/no-mixed-operators.js +1 -1
  36. package/lib/rules/no-mixed-requires.js +1 -1
  37. package/lib/rules/no-multi-spaces.js +1 -1
  38. package/lib/rules/no-native-reassign.js +1 -1
  39. package/lib/rules/no-new-object.js +1 -1
  40. package/lib/rules/no-new-wrappers.js +1 -1
  41. package/lib/rules/no-octal.js +2 -2
  42. package/lib/rules/no-prototype-builtins.js +3 -3
  43. package/lib/rules/no-shadow.js +5 -5
  44. package/lib/rules/no-sparse-arrays.js +1 -1
  45. package/lib/rules/no-underscore-dangle.js +31 -2
  46. package/lib/rules/no-unused-expressions.js +1 -1
  47. package/lib/rules/no-unused-vars.js +1 -1
  48. package/lib/rules/no-use-before-define.js +15 -2
  49. package/lib/rules/operator-assignment.js +2 -2
  50. package/lib/rules/prefer-const.js +1 -1
  51. package/lib/rules/prefer-reflect.js +2 -2
  52. package/lib/rules/prefer-regex-literals.js +3 -3
  53. package/lib/rules/quote-props.js +2 -2
  54. package/lib/rules/quotes.js +1 -1
  55. package/lib/rules/spaced-comment.js +1 -1
  56. package/lib/rules/valid-jsdoc.js +1 -1
  57. package/lib/rules/valid-typeof.js +4 -4
  58. package/lib/rules/yoda.js +1 -1
  59. package/lib/shared/types.js +1 -1
  60. package/package.json +25 -8
@@ -95,7 +95,7 @@ module.exports = {
95
95
  * @returns {boolean} `true` if it is an ES3 token.
96
96
  */
97
97
  function isKeyword(tokenStr) {
98
- return keywords.indexOf(tokenStr) >= 0;
98
+ return keywords.includes(tokenStr);
99
99
  }
100
100
 
101
101
  /**
@@ -108,7 +108,7 @@ module.exports = {
108
108
  */
109
109
  function areQuotesRedundant(rawKey, tokens, skipNumberLiterals) {
110
110
  return tokens.length === 1 && tokens[0].start === 0 && tokens[0].end === rawKey.length &&
111
- (["Identifier", "Keyword", "Null", "Boolean"].indexOf(tokens[0].type) >= 0 ||
111
+ (["Identifier", "Keyword", "Null", "Boolean"].includes(tokens[0].type) ||
112
112
  (tokens[0].type === "Numeric" && !skipNumberLiterals && String(+tokens[0].value) === tokens[0].value));
113
113
  }
114
114
 
@@ -283,7 +283,7 @@ module.exports = {
283
283
  astUtils.isSurroundedBy(rawVal, settings.quote);
284
284
 
285
285
  if (!isValid && avoidEscape) {
286
- isValid = astUtils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.indexOf(settings.quote) >= 0;
286
+ isValid = astUtils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.includes(settings.quote);
287
287
  }
288
288
 
289
289
  if (!isValid) {
@@ -39,7 +39,7 @@ function escapeAndRepeat(s) {
39
39
  function parseMarkersOption(markers) {
40
40
 
41
41
  // `*` is a marker for JSDoc comments.
42
- if (markers.indexOf("*") === -1) {
42
+ if (!markers.includes("*")) {
43
43
  return markers.concat("*");
44
44
  }
45
45
 
@@ -405,7 +405,7 @@ module.exports = {
405
405
  loc: getAbsoluteRange(jsdocNode, param),
406
406
  data: { name: param.name }
407
407
  });
408
- } else if (param.name.indexOf(".") === -1) {
408
+ } else if (!param.name.includes(".")) {
409
409
  paramTagsByName[param.name] = param;
410
410
  }
411
411
  });
@@ -42,8 +42,8 @@ module.exports = {
42
42
 
43
43
  create(context) {
44
44
 
45
- const VALID_TYPES = ["symbol", "undefined", "object", "boolean", "number", "string", "function", "bigint"],
46
- OPERATORS = ["==", "===", "!=", "!=="];
45
+ const VALID_TYPES = new Set(["symbol", "undefined", "object", "boolean", "number", "string", "function", "bigint"]),
46
+ OPERATORS = new Set(["==", "===", "!=", "!=="]);
47
47
 
48
48
  const requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals;
49
49
 
@@ -85,13 +85,13 @@ module.exports = {
85
85
  if (isTypeofExpression(node)) {
86
86
  const parent = context.getAncestors().pop();
87
87
 
88
- if (parent.type === "BinaryExpression" && OPERATORS.indexOf(parent.operator) !== -1) {
88
+ if (parent.type === "BinaryExpression" && OPERATORS.has(parent.operator)) {
89
89
  const sibling = parent.left === node ? parent.right : parent.left;
90
90
 
91
91
  if (sibling.type === "Literal" || sibling.type === "TemplateLiteral" && !sibling.expressions.length) {
92
92
  const value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked;
93
93
 
94
- if (VALID_TYPES.indexOf(value) === -1) {
94
+ if (!VALID_TYPES.has(value)) {
95
95
  context.report({ node: sibling, messageId: "invalidValue" });
96
96
  }
97
97
  } else if (sibling.type === "Identifier" && sibling.name === "undefined" && isReferenceToGlobalVariable(sibling)) {
package/lib/rules/yoda.js CHANGED
@@ -39,7 +39,7 @@ function isEqualityOperator(operator) {
39
39
  * @returns {boolean} Whether the operator is used in range tests.
40
40
  */
41
41
  function isRangeTestOperator(operator) {
42
- return ["<", "<="].indexOf(operator) >= 0;
42
+ return ["<", "<="].includes(operator);
43
43
  }
44
44
 
45
45
  /**
@@ -136,7 +136,6 @@ module.exports = {};
136
136
 
137
137
  /**
138
138
  * @typedef {Object} RuleMetaDocs
139
- * @property {string} category The category of the rule.
140
139
  * @property {string} description The description of the rule.
141
140
  * @property {boolean} recommended If `true` then the rule is included in `eslint:recommended` preset.
142
141
  * @property {string} url The URL of the rule documentation.
@@ -147,6 +146,7 @@ module.exports = {};
147
146
  * @property {boolean} [deprecated] If `true` then the rule has been deprecated.
148
147
  * @property {RuleMetaDocs} docs The document information of the rule.
149
148
  * @property {"code"|"whitespace"} [fixable] The autofix type.
149
+ * @property {boolean} [hasSuggestions] If `true` then the rule provides suggestions.
150
150
  * @property {Record<string,string>} [messages] The messages the rule reports.
151
151
  * @property {string[]} [replacedBy] The IDs of the alternative rules.
152
152
  * @property {Array|Object} schema The option schema of the rule.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "8.14.0",
3
+ "version": "8.17.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -16,7 +16,9 @@
16
16
  "test": "node Makefile.js test",
17
17
  "test:cli": "mocha",
18
18
  "lint": "node Makefile.js lint",
19
+ "lint:docsjs": "node Makefile.js lintDocsJS",
19
20
  "fix": "node Makefile.js lint -- fix",
21
+ "fix:docsjs": "node Makefile.js lintDocsJS -- fix",
20
22
  "fuzz": "node Makefile.js fuzz",
21
23
  "generate-release": "node Makefile.js generateRelease",
22
24
  "generate-alpharelease": "node Makefile.js generatePrerelease -- alpha",
@@ -25,14 +27,19 @@
25
27
  "publish-release": "node Makefile.js publishRelease",
26
28
  "gensite": "node Makefile.js gensite",
27
29
  "webpack": "node Makefile.js webpack",
28
- "perf": "node Makefile.js perf"
30
+ "perf": "node Makefile.js perf",
31
+ "docs:update-links": "node tools/fetch-docs-links.js"
29
32
  },
30
33
  "gitHooks": {
31
34
  "pre-commit": "lint-staged"
32
35
  },
33
36
  "lint-staged": {
34
37
  "*.js": "eslint --fix",
35
- "*.md": "markdownlint --fix"
38
+ "*.md": "markdownlint --fix",
39
+ "docs/src/rules/*.md": [
40
+ "node tools/fetch-docs-links.js",
41
+ "git add docs/src/_data/further_reading_links.json"
42
+ ]
36
43
  },
37
44
  "files": [
38
45
  "LICENSE",
@@ -47,7 +54,7 @@
47
54
  "homepage": "https://eslint.org",
48
55
  "bugs": "https://github.com/eslint/eslint/issues/",
49
56
  "dependencies": {
50
- "@eslint/eslintrc": "^1.2.2",
57
+ "@eslint/eslintrc": "^1.3.0",
51
58
  "@humanwhocodes/config-array": "^0.9.2",
52
59
  "ajv": "^6.10.0",
53
60
  "chalk": "^4.0.0",
@@ -58,14 +65,14 @@
58
65
  "eslint-scope": "^7.1.1",
59
66
  "eslint-utils": "^3.0.0",
60
67
  "eslint-visitor-keys": "^3.3.0",
61
- "espree": "^9.3.1",
68
+ "espree": "^9.3.2",
62
69
  "esquery": "^1.4.0",
63
70
  "esutils": "^2.0.2",
64
71
  "fast-deep-equal": "^3.1.3",
65
72
  "file-entry-cache": "^6.0.1",
66
73
  "functional-red-black-tree": "^1.0.1",
67
74
  "glob-parent": "^6.0.1",
68
- "globals": "^13.6.0",
75
+ "globals": "^13.15.0",
69
76
  "ignore": "^5.2.0",
70
77
  "import-fresh": "^3.0.0",
71
78
  "imurmurhash": "^0.1.4",
@@ -74,7 +81,7 @@
74
81
  "json-stable-stringify-without-jsonify": "^1.0.1",
75
82
  "levn": "^0.4.1",
76
83
  "lodash.merge": "^4.6.2",
77
- "minimatch": "^3.0.4",
84
+ "minimatch": "^3.1.2",
78
85
  "natural-compare": "^1.4.0",
79
86
  "optionator": "^0.9.1",
80
87
  "regexpp": "^3.2.0",
@@ -96,15 +103,19 @@
96
103
  "eslint": "file:.",
97
104
  "eslint-config-eslint": "file:packages/eslint-config-eslint",
98
105
  "eslint-plugin-eslint-comments": "^3.2.0",
99
- "eslint-plugin-eslint-plugin": "^4.0.1",
106
+ "eslint-plugin-eslint-plugin": "^4.2.0",
100
107
  "eslint-plugin-internal-rules": "file:tools/internal-rules",
101
108
  "eslint-plugin-jsdoc": "^37.0.0",
102
109
  "eslint-plugin-node": "^11.1.0",
110
+ "eslint-plugin-unicorn": "^42.0.0",
103
111
  "eslint-release": "^3.2.0",
104
112
  "eslump": "^3.0.0",
105
113
  "esprima": "^4.0.1",
114
+ "fast-glob": "^3.2.11",
106
115
  "fs-teardown": "^0.1.3",
107
116
  "glob": "^7.1.6",
117
+ "got": "^11.8.3",
118
+ "gray-matter": "^4.0.3",
108
119
  "jsdoc": "^3.5.5",
109
120
  "karma": "^6.1.1",
110
121
  "karma-chrome-launcher": "^3.1.0",
@@ -117,6 +128,12 @@
117
128
  "markdownlint-cli": "^0.30.0",
118
129
  "marked": "^4.0.8",
119
130
  "memfs": "^3.0.1",
131
+ "metascraper": "^5.25.7",
132
+ "metascraper-description": "^5.25.7",
133
+ "metascraper-image": "^5.29.3",
134
+ "metascraper-logo": "^5.25.7",
135
+ "metascraper-logo-favicon": "^5.25.7",
136
+ "metascraper-title": "^5.25.7",
120
137
  "mocha": "^8.3.2",
121
138
  "mocha-junit-reporter": "^2.0.0",
122
139
  "node-polyfill-webpack-plugin": "^1.0.3",