@utoo/lint 0.0.2
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/bin/eslint.js +15 -0
- package/bin/fishlint-lint-staged.js +58 -0
- package/bin/fishlint.js +1606 -0
- package/bin/migrate.js +361 -0
- package/bin/utoo-lint.js +26 -0
- package/config.cjs +155 -0
- package/config.d.ts +4 -0
- package/config.js +150 -0
- package/configs/frontend.json +40 -0
- package/index.cjs +4018 -0
- package/index.d.ts +318 -0
- package/index.js +4002 -0
- package/lib/binary.cjs +64 -0
- package/lib/binary.d.ts +2 -0
- package/lib/binary.js +62 -0
- package/package.json +81 -0
- package/schema.json +74 -0
- package/universal.cjs +3 -0
- package/universal.d.ts +1 -0
- package/universal.js +1 -0
- package/use-at-your-own-risk.cjs +28 -0
- package/use-at-your-own-risk.d.ts +12 -0
- package/use-at-your-own-risk.js +20 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
export interface LintMessage {
|
|
2
|
+
ruleId: string | null;
|
|
3
|
+
severity: 0 | 1 | 2;
|
|
4
|
+
message: string;
|
|
5
|
+
line: number;
|
|
6
|
+
column: number;
|
|
7
|
+
endLine?: number;
|
|
8
|
+
endColumn?: number;
|
|
9
|
+
nodeType?: string | null;
|
|
10
|
+
fix?: LintFix | LintFix[];
|
|
11
|
+
suggestions?: LintSuggestion[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface LintFix {
|
|
15
|
+
range: [number, number];
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LintSuggestion {
|
|
20
|
+
desc: string;
|
|
21
|
+
messageId?: string;
|
|
22
|
+
fix?: LintFix | LintFix[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface LintResult {
|
|
26
|
+
filePath: string;
|
|
27
|
+
messages: LintMessage[];
|
|
28
|
+
suppressedMessages: LintMessage[];
|
|
29
|
+
errorCount: number;
|
|
30
|
+
warningCount: number;
|
|
31
|
+
fixableErrorCount: number;
|
|
32
|
+
fixableWarningCount: number;
|
|
33
|
+
source?: string;
|
|
34
|
+
output?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface LintReport {
|
|
38
|
+
files: number;
|
|
39
|
+
filePaths: string[];
|
|
40
|
+
diagnostics: LintMessage[];
|
|
41
|
+
exitCode: number;
|
|
42
|
+
stderr?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface Formatter {
|
|
46
|
+
format(results: LintResult[] | LintReport): string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type RuleSeverity = "off" | "warn" | "warning" | "error" | 0 | 1 | 2 | false | true;
|
|
50
|
+
export type RuleConfig = RuleSeverity | [RuleSeverity, ...unknown[]];
|
|
51
|
+
|
|
52
|
+
export interface PluginObject {
|
|
53
|
+
rules?: Record<string, unknown>;
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ConfigObject {
|
|
58
|
+
name?: string;
|
|
59
|
+
files?: Array<string | string[]>;
|
|
60
|
+
ignores?: string[];
|
|
61
|
+
rules?: Record<string, RuleConfig>;
|
|
62
|
+
plugins?: Record<string, PluginObject>;
|
|
63
|
+
settings?: Record<string, unknown>;
|
|
64
|
+
languageOptions?: {
|
|
65
|
+
parser?: unknown;
|
|
66
|
+
parserOptions?: Record<string, unknown>;
|
|
67
|
+
globals?: Record<string, unknown>;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
};
|
|
70
|
+
parser?: unknown;
|
|
71
|
+
parserOptions?: Record<string, unknown>;
|
|
72
|
+
globals?: Record<string, unknown>;
|
|
73
|
+
env?: Record<string, unknown>;
|
|
74
|
+
extends?: Array<string | ConfigObject | ConfigObject[]>;
|
|
75
|
+
basePath?: string;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface LintOptions {
|
|
80
|
+
cwd?: string;
|
|
81
|
+
binary?: string;
|
|
82
|
+
env?: Record<string, string | undefined>;
|
|
83
|
+
threads?: number;
|
|
84
|
+
rules?: string[] | string;
|
|
85
|
+
config?: string;
|
|
86
|
+
configFile?: string;
|
|
87
|
+
noConfig?: boolean;
|
|
88
|
+
fix?: boolean;
|
|
89
|
+
useEslintrc?: boolean;
|
|
90
|
+
overrideConfigFile?: string | boolean;
|
|
91
|
+
baseConfig?: ConfigObject | ConfigObject[];
|
|
92
|
+
overrideConfig?: ConfigObject | ConfigObject[];
|
|
93
|
+
ignore?: boolean;
|
|
94
|
+
noIgnore?: boolean;
|
|
95
|
+
ignorePath?: string;
|
|
96
|
+
ignorePatterns?: string[];
|
|
97
|
+
quiet?: boolean;
|
|
98
|
+
warnIgnored?: boolean;
|
|
99
|
+
errorOnUnmatchedPattern?: boolean;
|
|
100
|
+
extraArgs?: string[];
|
|
101
|
+
flags?: string[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface TextLintOptions extends LintOptions {
|
|
105
|
+
filePath?: string;
|
|
106
|
+
filename?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface VerifyOptions {
|
|
110
|
+
filename?: string;
|
|
111
|
+
filePath?: string;
|
|
112
|
+
cwd?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface VerifyAndFixResult {
|
|
116
|
+
fixed: boolean;
|
|
117
|
+
messages: LintMessage[];
|
|
118
|
+
output: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface SourceLocation {
|
|
122
|
+
line: number;
|
|
123
|
+
column: number;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface SourceRange {
|
|
127
|
+
range?: [number, number];
|
|
128
|
+
loc?: {
|
|
129
|
+
start: SourceLocation;
|
|
130
|
+
end: SourceLocation;
|
|
131
|
+
};
|
|
132
|
+
[key: string]: unknown;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface SourceCodeTokenOptions {
|
|
136
|
+
includeComments?: boolean;
|
|
137
|
+
filter?: (token: SourceRange) => boolean;
|
|
138
|
+
skip?: number;
|
|
139
|
+
count?: number;
|
|
140
|
+
beforeCount?: number;
|
|
141
|
+
afterCount?: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export type SourceCodeTokenCountOrOptions = number | SourceCodeTokenOptions;
|
|
145
|
+
|
|
146
|
+
export class SourceCode {
|
|
147
|
+
static splitLines(text: string): string[];
|
|
148
|
+
constructor(text: string, ast?: SourceRange | null);
|
|
149
|
+
constructor(config: {
|
|
150
|
+
text: string;
|
|
151
|
+
ast?: SourceRange | null;
|
|
152
|
+
hasBOM?: boolean;
|
|
153
|
+
parserServices?: unknown;
|
|
154
|
+
scopeManager?: unknown;
|
|
155
|
+
visitorKeys?: unknown;
|
|
156
|
+
});
|
|
157
|
+
text: string;
|
|
158
|
+
ast: SourceRange | null;
|
|
159
|
+
lines: string[];
|
|
160
|
+
comments: SourceRange[];
|
|
161
|
+
tokens: SourceRange[];
|
|
162
|
+
getText(node?: SourceRange, beforeCount?: number, afterCount?: number): string;
|
|
163
|
+
getLines(): string[];
|
|
164
|
+
getAllComments(): SourceRange[];
|
|
165
|
+
getIndexFromLoc(loc: SourceLocation): number;
|
|
166
|
+
getLocFromIndex(index: number): SourceLocation;
|
|
167
|
+
getRange(node?: SourceRange): [number, number];
|
|
168
|
+
getLoc(node?: SourceRange): { start: SourceLocation; end: SourceLocation };
|
|
169
|
+
getAllTokens(): SourceRange[];
|
|
170
|
+
getTokens(node?: SourceRange, beforeCount?: number, afterCount?: number): SourceRange[];
|
|
171
|
+
getTokens(node?: SourceRange, options?: SourceCodeTokenOptions): SourceRange[];
|
|
172
|
+
getFirstToken(node?: SourceRange, skipOrOptions?: SourceCodeTokenCountOrOptions): SourceRange | null;
|
|
173
|
+
getFirstTokens(node?: SourceRange, countOrOptions?: SourceCodeTokenCountOrOptions): SourceRange[];
|
|
174
|
+
getLastToken(node?: SourceRange, skipOrOptions?: SourceCodeTokenCountOrOptions): SourceRange | null;
|
|
175
|
+
getLastTokens(node?: SourceRange, countOrOptions?: SourceCodeTokenCountOrOptions): SourceRange[];
|
|
176
|
+
getTokenBefore(nodeOrToken: SourceRange, skipOrOptions?: SourceCodeTokenCountOrOptions): SourceRange | null;
|
|
177
|
+
getTokensBefore(nodeOrToken: SourceRange, countOrOptions?: SourceCodeTokenCountOrOptions): SourceRange[];
|
|
178
|
+
getTokenAfter(nodeOrToken: SourceRange, skipOrOptions?: SourceCodeTokenCountOrOptions): SourceRange | null;
|
|
179
|
+
getTokensAfter(nodeOrToken: SourceRange, countOrOptions?: SourceCodeTokenCountOrOptions): SourceRange[];
|
|
180
|
+
getTokensBetween(left: SourceRange, right: SourceRange, countOrOptions?: SourceCodeTokenCountOrOptions): SourceRange[];
|
|
181
|
+
getFirstTokenBetween(left: SourceRange, right: SourceRange, skipOrOptions?: SourceCodeTokenCountOrOptions): SourceRange | null;
|
|
182
|
+
getFirstTokensBetween(left: SourceRange, right: SourceRange, countOrOptions?: SourceCodeTokenCountOrOptions): SourceRange[];
|
|
183
|
+
getLastTokenBetween(left: SourceRange, right: SourceRange, skipOrOptions?: SourceCodeTokenCountOrOptions): SourceRange | null;
|
|
184
|
+
getLastTokensBetween(left: SourceRange, right: SourceRange, countOrOptions?: SourceCodeTokenCountOrOptions): SourceRange[];
|
|
185
|
+
getTokenByRangeStart(index: number, options?: Pick<SourceCodeTokenOptions, "includeComments">): SourceRange | null;
|
|
186
|
+
getTokenOrCommentBefore(nodeOrToken: SourceRange): SourceRange | null;
|
|
187
|
+
getTokenOrCommentAfter(nodeOrToken: SourceRange): SourceRange | null;
|
|
188
|
+
getCommentsBefore(nodeOrToken: SourceRange): SourceRange[];
|
|
189
|
+
getCommentsAfter(nodeOrToken: SourceRange): SourceRange[];
|
|
190
|
+
getCommentsInside(node: SourceRange): SourceRange[];
|
|
191
|
+
getComments(node: SourceRange): { before: SourceRange[]; after: SourceRange[]; inside: SourceRange[] };
|
|
192
|
+
getJSDocComment(node: SourceRange): SourceRange | null;
|
|
193
|
+
commentsExistBetween(left: SourceRange, right: SourceRange): boolean;
|
|
194
|
+
isSpaceBetween(left: SourceRange, right: SourceRange): boolean;
|
|
195
|
+
isSpaceBetweenTokens(left: SourceRange, right: SourceRange): boolean;
|
|
196
|
+
getNodeByRangeIndex(index: number): SourceRange | null;
|
|
197
|
+
getAncestors(node?: SourceRange): SourceRange[];
|
|
198
|
+
getDeclaredVariables(node?: SourceRange): unknown[];
|
|
199
|
+
getScope(node?: SourceRange): unknown;
|
|
200
|
+
markVariableAsUsed(name: string, node?: SourceRange): boolean;
|
|
201
|
+
getDisableDirectives(): unknown[];
|
|
202
|
+
getInlineConfigNodes(): unknown[];
|
|
203
|
+
applyInlineConfig(): undefined;
|
|
204
|
+
applyLanguageOptions(): undefined;
|
|
205
|
+
finalize(): undefined;
|
|
206
|
+
traverse(): unknown[];
|
|
207
|
+
isGlobalReference(): boolean;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export class Linter {
|
|
211
|
+
static readonly version: string;
|
|
212
|
+
constructor(options?: { flags?: string[] });
|
|
213
|
+
verify(code: string, config?: ConfigObject, options?: VerifyOptions | string): LintMessage[];
|
|
214
|
+
verifyAndFix(code: string, config?: ConfigObject, options?: VerifyOptions | string): VerifyAndFixResult;
|
|
215
|
+
getSourceCode(): SourceCode | null;
|
|
216
|
+
getSuppressedMessages(): LintMessage[];
|
|
217
|
+
getTimes(): { passes: unknown[] };
|
|
218
|
+
getFixPassCount(): number;
|
|
219
|
+
hasFlag(flag: string): boolean;
|
|
220
|
+
getRules(): Map<string, unknown>;
|
|
221
|
+
defineRule(ruleId: string, rule: unknown): void;
|
|
222
|
+
defineRules(rules: Record<string, unknown>): void;
|
|
223
|
+
defineParser(parserId: string, parser: unknown): void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface RuleTesterValidCase extends ConfigObject {
|
|
227
|
+
code: string;
|
|
228
|
+
name?: string;
|
|
229
|
+
filename?: string;
|
|
230
|
+
filePath?: string;
|
|
231
|
+
options?: unknown[];
|
|
232
|
+
only?: boolean;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export interface RuleTesterInvalidCase extends RuleTesterValidCase {
|
|
236
|
+
errors?: number | Array<number | Partial<LintMessage> & {
|
|
237
|
+
messageId?: string;
|
|
238
|
+
data?: Record<string, unknown>;
|
|
239
|
+
type?: string | null;
|
|
240
|
+
suggestions?: number | null | Array<Partial<LintSuggestion> & { data?: Record<string, unknown>; output?: string | null }>;
|
|
241
|
+
}>;
|
|
242
|
+
output?: string | null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export class RuleTester {
|
|
246
|
+
static readonly version: string;
|
|
247
|
+
static setDefaultConfig(config: ConfigObject): void;
|
|
248
|
+
static getDefaultConfig(): ConfigObject;
|
|
249
|
+
static resetDefaultConfig(): void;
|
|
250
|
+
static describe: ((name: string, fn: () => void) => unknown) | null;
|
|
251
|
+
static it: ((name: string, fn: () => void) => unknown) | null;
|
|
252
|
+
static itOnly: ((name: string, fn: () => void) => unknown) | null;
|
|
253
|
+
static only<T extends string | RuleTesterValidCase | RuleTesterInvalidCase>(item: T): T extends string ? RuleTesterValidCase : T & { only: true };
|
|
254
|
+
constructor(config?: ConfigObject);
|
|
255
|
+
run(ruleName: string, rule: unknown, tests?: {
|
|
256
|
+
valid?: Array<string | RuleTesterValidCase>;
|
|
257
|
+
invalid?: RuleTesterInvalidCase[];
|
|
258
|
+
}): void;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export class UtooLint {
|
|
262
|
+
static readonly version: string;
|
|
263
|
+
static readonly configType: "flat";
|
|
264
|
+
static readonly defaultConfig: ConfigObject[];
|
|
265
|
+
static fromOptionsModule(optionsURL: URL): Promise<UtooLint>;
|
|
266
|
+
static outputFixes(results: LintResult[]): Promise<void>;
|
|
267
|
+
static getErrorResults(results: LintResult[]): LintResult[];
|
|
268
|
+
constructor(options?: LintOptions);
|
|
269
|
+
lintFiles(patterns?: string | string[], options?: LintOptions): Promise<LintResult[]>;
|
|
270
|
+
lintText(code: string, options?: TextLintOptions): Promise<LintResult[]>;
|
|
271
|
+
isPathIgnored(filePath: string): Promise<boolean>;
|
|
272
|
+
calculateConfigForFile(filePath: string): Promise<ConfigObject>;
|
|
273
|
+
findConfigFile(filePath?: string): Promise<string | undefined>;
|
|
274
|
+
getRulesMetaForResults(results: LintResult[]): Record<string, unknown>;
|
|
275
|
+
hasFlag(flag: string): boolean;
|
|
276
|
+
loadFormatter(name?: string): Promise<Formatter>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export { UtooLint as ESLint };
|
|
280
|
+
|
|
281
|
+
export class CLIEngine {
|
|
282
|
+
static readonly version: string;
|
|
283
|
+
static outputFixes(report: { results?: LintResult[] } | LintResult[]): void;
|
|
284
|
+
static getErrorResults(results: LintResult[]): LintResult[];
|
|
285
|
+
constructor(options?: LintOptions);
|
|
286
|
+
executeOnFiles(patterns: string | string[]): {
|
|
287
|
+
results: LintResult[];
|
|
288
|
+
errorCount: number;
|
|
289
|
+
warningCount: number;
|
|
290
|
+
fixableErrorCount: number;
|
|
291
|
+
fixableWarningCount: number;
|
|
292
|
+
};
|
|
293
|
+
executeOnText(code: string, filePathOrOptions?: string | TextLintOptions): {
|
|
294
|
+
results: LintResult[];
|
|
295
|
+
errorCount: number;
|
|
296
|
+
warningCount: number;
|
|
297
|
+
fixableErrorCount: number;
|
|
298
|
+
fixableWarningCount: number;
|
|
299
|
+
};
|
|
300
|
+
getFormatter(name?: string): (results: LintResult[]) => string;
|
|
301
|
+
getRules(): Map<string, unknown>;
|
|
302
|
+
addPlugin(name: string, pluginObject: unknown): void;
|
|
303
|
+
resolveFileGlobPatterns(patterns: string | string[]): string[];
|
|
304
|
+
isPathIgnored(filePath: string): boolean;
|
|
305
|
+
getConfigForFile(filePath: string): ConfigObject;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function loadESLint(options?: { useFlatConfig?: boolean; cwd?: string }): Promise<typeof UtooLint>;
|
|
309
|
+
export function lintFiles(patterns?: string | string[], options?: LintOptions): LintReport;
|
|
310
|
+
export function lintText(code: string, options?: TextLintOptions): LintReport;
|
|
311
|
+
export function run(args?: string[], options?: LintOptions): unknown;
|
|
312
|
+
export function runFishlint(args?: string[], options?: LintOptions): unknown;
|
|
313
|
+
export function translateFishlintArgs(args?: string[], options?: { command?: string; warn?: (message: string) => void }): string[];
|
|
314
|
+
export function resolveBinary(options?: { env?: Record<string, string | undefined>; platform?: string; arch?: string }): string;
|
|
315
|
+
export function platformPackageName(platform?: string, arch?: string): string | undefined;
|
|
316
|
+
|
|
317
|
+
export const version: string;
|
|
318
|
+
export default UtooLint;
|