eslint 8.56.0 → 9.0.0-alpha.1

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 (121) hide show
  1. package/README.md +7 -2
  2. package/conf/ecma-version.js +16 -0
  3. package/conf/rule-type-list.json +3 -1
  4. package/lib/api.js +1 -1
  5. package/lib/cli-engine/cli-engine.js +14 -3
  6. package/lib/cli-engine/formatters/formatters-meta.json +1 -29
  7. package/lib/cli-engine/lint-result-cache.js +2 -2
  8. package/lib/cli.js +46 -25
  9. package/lib/config/default-config.js +3 -0
  10. package/lib/config/flat-config-array.js +0 -20
  11. package/lib/config/flat-config-helpers.js +41 -20
  12. package/lib/config/flat-config-schema.js +35 -25
  13. package/lib/config/rule-validator.js +27 -4
  14. package/lib/eslint/eslint-helpers.js +32 -12
  15. package/lib/eslint/eslint.js +856 -373
  16. package/lib/eslint/index.js +2 -2
  17. package/lib/eslint/legacy-eslint.js +722 -0
  18. package/lib/linter/apply-disable-directives.js +35 -7
  19. package/lib/linter/code-path-analysis/code-path.js +5 -19
  20. package/lib/linter/code-path-analysis/fork-context.js +1 -1
  21. package/lib/linter/config-comment-parser.js +8 -11
  22. package/lib/linter/linter.js +196 -100
  23. package/lib/linter/report-translator.js +2 -2
  24. package/lib/linter/rules.js +6 -15
  25. package/lib/linter/source-code-fixer.js +1 -1
  26. package/lib/options.js +9 -1
  27. package/lib/rule-tester/rule-tester.js +234 -291
  28. package/lib/rules/array-bracket-newline.js +1 -1
  29. package/lib/rules/array-bracket-spacing.js +1 -1
  30. package/lib/rules/block-scoped-var.js +1 -1
  31. package/lib/rules/callback-return.js +2 -2
  32. package/lib/rules/comma-dangle.js +1 -1
  33. package/lib/rules/comma-style.js +2 -2
  34. package/lib/rules/complexity.js +1 -1
  35. package/lib/rules/constructor-super.js +1 -1
  36. package/lib/rules/default-case.js +1 -1
  37. package/lib/rules/eol-last.js +2 -2
  38. package/lib/rules/function-paren-newline.js +2 -2
  39. package/lib/rules/indent-legacy.js +5 -5
  40. package/lib/rules/indent.js +5 -5
  41. package/lib/rules/index.js +1 -2
  42. package/lib/rules/key-spacing.js +2 -2
  43. package/lib/rules/line-comment-position.js +1 -1
  44. package/lib/rules/lines-around-directive.js +2 -2
  45. package/lib/rules/max-depth.js +1 -1
  46. package/lib/rules/max-len.js +3 -3
  47. package/lib/rules/max-lines.js +3 -3
  48. package/lib/rules/max-nested-callbacks.js +1 -1
  49. package/lib/rules/max-params.js +1 -1
  50. package/lib/rules/max-statements.js +1 -1
  51. package/lib/rules/multiline-comment-style.js +7 -7
  52. package/lib/rules/new-cap.js +1 -1
  53. package/lib/rules/newline-after-var.js +1 -1
  54. package/lib/rules/newline-before-return.js +1 -1
  55. package/lib/rules/no-constant-binary-expression.js +6 -6
  56. package/lib/rules/no-constructor-return.js +2 -2
  57. package/lib/rules/no-dupe-class-members.js +2 -2
  58. package/lib/rules/no-else-return.js +1 -1
  59. package/lib/rules/no-empty-function.js +2 -2
  60. package/lib/rules/no-empty-static-block.js +1 -1
  61. package/lib/rules/no-extra-semi.js +1 -1
  62. package/lib/rules/no-fallthrough.js +1 -1
  63. package/lib/rules/no-implicit-coercion.js +17 -1
  64. package/lib/rules/no-inner-declarations.js +23 -2
  65. package/lib/rules/no-invalid-regexp.js +1 -1
  66. package/lib/rules/no-invalid-this.js +1 -1
  67. package/lib/rules/no-lone-blocks.js +2 -2
  68. package/lib/rules/no-loss-of-precision.js +1 -1
  69. package/lib/rules/no-misleading-character-class.js +174 -65
  70. package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
  71. package/lib/rules/no-multiple-empty-lines.js +1 -1
  72. package/lib/rules/no-new-native-nonconstructor.js +1 -1
  73. package/lib/rules/no-new-symbol.js +8 -1
  74. package/lib/rules/no-restricted-globals.js +1 -1
  75. package/lib/rules/no-restricted-imports.js +2 -2
  76. package/lib/rules/no-restricted-modules.js +2 -2
  77. package/lib/rules/no-return-await.js +1 -1
  78. package/lib/rules/no-sequences.js +1 -0
  79. package/lib/rules/no-trailing-spaces.js +2 -3
  80. package/lib/rules/no-unneeded-ternary.js +1 -1
  81. package/lib/rules/no-unsafe-optional-chaining.js +1 -1
  82. package/lib/rules/no-unused-private-class-members.js +1 -1
  83. package/lib/rules/no-unused-vars.js +6 -8
  84. package/lib/rules/no-useless-assignment.js +566 -0
  85. package/lib/rules/no-useless-backreference.js +1 -1
  86. package/lib/rules/object-curly-spacing.js +3 -3
  87. package/lib/rules/object-property-newline.js +1 -1
  88. package/lib/rules/one-var.js +5 -5
  89. package/lib/rules/padded-blocks.js +7 -7
  90. package/lib/rules/prefer-arrow-callback.js +3 -3
  91. package/lib/rules/prefer-reflect.js +1 -1
  92. package/lib/rules/prefer-regex-literals.js +1 -1
  93. package/lib/rules/prefer-template.js +1 -1
  94. package/lib/rules/radix.js +2 -2
  95. package/lib/rules/semi-style.js +1 -1
  96. package/lib/rules/sort-imports.js +1 -1
  97. package/lib/rules/sort-keys.js +1 -1
  98. package/lib/rules/sort-vars.js +1 -1
  99. package/lib/rules/space-unary-ops.js +1 -1
  100. package/lib/rules/strict.js +1 -1
  101. package/lib/rules/utils/ast-utils.js +7 -7
  102. package/lib/rules/yield-star-spacing.js +1 -1
  103. package/lib/shared/types.js +1 -1
  104. package/lib/source-code/source-code.js +5 -83
  105. package/lib/source-code/token-store/index.js +2 -2
  106. package/lib/unsupported-api.js +3 -5
  107. package/package.json +12 -14
  108. package/conf/config-schema.js +0 -93
  109. package/lib/cli-engine/formatters/checkstyle.js +0 -60
  110. package/lib/cli-engine/formatters/compact.js +0 -60
  111. package/lib/cli-engine/formatters/jslint-xml.js +0 -41
  112. package/lib/cli-engine/formatters/junit.js +0 -82
  113. package/lib/cli-engine/formatters/tap.js +0 -95
  114. package/lib/cli-engine/formatters/unix.js +0 -58
  115. package/lib/cli-engine/formatters/visualstudio.js +0 -63
  116. package/lib/eslint/flat-eslint.js +0 -1142
  117. package/lib/rule-tester/flat-rule-tester.js +0 -1122
  118. package/lib/rules/require-jsdoc.js +0 -122
  119. package/lib/rules/valid-jsdoc.js +0 -516
  120. package/lib/shared/config-validator.js +0 -347
  121. package/lib/shared/relative-module-resolver.js +0 -50
@@ -105,20 +105,30 @@ class AllFilesIgnoredError extends Error {
105
105
 
106
106
  /**
107
107
  * Check if a given value is a non-empty string or not.
108
- * @param {any} x The value to check.
109
- * @returns {boolean} `true` if `x` is a non-empty string.
108
+ * @param {any} value The value to check.
109
+ * @returns {boolean} `true` if `value` is a non-empty string.
110
110
  */
111
- function isNonEmptyString(x) {
112
- return typeof x === "string" && x.trim() !== "";
111
+ function isNonEmptyString(value) {
112
+ return typeof value === "string" && value.trim() !== "";
113
113
  }
114
114
 
115
115
  /**
116
116
  * Check if a given value is an array of non-empty strings or not.
117
- * @param {any} x The value to check.
118
- * @returns {boolean} `true` if `x` is an array of non-empty strings.
117
+ * @param {any} value The value to check.
118
+ * @returns {boolean} `true` if `value` is an array of non-empty strings.
119
+ */
120
+ function isArrayOfNonEmptyString(value) {
121
+ return Array.isArray(value) && value.length && value.every(isNonEmptyString);
122
+ }
123
+
124
+ /**
125
+ * Check if a given value is an empty array or an array of non-empty strings.
126
+ * @param {any} value The value to check.
127
+ * @returns {boolean} `true` if `value` is an empty array or an array of non-empty
128
+ * strings.
119
129
  */
120
- function isArrayOfNonEmptyString(x) {
121
- return Array.isArray(x) && x.every(isNonEmptyString);
130
+ function isEmptyArrayOrArrayOfNonEmptyString(value) {
131
+ return Array.isArray(value) && value.every(isNonEmptyString);
122
132
  }
123
133
 
124
134
  //-----------------------------------------------------------------------------
@@ -655,9 +665,9 @@ class ESLintInvalidOptionsError extends Error {
655
665
 
656
666
  /**
657
667
  * Validates and normalizes options for the wrapped CLIEngine instance.
658
- * @param {FlatESLintOptions} options The options to process.
668
+ * @param {ESLintOptions} options The options to process.
659
669
  * @throws {ESLintInvalidOptionsError} If of any of a variety of type errors.
660
- * @returns {FlatESLintOptions} The normalized options.
670
+ * @returns {ESLintOptions} The normalized options.
661
671
  */
662
672
  function processOptions({
663
673
  allowInlineConfig = true, // ← we cannot use `overrideConfig.noInlineConfig` instead because `allowInlineConfig` has side-effect that suppress warnings that show inline configs are ignored.
@@ -676,6 +686,8 @@ function processOptions({
676
686
  overrideConfigFile = null,
677
687
  plugins = {},
678
688
  warnIgnored = true,
689
+ passOnNoPatterns = false,
690
+ ruleFilter = () => true,
679
691
  ...unknownOptions
680
692
  }) {
681
693
  const errors = [];
@@ -759,7 +771,7 @@ function processOptions({
759
771
  if (typeof ignore !== "boolean") {
760
772
  errors.push("'ignore' must be a boolean.");
761
773
  }
762
- if (!isArrayOfNonEmptyString(ignorePatterns) && ignorePatterns !== null) {
774
+ if (!isEmptyArrayOrArrayOfNonEmptyString(ignorePatterns) && ignorePatterns !== null) {
763
775
  errors.push("'ignorePatterns' must be an array of non-empty strings or null.");
764
776
  }
765
777
  if (typeof overrideConfig !== "object") {
@@ -768,6 +780,9 @@ function processOptions({
768
780
  if (!isNonEmptyString(overrideConfigFile) && overrideConfigFile !== null && overrideConfigFile !== true) {
769
781
  errors.push("'overrideConfigFile' must be a non-empty string, null, or true.");
770
782
  }
783
+ if (typeof passOnNoPatterns !== "boolean") {
784
+ errors.push("'passOnNoPatterns' must be a boolean.");
785
+ }
771
786
  if (typeof plugins !== "object") {
772
787
  errors.push("'plugins' must be an object or null.");
773
788
  } else if (plugins !== null && Object.keys(plugins).includes("")) {
@@ -779,6 +794,9 @@ function processOptions({
779
794
  if (typeof warnIgnored !== "boolean") {
780
795
  errors.push("'warnIgnored' must be a boolean.");
781
796
  }
797
+ if (typeof ruleFilter !== "function") {
798
+ errors.push("'ruleFilter' must be a function.");
799
+ }
782
800
  if (errors.length > 0) {
783
801
  throw new ESLintInvalidOptionsError(errors);
784
802
  }
@@ -800,7 +818,9 @@ function processOptions({
800
818
  globInputPaths,
801
819
  ignore,
802
820
  ignorePatterns,
803
- warnIgnored
821
+ passOnNoPatterns,
822
+ warnIgnored,
823
+ ruleFilter
804
824
  };
805
825
  }
806
826