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.
- package/README.md +7 -2
- package/conf/ecma-version.js +16 -0
- package/conf/rule-type-list.json +3 -1
- package/lib/api.js +1 -1
- package/lib/cli-engine/cli-engine.js +14 -3
- package/lib/cli-engine/formatters/formatters-meta.json +1 -29
- package/lib/cli-engine/lint-result-cache.js +2 -2
- package/lib/cli.js +46 -25
- package/lib/config/default-config.js +3 -0
- package/lib/config/flat-config-array.js +0 -20
- package/lib/config/flat-config-helpers.js +41 -20
- package/lib/config/flat-config-schema.js +35 -25
- package/lib/config/rule-validator.js +27 -4
- package/lib/eslint/eslint-helpers.js +32 -12
- package/lib/eslint/eslint.js +856 -373
- package/lib/eslint/index.js +2 -2
- package/lib/eslint/legacy-eslint.js +722 -0
- package/lib/linter/apply-disable-directives.js +35 -7
- package/lib/linter/code-path-analysis/code-path.js +5 -19
- package/lib/linter/code-path-analysis/fork-context.js +1 -1
- package/lib/linter/config-comment-parser.js +8 -11
- package/lib/linter/linter.js +196 -100
- package/lib/linter/report-translator.js +2 -2
- package/lib/linter/rules.js +6 -15
- package/lib/linter/source-code-fixer.js +1 -1
- package/lib/options.js +9 -1
- package/lib/rule-tester/rule-tester.js +234 -291
- package/lib/rules/array-bracket-newline.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/block-scoped-var.js +1 -1
- package/lib/rules/callback-return.js +2 -2
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-style.js +2 -2
- package/lib/rules/complexity.js +1 -1
- package/lib/rules/constructor-super.js +1 -1
- package/lib/rules/default-case.js +1 -1
- package/lib/rules/eol-last.js +2 -2
- package/lib/rules/function-paren-newline.js +2 -2
- package/lib/rules/indent-legacy.js +5 -5
- package/lib/rules/indent.js +5 -5
- package/lib/rules/index.js +1 -2
- package/lib/rules/key-spacing.js +2 -2
- package/lib/rules/line-comment-position.js +1 -1
- package/lib/rules/lines-around-directive.js +2 -2
- package/lib/rules/max-depth.js +1 -1
- package/lib/rules/max-len.js +3 -3
- package/lib/rules/max-lines.js +3 -3
- package/lib/rules/max-nested-callbacks.js +1 -1
- package/lib/rules/max-params.js +1 -1
- package/lib/rules/max-statements.js +1 -1
- package/lib/rules/multiline-comment-style.js +7 -7
- package/lib/rules/new-cap.js +1 -1
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-before-return.js +1 -1
- package/lib/rules/no-constant-binary-expression.js +6 -6
- package/lib/rules/no-constructor-return.js +2 -2
- package/lib/rules/no-dupe-class-members.js +2 -2
- package/lib/rules/no-else-return.js +1 -1
- package/lib/rules/no-empty-function.js +2 -2
- package/lib/rules/no-empty-static-block.js +1 -1
- package/lib/rules/no-extra-semi.js +1 -1
- package/lib/rules/no-fallthrough.js +1 -1
- package/lib/rules/no-implicit-coercion.js +17 -1
- package/lib/rules/no-inner-declarations.js +23 -2
- package/lib/rules/no-invalid-regexp.js +1 -1
- package/lib/rules/no-invalid-this.js +1 -1
- package/lib/rules/no-lone-blocks.js +2 -2
- package/lib/rules/no-loss-of-precision.js +1 -1
- package/lib/rules/no-misleading-character-class.js +174 -65
- package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
- package/lib/rules/no-multiple-empty-lines.js +1 -1
- package/lib/rules/no-new-native-nonconstructor.js +1 -1
- package/lib/rules/no-new-symbol.js +8 -1
- package/lib/rules/no-restricted-globals.js +1 -1
- package/lib/rules/no-restricted-imports.js +2 -2
- package/lib/rules/no-restricted-modules.js +2 -2
- package/lib/rules/no-return-await.js +1 -1
- package/lib/rules/no-sequences.js +1 -0
- package/lib/rules/no-trailing-spaces.js +2 -3
- package/lib/rules/no-unneeded-ternary.js +1 -1
- package/lib/rules/no-unsafe-optional-chaining.js +1 -1
- package/lib/rules/no-unused-private-class-members.js +1 -1
- package/lib/rules/no-unused-vars.js +6 -8
- package/lib/rules/no-useless-assignment.js +566 -0
- package/lib/rules/no-useless-backreference.js +1 -1
- package/lib/rules/object-curly-spacing.js +3 -3
- package/lib/rules/object-property-newline.js +1 -1
- package/lib/rules/one-var.js +5 -5
- package/lib/rules/padded-blocks.js +7 -7
- package/lib/rules/prefer-arrow-callback.js +3 -3
- package/lib/rules/prefer-reflect.js +1 -1
- package/lib/rules/prefer-regex-literals.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/radix.js +2 -2
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/sort-imports.js +1 -1
- package/lib/rules/sort-keys.js +1 -1
- package/lib/rules/sort-vars.js +1 -1
- package/lib/rules/space-unary-ops.js +1 -1
- package/lib/rules/strict.js +1 -1
- package/lib/rules/utils/ast-utils.js +7 -7
- package/lib/rules/yield-star-spacing.js +1 -1
- package/lib/shared/types.js +1 -1
- package/lib/source-code/source-code.js +5 -83
- package/lib/source-code/token-store/index.js +2 -2
- package/lib/unsupported-api.js +3 -5
- package/package.json +12 -14
- package/conf/config-schema.js +0 -93
- package/lib/cli-engine/formatters/checkstyle.js +0 -60
- package/lib/cli-engine/formatters/compact.js +0 -60
- package/lib/cli-engine/formatters/jslint-xml.js +0 -41
- package/lib/cli-engine/formatters/junit.js +0 -82
- package/lib/cli-engine/formatters/tap.js +0 -95
- package/lib/cli-engine/formatters/unix.js +0 -58
- package/lib/cli-engine/formatters/visualstudio.js +0 -63
- package/lib/eslint/flat-eslint.js +0 -1142
- package/lib/rule-tester/flat-rule-tester.js +0 -1122
- package/lib/rules/require-jsdoc.js +0 -122
- package/lib/rules/valid-jsdoc.js +0 -516
- package/lib/shared/config-validator.js +0 -347
- 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}
|
109
|
-
* @returns {boolean} `true` if `
|
108
|
+
* @param {any} value The value to check.
|
109
|
+
* @returns {boolean} `true` if `value` is a non-empty string.
|
110
110
|
*/
|
111
|
-
function isNonEmptyString(
|
112
|
-
return typeof
|
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}
|
118
|
-
* @returns {boolean} `true` if `
|
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
|
121
|
-
return Array.isArray(
|
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 {
|
668
|
+
* @param {ESLintOptions} options The options to process.
|
659
669
|
* @throws {ESLintInvalidOptionsError} If of any of a variety of type errors.
|
660
|
-
* @returns {
|
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 (!
|
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
|
-
|
821
|
+
passOnNoPatterns,
|
822
|
+
warnIgnored,
|
823
|
+
ruleFilter
|
804
824
|
};
|
805
825
|
}
|
806
826
|
|