eslint-cli-bundle 1.0.5 → 2.0.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 +1 -0
- package/dist/api.d.ts +235 -162
- package/dist/api.js +7 -5
- package/dist/babel.cjs +38 -27
- package/dist/config.d.ts +9 -1
- package/dist/config.js +1 -1
- package/dist/eslint-BYId4sVl.js +535 -0
- package/dist/eslint.js +14 -12
- package/dist/jiti-LuDw_cZG.js +15 -0
- package/dist/rolldown-runtime-CN7XbDR5.js +1 -0
- package/dist/src-CBWp9Y5K.js +1 -0
- package/dist/{types-CRoZH7Is.d.ts → types-BkIPfpy7.d.ts} +79 -58
- package/package.json +21 -12
- package/dist/chunk-qnHZjHhP.js +0 -1
- package/dist/jiti-DyCiGFB9.js +0 -9
- package/dist/legacy-eslint-DYfSFaC6.js +0 -269
- package/dist/src-FNB-unmu.js +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
# eslint-cli-bundle
|
|
2
|
+
[](https://www.npmjs.org/package/eslint-cli-bundle) [](https://www.npmjs.org/package/eslint-cli-bundle) [](https://packagephobia.com/result?p=eslint-cli-bundle)
|
|
2
3
|
|
|
3
4
|
Bundled version of [`eslint`](https://github.com/eslint/eslint).
|
package/dist/api.d.ts
CHANGED
|
@@ -27,8 +27,6 @@
|
|
|
27
27
|
|
|
28
28
|
import * as ESTree from "estree";
|
|
29
29
|
import type {
|
|
30
|
-
CustomRuleDefinitionType,
|
|
31
|
-
CustomRuleTypeDefinitions,
|
|
32
30
|
DeprecatedInfo,
|
|
33
31
|
LanguageOptions as GenericLanguageOptions,
|
|
34
32
|
RuleContext as CoreRuleContext,
|
|
@@ -53,7 +51,6 @@ import type {
|
|
|
53
51
|
EcmaVersion as CoreEcmaVersion,
|
|
54
52
|
ConfigOverride as CoreConfigOverride,
|
|
55
53
|
ProcessorFile as CoreProcessorFile,
|
|
56
|
-
JavaScriptParserOptionsConfig,
|
|
57
54
|
RulesMeta,
|
|
58
55
|
RuleConfig,
|
|
59
56
|
RuleTextEditor,
|
|
@@ -71,19 +68,13 @@ import type {
|
|
|
71
68
|
SuggestedEditBase,
|
|
72
69
|
SuggestedEdit,
|
|
73
70
|
ViolationReport,
|
|
71
|
+
MessagePlaceholderData,
|
|
74
72
|
} from "@eslint/core";
|
|
75
|
-
import {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/** Adds matching `:exit` selectors for all properties of a `RuleVisitor`. */
|
|
82
|
-
type WithExit<RuleVisitorType extends RuleVisitor> = {
|
|
83
|
-
[Key in keyof RuleVisitorType as
|
|
84
|
-
| Key
|
|
85
|
-
| `${Key & string}:exit`]: RuleVisitorType[Key];
|
|
86
|
-
};
|
|
73
|
+
import type {
|
|
74
|
+
CustomRuleDefinitionType,
|
|
75
|
+
CustomRuleTypeDefinitions,
|
|
76
|
+
CustomRuleVisitorWithExit,
|
|
77
|
+
} from "@eslint/plugin-kit";
|
|
87
78
|
|
|
88
79
|
//------------------------------------------------------------------------------
|
|
89
80
|
// Exports
|
|
@@ -116,7 +107,7 @@ export namespace AST {
|
|
|
116
107
|
end: ESTree.Position;
|
|
117
108
|
}
|
|
118
109
|
|
|
119
|
-
type Range =
|
|
110
|
+
type Range = SourceRange;
|
|
120
111
|
|
|
121
112
|
interface Program extends ESTree.Program {
|
|
122
113
|
comments: ESTree.Comment[];
|
|
@@ -126,6 +117,11 @@ export namespace AST {
|
|
|
126
117
|
}
|
|
127
118
|
}
|
|
128
119
|
|
|
120
|
+
interface JSXIdentifier extends ESTree.BaseNode {
|
|
121
|
+
type: "JSXIdentifier";
|
|
122
|
+
name: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
129
125
|
export namespace Scope {
|
|
130
126
|
interface ScopeManager {
|
|
131
127
|
scopes: Scope[];
|
|
@@ -134,6 +130,8 @@ export namespace Scope {
|
|
|
134
130
|
acquire(node: ESTree.Node, inner?: boolean): Scope | null;
|
|
135
131
|
|
|
136
132
|
getDeclaredVariables(node: ESTree.Node): Variable[];
|
|
133
|
+
|
|
134
|
+
addGlobals(names: ReadonlyArray<string>): void;
|
|
137
135
|
}
|
|
138
136
|
|
|
139
137
|
interface Scope {
|
|
@@ -149,8 +147,7 @@ export namespace Scope {
|
|
|
149
147
|
| "global"
|
|
150
148
|
| "module"
|
|
151
149
|
| "switch"
|
|
152
|
-
| "with"
|
|
153
|
-
| "TDZ";
|
|
150
|
+
| "with";
|
|
154
151
|
isStrict: boolean;
|
|
155
152
|
upper: Scope | null;
|
|
156
153
|
childScopes: Scope[];
|
|
@@ -176,11 +173,11 @@ export namespace Scope {
|
|
|
176
173
|
}
|
|
177
174
|
|
|
178
175
|
interface Reference {
|
|
179
|
-
identifier: ESTree.Identifier;
|
|
176
|
+
identifier: ESTree.Identifier | JSXIdentifier;
|
|
180
177
|
from: Scope;
|
|
181
178
|
resolved: Variable | null;
|
|
182
|
-
writeExpr
|
|
183
|
-
init
|
|
179
|
+
writeExpr?: ESTree.Expression | null;
|
|
180
|
+
init?: boolean;
|
|
184
181
|
|
|
185
182
|
isWrite(): boolean;
|
|
186
183
|
|
|
@@ -229,7 +226,6 @@ export namespace Scope {
|
|
|
229
226
|
| ESTree.ArrowFunctionExpression;
|
|
230
227
|
parent: null;
|
|
231
228
|
}
|
|
232
|
-
| { type: "TDZ"; node: any; parent: null }
|
|
233
229
|
| {
|
|
234
230
|
type: "Variable";
|
|
235
231
|
node: ESTree.VariableDeclarator;
|
|
@@ -241,15 +237,12 @@ export namespace Scope {
|
|
|
241
237
|
|
|
242
238
|
// #region SourceCode
|
|
243
239
|
|
|
244
|
-
export class SourceCode
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
ConfigNode: ESTree.Comment;
|
|
251
|
-
}>
|
|
252
|
-
{
|
|
240
|
+
export class SourceCode implements TextSourceCode<{
|
|
241
|
+
LangOptions: Linter.LanguageOptions;
|
|
242
|
+
RootNode: AST.Program;
|
|
243
|
+
SyntaxElementWithLoc: AST.Token | ESTree.Node;
|
|
244
|
+
ConfigNode: ESTree.Comment;
|
|
245
|
+
}> {
|
|
253
246
|
text: string;
|
|
254
247
|
ast: AST.Program;
|
|
255
248
|
lines: string[];
|
|
@@ -280,17 +273,8 @@ export class SourceCode
|
|
|
280
273
|
|
|
281
274
|
getDeclaredVariables(node: ESTree.Node): Scope.Variable[];
|
|
282
275
|
|
|
283
|
-
/** @deprecated */
|
|
284
|
-
getJSDocComment(node: ESTree.Node): ESTree.Comment | null;
|
|
285
|
-
|
|
286
276
|
getNodeByRangeIndex(index: number): ESTree.Node | null;
|
|
287
277
|
|
|
288
|
-
/** @deprecated Use `isSpaceBetween()` instead. */
|
|
289
|
-
isSpaceBetweenTokens(
|
|
290
|
-
first: ESTree.Node | AST.Token,
|
|
291
|
-
second: ESTree.Node | AST.Token,
|
|
292
|
-
): boolean;
|
|
293
|
-
|
|
294
278
|
getLocFromIndex(index: number): ESTree.Position;
|
|
295
279
|
|
|
296
280
|
getIndexFromLoc(location: ESTree.Position): number;
|
|
@@ -323,18 +307,6 @@ export class SourceCode
|
|
|
323
307
|
|
|
324
308
|
getTokensAfter: SourceCode.UnaryCursorWithCountOptions;
|
|
325
309
|
|
|
326
|
-
/** @deprecated Use `getTokenBefore()` instead. */
|
|
327
|
-
getTokenOrCommentBefore(
|
|
328
|
-
node: ESTree.Node | AST.Token | ESTree.Comment,
|
|
329
|
-
skip?: number | undefined,
|
|
330
|
-
): AST.Token | ESTree.Comment | null;
|
|
331
|
-
|
|
332
|
-
/** @deprecated Use `getTokenAfter()` instead. */
|
|
333
|
-
getTokenOrCommentAfter(
|
|
334
|
-
node: ESTree.Node | AST.Token | ESTree.Comment,
|
|
335
|
-
skip?: number | undefined,
|
|
336
|
-
): AST.Token | ESTree.Comment | null;
|
|
337
|
-
|
|
338
310
|
getFirstTokenBetween: SourceCode.BinaryCursorWithSkipOptions;
|
|
339
311
|
|
|
340
312
|
getFirstTokensBetween: SourceCode.BinaryCursorWithCountOptions;
|
|
@@ -674,32 +646,29 @@ export type JSSyntaxElement = {
|
|
|
674
646
|
};
|
|
675
647
|
|
|
676
648
|
export namespace Rule {
|
|
677
|
-
interface RuleModule
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
}> {
|
|
649
|
+
interface RuleModule extends RuleDefinition<{
|
|
650
|
+
LangOptions: Linter.LanguageOptions;
|
|
651
|
+
Code: SourceCode;
|
|
652
|
+
RuleOptions: any[];
|
|
653
|
+
Visitor: RuleListener;
|
|
654
|
+
Node: JSSyntaxElement;
|
|
655
|
+
MessageIds: string;
|
|
656
|
+
ExtRuleDocs: {};
|
|
657
|
+
}> {
|
|
687
658
|
create(context: RuleContext): RuleListener;
|
|
688
659
|
}
|
|
689
660
|
|
|
690
661
|
type NodeTypes = ESTree.Node["type"];
|
|
691
662
|
|
|
692
|
-
interface NodeListener
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
}
|
|
702
|
-
> {}
|
|
663
|
+
interface NodeListener extends CustomRuleVisitorWithExit<
|
|
664
|
+
{
|
|
665
|
+
[Node in Rule.Node as Node["type"]]?:
|
|
666
|
+
((node: Node) => void) | undefined;
|
|
667
|
+
} & {
|
|
668
|
+
// A `Program` visitor's node type has no `parent` property.
|
|
669
|
+
Program?: ((node: AST.Program) => void) | undefined;
|
|
670
|
+
}
|
|
671
|
+
> {}
|
|
703
672
|
|
|
704
673
|
interface NodeParentExtension {
|
|
705
674
|
parent: Node;
|
|
@@ -753,6 +722,22 @@ export namespace Rule {
|
|
|
753
722
|
| "class-field-initializer"
|
|
754
723
|
| "class-static-block";
|
|
755
724
|
|
|
725
|
+
interface CodePathSegmentTraversalController {
|
|
726
|
+
skip(): void;
|
|
727
|
+
break(): void;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
type CodePathSegmentTraversalCallback = (
|
|
731
|
+
this: CodePath,
|
|
732
|
+
segment: CodePathSegment,
|
|
733
|
+
controller: CodePathSegmentTraversalController,
|
|
734
|
+
) => void;
|
|
735
|
+
|
|
736
|
+
interface CodePathTraversalOptions {
|
|
737
|
+
first?: CodePathSegment | undefined;
|
|
738
|
+
last?: CodePathSegment | undefined;
|
|
739
|
+
}
|
|
740
|
+
|
|
756
741
|
interface CodePath {
|
|
757
742
|
id: string;
|
|
758
743
|
origin: CodePathOrigin;
|
|
@@ -762,30 +747,36 @@ export namespace Rule {
|
|
|
762
747
|
thrownSegments: CodePathSegment[];
|
|
763
748
|
upper: CodePath | null;
|
|
764
749
|
childCodePaths: CodePath[];
|
|
750
|
+
traverseSegments(callback: CodePathSegmentTraversalCallback): void;
|
|
751
|
+
traverseSegments(
|
|
752
|
+
options: CodePathTraversalOptions,
|
|
753
|
+
callback: CodePathSegmentTraversalCallback,
|
|
754
|
+
): void;
|
|
765
755
|
}
|
|
766
756
|
|
|
767
757
|
interface CodePathSegment {
|
|
768
758
|
id: string;
|
|
769
759
|
nextSegments: CodePathSegment[];
|
|
770
760
|
prevSegments: CodePathSegment[];
|
|
761
|
+
allNextSegments: CodePathSegment[];
|
|
762
|
+
allPrevSegments: CodePathSegment[];
|
|
771
763
|
reachable: boolean;
|
|
772
764
|
}
|
|
773
765
|
|
|
774
766
|
type RuleMetaData = RulesMeta;
|
|
775
767
|
|
|
776
|
-
interface RuleContext
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
}> {}
|
|
768
|
+
interface RuleContext extends CoreRuleContext<{
|
|
769
|
+
LangOptions: Linter.LanguageOptions;
|
|
770
|
+
Code: SourceCode;
|
|
771
|
+
RuleOptions: any[];
|
|
772
|
+
Node: JSSyntaxElement;
|
|
773
|
+
MessageIds: string;
|
|
774
|
+
}> {}
|
|
784
775
|
|
|
785
776
|
type ReportFixer = CoreRuleFixer;
|
|
786
777
|
|
|
787
778
|
/** @deprecated Use `ReportDescriptorOptions` instead. */
|
|
788
|
-
type ReportDescriptorOptionsBase = ViolationReportBase
|
|
779
|
+
type ReportDescriptorOptionsBase = Omit<ViolationReportBase, "suggest">;
|
|
789
780
|
|
|
790
781
|
type SuggestionReportOptions = SuggestedEditBase;
|
|
791
782
|
type SuggestionDescriptorMessage = SuggestionMessage;
|
|
@@ -794,9 +785,9 @@ export namespace Rule {
|
|
|
794
785
|
// redundant with ReportDescriptorOptionsBase but kept for clarity
|
|
795
786
|
type ReportDescriptorOptions = ViolationReportBase;
|
|
796
787
|
|
|
797
|
-
type ReportDescriptor = ViolationReport<
|
|
788
|
+
type ReportDescriptor = ViolationReport<JSSyntaxElement>;
|
|
798
789
|
type ReportDescriptorMessage = ViolationMessage;
|
|
799
|
-
type ReportDescriptorLocation = ViolationLocation<
|
|
790
|
+
type ReportDescriptorLocation = ViolationLocation<JSSyntaxElement>;
|
|
800
791
|
|
|
801
792
|
type RuleFixer = RuleTextEditor<ESTree.Node | AST.Token>;
|
|
802
793
|
type Fix = RuleTextEdit;
|
|
@@ -823,43 +814,32 @@ export class Linter {
|
|
|
823
814
|
|
|
824
815
|
version: string;
|
|
825
816
|
|
|
826
|
-
constructor(options?: {
|
|
827
|
-
cwd?: string | undefined;
|
|
828
|
-
configType?: "flat" | "eslintrc";
|
|
829
|
-
});
|
|
817
|
+
constructor(options?: { cwd?: string | undefined; configType?: "flat" });
|
|
830
818
|
|
|
831
819
|
verify(
|
|
832
820
|
code: SourceCode | string,
|
|
833
|
-
config: Linter.
|
|
821
|
+
config: Linter.Config | Linter.Config[],
|
|
834
822
|
filename?: string,
|
|
835
823
|
): Linter.LintMessage[];
|
|
836
824
|
verify(
|
|
837
825
|
code: SourceCode | string,
|
|
838
|
-
config: Linter.
|
|
826
|
+
config: Linter.Config | Linter.Config[],
|
|
839
827
|
options: Linter.LintOptions,
|
|
840
828
|
): Linter.LintMessage[];
|
|
841
829
|
|
|
842
830
|
verifyAndFix(
|
|
843
831
|
code: string,
|
|
844
|
-
config: Linter.
|
|
832
|
+
config: Linter.Config | Linter.Config[],
|
|
845
833
|
filename?: string,
|
|
846
834
|
): Linter.FixReport;
|
|
847
835
|
verifyAndFix(
|
|
848
836
|
code: string,
|
|
849
|
-
config: Linter.
|
|
837
|
+
config: Linter.Config | Linter.Config[],
|
|
850
838
|
options: Linter.FixOptions,
|
|
851
839
|
): Linter.FixReport;
|
|
852
840
|
|
|
853
841
|
getSourceCode(): SourceCode;
|
|
854
842
|
|
|
855
|
-
defineRule(name: string, rule: Rule.RuleModule): void;
|
|
856
|
-
|
|
857
|
-
defineRules(rules: { [name: string]: Rule.RuleModule }): void;
|
|
858
|
-
|
|
859
|
-
getRules(): Map<string, Rule.RuleModule>;
|
|
860
|
-
|
|
861
|
-
defineParser(name: string, parser: Linter.Parser): void;
|
|
862
|
-
|
|
863
843
|
getTimes(): Linter.Stats["times"];
|
|
864
844
|
|
|
865
845
|
getFixPassCount(): Linter.Stats["fixPasses"];
|
|
@@ -961,7 +941,43 @@ export namespace Linter {
|
|
|
961
941
|
*
|
|
962
942
|
* @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
|
|
963
943
|
*/
|
|
964
|
-
|
|
944
|
+
interface ParserOptions {
|
|
945
|
+
/**
|
|
946
|
+
* Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
|
|
947
|
+
*
|
|
948
|
+
* @default false
|
|
949
|
+
*/
|
|
950
|
+
allowReserved?: boolean | undefined;
|
|
951
|
+
/**
|
|
952
|
+
* An object indicating which additional language features you'd like to use.
|
|
953
|
+
*
|
|
954
|
+
* @see https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options
|
|
955
|
+
*/
|
|
956
|
+
ecmaFeatures?:
|
|
957
|
+
| {
|
|
958
|
+
/**
|
|
959
|
+
* Allow `return` statements in the global scope.
|
|
960
|
+
*
|
|
961
|
+
* @default false
|
|
962
|
+
*/
|
|
963
|
+
globalReturn?: boolean | undefined;
|
|
964
|
+
/**
|
|
965
|
+
* Enable global [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) (if `ecmaVersion` is 5 or greater).
|
|
966
|
+
*
|
|
967
|
+
* @default false
|
|
968
|
+
*/
|
|
969
|
+
impliedStrict?: boolean | undefined;
|
|
970
|
+
/**
|
|
971
|
+
* Enable [JSX](https://react.github.io/jsx/).
|
|
972
|
+
*
|
|
973
|
+
* @default false
|
|
974
|
+
*/
|
|
975
|
+
jsx?: boolean | undefined;
|
|
976
|
+
[key: string]: any;
|
|
977
|
+
}
|
|
978
|
+
| undefined;
|
|
979
|
+
[key: string]: any;
|
|
980
|
+
}
|
|
965
981
|
|
|
966
982
|
/**
|
|
967
983
|
* Options used for linting code with `Linter#verify` and `Linter#verifyAndFix`.
|
|
@@ -970,11 +986,9 @@ export namespace Linter {
|
|
|
970
986
|
filename?: string | undefined;
|
|
971
987
|
preprocess?: ((code: string) => string[]) | undefined;
|
|
972
988
|
postprocess?:
|
|
973
|
-
|
|
974
|
-
| undefined;
|
|
989
|
+
((problemLists: LintMessage[][]) => LintMessage[]) | undefined;
|
|
975
990
|
filterCodeBlock?:
|
|
976
|
-
|
|
977
|
-
| undefined;
|
|
991
|
+
((filename: string, text: string) => boolean) | undefined;
|
|
978
992
|
disableFixes?: boolean | undefined;
|
|
979
993
|
allowInlineConfig?: boolean | undefined;
|
|
980
994
|
reportUnusedDisableDirectives?: boolean | undefined;
|
|
@@ -1111,8 +1125,9 @@ export namespace Linter {
|
|
|
1111
1125
|
interface TimePass {
|
|
1112
1126
|
/**
|
|
1113
1127
|
* The parse object containing all parse time information.
|
|
1128
|
+
* If no parsing was performed, the property is omitted.
|
|
1114
1129
|
*/
|
|
1115
|
-
parse
|
|
1130
|
+
parse?: { total: number };
|
|
1116
1131
|
|
|
1117
1132
|
/**
|
|
1118
1133
|
* The rules object containing all lint time information for each rule.
|
|
@@ -1195,74 +1210,98 @@ export namespace ESLint {
|
|
|
1195
1210
|
|
|
1196
1211
|
type CacheStrategy = "content" | "metadata";
|
|
1197
1212
|
|
|
1213
|
+
/** The options with which to configure the ESLint instance. */
|
|
1198
1214
|
interface Options {
|
|
1199
1215
|
// File enumeration
|
|
1216
|
+
|
|
1217
|
+
/** The value to use for the current working directory. */
|
|
1200
1218
|
cwd?: string | undefined;
|
|
1219
|
+
|
|
1220
|
+
/** If `false` then `ESLint#lintFiles()` doesn't throw even if no target files found. Defaults to `true`. */
|
|
1201
1221
|
errorOnUnmatchedPattern?: boolean | undefined;
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* Set to false to skip glob resolution of input file paths to lint (default: true).
|
|
1225
|
+
* If false, each input file path is assumed to be a non-glob path to an existing file.
|
|
1226
|
+
*/
|
|
1202
1227
|
globInputPaths?: boolean | undefined;
|
|
1228
|
+
|
|
1229
|
+
/** False disables all ignore patterns except for the default ones. */
|
|
1203
1230
|
ignore?: boolean | undefined;
|
|
1231
|
+
|
|
1232
|
+
/** Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`. */
|
|
1204
1233
|
ignorePatterns?: string[] | null | undefined;
|
|
1234
|
+
|
|
1235
|
+
/** When set to true, missing patterns cause the linting operation to short circuit and not report any failures. */
|
|
1205
1236
|
passOnNoPatterns?: boolean | undefined;
|
|
1237
|
+
|
|
1238
|
+
/** Show warnings when the file list includes ignored files. */
|
|
1206
1239
|
warnIgnored?: boolean | undefined;
|
|
1207
1240
|
|
|
1208
1241
|
// Linting
|
|
1242
|
+
|
|
1243
|
+
/** Enable or disable inline configuration comments. */
|
|
1209
1244
|
allowInlineConfig?: boolean | undefined;
|
|
1245
|
+
|
|
1246
|
+
/** Base config, extended by all configs used with this instance. */
|
|
1210
1247
|
baseConfig?: Linter.Config | Linter.Config[] | null | undefined;
|
|
1248
|
+
|
|
1249
|
+
/** Override config, overrides all configs used with this instance. */
|
|
1211
1250
|
overrideConfig?: Linter.Config | Linter.Config[] | null | undefined;
|
|
1251
|
+
|
|
1252
|
+
/**
|
|
1253
|
+
* Searches for default config file when falsy; doesn't do any config file lookup when `true`; considered to be a config filename when a string.
|
|
1254
|
+
*/
|
|
1212
1255
|
overrideConfigFile?: string | true | null | undefined;
|
|
1256
|
+
|
|
1257
|
+
/** An array of plugin implementations. */
|
|
1213
1258
|
plugins?: Record<string, Plugin> | null | undefined;
|
|
1259
|
+
|
|
1260
|
+
/**
|
|
1261
|
+
* Default is `() => true`. A predicate function that filters rules to be run.
|
|
1262
|
+
* This function is called with an object containing `ruleId` and `severity`, and returns `true` if the rule should be run.
|
|
1263
|
+
*/
|
|
1214
1264
|
ruleFilter?:
|
|
1215
1265
|
| ((arg: {
|
|
1216
1266
|
ruleId: string;
|
|
1217
1267
|
severity: Exclude<Linter.Severity, 0>;
|
|
1218
1268
|
}) => boolean)
|
|
1219
1269
|
| undefined;
|
|
1270
|
+
|
|
1271
|
+
/** True enables added statistics on lint results. */
|
|
1220
1272
|
stats?: boolean | undefined;
|
|
1221
1273
|
|
|
1222
1274
|
// Autofix
|
|
1275
|
+
|
|
1276
|
+
/** Execute in autofix mode. If a function, should return a boolean. */
|
|
1223
1277
|
fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined;
|
|
1278
|
+
|
|
1279
|
+
/** Array of rule types to apply fixes for. */
|
|
1224
1280
|
fixTypes?: FixType[] | null | undefined;
|
|
1225
1281
|
|
|
1226
1282
|
// Cache-related
|
|
1283
|
+
|
|
1284
|
+
/** Enable result caching. */
|
|
1227
1285
|
cache?: boolean | undefined;
|
|
1286
|
+
|
|
1287
|
+
/** The cache file to use instead of .eslintcache. */
|
|
1228
1288
|
cacheLocation?: string | undefined;
|
|
1229
|
-
cacheStrategy?: CacheStrategy | undefined;
|
|
1230
1289
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
flags?: string[] | undefined;
|
|
1234
|
-
}
|
|
1290
|
+
/** The strategy used to detect changed files. */
|
|
1291
|
+
cacheStrategy?: CacheStrategy | undefined;
|
|
1235
1292
|
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
cwd?: string | undefined;
|
|
1239
|
-
errorOnUnmatchedPattern?: boolean | undefined;
|
|
1240
|
-
extensions?: string[] | undefined;
|
|
1241
|
-
globInputPaths?: boolean | undefined;
|
|
1242
|
-
ignore?: boolean | undefined;
|
|
1243
|
-
ignorePath?: string | undefined;
|
|
1293
|
+
/** If true, apply suppressions automatically. Defaults to false. */
|
|
1294
|
+
applySuppressions?: boolean | undefined;
|
|
1244
1295
|
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
baseConfig?: Linter.LegacyConfig | undefined;
|
|
1248
|
-
overrideConfig?: Linter.LegacyConfig | undefined;
|
|
1249
|
-
overrideConfigFile?: string | undefined;
|
|
1250
|
-
plugins?: Record<string, Plugin> | undefined;
|
|
1251
|
-
reportUnusedDisableDirectives?: Linter.StringSeverity | undefined;
|
|
1252
|
-
resolvePluginsRelativeTo?: string | undefined;
|
|
1253
|
-
rulePaths?: string[] | undefined;
|
|
1254
|
-
useEslintrc?: boolean | undefined;
|
|
1296
|
+
/** Path to suppressions file. Relative to cwd. Defaults to eslint-suppressions.json in cwd. */
|
|
1297
|
+
suppressionsLocation?: string | undefined;
|
|
1255
1298
|
|
|
1256
|
-
//
|
|
1257
|
-
fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined;
|
|
1258
|
-
fixTypes?: FixType[] | null | undefined;
|
|
1299
|
+
// Other Options
|
|
1259
1300
|
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
cacheLocation?: string | undefined;
|
|
1263
|
-
cacheStrategy?: CacheStrategy | undefined;
|
|
1301
|
+
/** Maximum number of linting threads, "auto" to choose automatically, "off" for no multithreading. */
|
|
1302
|
+
concurrency?: number | "auto" | "off" | undefined;
|
|
1264
1303
|
|
|
1265
|
-
|
|
1304
|
+
/** Array of feature flags to enable. */
|
|
1266
1305
|
flags?: string[] | undefined;
|
|
1267
1306
|
}
|
|
1268
1307
|
|
|
@@ -1320,9 +1359,8 @@ export namespace ESLint {
|
|
|
1320
1359
|
foundWarnings: number;
|
|
1321
1360
|
}
|
|
1322
1361
|
|
|
1323
|
-
interface LintResultData {
|
|
1362
|
+
interface LintResultData extends ResultsMeta {
|
|
1324
1363
|
cwd: string;
|
|
1325
|
-
maxWarningsExceeded?: MaxWarningsExceeded | undefined;
|
|
1326
1364
|
rulesMeta: {
|
|
1327
1365
|
[ruleId: string]: Rule.RuleMetaData;
|
|
1328
1366
|
};
|
|
@@ -1354,6 +1392,14 @@ export namespace ESLint {
|
|
|
1354
1392
|
* Metadata about results for formatters.
|
|
1355
1393
|
*/
|
|
1356
1394
|
interface ResultsMeta {
|
|
1395
|
+
/**
|
|
1396
|
+
* Whether or not to use color in the formatter output.
|
|
1397
|
+
* - If `--color` was set, this property is `true`.
|
|
1398
|
+
* - If `--no-color` was set, it is `false`.
|
|
1399
|
+
* - If neither option was provided, the property is omitted.
|
|
1400
|
+
*/
|
|
1401
|
+
color?: boolean | undefined;
|
|
1402
|
+
|
|
1357
1403
|
/**
|
|
1358
1404
|
* Present if the maxWarnings threshold was exceeded.
|
|
1359
1405
|
*/
|
|
@@ -1365,9 +1411,9 @@ export namespace ESLint {
|
|
|
1365
1411
|
/**
|
|
1366
1412
|
* Used to call the underlying formatter.
|
|
1367
1413
|
* @param results An array of lint results to format.
|
|
1368
|
-
* @param resultsMeta An object with
|
|
1414
|
+
* @param resultsMeta An object with optional `color` and `maxWarningsExceeded` properties that will be
|
|
1369
1415
|
* passed to the underlying formatter function along with other properties set by ESLint.
|
|
1370
|
-
* This argument can be omitted if `maxWarningsExceeded`
|
|
1416
|
+
* This argument can be omitted if `color` and `maxWarningsExceeded` are not needed.
|
|
1371
1417
|
* @return The formatter output.
|
|
1372
1418
|
*/
|
|
1373
1419
|
format(
|
|
@@ -1396,15 +1442,10 @@ export namespace ESLint {
|
|
|
1396
1442
|
|
|
1397
1443
|
// #endregion
|
|
1398
1444
|
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
export function loadESLint(
|
|
1403
|
-
useFlatConfig: false;
|
|
1404
|
-
}): Promise<typeof LegacyESLint>;
|
|
1405
|
-
export function loadESLint(options?: {
|
|
1406
|
-
useFlatConfig?: boolean | undefined;
|
|
1407
|
-
}): Promise<typeof ESLint | typeof LegacyESLint>;
|
|
1445
|
+
/**
|
|
1446
|
+
* Loads the correct `ESLint` constructor.
|
|
1447
|
+
*/
|
|
1448
|
+
export function loadESLint(): Promise<typeof ESLint>;
|
|
1408
1449
|
|
|
1409
1450
|
// #region RuleTester
|
|
1410
1451
|
|
|
@@ -1412,6 +1453,9 @@ export class RuleTester {
|
|
|
1412
1453
|
static describe: ((...args: any) => any) | null;
|
|
1413
1454
|
static it: ((...args: any) => any) | null;
|
|
1414
1455
|
static itOnly: ((...args: any) => any) | null;
|
|
1456
|
+
static setDefaultConfig(config: Linter.Config): void;
|
|
1457
|
+
static getDefaultConfig(): Linter.Config;
|
|
1458
|
+
static resetDefaultConfig(): void;
|
|
1415
1459
|
|
|
1416
1460
|
constructor(config?: Linter.Config);
|
|
1417
1461
|
|
|
@@ -1421,6 +1465,32 @@ export class RuleTester {
|
|
|
1421
1465
|
tests: {
|
|
1422
1466
|
valid: Array<string | RuleTester.ValidTestCase>;
|
|
1423
1467
|
invalid: RuleTester.InvalidTestCase[];
|
|
1468
|
+
/**
|
|
1469
|
+
* Additional assertions for the "error" matchers of invalid test cases to enforce consistency.
|
|
1470
|
+
*/
|
|
1471
|
+
assertionOptions?: {
|
|
1472
|
+
/**
|
|
1473
|
+
* If true, each `errors` block must check the expected error
|
|
1474
|
+
* message, either via a string in the `errors` array, or via
|
|
1475
|
+
* `message`/`messageId` in an errors object.
|
|
1476
|
+
* `"message"`/`"messageId"` can be used to further limit the
|
|
1477
|
+
* message assertions to the respective versions.
|
|
1478
|
+
*/
|
|
1479
|
+
requireMessage?: boolean | "message" | "messageId";
|
|
1480
|
+
/**
|
|
1481
|
+
* If true, each `errors` block must be an array of objects,
|
|
1482
|
+
* that each check all location properties `line`, `column`,
|
|
1483
|
+
* `endLine`, `endColumn`, the later may be omitted, if the
|
|
1484
|
+
* error does not contain them.
|
|
1485
|
+
*/
|
|
1486
|
+
requireLocation?: boolean;
|
|
1487
|
+
/**
|
|
1488
|
+
* If true, each error and suggestion with a `messageId` must specify a `data`
|
|
1489
|
+
* property if the referenced message contains placeholders.
|
|
1490
|
+
* `"error"` and `"suggestion" limit the assertion to errors and suggestions respectively.
|
|
1491
|
+
*/
|
|
1492
|
+
requireData?: boolean | "error" | "suggestion";
|
|
1493
|
+
};
|
|
1424
1494
|
},
|
|
1425
1495
|
): void;
|
|
1426
1496
|
|
|
@@ -1430,14 +1500,21 @@ export class RuleTester {
|
|
|
1430
1500
|
}
|
|
1431
1501
|
|
|
1432
1502
|
export namespace RuleTester {
|
|
1433
|
-
interface ValidTestCase
|
|
1503
|
+
interface ValidTestCase extends Omit<
|
|
1504
|
+
Linter.Config,
|
|
1505
|
+
| "name"
|
|
1506
|
+
| "basePath"
|
|
1507
|
+
| "files"
|
|
1508
|
+
| "ignores"
|
|
1509
|
+
| "linterOptions"
|
|
1510
|
+
| "plugins"
|
|
1511
|
+
| "rules"
|
|
1512
|
+
> {
|
|
1434
1513
|
name?: string;
|
|
1435
1514
|
code: string;
|
|
1436
|
-
options?: any;
|
|
1515
|
+
options?: any[];
|
|
1437
1516
|
filename?: string | undefined;
|
|
1438
1517
|
only?: boolean;
|
|
1439
|
-
languageOptions?: Linter.LanguageOptions | undefined;
|
|
1440
|
-
settings?: { [name: string]: any } | undefined;
|
|
1441
1518
|
before?: () => void;
|
|
1442
1519
|
after?: () => void;
|
|
1443
1520
|
}
|
|
@@ -1445,28 +1522,24 @@ export namespace RuleTester {
|
|
|
1445
1522
|
interface SuggestionOutput {
|
|
1446
1523
|
messageId?: string;
|
|
1447
1524
|
desc?: string;
|
|
1448
|
-
data?:
|
|
1525
|
+
data?: MessagePlaceholderData | undefined;
|
|
1449
1526
|
output: string;
|
|
1450
1527
|
}
|
|
1451
1528
|
|
|
1452
1529
|
interface InvalidTestCase extends ValidTestCase {
|
|
1453
|
-
errors: number | Array<TestCaseError | string>;
|
|
1530
|
+
errors: number | Array<TestCaseError | string | RegExp>;
|
|
1454
1531
|
output?: string | null | undefined;
|
|
1455
1532
|
}
|
|
1456
1533
|
|
|
1457
1534
|
interface TestCaseError {
|
|
1458
1535
|
message?: string | RegExp;
|
|
1459
1536
|
messageId?: string;
|
|
1460
|
-
|
|
1461
|
-
* @deprecated `type` is deprecated and will be removed in the next major version.
|
|
1462
|
-
*/
|
|
1463
|
-
type?: string | undefined;
|
|
1464
|
-
data?: any;
|
|
1537
|
+
data?: MessagePlaceholderData | undefined;
|
|
1465
1538
|
line?: number | undefined;
|
|
1466
1539
|
column?: number | undefined;
|
|
1467
1540
|
endLine?: number | undefined;
|
|
1468
1541
|
endColumn?: number | undefined;
|
|
1469
|
-
suggestions?: SuggestionOutput[] | undefined;
|
|
1542
|
+
suggestions?: SuggestionOutput[] | number | undefined;
|
|
1470
1543
|
}
|
|
1471
1544
|
}
|
|
1472
1545
|
|