eslint 8.15.0 → 8.18.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 (63) hide show
  1. package/README.md +2 -7
  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/linter/linter.js +1 -1
  10. package/lib/linter/timing.js +2 -1
  11. package/lib/rules/accessor-pairs.js +4 -4
  12. package/lib/rules/callback-return.js +2 -2
  13. package/lib/rules/capitalized-comments.js +1 -1
  14. package/lib/rules/consistent-this.js +1 -1
  15. package/lib/rules/dot-notation.js +2 -2
  16. package/lib/rules/function-paren-newline.js +8 -5
  17. package/lib/rules/global-require.js +3 -3
  18. package/lib/rules/indent-legacy.js +2 -2
  19. package/lib/rules/indent.js +45 -13
  20. package/lib/rules/jsx-quotes.js +1 -1
  21. package/lib/rules/lines-around-comment.js +3 -3
  22. package/lib/rules/max-lines.js +2 -2
  23. package/lib/rules/max-statements.js +1 -1
  24. package/lib/rules/newline-before-return.js +1 -1
  25. package/lib/rules/no-bitwise.js +2 -2
  26. package/lib/rules/no-console.js +1 -1
  27. package/lib/rules/no-constant-binary-expression.js +3 -3
  28. package/lib/rules/no-control-regex.js +23 -10
  29. package/lib/rules/no-empty-function.js +1 -1
  30. package/lib/rules/no-extra-boolean-cast.js +3 -3
  31. package/lib/rules/no-extra-semi.js +1 -1
  32. package/lib/rules/no-global-assign.js +1 -1
  33. package/lib/rules/no-implicit-coercion.js +8 -8
  34. package/lib/rules/no-loop-func.js +1 -1
  35. package/lib/rules/no-magic-numbers.js +3 -3
  36. package/lib/rules/no-misleading-character-class.js +90 -17
  37. package/lib/rules/no-mixed-operators.js +1 -1
  38. package/lib/rules/no-mixed-requires.js +1 -1
  39. package/lib/rules/no-multi-spaces.js +1 -1
  40. package/lib/rules/no-native-reassign.js +1 -1
  41. package/lib/rules/no-new-object.js +1 -1
  42. package/lib/rules/no-new-wrappers.js +1 -1
  43. package/lib/rules/no-octal.js +2 -2
  44. package/lib/rules/no-prototype-builtins.js +3 -3
  45. package/lib/rules/no-shadow.js +5 -5
  46. package/lib/rules/no-sparse-arrays.js +1 -1
  47. package/lib/rules/no-underscore-dangle.js +1 -1
  48. package/lib/rules/no-unused-expressions.js +1 -1
  49. package/lib/rules/no-unused-vars.js +5 -5
  50. package/lib/rules/no-use-before-define.js +15 -2
  51. package/lib/rules/operator-assignment.js +2 -2
  52. package/lib/rules/prefer-const.js +1 -1
  53. package/lib/rules/prefer-reflect.js +2 -2
  54. package/lib/rules/prefer-regex-literals.js +3 -3
  55. package/lib/rules/quote-props.js +2 -2
  56. package/lib/rules/quotes.js +1 -1
  57. package/lib/rules/spaced-comment.js +1 -1
  58. package/lib/rules/valid-jsdoc.js +1 -1
  59. package/lib/rules/valid-typeof.js +4 -4
  60. package/lib/rules/yoda.js +1 -1
  61. package/lib/shared/deprecation-warnings.js +1 -8
  62. package/lib/shared/types.js +1 -1
  63. package/package.json +23 -6
@@ -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
  /**
@@ -17,14 +17,7 @@ const path = require("path");
17
17
  // Definitions for deprecation warnings.
18
18
  const deprecationWarningMessages = {
19
19
  ESLINT_LEGACY_ECMAFEATURES:
20
- "The 'ecmaFeatures' config file property is deprecated and has no effect.",
21
- ESLINT_PERSONAL_CONFIG_LOAD:
22
- "'~/.eslintrc.*' config files have been deprecated. " +
23
- "Please use a config file per project or the '--config' option.",
24
- ESLINT_PERSONAL_CONFIG_SUPPRESS:
25
- "'~/.eslintrc.*' config files have been deprecated. " +
26
- "Please remove it or add 'root:true' to the config files in your " +
27
- "projects in order to avoid loading '~/.eslintrc.*' accidentally."
20
+ "The 'ecmaFeatures' config file property is deprecated and has no effect."
28
21
  };
29
22
 
30
23
  const sourceFileErrorCache = new Set();
@@ -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.15.0",
3
+ "version": "8.18.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.3",
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",
@@ -65,7 +72,7 @@
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",
@@ -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",