@depup/typescript-eslint__utils 8.57.1-depup.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/LICENSE +21 -0
- package/README.md +25 -0
- package/changes.json +5 -0
- package/dist/ast-utils/eslint-utils/PatternMatcher.d.ts +47 -0
- package/dist/ast-utils/eslint-utils/PatternMatcher.js +44 -0
- package/dist/ast-utils/eslint-utils/ReferenceTracker.d.ts +75 -0
- package/dist/ast-utils/eslint-utils/ReferenceTracker.js +48 -0
- package/dist/ast-utils/eslint-utils/astUtilities.d.ts +83 -0
- package/dist/ast-utils/eslint-utils/astUtilities.js +101 -0
- package/dist/ast-utils/eslint-utils/index.d.ts +5 -0
- package/dist/ast-utils/eslint-utils/index.js +21 -0
- package/dist/ast-utils/eslint-utils/predicates.d.ts +31 -0
- package/dist/ast-utils/eslint-utils/predicates.js +59 -0
- package/dist/ast-utils/eslint-utils/scopeAnalysis.d.ts +16 -0
- package/dist/ast-utils/eslint-utils/scopeAnalysis.js +51 -0
- package/dist/ast-utils/helpers.d.ts +18 -0
- package/dist/ast-utils/helpers.js +21 -0
- package/dist/ast-utils/index.d.ts +4 -0
- package/dist/ast-utils/index.js +20 -0
- package/dist/ast-utils/misc.d.ts +6 -0
- package/dist/ast-utils/misc.js +11 -0
- package/dist/ast-utils/predicates.d.ts +68 -0
- package/dist/ast-utils/predicates.js +108 -0
- package/dist/eslint-utils/InferTypesFromRule.d.ts +9 -0
- package/dist/eslint-utils/InferTypesFromRule.js +2 -0
- package/dist/eslint-utils/RuleCreator.d.ts +32 -0
- package/dist/eslint-utils/RuleCreator.js +54 -0
- package/dist/eslint-utils/applyDefault.d.ts +8 -0
- package/dist/eslint-utils/applyDefault.js +33 -0
- package/dist/eslint-utils/deepMerge.d.ts +14 -0
- package/dist/eslint-utils/deepMerge.js +46 -0
- package/dist/eslint-utils/getParserServices.d.ts +22 -0
- package/dist/eslint-utils/getParserServices.js +41 -0
- package/dist/eslint-utils/index.d.ts +6 -0
- package/dist/eslint-utils/index.js +22 -0
- package/dist/eslint-utils/nullThrows.d.ts +12 -0
- package/dist/eslint-utils/nullThrows.js +21 -0
- package/dist/eslint-utils/parserSeemsToBeTSESLint.d.ts +1 -0
- package/dist/eslint-utils/parserSeemsToBeTSESLint.js +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +45 -0
- package/dist/json-schema.d.ts +387 -0
- package/dist/json-schema.js +8 -0
- package/dist/ts-eslint/AST.d.ts +8 -0
- package/dist/ts-eslint/AST.js +3 -0
- package/dist/ts-eslint/Config.d.ts +291 -0
- package/dist/ts-eslint/Config.js +3 -0
- package/dist/ts-eslint/ESLint.d.ts +7 -0
- package/dist/ts-eslint/ESLint.js +13 -0
- package/dist/ts-eslint/Linter.d.ts +255 -0
- package/dist/ts-eslint/Linter.js +13 -0
- package/dist/ts-eslint/Parser.d.ts +94 -0
- package/dist/ts-eslint/Parser.js +3 -0
- package/dist/ts-eslint/ParserOptions.d.ts +1 -0
- package/dist/ts-eslint/ParserOptions.js +2 -0
- package/dist/ts-eslint/Processor.d.ts +63 -0
- package/dist/ts-eslint/Processor.js +3 -0
- package/dist/ts-eslint/Rule.d.ts +614 -0
- package/dist/ts-eslint/Rule.js +2 -0
- package/dist/ts-eslint/RuleTester.d.ts +183 -0
- package/dist/ts-eslint/RuleTester.js +11 -0
- package/dist/ts-eslint/Scope.d.ts +42 -0
- package/dist/ts-eslint/Scope.js +43 -0
- package/dist/ts-eslint/SourceCode.d.ts +354 -0
- package/dist/ts-eslint/SourceCode.js +8 -0
- package/dist/ts-eslint/eslint/ESLintShared.d.ts +381 -0
- package/dist/ts-eslint/eslint/ESLintShared.js +2 -0
- package/dist/ts-eslint/eslint/FlatESLint.d.ts +87 -0
- package/dist/ts-eslint/eslint/FlatESLint.js +19 -0
- package/dist/ts-eslint/eslint/LegacyESLint.d.ts +72 -0
- package/dist/ts-eslint/eslint/LegacyESLint.js +36 -0
- package/dist/ts-eslint/index.d.ts +11 -0
- package/dist/ts-eslint/index.js +27 -0
- package/dist/ts-estree.d.ts +3 -0
- package/dist/ts-estree.js +9 -0
- package/dist/ts-utils/NoInfer.d.ts +9 -0
- package/dist/ts-utils/NoInfer.js +2 -0
- package/dist/ts-utils/index.d.ts +2 -0
- package/dist/ts-utils/index.js +18 -0
- package/dist/ts-utils/isArray.d.ts +1 -0
- package/dist/ts-utils/isArray.js +7 -0
- package/package.json +120 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import type { Linter } from '../Linter';
|
|
2
|
+
import type { RuleMetaData } from '../Rule';
|
|
3
|
+
export declare class ESLintBase<Config extends Linter.ConfigType, Options extends ESLintOptions<Config>> {
|
|
4
|
+
/**
|
|
5
|
+
* Creates a new instance of the main ESLint API.
|
|
6
|
+
* @param options The options for this instance.
|
|
7
|
+
*/
|
|
8
|
+
constructor(options?: Options);
|
|
9
|
+
/**
|
|
10
|
+
* This method calculates the configuration for a given file, which can be useful for debugging purposes.
|
|
11
|
+
* - It resolves and merges extends and overrides settings into the top level configuration.
|
|
12
|
+
* - It resolves the parser setting to absolute paths.
|
|
13
|
+
* - It normalizes the plugins setting to align short names. (e.g., eslint-plugin-foo → foo)
|
|
14
|
+
* - It adds the processor setting if a legacy file extension processor is matched.
|
|
15
|
+
* - It doesn't interpret the env setting to the globals and parserOptions settings, so the result object contains
|
|
16
|
+
* the env setting as is.
|
|
17
|
+
* @param filePath The path to the file whose configuration you would like to calculate. Directory paths are forbidden
|
|
18
|
+
* because ESLint cannot handle the overrides setting.
|
|
19
|
+
* @returns The promise that will be fulfilled with a configuration object.
|
|
20
|
+
*/
|
|
21
|
+
calculateConfigForFile(filePath: string): Promise<Config>;
|
|
22
|
+
getRulesMetaForResults(results: LintResult[]): Record<string, RuleMetaData<string, Record<string, unknown>>>;
|
|
23
|
+
/**
|
|
24
|
+
* This method checks if a given file is ignored by your configuration.
|
|
25
|
+
* @param filePath The path to the file you want to check.
|
|
26
|
+
* @returns The promise that will be fulfilled with whether the file is ignored or not. If the file is ignored, then
|
|
27
|
+
* it will return true.
|
|
28
|
+
*/
|
|
29
|
+
isPathIgnored(filePath: string): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* This method lints the files that match the glob patterns and then returns the results.
|
|
32
|
+
* @param patterns The lint target files. This can contain any of file paths, directory paths, and glob patterns.
|
|
33
|
+
* @returns The promise that will be fulfilled with an array of LintResult objects.
|
|
34
|
+
*/
|
|
35
|
+
lintFiles(patterns: string | string[]): Promise<LintResult[]>;
|
|
36
|
+
/**
|
|
37
|
+
* This method lints the given source code text and then returns the results.
|
|
38
|
+
*
|
|
39
|
+
* By default, this method uses the configuration that applies to files in the current working directory (the cwd
|
|
40
|
+
* constructor option). If you want to use a different configuration, pass options.filePath, and ESLint will load the
|
|
41
|
+
* same configuration that eslint.lintFiles() would use for a file at options.filePath.
|
|
42
|
+
*
|
|
43
|
+
* If the options.filePath value is configured to be ignored, this method returns an empty array. If the
|
|
44
|
+
* options.warnIgnored option is set along with the options.filePath option, this method returns a LintResult object.
|
|
45
|
+
* In that case, the result may contain a warning that indicates the file was ignored.
|
|
46
|
+
* @param code The source code text to check.
|
|
47
|
+
* @returns The promise that will be fulfilled with an array of LintResult objects. This is an array (despite there
|
|
48
|
+
* being only one lint result) in order to keep the interfaces between this and the eslint.lintFiles()
|
|
49
|
+
* method similar.
|
|
50
|
+
*/
|
|
51
|
+
lintText(code: string, options?: LintTextOptions): Promise<LintResult[]>;
|
|
52
|
+
/**
|
|
53
|
+
* This method loads a formatter. Formatters convert lint results to a human- or machine-readable string.
|
|
54
|
+
* @param name TThe path to the file you want to check.
|
|
55
|
+
* The following values are allowed:
|
|
56
|
+
* - undefined. In this case, loads the "stylish" built-in formatter.
|
|
57
|
+
* - A name of built-in formatters.
|
|
58
|
+
* - A name of third-party formatters. For examples:
|
|
59
|
+
* -- `foo` will load eslint-formatter-foo.
|
|
60
|
+
* -- `@foo` will load `@foo/eslint-formatter`.
|
|
61
|
+
* -- `@foo/bar` will load `@foo/eslint-formatter-bar`.
|
|
62
|
+
* - A path to the file that defines a formatter. The path must contain one or more path separators (/) in order to distinguish if it's a path or not. For example, start with ./.
|
|
63
|
+
* @returns The promise that will be fulfilled with a Formatter object.
|
|
64
|
+
*/
|
|
65
|
+
loadFormatter(name?: string): Promise<Formatter>;
|
|
66
|
+
/**
|
|
67
|
+
* This method copies the given results and removes warnings. The returned value contains only errors.
|
|
68
|
+
* @param results The LintResult objects to filter.
|
|
69
|
+
* @returns The filtered LintResult objects.
|
|
70
|
+
*/
|
|
71
|
+
static getErrorResults(results: LintResult): LintResult;
|
|
72
|
+
/**
|
|
73
|
+
* This method writes code modified by ESLint's autofix feature into its respective file. If any of the modified
|
|
74
|
+
* files don't exist, this method does nothing.
|
|
75
|
+
* @param results The LintResult objects to write.
|
|
76
|
+
* @returns The promise that will be fulfilled after all files are written.
|
|
77
|
+
*/
|
|
78
|
+
static outputFixes(results: LintResult[]): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* The version text.
|
|
81
|
+
*/
|
|
82
|
+
static readonly version: string;
|
|
83
|
+
/**
|
|
84
|
+
* The type of configuration used by this class.
|
|
85
|
+
*/
|
|
86
|
+
static readonly configType: Linter.ConfigTypeSpecifier;
|
|
87
|
+
}
|
|
88
|
+
export interface ESLintOptions<Config extends Linter.ConfigType> {
|
|
89
|
+
/**
|
|
90
|
+
* If false is present, ESLint suppresses comment directives in source code.
|
|
91
|
+
* If this option is false, it overrides the noInlineConfig setting in your configurations.
|
|
92
|
+
* @default true
|
|
93
|
+
*/
|
|
94
|
+
allowInlineConfig?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Configuration object, extended by all configurations used with this instance.
|
|
97
|
+
* You can use this option to define the default settings that will be used if your configuration files don't
|
|
98
|
+
* configure it.
|
|
99
|
+
* @default null
|
|
100
|
+
*/
|
|
101
|
+
baseConfig?: Config | null;
|
|
102
|
+
/**
|
|
103
|
+
* If `true` is present, the `eslint.lintFiles()` method caches lint results and uses it if each target file is not
|
|
104
|
+
* changed. Please mind that ESLint doesn't clear the cache when you upgrade ESLint plugins. In that case, you have
|
|
105
|
+
* to remove the cache file manually. The `eslint.lintText()` method doesn't use caches even if you pass the
|
|
106
|
+
* options.filePath to the method.
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
cache?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* The eslint.lintFiles() method writes caches into this file.
|
|
112
|
+
* @default '.eslintcache'
|
|
113
|
+
*/
|
|
114
|
+
cacheLocation?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Strategy for the cache to use for detecting changed files.
|
|
117
|
+
* @default 'metadata'
|
|
118
|
+
*/
|
|
119
|
+
cacheStrategy?: 'content' | 'metadata';
|
|
120
|
+
/**
|
|
121
|
+
* The working directory. This must be an absolute path.
|
|
122
|
+
* @default process.cwd()
|
|
123
|
+
*/
|
|
124
|
+
cwd?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Unless set to false, the `eslint.lintFiles()` method will throw an error when no target files are found.
|
|
127
|
+
* @default true
|
|
128
|
+
*/
|
|
129
|
+
errorOnUnmatchedPattern?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* If `true` is present, the `eslint.lintFiles()` and `eslint.lintText()` methods work in autofix mode.
|
|
132
|
+
* If a predicate function is present, the methods pass each lint message to the function, then use only the
|
|
133
|
+
* lint messages for which the function returned true.
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
fix?: boolean | ((message: LintMessage) => boolean);
|
|
137
|
+
/**
|
|
138
|
+
* The types of the rules that the `eslint.lintFiles()` and `eslint.lintText()` methods use for autofix.
|
|
139
|
+
* @default null
|
|
140
|
+
*/
|
|
141
|
+
fixTypes?: ('directive' | 'problem' | 'suggestion')[] | null;
|
|
142
|
+
/**
|
|
143
|
+
* If false is present, the `eslint.lintFiles()` method doesn't interpret glob patterns.
|
|
144
|
+
* @default true
|
|
145
|
+
*/
|
|
146
|
+
globInputPaths?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Configuration object, overrides all configurations used with this instance.
|
|
149
|
+
* You can use this option to define the settings that will be used even if your configuration files configure it.
|
|
150
|
+
* @default null
|
|
151
|
+
*/
|
|
152
|
+
overrideConfig?: Config | null;
|
|
153
|
+
/**
|
|
154
|
+
* When set to true, missing patterns cause the linting operation to short circuit and not report any failures.
|
|
155
|
+
* @default false
|
|
156
|
+
*/
|
|
157
|
+
passOnNoPatterns?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* The plugin implementations that ESLint uses for the plugins setting of your configuration.
|
|
160
|
+
* This is a map-like object. Those keys are plugin IDs and each value is implementation.
|
|
161
|
+
* @default null
|
|
162
|
+
*/
|
|
163
|
+
plugins?: Record<string, Linter.Plugin> | null;
|
|
164
|
+
}
|
|
165
|
+
export interface DeprecatedRuleInfo {
|
|
166
|
+
/**
|
|
167
|
+
* The rule IDs that replace this deprecated rule.
|
|
168
|
+
*/
|
|
169
|
+
replacedBy: string[];
|
|
170
|
+
/**
|
|
171
|
+
* The rule ID.
|
|
172
|
+
*/
|
|
173
|
+
ruleId: string;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* The LintResult value is the information of the linting result of each file.
|
|
177
|
+
*/
|
|
178
|
+
export interface LintResult {
|
|
179
|
+
/**
|
|
180
|
+
* The number of errors. This includes fixable errors.
|
|
181
|
+
*/
|
|
182
|
+
errorCount: number;
|
|
183
|
+
/**
|
|
184
|
+
* The number of fatal errors.
|
|
185
|
+
*/
|
|
186
|
+
fatalErrorCount: number;
|
|
187
|
+
/**
|
|
188
|
+
* The absolute path to the file of this result. This is the string "<text>" if the file path is unknown (when you
|
|
189
|
+
* didn't pass the options.filePath option to the eslint.lintText() method).
|
|
190
|
+
*/
|
|
191
|
+
filePath: string;
|
|
192
|
+
/**
|
|
193
|
+
* The number of errors that can be fixed automatically by the fix constructor option.
|
|
194
|
+
*/
|
|
195
|
+
fixableErrorCount: number;
|
|
196
|
+
/**
|
|
197
|
+
* The number of warnings that can be fixed automatically by the fix constructor option.
|
|
198
|
+
*/
|
|
199
|
+
fixableWarningCount: number;
|
|
200
|
+
/**
|
|
201
|
+
* The array of LintMessage objects.
|
|
202
|
+
*/
|
|
203
|
+
messages: LintMessage[];
|
|
204
|
+
/**
|
|
205
|
+
* The source code of the file that was linted, with as many fixes applied as possible.
|
|
206
|
+
*/
|
|
207
|
+
output?: string;
|
|
208
|
+
/**
|
|
209
|
+
* The original source code text. This property is undefined if any messages didn't exist or the output
|
|
210
|
+
* property exists.
|
|
211
|
+
*/
|
|
212
|
+
source?: string;
|
|
213
|
+
/**
|
|
214
|
+
* Timing information of the lint run.
|
|
215
|
+
* This exists if and only if the `--stats` CLI flag was added or the `stats: true`
|
|
216
|
+
* option was passed to the ESLint class
|
|
217
|
+
* @since 9.0.0
|
|
218
|
+
*/
|
|
219
|
+
stats?: LintStats;
|
|
220
|
+
/**
|
|
221
|
+
* The array of SuppressedLintMessage objects.
|
|
222
|
+
*/
|
|
223
|
+
suppressedMessages: SuppressedLintMessage[];
|
|
224
|
+
/**
|
|
225
|
+
* The information about the deprecated rules that were used to check this file.
|
|
226
|
+
*/
|
|
227
|
+
usedDeprecatedRules: DeprecatedRuleInfo[];
|
|
228
|
+
/**
|
|
229
|
+
* The number of warnings. This includes fixable warnings.
|
|
230
|
+
*/
|
|
231
|
+
warningCount: number;
|
|
232
|
+
}
|
|
233
|
+
export interface LintStats {
|
|
234
|
+
/**
|
|
235
|
+
* The number of times ESLint has applied at least one fix after linting.
|
|
236
|
+
*/
|
|
237
|
+
fixPasses: number;
|
|
238
|
+
/**
|
|
239
|
+
* The times spent on (parsing, fixing, linting) a file, where the linting refers to the timing information for each rule.
|
|
240
|
+
*/
|
|
241
|
+
times: {
|
|
242
|
+
passes: LintStatsTimePass[];
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
export interface LintStatsTimePass {
|
|
246
|
+
/**
|
|
247
|
+
* The total time that is spent on applying fixes to the code.
|
|
248
|
+
*/
|
|
249
|
+
fix: LintStatsFixTime;
|
|
250
|
+
/**
|
|
251
|
+
* The total time that is spent when parsing a file.
|
|
252
|
+
*/
|
|
253
|
+
parse: LintStatsParseTime;
|
|
254
|
+
/**
|
|
255
|
+
* The total time that is spent on a rule.
|
|
256
|
+
*/
|
|
257
|
+
rules?: Record<string, LintStatsRuleTime>;
|
|
258
|
+
/**
|
|
259
|
+
* The cumulative total
|
|
260
|
+
*/
|
|
261
|
+
total: number;
|
|
262
|
+
}
|
|
263
|
+
export interface LintStatsParseTime {
|
|
264
|
+
total: number;
|
|
265
|
+
}
|
|
266
|
+
export interface LintStatsRuleTime {
|
|
267
|
+
total: number;
|
|
268
|
+
}
|
|
269
|
+
export interface LintStatsFixTime {
|
|
270
|
+
total: number;
|
|
271
|
+
}
|
|
272
|
+
export interface LintTextOptions {
|
|
273
|
+
/**
|
|
274
|
+
* The path to the file of the source code text. If omitted, the result.filePath becomes the string "<text>".
|
|
275
|
+
*/
|
|
276
|
+
filePath?: string;
|
|
277
|
+
/**
|
|
278
|
+
* If true is present and the options.filePath is a file ESLint should ignore, this method returns a lint result
|
|
279
|
+
* contains a warning message.
|
|
280
|
+
*/
|
|
281
|
+
warnIgnored?: boolean;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The LintMessage value is the information of each linting error.
|
|
285
|
+
*/
|
|
286
|
+
export interface LintMessage {
|
|
287
|
+
/**
|
|
288
|
+
* The 1-based column number of the begin point of this message.
|
|
289
|
+
*/
|
|
290
|
+
column: number | undefined;
|
|
291
|
+
/**
|
|
292
|
+
* The 1-based column number of the end point of this message. This property is undefined if this message
|
|
293
|
+
* is not a range.
|
|
294
|
+
*/
|
|
295
|
+
endColumn: number | undefined;
|
|
296
|
+
/**
|
|
297
|
+
* The 1-based line number of the end point of this message. This property is undefined if this
|
|
298
|
+
* message is not a range.
|
|
299
|
+
*/
|
|
300
|
+
endLine: number | undefined;
|
|
301
|
+
/**
|
|
302
|
+
* `true` if this is a fatal error unrelated to a rule, like a parsing error.
|
|
303
|
+
*/
|
|
304
|
+
fatal?: boolean | undefined;
|
|
305
|
+
/**
|
|
306
|
+
* The EditInfo object of autofix. This property is undefined if this message is not fixable.
|
|
307
|
+
*/
|
|
308
|
+
fix: EditInfo | undefined;
|
|
309
|
+
/**
|
|
310
|
+
* The 1-based line number of the begin point of this message.
|
|
311
|
+
*/
|
|
312
|
+
line: number | undefined;
|
|
313
|
+
/**
|
|
314
|
+
* The error message
|
|
315
|
+
*/
|
|
316
|
+
message: string;
|
|
317
|
+
/**
|
|
318
|
+
* The rule name that generates this lint message. If this message is generated by the ESLint core rather than
|
|
319
|
+
* rules, this is null.
|
|
320
|
+
*/
|
|
321
|
+
ruleId: string | null;
|
|
322
|
+
/**
|
|
323
|
+
* The severity of this message. 1 means warning and 2 means error.
|
|
324
|
+
*/
|
|
325
|
+
severity: 1 | 2;
|
|
326
|
+
/**
|
|
327
|
+
* The list of suggestions. Each suggestion is the pair of a description and an EditInfo object to fix code. API
|
|
328
|
+
* users such as editor integrations can choose one of them to fix the problem of this message. This property is
|
|
329
|
+
* undefined if this message doesn't have any suggestions.
|
|
330
|
+
*/
|
|
331
|
+
suggestions: {
|
|
332
|
+
desc: string;
|
|
333
|
+
fix: EditInfo;
|
|
334
|
+
}[] | undefined;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* The SuppressedLintMessage value is the information of each suppressed linting error.
|
|
338
|
+
*/
|
|
339
|
+
export interface SuppressedLintMessage extends LintMessage {
|
|
340
|
+
/**
|
|
341
|
+
* The list of suppressions.
|
|
342
|
+
*/
|
|
343
|
+
suppressions?: {
|
|
344
|
+
/**
|
|
345
|
+
* The free text description added after the `--` in the comment
|
|
346
|
+
*/
|
|
347
|
+
justification: string;
|
|
348
|
+
/**
|
|
349
|
+
* Right now, this is always `directive`
|
|
350
|
+
*/
|
|
351
|
+
kind: string;
|
|
352
|
+
}[];
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* The EditInfo value is information to edit text.
|
|
356
|
+
*
|
|
357
|
+
* This edit information means replacing the range of the range property by the text property value. It's like
|
|
358
|
+
* sourceCodeText.slice(0, edit.range[0]) + edit.text + sourceCodeText.slice(edit.range[1]). Therefore, it's an add
|
|
359
|
+
* if the range[0] and range[1] property values are the same value, and it's removal if the text property value is
|
|
360
|
+
* empty string.
|
|
361
|
+
*/
|
|
362
|
+
export interface EditInfo {
|
|
363
|
+
/**
|
|
364
|
+
* The pair of 0-based indices in source code text to remove.
|
|
365
|
+
*/
|
|
366
|
+
range: [number, number];
|
|
367
|
+
/**
|
|
368
|
+
* The text to add.
|
|
369
|
+
*/
|
|
370
|
+
text: string;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* The Formatter value is the object to convert the LintResult objects to text.
|
|
374
|
+
*/
|
|
375
|
+
export interface Formatter {
|
|
376
|
+
/**
|
|
377
|
+
* The method to convert the LintResult objects to text.
|
|
378
|
+
* Promise return supported since 8.4.0
|
|
379
|
+
*/
|
|
380
|
+
format(results: LintResult[]): string | Promise<string>;
|
|
381
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { FlatConfig } from '../Config';
|
|
2
|
+
import type * as Shared from './ESLintShared';
|
|
3
|
+
declare class FlatESLintBase extends Shared.ESLintBase<FlatConfig.Config | FlatConfig.ConfigArray, FlatESLint.ESLintOptions> {
|
|
4
|
+
static readonly configType: 'flat';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a configuration object for the given file based on the CLI options.
|
|
7
|
+
* This is the same logic used by the ESLint CLI executable to determine
|
|
8
|
+
* configuration for each file it processes.
|
|
9
|
+
* @param filePath The path of the file to retrieve a config object for.
|
|
10
|
+
* @returns A configuration object for the file or `undefined` if there is no configuration data for the object.
|
|
11
|
+
*/
|
|
12
|
+
calculateConfigForFile(filePath: string): Promise<FlatConfig.Config>;
|
|
13
|
+
/**
|
|
14
|
+
* Finds the config file being used by this instance based on the options
|
|
15
|
+
* passed to the constructor.
|
|
16
|
+
* @returns The path to the config file being used or `undefined` if no config file is being used.
|
|
17
|
+
*/
|
|
18
|
+
findConfigFile(): Promise<string | undefined>;
|
|
19
|
+
}
|
|
20
|
+
declare const FlatESLint_base: typeof FlatESLintBase;
|
|
21
|
+
/**
|
|
22
|
+
* The ESLint class is the primary class to use in Node.js applications.
|
|
23
|
+
* This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
|
|
24
|
+
*
|
|
25
|
+
* If you want to lint code on browsers, use the Linter class instead.
|
|
26
|
+
*/
|
|
27
|
+
export declare class FlatESLint extends FlatESLint_base {
|
|
28
|
+
}
|
|
29
|
+
export declare namespace FlatESLint {
|
|
30
|
+
interface ESLintOptions extends Shared.ESLintOptions<FlatConfig.ConfigArray> {
|
|
31
|
+
/**
|
|
32
|
+
* If false is present, the eslint.lintFiles() method doesn't respect `ignorePatterns` ignorePatterns in your configuration.
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
ignore?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Ignore file patterns to use in addition to config ignores. These patterns are relative to cwd.
|
|
38
|
+
* @default null
|
|
39
|
+
*/
|
|
40
|
+
ignorePatterns?: string[] | null;
|
|
41
|
+
/**
|
|
42
|
+
* The path to a configuration file. Overrides all configurations used with this instance.
|
|
43
|
+
* The options.overrideConfig option is applied after this option is applied.
|
|
44
|
+
*
|
|
45
|
+
* - When falsy, searches for default config file.
|
|
46
|
+
* - When `true`, does not do any config file lookup.
|
|
47
|
+
* - When a string, considered to be a config file name.
|
|
48
|
+
*
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
overrideConfigFile?: boolean | string;
|
|
52
|
+
/**
|
|
53
|
+
* A predicate function that filters rules to be run.
|
|
54
|
+
* This function is called with an object containing `ruleId` and `severity`, and returns `true` if the rule should be run.
|
|
55
|
+
* @default () => true
|
|
56
|
+
*/
|
|
57
|
+
ruleFilter?: RuleFilter;
|
|
58
|
+
/**
|
|
59
|
+
* When set to true, additional statistics are added to the lint results.
|
|
60
|
+
* @see {@link https://eslint.org/docs/latest/extend/stats}
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
stats?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Show warnings when the file list includes ignored files.
|
|
66
|
+
* @default true
|
|
67
|
+
*/
|
|
68
|
+
warnIgnored?: boolean;
|
|
69
|
+
}
|
|
70
|
+
type DeprecatedRuleInfo = Shared.DeprecatedRuleInfo;
|
|
71
|
+
type EditInfo = Shared.EditInfo;
|
|
72
|
+
type Formatter = Shared.Formatter;
|
|
73
|
+
type LintMessage = Shared.LintMessage;
|
|
74
|
+
type LintResult = Shared.LintResult;
|
|
75
|
+
type LintStats = Shared.LintStats;
|
|
76
|
+
type LintStatsFixTime = Shared.LintStatsFixTime;
|
|
77
|
+
type LintStatsParseTime = Shared.LintStatsParseTime;
|
|
78
|
+
type LintStatsRuleTime = Shared.LintStatsRuleTime;
|
|
79
|
+
type LintStatsTimePass = Shared.LintStatsTimePass;
|
|
80
|
+
type LintTextOptions = Shared.LintTextOptions;
|
|
81
|
+
type SuppressedLintMessage = Shared.SuppressedLintMessage;
|
|
82
|
+
type RuleFilter = (rule: {
|
|
83
|
+
ruleId: string;
|
|
84
|
+
severity: number;
|
|
85
|
+
}) => boolean;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FlatESLint = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
8
|
+
const eslint_1 = require("eslint");
|
|
9
|
+
const use_at_your_own_risk_1 = __importDefault(require("eslint/use-at-your-own-risk"));
|
|
10
|
+
/**
|
|
11
|
+
* The ESLint class is the primary class to use in Node.js applications.
|
|
12
|
+
* This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
|
|
13
|
+
*
|
|
14
|
+
* If you want to lint code on browsers, use the Linter class instead.
|
|
15
|
+
*/
|
|
16
|
+
class FlatESLint extends (use_at_your_own_risk_1.default.FlatESLint ??
|
|
17
|
+
eslint_1.ESLint) {
|
|
18
|
+
}
|
|
19
|
+
exports.FlatESLint = FlatESLint;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { ClassicConfig } from '../Config';
|
|
2
|
+
import type { Linter } from '../Linter';
|
|
3
|
+
import type * as Shared from './ESLintShared';
|
|
4
|
+
declare class LegacyESLintBase extends Shared.ESLintBase<ClassicConfig.Config, LegacyESLint.ESLintOptions> {
|
|
5
|
+
static readonly configType: 'eslintrc';
|
|
6
|
+
}
|
|
7
|
+
declare const LegacyESLint_base: typeof LegacyESLintBase;
|
|
8
|
+
/**
|
|
9
|
+
* The ESLint class is the primary class to use in Node.js applications.
|
|
10
|
+
* This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
|
|
11
|
+
*
|
|
12
|
+
* If you want to lint code on browsers, use the Linter class instead.
|
|
13
|
+
*/
|
|
14
|
+
export declare class LegacyESLint extends LegacyESLint_base {
|
|
15
|
+
}
|
|
16
|
+
export declare namespace LegacyESLint {
|
|
17
|
+
interface ESLintOptions extends Shared.ESLintOptions<ClassicConfig.Config> {
|
|
18
|
+
/**
|
|
19
|
+
* If you pass directory paths to the eslint.lintFiles() method, ESLint checks the files in those directories that
|
|
20
|
+
* have the given extensions. For example, when passing the src/ directory and extensions is [".js", ".ts"], ESLint
|
|
21
|
+
* will lint *.js and *.ts files in src/. If extensions is null, ESLint checks *.js files and files that match
|
|
22
|
+
* overrides[].files patterns in your configuration.
|
|
23
|
+
* Note: This option only applies when you pass directory paths to the eslint.lintFiles() method.
|
|
24
|
+
* If you pass glob patterns, ESLint will lint all files matching the glob pattern regardless of extension.
|
|
25
|
+
*/
|
|
26
|
+
extensions?: string[] | null;
|
|
27
|
+
/**
|
|
28
|
+
* If false is present, the eslint.lintFiles() method doesn't respect `.eslintignore` files in your configuration.
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
ignore?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The path to a file ESLint uses instead of `$CWD/.eslintignore`.
|
|
34
|
+
* If a path is present and the file doesn't exist, this constructor will throw an error.
|
|
35
|
+
*/
|
|
36
|
+
ignorePath?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The path to a configuration file, overrides all configurations used with this instance.
|
|
39
|
+
* The options.overrideConfig option is applied after this option is applied.
|
|
40
|
+
*/
|
|
41
|
+
overrideConfigFile?: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* The severity to report unused eslint-disable directives.
|
|
44
|
+
* If this option is a severity, it overrides the reportUnusedDisableDirectives setting in your configurations.
|
|
45
|
+
*/
|
|
46
|
+
reportUnusedDisableDirectives?: Linter.SeverityString | null;
|
|
47
|
+
/**
|
|
48
|
+
* The path to a directory where plugins should be resolved from.
|
|
49
|
+
* If null is present, ESLint loads plugins from the location of the configuration file that contains the plugin
|
|
50
|
+
* setting.
|
|
51
|
+
* If a path is present, ESLint loads all plugins from there.
|
|
52
|
+
*/
|
|
53
|
+
resolvePluginsRelativeTo?: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* An array of paths to directories to load custom rules from.
|
|
56
|
+
*/
|
|
57
|
+
rulePaths?: string[];
|
|
58
|
+
/**
|
|
59
|
+
* If false is present, ESLint doesn't load configuration files (.eslintrc.* files).
|
|
60
|
+
* Only the configuration of the constructor options is valid.
|
|
61
|
+
*/
|
|
62
|
+
useEslintrc?: boolean;
|
|
63
|
+
}
|
|
64
|
+
type DeprecatedRuleInfo = Shared.DeprecatedRuleInfo;
|
|
65
|
+
type EditInfo = Shared.EditInfo;
|
|
66
|
+
type Formatter = Shared.Formatter;
|
|
67
|
+
type LintMessage = Shared.LintMessage;
|
|
68
|
+
type LintResult = Omit<Shared.LintResult, 'stats'>;
|
|
69
|
+
type LintTextOptions = Shared.LintTextOptions;
|
|
70
|
+
type SuppressedLintMessage = Shared.SuppressedLintMessage;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.LegacyESLint = void 0;
|
|
8
|
+
const eslint_1 = require("eslint");
|
|
9
|
+
const use_at_your_own_risk_1 = __importDefault(require("eslint/use-at-your-own-risk"));
|
|
10
|
+
function throwMissingLegacyESLintError() {
|
|
11
|
+
throw new Error('LegacyESLint is not available with the current version of ESLint.');
|
|
12
|
+
}
|
|
13
|
+
/* eslint-disable-next-line @typescript-eslint/no-extraneous-class */
|
|
14
|
+
class MissingLegacyESLint {
|
|
15
|
+
static configType = 'eslintrc';
|
|
16
|
+
static version = eslint_1.ESLint.version;
|
|
17
|
+
constructor() {
|
|
18
|
+
throwMissingLegacyESLintError();
|
|
19
|
+
}
|
|
20
|
+
static getErrorResults() {
|
|
21
|
+
throwMissingLegacyESLintError();
|
|
22
|
+
}
|
|
23
|
+
static outputFixes() {
|
|
24
|
+
throwMissingLegacyESLintError();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The ESLint class is the primary class to use in Node.js applications.
|
|
29
|
+
* This class depends on the Node.js fs module and the file system, so you cannot use it in browsers.
|
|
30
|
+
*
|
|
31
|
+
* If you want to lint code on browsers, use the Linter class instead.
|
|
32
|
+
*/
|
|
33
|
+
class LegacyESLint extends (use_at_your_own_risk_1.default.LegacyESLint ??
|
|
34
|
+
MissingLegacyESLint) {
|
|
35
|
+
}
|
|
36
|
+
exports.LegacyESLint = LegacyESLint;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './AST';
|
|
2
|
+
export * from './Config';
|
|
3
|
+
export * from './ESLint';
|
|
4
|
+
export * from './Linter';
|
|
5
|
+
export * from './Parser';
|
|
6
|
+
export * from './ParserOptions';
|
|
7
|
+
export * from './Processor';
|
|
8
|
+
export * from './Rule';
|
|
9
|
+
export * from './RuleTester';
|
|
10
|
+
export * from './Scope';
|
|
11
|
+
export * from './SourceCode';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AST"), exports);
|
|
18
|
+
__exportStar(require("./Config"), exports);
|
|
19
|
+
__exportStar(require("./ESLint"), exports);
|
|
20
|
+
__exportStar(require("./Linter"), exports);
|
|
21
|
+
__exportStar(require("./Parser"), exports);
|
|
22
|
+
__exportStar(require("./ParserOptions"), exports);
|
|
23
|
+
__exportStar(require("./Processor"), exports);
|
|
24
|
+
__exportStar(require("./Rule"), exports);
|
|
25
|
+
__exportStar(require("./RuleTester"), exports);
|
|
26
|
+
__exportStar(require("./Scope"), exports);
|
|
27
|
+
__exportStar(require("./SourceCode"), exports);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree, } from '@typescript-eslint/types';
|
|
2
|
+
export type { NodeWithParent } from '@typescript-eslint/types';
|
|
3
|
+
export type { ParserServices, ParserServicesWithoutTypeInformation, ParserServicesWithTypeInformation, } from '@typescript-eslint/typescript-estree';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TSESTree = exports.AST_TOKEN_TYPES = exports.AST_NODE_TYPES = void 0;
|
|
4
|
+
// for convenience's sake - export the types directly from here so consumers
|
|
5
|
+
// don't need to reference/install both packages in their code
|
|
6
|
+
var types_1 = require("@typescript-eslint/types");
|
|
7
|
+
Object.defineProperty(exports, "AST_NODE_TYPES", { enumerable: true, get: function () { return types_1.AST_NODE_TYPES; } });
|
|
8
|
+
Object.defineProperty(exports, "AST_TOKEN_TYPES", { enumerable: true, get: function () { return types_1.AST_TOKEN_TYPES; } });
|
|
9
|
+
Object.defineProperty(exports, "TSESTree", { enumerable: true, get: function () { return types_1.TSESTree; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We could use NoInfer typescript build-in utility
|
|
3
|
+
* introduced in typescript 5.4, however at the moment of creation
|
|
4
|
+
* the supported ts versions are >=4.8.4 <5.7.0
|
|
5
|
+
* so for the moment we have to stick to this polyfill.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/millsp/ts-toolbelt/blob/master/sources/Function/NoInfer.ts
|
|
8
|
+
*/
|
|
9
|
+
export type NoInfer<A> = [A][A extends unknown ? 0 : never];
|