eslint-cli-bundle 1.0.5 → 2.0.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.
- package/dist/api.d.ts +209 -157
- package/dist/api.js +7 -5
- package/dist/eslint-BTrx12MV.js +256 -0
- package/dist/eslint.js +11 -12
- package/dist/{jiti-DyCiGFB9.js → jiti-BvM1NyiB.js} +1 -1
- package/dist/{types-CRoZH7Is.d.ts → types-CXey2reC.d.ts} +17 -54
- package/package.json +15 -10
- package/dist/legacy-eslint-DYfSFaC6.js +0 -269
- /package/dist/{src-FNB-unmu.js → src-D7slgxDU.js} +0 -0
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,30 @@ 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)
|
|
667
|
+
| undefined;
|
|
668
|
+
} & {
|
|
669
|
+
// A `Program` visitor's node type has no `parent` property.
|
|
670
|
+
Program?: ((node: AST.Program) => void) | undefined;
|
|
671
|
+
}
|
|
672
|
+
> {}
|
|
703
673
|
|
|
704
674
|
interface NodeParentExtension {
|
|
705
675
|
parent: Node;
|
|
@@ -773,19 +743,18 @@ export namespace Rule {
|
|
|
773
743
|
|
|
774
744
|
type RuleMetaData = RulesMeta;
|
|
775
745
|
|
|
776
|
-
interface RuleContext
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
}> {}
|
|
746
|
+
interface RuleContext extends CoreRuleContext<{
|
|
747
|
+
LangOptions: Linter.LanguageOptions;
|
|
748
|
+
Code: SourceCode;
|
|
749
|
+
RuleOptions: any[];
|
|
750
|
+
Node: JSSyntaxElement;
|
|
751
|
+
MessageIds: string;
|
|
752
|
+
}> {}
|
|
784
753
|
|
|
785
754
|
type ReportFixer = CoreRuleFixer;
|
|
786
755
|
|
|
787
756
|
/** @deprecated Use `ReportDescriptorOptions` instead. */
|
|
788
|
-
type ReportDescriptorOptionsBase = ViolationReportBase
|
|
757
|
+
type ReportDescriptorOptionsBase = Omit<ViolationReportBase, "suggest">;
|
|
789
758
|
|
|
790
759
|
type SuggestionReportOptions = SuggestedEditBase;
|
|
791
760
|
type SuggestionDescriptorMessage = SuggestionMessage;
|
|
@@ -794,9 +763,9 @@ export namespace Rule {
|
|
|
794
763
|
// redundant with ReportDescriptorOptionsBase but kept for clarity
|
|
795
764
|
type ReportDescriptorOptions = ViolationReportBase;
|
|
796
765
|
|
|
797
|
-
type ReportDescriptor = ViolationReport<
|
|
766
|
+
type ReportDescriptor = ViolationReport<JSSyntaxElement>;
|
|
798
767
|
type ReportDescriptorMessage = ViolationMessage;
|
|
799
|
-
type ReportDescriptorLocation = ViolationLocation<
|
|
768
|
+
type ReportDescriptorLocation = ViolationLocation<JSSyntaxElement>;
|
|
800
769
|
|
|
801
770
|
type RuleFixer = RuleTextEditor<ESTree.Node | AST.Token>;
|
|
802
771
|
type Fix = RuleTextEdit;
|
|
@@ -823,43 +792,32 @@ export class Linter {
|
|
|
823
792
|
|
|
824
793
|
version: string;
|
|
825
794
|
|
|
826
|
-
constructor(options?: {
|
|
827
|
-
cwd?: string | undefined;
|
|
828
|
-
configType?: "flat" | "eslintrc";
|
|
829
|
-
});
|
|
795
|
+
constructor(options?: { cwd?: string | undefined; configType?: "flat" });
|
|
830
796
|
|
|
831
797
|
verify(
|
|
832
798
|
code: SourceCode | string,
|
|
833
|
-
config: Linter.
|
|
799
|
+
config: Linter.Config | Linter.Config[],
|
|
834
800
|
filename?: string,
|
|
835
801
|
): Linter.LintMessage[];
|
|
836
802
|
verify(
|
|
837
803
|
code: SourceCode | string,
|
|
838
|
-
config: Linter.
|
|
804
|
+
config: Linter.Config | Linter.Config[],
|
|
839
805
|
options: Linter.LintOptions,
|
|
840
806
|
): Linter.LintMessage[];
|
|
841
807
|
|
|
842
808
|
verifyAndFix(
|
|
843
809
|
code: string,
|
|
844
|
-
config: Linter.
|
|
810
|
+
config: Linter.Config | Linter.Config[],
|
|
845
811
|
filename?: string,
|
|
846
812
|
): Linter.FixReport;
|
|
847
813
|
verifyAndFix(
|
|
848
814
|
code: string,
|
|
849
|
-
config: Linter.
|
|
815
|
+
config: Linter.Config | Linter.Config[],
|
|
850
816
|
options: Linter.FixOptions,
|
|
851
817
|
): Linter.FixReport;
|
|
852
818
|
|
|
853
819
|
getSourceCode(): SourceCode;
|
|
854
820
|
|
|
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
821
|
getTimes(): Linter.Stats["times"];
|
|
864
822
|
|
|
865
823
|
getFixPassCount(): Linter.Stats["fixPasses"];
|
|
@@ -961,7 +919,43 @@ export namespace Linter {
|
|
|
961
919
|
*
|
|
962
920
|
* @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
|
|
963
921
|
*/
|
|
964
|
-
|
|
922
|
+
interface ParserOptions {
|
|
923
|
+
/**
|
|
924
|
+
* Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
|
|
925
|
+
*
|
|
926
|
+
* @default false
|
|
927
|
+
*/
|
|
928
|
+
allowReserved?: boolean | undefined;
|
|
929
|
+
/**
|
|
930
|
+
* An object indicating which additional language features you'd like to use.
|
|
931
|
+
*
|
|
932
|
+
* @see https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options
|
|
933
|
+
*/
|
|
934
|
+
ecmaFeatures?:
|
|
935
|
+
| {
|
|
936
|
+
/**
|
|
937
|
+
* Allow `return` statements in the global scope.
|
|
938
|
+
*
|
|
939
|
+
* @default false
|
|
940
|
+
*/
|
|
941
|
+
globalReturn?: boolean | undefined;
|
|
942
|
+
/**
|
|
943
|
+
* Enable global [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode) (if `ecmaVersion` is 5 or greater).
|
|
944
|
+
*
|
|
945
|
+
* @default false
|
|
946
|
+
*/
|
|
947
|
+
impliedStrict?: boolean | undefined;
|
|
948
|
+
/**
|
|
949
|
+
* Enable [JSX](https://facebook.github.io/jsx/).
|
|
950
|
+
*
|
|
951
|
+
* @default false
|
|
952
|
+
*/
|
|
953
|
+
jsx?: boolean | undefined;
|
|
954
|
+
[key: string]: any;
|
|
955
|
+
}
|
|
956
|
+
| undefined;
|
|
957
|
+
[key: string]: any;
|
|
958
|
+
}
|
|
965
959
|
|
|
966
960
|
/**
|
|
967
961
|
* Options used for linting code with `Linter#verify` and `Linter#verifyAndFix`.
|
|
@@ -1195,74 +1189,98 @@ export namespace ESLint {
|
|
|
1195
1189
|
|
|
1196
1190
|
type CacheStrategy = "content" | "metadata";
|
|
1197
1191
|
|
|
1192
|
+
/** The options with which to configure the ESLint instance. */
|
|
1198
1193
|
interface Options {
|
|
1199
1194
|
// File enumeration
|
|
1195
|
+
|
|
1196
|
+
/** The value to use for the current working directory. */
|
|
1200
1197
|
cwd?: string | undefined;
|
|
1198
|
+
|
|
1199
|
+
/** If `false` then `ESLint#lintFiles()` doesn't throw even if no target files found. Defaults to `true`. */
|
|
1201
1200
|
errorOnUnmatchedPattern?: boolean | undefined;
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Set to false to skip glob resolution of input file paths to lint (default: true).
|
|
1204
|
+
* If false, each input file path is assumed to be a non-glob path to an existing file.
|
|
1205
|
+
*/
|
|
1202
1206
|
globInputPaths?: boolean | undefined;
|
|
1207
|
+
|
|
1208
|
+
/** False disables all ignore patterns except for the default ones. */
|
|
1203
1209
|
ignore?: boolean | undefined;
|
|
1210
|
+
|
|
1211
|
+
/** Ignore file patterns to use in addition to config ignores. These patterns are relative to `cwd`. */
|
|
1204
1212
|
ignorePatterns?: string[] | null | undefined;
|
|
1213
|
+
|
|
1214
|
+
/** When set to true, missing patterns cause the linting operation to short circuit and not report any failures. */
|
|
1205
1215
|
passOnNoPatterns?: boolean | undefined;
|
|
1216
|
+
|
|
1217
|
+
/** Show warnings when the file list includes ignored files. */
|
|
1206
1218
|
warnIgnored?: boolean | undefined;
|
|
1207
1219
|
|
|
1208
1220
|
// Linting
|
|
1221
|
+
|
|
1222
|
+
/** Enable or disable inline configuration comments. */
|
|
1209
1223
|
allowInlineConfig?: boolean | undefined;
|
|
1224
|
+
|
|
1225
|
+
/** Base config, extended by all configs used with this instance. */
|
|
1210
1226
|
baseConfig?: Linter.Config | Linter.Config[] | null | undefined;
|
|
1227
|
+
|
|
1228
|
+
/** Override config, overrides all configs used with this instance. */
|
|
1211
1229
|
overrideConfig?: Linter.Config | Linter.Config[] | null | undefined;
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* 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.
|
|
1233
|
+
*/
|
|
1212
1234
|
overrideConfigFile?: string | true | null | undefined;
|
|
1235
|
+
|
|
1236
|
+
/** An array of plugin implementations. */
|
|
1213
1237
|
plugins?: Record<string, Plugin> | null | undefined;
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Default is `() => true`. A predicate function that filters rules to be run.
|
|
1241
|
+
* This function is called with an object containing `ruleId` and `severity`, and returns `true` if the rule should be run.
|
|
1242
|
+
*/
|
|
1214
1243
|
ruleFilter?:
|
|
1215
1244
|
| ((arg: {
|
|
1216
1245
|
ruleId: string;
|
|
1217
1246
|
severity: Exclude<Linter.Severity, 0>;
|
|
1218
1247
|
}) => boolean)
|
|
1219
1248
|
| undefined;
|
|
1249
|
+
|
|
1250
|
+
/** True enables added statistics on lint results. */
|
|
1220
1251
|
stats?: boolean | undefined;
|
|
1221
1252
|
|
|
1222
1253
|
// Autofix
|
|
1254
|
+
|
|
1255
|
+
/** Execute in autofix mode. If a function, should return a boolean. */
|
|
1223
1256
|
fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined;
|
|
1257
|
+
|
|
1258
|
+
/** Array of rule types to apply fixes for. */
|
|
1224
1259
|
fixTypes?: FixType[] | null | undefined;
|
|
1225
1260
|
|
|
1226
1261
|
// Cache-related
|
|
1262
|
+
|
|
1263
|
+
/** Enable result caching. */
|
|
1227
1264
|
cache?: boolean | undefined;
|
|
1265
|
+
|
|
1266
|
+
/** The cache file to use instead of .eslintcache. */
|
|
1228
1267
|
cacheLocation?: string | undefined;
|
|
1229
|
-
cacheStrategy?: CacheStrategy | undefined;
|
|
1230
1268
|
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
flags?: string[] | undefined;
|
|
1234
|
-
}
|
|
1269
|
+
/** The strategy used to detect changed files. */
|
|
1270
|
+
cacheStrategy?: CacheStrategy | undefined;
|
|
1235
1271
|
|
|
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;
|
|
1272
|
+
/** If true, apply suppressions automatically. Defaults to false. */
|
|
1273
|
+
applySuppressions?: boolean | undefined;
|
|
1244
1274
|
|
|
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;
|
|
1275
|
+
/** Path to suppressions file. Relative to cwd. Defaults to eslint-suppressions.json in cwd. */
|
|
1276
|
+
suppressionsLocation?: string | undefined;
|
|
1255
1277
|
|
|
1256
|
-
//
|
|
1257
|
-
fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined;
|
|
1258
|
-
fixTypes?: FixType[] | null | undefined;
|
|
1278
|
+
// Other Options
|
|
1259
1279
|
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
cacheLocation?: string | undefined;
|
|
1263
|
-
cacheStrategy?: CacheStrategy | undefined;
|
|
1280
|
+
/** Maximum number of linting threads, "auto" to choose automatically, "off" for no multithreading. */
|
|
1281
|
+
concurrency?: number | "auto" | "off" | undefined;
|
|
1264
1282
|
|
|
1265
|
-
|
|
1283
|
+
/** Array of feature flags to enable. */
|
|
1266
1284
|
flags?: string[] | undefined;
|
|
1267
1285
|
}
|
|
1268
1286
|
|
|
@@ -1320,9 +1338,8 @@ export namespace ESLint {
|
|
|
1320
1338
|
foundWarnings: number;
|
|
1321
1339
|
}
|
|
1322
1340
|
|
|
1323
|
-
interface LintResultData {
|
|
1341
|
+
interface LintResultData extends ResultsMeta {
|
|
1324
1342
|
cwd: string;
|
|
1325
|
-
maxWarningsExceeded?: MaxWarningsExceeded | undefined;
|
|
1326
1343
|
rulesMeta: {
|
|
1327
1344
|
[ruleId: string]: Rule.RuleMetaData;
|
|
1328
1345
|
};
|
|
@@ -1354,6 +1371,14 @@ export namespace ESLint {
|
|
|
1354
1371
|
* Metadata about results for formatters.
|
|
1355
1372
|
*/
|
|
1356
1373
|
interface ResultsMeta {
|
|
1374
|
+
/**
|
|
1375
|
+
* Whether or not to use color in the formatter output.
|
|
1376
|
+
* - If `--color` was set, this property is `true`.
|
|
1377
|
+
* - If `--no-color` was set, it is `false`.
|
|
1378
|
+
* - If neither option was provided, the property is omitted.
|
|
1379
|
+
*/
|
|
1380
|
+
color?: boolean | undefined;
|
|
1381
|
+
|
|
1357
1382
|
/**
|
|
1358
1383
|
* Present if the maxWarnings threshold was exceeded.
|
|
1359
1384
|
*/
|
|
@@ -1365,9 +1390,9 @@ export namespace ESLint {
|
|
|
1365
1390
|
/**
|
|
1366
1391
|
* Used to call the underlying formatter.
|
|
1367
1392
|
* @param results An array of lint results to format.
|
|
1368
|
-
* @param resultsMeta An object with
|
|
1393
|
+
* @param resultsMeta An object with optional `color` and `maxWarningsExceeded` properties that will be
|
|
1369
1394
|
* passed to the underlying formatter function along with other properties set by ESLint.
|
|
1370
|
-
* This argument can be omitted if `maxWarningsExceeded`
|
|
1395
|
+
* This argument can be omitted if `color` and `maxWarningsExceeded` are not needed.
|
|
1371
1396
|
* @return The formatter output.
|
|
1372
1397
|
*/
|
|
1373
1398
|
format(
|
|
@@ -1396,15 +1421,10 @@ export namespace ESLint {
|
|
|
1396
1421
|
|
|
1397
1422
|
// #endregion
|
|
1398
1423
|
|
|
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>;
|
|
1424
|
+
/**
|
|
1425
|
+
* Loads the correct `ESLint` constructor.
|
|
1426
|
+
*/
|
|
1427
|
+
export function loadESLint(): Promise<typeof ESLint>;
|
|
1408
1428
|
|
|
1409
1429
|
// #region RuleTester
|
|
1410
1430
|
|
|
@@ -1412,6 +1432,9 @@ export class RuleTester {
|
|
|
1412
1432
|
static describe: ((...args: any) => any) | null;
|
|
1413
1433
|
static it: ((...args: any) => any) | null;
|
|
1414
1434
|
static itOnly: ((...args: any) => any) | null;
|
|
1435
|
+
static setDefaultConfig(config: Linter.Config): void;
|
|
1436
|
+
static getDefaultConfig(): Linter.Config;
|
|
1437
|
+
static resetDefaultConfig(): void;
|
|
1415
1438
|
|
|
1416
1439
|
constructor(config?: Linter.Config);
|
|
1417
1440
|
|
|
@@ -1421,6 +1444,32 @@ export class RuleTester {
|
|
|
1421
1444
|
tests: {
|
|
1422
1445
|
valid: Array<string | RuleTester.ValidTestCase>;
|
|
1423
1446
|
invalid: RuleTester.InvalidTestCase[];
|
|
1447
|
+
/**
|
|
1448
|
+
* Additional assertions for the "error" matchers of invalid test cases to enforce consistency.
|
|
1449
|
+
*/
|
|
1450
|
+
assertionOptions?: {
|
|
1451
|
+
/**
|
|
1452
|
+
* If true, each `errors` block must check the expected error
|
|
1453
|
+
* message, either via a string in the `errors` array, or via
|
|
1454
|
+
* `message`/`messageId` in an errors object.
|
|
1455
|
+
* `"message"`/`"messageId"` can be used to further limit the
|
|
1456
|
+
* message assertions to the respective versions.
|
|
1457
|
+
*/
|
|
1458
|
+
requireMessage?: boolean | "message" | "messageId";
|
|
1459
|
+
/**
|
|
1460
|
+
* If true, each `errors` block must be an array of objects,
|
|
1461
|
+
* that each check all location properties `line`, `column`,
|
|
1462
|
+
* `endLine`, `endColumn`, the later may be omitted, if the
|
|
1463
|
+
* error does not contain them.
|
|
1464
|
+
*/
|
|
1465
|
+
requireLocation?: boolean;
|
|
1466
|
+
/**
|
|
1467
|
+
* If true, each error and suggestion with a `messageId` must specify a `data`
|
|
1468
|
+
* property if the referenced message contains placeholders.
|
|
1469
|
+
* `"error"` and `"suggestion" limit the assertion to errors and suggestions respectively.
|
|
1470
|
+
*/
|
|
1471
|
+
requireData?: boolean | "error" | "suggestion";
|
|
1472
|
+
};
|
|
1424
1473
|
},
|
|
1425
1474
|
): void;
|
|
1426
1475
|
|
|
@@ -1430,14 +1479,21 @@ export class RuleTester {
|
|
|
1430
1479
|
}
|
|
1431
1480
|
|
|
1432
1481
|
export namespace RuleTester {
|
|
1433
|
-
interface ValidTestCase
|
|
1482
|
+
interface ValidTestCase extends Omit<
|
|
1483
|
+
Linter.Config,
|
|
1484
|
+
| "name"
|
|
1485
|
+
| "basePath"
|
|
1486
|
+
| "files"
|
|
1487
|
+
| "ignores"
|
|
1488
|
+
| "linterOptions"
|
|
1489
|
+
| "plugins"
|
|
1490
|
+
| "rules"
|
|
1491
|
+
> {
|
|
1434
1492
|
name?: string;
|
|
1435
1493
|
code: string;
|
|
1436
|
-
options?: any;
|
|
1494
|
+
options?: any[];
|
|
1437
1495
|
filename?: string | undefined;
|
|
1438
1496
|
only?: boolean;
|
|
1439
|
-
languageOptions?: Linter.LanguageOptions | undefined;
|
|
1440
|
-
settings?: { [name: string]: any } | undefined;
|
|
1441
1497
|
before?: () => void;
|
|
1442
1498
|
after?: () => void;
|
|
1443
1499
|
}
|
|
@@ -1445,28 +1501,24 @@ export namespace RuleTester {
|
|
|
1445
1501
|
interface SuggestionOutput {
|
|
1446
1502
|
messageId?: string;
|
|
1447
1503
|
desc?: string;
|
|
1448
|
-
data?:
|
|
1504
|
+
data?: MessagePlaceholderData | undefined;
|
|
1449
1505
|
output: string;
|
|
1450
1506
|
}
|
|
1451
1507
|
|
|
1452
1508
|
interface InvalidTestCase extends ValidTestCase {
|
|
1453
|
-
errors: number | Array<TestCaseError | string>;
|
|
1509
|
+
errors: number | Array<TestCaseError | string | RegExp>;
|
|
1454
1510
|
output?: string | null | undefined;
|
|
1455
1511
|
}
|
|
1456
1512
|
|
|
1457
1513
|
interface TestCaseError {
|
|
1458
1514
|
message?: string | RegExp;
|
|
1459
1515
|
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;
|
|
1516
|
+
data?: MessagePlaceholderData | undefined;
|
|
1465
1517
|
line?: number | undefined;
|
|
1466
1518
|
column?: number | undefined;
|
|
1467
1519
|
endLine?: number | undefined;
|
|
1468
1520
|
endColumn?: number | undefined;
|
|
1469
|
-
suggestions?: SuggestionOutput[] | undefined;
|
|
1521
|
+
suggestions?: SuggestionOutput[] | number | undefined;
|
|
1470
1522
|
}
|
|
1471
1523
|
}
|
|
1472
1524
|
|