@alint-js/languages 0.1.5
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 +85 -0
- package/dist/index.d.mts +1036 -0
- package/dist/index.mjs +288 -0
- package/package.json +31 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1036 @@
|
|
|
1
|
+
import { SourceFile, SourceTarget } from "@alint-js/core";
|
|
2
|
+
//#region ../plugin/dist/index.d.mts
|
|
3
|
+
//#region ../core/dist/types-DM4idR4w.d.mts
|
|
4
|
+
//#region src/core/source/types.d.ts
|
|
5
|
+
interface BaseSourceFile {
|
|
6
|
+
contentHash: string;
|
|
7
|
+
language: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}
|
|
10
|
+
type ClassTarget = PlannedSourceTargetOfKind<'class'>;
|
|
11
|
+
type FileTarget = PlannedSourceTargetOfKind<'file'>;
|
|
12
|
+
type FunctionTarget = PlannedSourceTargetOfKind<'function'>;
|
|
13
|
+
interface LanguageContext {
|
|
14
|
+
cwd: string;
|
|
15
|
+
languageOptions: Record<string, unknown>;
|
|
16
|
+
src: SourceRuntime;
|
|
17
|
+
}
|
|
18
|
+
interface LineRange {
|
|
19
|
+
endLine: number;
|
|
20
|
+
startLine: number;
|
|
21
|
+
}
|
|
22
|
+
interface PlannedSourceTarget {
|
|
23
|
+
file: BaseSourceFile;
|
|
24
|
+
identity: string;
|
|
25
|
+
kind: SourceTargetKind;
|
|
26
|
+
language: string;
|
|
27
|
+
loc?: SourceLocation;
|
|
28
|
+
metadata?: SourceTargetMetadata;
|
|
29
|
+
name?: string;
|
|
30
|
+
origin?: SourceTargetOrigin;
|
|
31
|
+
range?: SourceRange;
|
|
32
|
+
}
|
|
33
|
+
type PlannedSourceTargetOfKind<Kind extends SourceTargetKind> = Omit<PlannedSourceTarget, 'kind'> & {
|
|
34
|
+
kind: Kind;
|
|
35
|
+
};
|
|
36
|
+
interface ProcessedSource {
|
|
37
|
+
identity: string;
|
|
38
|
+
language?: string;
|
|
39
|
+
origin?: ProcessedSourceOrigin;
|
|
40
|
+
path: string;
|
|
41
|
+
text: string;
|
|
42
|
+
}
|
|
43
|
+
interface ProcessedSourceOrigin {
|
|
44
|
+
physicalPath: string;
|
|
45
|
+
range?: SourceRange;
|
|
46
|
+
virtualPath?: string;
|
|
47
|
+
}
|
|
48
|
+
interface ProcessorContext {
|
|
49
|
+
cwd: string;
|
|
50
|
+
options: Record<string, unknown>;
|
|
51
|
+
src: SourceRuntime;
|
|
52
|
+
}
|
|
53
|
+
interface ProcessorPostprocessContext extends ProcessorContext {
|
|
54
|
+
file: SourceFile$1;
|
|
55
|
+
processedSources: ProcessedSource[];
|
|
56
|
+
}
|
|
57
|
+
interface SourceExtractOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Overrides the file's configured `language:` pin.
|
|
60
|
+
*
|
|
61
|
+
* For a caller walking a mixed tree, where the file's own config cannot know what each file is.
|
|
62
|
+
*/
|
|
63
|
+
language?: string;
|
|
64
|
+
}
|
|
65
|
+
interface SourceFile$1 extends BaseSourceFile {
|
|
66
|
+
lines: string[];
|
|
67
|
+
text: string;
|
|
68
|
+
}
|
|
69
|
+
interface SourceLocation {
|
|
70
|
+
end: SourcePosition;
|
|
71
|
+
start: SourcePosition;
|
|
72
|
+
}
|
|
73
|
+
interface SourceMetadataObject {
|
|
74
|
+
readonly [key: string]: SourceMetadataValue;
|
|
75
|
+
}
|
|
76
|
+
type SourceMetadataValue = boolean | null | number | readonly SourceMetadataValue[] | SourceMetadataObject | SourceRange | string;
|
|
77
|
+
interface SourcePosition {
|
|
78
|
+
column: number;
|
|
79
|
+
line: number;
|
|
80
|
+
}
|
|
81
|
+
interface SourceRange {
|
|
82
|
+
end: number;
|
|
83
|
+
start: number;
|
|
84
|
+
}
|
|
85
|
+
interface SourceRuntime {
|
|
86
|
+
/**
|
|
87
|
+
* Targets for any file, linted or not.
|
|
88
|
+
*
|
|
89
|
+
* Resolves the file's own config the way linting does, resolves its language from that config,
|
|
90
|
+
* and runs that language's extract. A rule handed `ProjectTarget.files`, or an index builder
|
|
91
|
+
* sweeping files outside the lint set, has no other way to parse them.
|
|
92
|
+
*
|
|
93
|
+
* An ignored file extracts to `[]` rather than throwing: sweeping broadly and skipping what the
|
|
94
|
+
* config excluded is the normal case, not an error.
|
|
95
|
+
*
|
|
96
|
+
* Only wired inside a run. A runtime built by `createSourceRuntime()` with no extractor throws,
|
|
97
|
+
* because there is no config to resolve the file against.
|
|
98
|
+
*/
|
|
99
|
+
extract: (filePath: string, options?: SourceExtractOptions) => Promise<SourceTarget$1[]>;
|
|
100
|
+
getText: (file: SourceFile$1) => string;
|
|
101
|
+
readFile: (file: BaseSourceFile | string) => Promise<SourceFile$1>;
|
|
102
|
+
sliceLines: (file: SourceFile$1, range: LineRange) => SourceText;
|
|
103
|
+
sliceRange: (file: SourceFile$1, range: SourceRange) => SourceText;
|
|
104
|
+
}
|
|
105
|
+
interface SourceTarget$1 {
|
|
106
|
+
file: SourceFile$1;
|
|
107
|
+
identity: string;
|
|
108
|
+
kind: SourceTargetKind;
|
|
109
|
+
language: string;
|
|
110
|
+
loc?: SourceLocation;
|
|
111
|
+
metadata?: SourceTargetMetadata;
|
|
112
|
+
name?: string;
|
|
113
|
+
origin?: SourceTargetOrigin;
|
|
114
|
+
range?: SourceRange;
|
|
115
|
+
text: string;
|
|
116
|
+
}
|
|
117
|
+
type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {});
|
|
118
|
+
type SourceTargetMetadata = Readonly<Record<string, SourceMetadataValue>>;
|
|
119
|
+
interface SourceTargetOrigin {
|
|
120
|
+
physicalPath: string;
|
|
121
|
+
range?: SourceRange;
|
|
122
|
+
virtualPath?: string;
|
|
123
|
+
}
|
|
124
|
+
interface SourceText {
|
|
125
|
+
filePath: string;
|
|
126
|
+
loc: SourceLocation;
|
|
127
|
+
text: string;
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region ../../node_modules/.pnpm/valibot@1.4.2_typescript@6.0.3/node_modules/valibot/dist/index.d.mts
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/types/metadata.d.ts
|
|
133
|
+
/**
|
|
134
|
+
* Base metadata interface.
|
|
135
|
+
*/
|
|
136
|
+
interface BaseMetadata<TInput$1> {
|
|
137
|
+
/**
|
|
138
|
+
* The object kind.
|
|
139
|
+
*/
|
|
140
|
+
readonly kind: "metadata";
|
|
141
|
+
/**
|
|
142
|
+
* The metadata type.
|
|
143
|
+
*/
|
|
144
|
+
readonly type: string;
|
|
145
|
+
/**
|
|
146
|
+
* The metadata reference.
|
|
147
|
+
*/
|
|
148
|
+
readonly reference: (...args: any[]) => BaseMetadata<any>;
|
|
149
|
+
/**
|
|
150
|
+
* The input, output and issue type.
|
|
151
|
+
*
|
|
152
|
+
* @internal
|
|
153
|
+
*/
|
|
154
|
+
readonly "~types"?: {
|
|
155
|
+
readonly input: TInput$1;
|
|
156
|
+
readonly output: TInput$1;
|
|
157
|
+
readonly issue: never;
|
|
158
|
+
} | undefined;
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/types/dataset.d.ts
|
|
162
|
+
/**
|
|
163
|
+
* Unknown dataset interface.
|
|
164
|
+
*/
|
|
165
|
+
interface UnknownDataset {
|
|
166
|
+
/**
|
|
167
|
+
* Whether is's typed.
|
|
168
|
+
*/
|
|
169
|
+
typed?: false;
|
|
170
|
+
/**
|
|
171
|
+
* The dataset value.
|
|
172
|
+
*/
|
|
173
|
+
value: unknown;
|
|
174
|
+
/**
|
|
175
|
+
* The dataset issues.
|
|
176
|
+
*/
|
|
177
|
+
issues?: undefined;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Success dataset interface.
|
|
181
|
+
*/
|
|
182
|
+
interface SuccessDataset<TValue$1> {
|
|
183
|
+
/**
|
|
184
|
+
* Whether is's typed.
|
|
185
|
+
*/
|
|
186
|
+
typed: true;
|
|
187
|
+
/**
|
|
188
|
+
* The dataset value.
|
|
189
|
+
*/
|
|
190
|
+
value: TValue$1;
|
|
191
|
+
/**
|
|
192
|
+
* The dataset issues.
|
|
193
|
+
*/
|
|
194
|
+
issues?: undefined;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Partial dataset interface.
|
|
198
|
+
*/
|
|
199
|
+
interface PartialDataset<TValue$1, TIssue extends BaseIssue<unknown>> {
|
|
200
|
+
/**
|
|
201
|
+
* Whether is's typed.
|
|
202
|
+
*/
|
|
203
|
+
typed: true;
|
|
204
|
+
/**
|
|
205
|
+
* The dataset value.
|
|
206
|
+
*/
|
|
207
|
+
value: TValue$1;
|
|
208
|
+
/**
|
|
209
|
+
* The dataset issues.
|
|
210
|
+
*/
|
|
211
|
+
issues: [TIssue, ...TIssue[]];
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Failure dataset interface.
|
|
215
|
+
*/
|
|
216
|
+
interface FailureDataset<TIssue extends BaseIssue<unknown>> {
|
|
217
|
+
/**
|
|
218
|
+
* Whether is's typed.
|
|
219
|
+
*/
|
|
220
|
+
typed: false;
|
|
221
|
+
/**
|
|
222
|
+
* The dataset value.
|
|
223
|
+
*/
|
|
224
|
+
value: unknown;
|
|
225
|
+
/**
|
|
226
|
+
* The dataset issues.
|
|
227
|
+
*/
|
|
228
|
+
issues: [TIssue, ...TIssue[]];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Output dataset type.
|
|
232
|
+
*/
|
|
233
|
+
type OutputDataset<TValue$1, TIssue extends BaseIssue<unknown>> = SuccessDataset<TValue$1> | PartialDataset<TValue$1, TIssue> | FailureDataset<TIssue>;
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/types/standard.d.ts
|
|
236
|
+
/**
|
|
237
|
+
* The Standard Schema properties interface.
|
|
238
|
+
*/
|
|
239
|
+
interface StandardProps<TInput$1, TOutput$1> {
|
|
240
|
+
/**
|
|
241
|
+
* The version number of the standard.
|
|
242
|
+
*/
|
|
243
|
+
readonly version: 1;
|
|
244
|
+
/**
|
|
245
|
+
* The vendor name of the schema library.
|
|
246
|
+
*/
|
|
247
|
+
readonly vendor: "valibot";
|
|
248
|
+
/**
|
|
249
|
+
* Validates unknown input values.
|
|
250
|
+
*/
|
|
251
|
+
readonly validate: (value: unknown) => StandardResult<TOutput$1> | Promise<StandardResult<TOutput$1>>;
|
|
252
|
+
/**
|
|
253
|
+
* Inferred types associated with the schema.
|
|
254
|
+
*/
|
|
255
|
+
readonly types?: StandardTypes<TInput$1, TOutput$1> | undefined;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The result interface of the validate function.
|
|
259
|
+
*/
|
|
260
|
+
type StandardResult<TOutput$1> = StandardSuccessResult<TOutput$1> | StandardFailureResult;
|
|
261
|
+
/**
|
|
262
|
+
* The result interface if validation succeeds.
|
|
263
|
+
*/
|
|
264
|
+
interface StandardSuccessResult<TOutput$1> {
|
|
265
|
+
/**
|
|
266
|
+
* The typed output value.
|
|
267
|
+
*/
|
|
268
|
+
readonly value: TOutput$1;
|
|
269
|
+
/**
|
|
270
|
+
* The non-existent issues.
|
|
271
|
+
*/
|
|
272
|
+
readonly issues?: undefined;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The result interface if validation fails.
|
|
276
|
+
*/
|
|
277
|
+
interface StandardFailureResult {
|
|
278
|
+
/**
|
|
279
|
+
* The issues of failed validation.
|
|
280
|
+
*/
|
|
281
|
+
readonly issues: readonly StandardIssue[];
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* The issue interface of the failure output.
|
|
285
|
+
*/
|
|
286
|
+
interface StandardIssue {
|
|
287
|
+
/**
|
|
288
|
+
* The error message of the issue.
|
|
289
|
+
*/
|
|
290
|
+
readonly message: string;
|
|
291
|
+
/**
|
|
292
|
+
* The path of the issue, if any.
|
|
293
|
+
*/
|
|
294
|
+
readonly path?: readonly (PropertyKey | StandardPathItem)[] | undefined;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The path item interface of the issue.
|
|
298
|
+
*/
|
|
299
|
+
interface StandardPathItem {
|
|
300
|
+
/**
|
|
301
|
+
* The key of the path item.
|
|
302
|
+
*/
|
|
303
|
+
readonly key: PropertyKey;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* The Standard Schema types interface.
|
|
307
|
+
*/
|
|
308
|
+
interface StandardTypes<TInput$1, TOutput$1> {
|
|
309
|
+
/**
|
|
310
|
+
* The input type of the schema.
|
|
311
|
+
*/
|
|
312
|
+
readonly input: TInput$1;
|
|
313
|
+
/**
|
|
314
|
+
* The output type of the schema.
|
|
315
|
+
*/
|
|
316
|
+
readonly output: TOutput$1;
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/types/schema.d.ts
|
|
320
|
+
/**
|
|
321
|
+
* Base schema interface.
|
|
322
|
+
*/
|
|
323
|
+
interface BaseSchema<TInput$1, TOutput$1, TIssue extends BaseIssue<unknown>> {
|
|
324
|
+
/**
|
|
325
|
+
* The object kind.
|
|
326
|
+
*/
|
|
327
|
+
readonly kind: "schema";
|
|
328
|
+
/**
|
|
329
|
+
* The schema type.
|
|
330
|
+
*/
|
|
331
|
+
readonly type: string;
|
|
332
|
+
/**
|
|
333
|
+
* The schema reference.
|
|
334
|
+
*/
|
|
335
|
+
readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>>;
|
|
336
|
+
/**
|
|
337
|
+
* The expected property.
|
|
338
|
+
*/
|
|
339
|
+
readonly expects: string;
|
|
340
|
+
/**
|
|
341
|
+
* Whether it's async.
|
|
342
|
+
*/
|
|
343
|
+
readonly async: false;
|
|
344
|
+
/**
|
|
345
|
+
* The Standard Schema properties.
|
|
346
|
+
*
|
|
347
|
+
* @internal
|
|
348
|
+
*/
|
|
349
|
+
readonly "~standard": StandardProps<TInput$1, TOutput$1>;
|
|
350
|
+
/**
|
|
351
|
+
* Parses unknown input values.
|
|
352
|
+
*
|
|
353
|
+
* @param dataset The input dataset.
|
|
354
|
+
* @param config The configuration.
|
|
355
|
+
*
|
|
356
|
+
* @returns The output dataset.
|
|
357
|
+
*
|
|
358
|
+
* @internal
|
|
359
|
+
*/
|
|
360
|
+
readonly "~run": (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput$1, TIssue>;
|
|
361
|
+
/**
|
|
362
|
+
* The input, output and issue type.
|
|
363
|
+
*
|
|
364
|
+
* @internal
|
|
365
|
+
*/
|
|
366
|
+
readonly "~types"?: {
|
|
367
|
+
readonly input: TInput$1;
|
|
368
|
+
readonly output: TOutput$1;
|
|
369
|
+
readonly issue: TIssue;
|
|
370
|
+
} | undefined;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Base schema async interface.
|
|
374
|
+
*/
|
|
375
|
+
interface BaseSchemaAsync<TInput$1, TOutput$1, TIssue extends BaseIssue<unknown>> extends Omit<BaseSchema<TInput$1, TOutput$1, TIssue>, "reference" | "async" | "~run"> {
|
|
376
|
+
/**
|
|
377
|
+
* The schema reference.
|
|
378
|
+
*/
|
|
379
|
+
readonly reference: (...args: any[]) => BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>>;
|
|
380
|
+
/**
|
|
381
|
+
* Whether it's async.
|
|
382
|
+
*/
|
|
383
|
+
readonly async: true;
|
|
384
|
+
/**
|
|
385
|
+
* Parses unknown input values.
|
|
386
|
+
*
|
|
387
|
+
* @param dataset The input dataset.
|
|
388
|
+
* @param config The configuration.
|
|
389
|
+
*
|
|
390
|
+
* @returns The output dataset.
|
|
391
|
+
*
|
|
392
|
+
* @internal
|
|
393
|
+
*/
|
|
394
|
+
readonly "~run": (dataset: UnknownDataset, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput$1, TIssue>>;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Generic schema type.
|
|
398
|
+
*/
|
|
399
|
+
type GenericSchema<TInput$1 = unknown, TOutput$1 = TInput$1, TIssue extends BaseIssue<unknown> = BaseIssue<unknown>> = BaseSchema<TInput$1, TOutput$1, TIssue>;
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region src/types/transformation.d.ts
|
|
402
|
+
/**
|
|
403
|
+
* Base transformation interface.
|
|
404
|
+
*/
|
|
405
|
+
interface BaseTransformation<TInput$1, TOutput$1, TIssue extends BaseIssue<unknown>> {
|
|
406
|
+
/**
|
|
407
|
+
* The object kind.
|
|
408
|
+
*/
|
|
409
|
+
readonly kind: "transformation";
|
|
410
|
+
/**
|
|
411
|
+
* The transformation type.
|
|
412
|
+
*/
|
|
413
|
+
readonly type: string;
|
|
414
|
+
/**
|
|
415
|
+
* The transformation reference.
|
|
416
|
+
*/
|
|
417
|
+
readonly reference: (...args: any[]) => BaseTransformation<any, any, BaseIssue<unknown>>;
|
|
418
|
+
/**
|
|
419
|
+
* Whether it's async.
|
|
420
|
+
*/
|
|
421
|
+
readonly async: false;
|
|
422
|
+
/**
|
|
423
|
+
* Transforms known input values.
|
|
424
|
+
*
|
|
425
|
+
* @param dataset The input dataset.
|
|
426
|
+
* @param config The configuration.
|
|
427
|
+
*
|
|
428
|
+
* @returns The output dataset.
|
|
429
|
+
*
|
|
430
|
+
* @internal
|
|
431
|
+
*/
|
|
432
|
+
readonly "~run": (dataset: SuccessDataset<TInput$1>, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput$1, BaseIssue<unknown> | TIssue>;
|
|
433
|
+
/**
|
|
434
|
+
* The input, output and issue type.
|
|
435
|
+
*
|
|
436
|
+
* @internal
|
|
437
|
+
*/
|
|
438
|
+
readonly "~types"?: {
|
|
439
|
+
readonly input: TInput$1;
|
|
440
|
+
readonly output: TOutput$1;
|
|
441
|
+
readonly issue: TIssue;
|
|
442
|
+
} | undefined;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Base transformation async interface.
|
|
446
|
+
*/
|
|
447
|
+
interface BaseTransformationAsync<TInput$1, TOutput$1, TIssue extends BaseIssue<unknown>> extends Omit<BaseTransformation<TInput$1, TOutput$1, TIssue>, "reference" | "async" | "~run"> {
|
|
448
|
+
/**
|
|
449
|
+
* The transformation reference.
|
|
450
|
+
*/
|
|
451
|
+
readonly reference: (...args: any[]) => BaseTransformation<any, any, BaseIssue<unknown>> | BaseTransformationAsync<any, any, BaseIssue<unknown>>;
|
|
452
|
+
/**
|
|
453
|
+
* Whether it's async.
|
|
454
|
+
*/
|
|
455
|
+
readonly async: true;
|
|
456
|
+
/**
|
|
457
|
+
* Transforms known input values.
|
|
458
|
+
*
|
|
459
|
+
* @param dataset The input dataset.
|
|
460
|
+
* @param config The configuration.
|
|
461
|
+
*
|
|
462
|
+
* @returns The output dataset.
|
|
463
|
+
*
|
|
464
|
+
* @internal
|
|
465
|
+
*/
|
|
466
|
+
readonly "~run": (dataset: SuccessDataset<TInput$1>, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput$1, BaseIssue<unknown> | TIssue>>;
|
|
467
|
+
}
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/types/validation.d.ts
|
|
470
|
+
/**
|
|
471
|
+
* Base validation interface.
|
|
472
|
+
*/
|
|
473
|
+
interface BaseValidation<TInput$1, TOutput$1, TIssue extends BaseIssue<unknown>> {
|
|
474
|
+
/**
|
|
475
|
+
* The object kind.
|
|
476
|
+
*/
|
|
477
|
+
readonly kind: "validation";
|
|
478
|
+
/**
|
|
479
|
+
* The validation type.
|
|
480
|
+
*/
|
|
481
|
+
readonly type: string;
|
|
482
|
+
/**
|
|
483
|
+
* The validation reference.
|
|
484
|
+
*/
|
|
485
|
+
readonly reference: (...args: any[]) => BaseValidation<any, any, BaseIssue<unknown>>;
|
|
486
|
+
/**
|
|
487
|
+
* The expected property.
|
|
488
|
+
*/
|
|
489
|
+
readonly expects: string | null;
|
|
490
|
+
/**
|
|
491
|
+
* Whether it's async.
|
|
492
|
+
*/
|
|
493
|
+
readonly async: false;
|
|
494
|
+
/**
|
|
495
|
+
* Validates known input values.
|
|
496
|
+
*
|
|
497
|
+
* @param dataset The input dataset.
|
|
498
|
+
* @param config The configuration.
|
|
499
|
+
*
|
|
500
|
+
* @returns The output dataset.
|
|
501
|
+
*
|
|
502
|
+
* @internal
|
|
503
|
+
*/
|
|
504
|
+
readonly "~run": (dataset: OutputDataset<TInput$1, BaseIssue<unknown>>, config: Config<BaseIssue<unknown>>) => OutputDataset<TOutput$1, BaseIssue<unknown> | TIssue>;
|
|
505
|
+
/**
|
|
506
|
+
* The input, output and issue type.
|
|
507
|
+
*
|
|
508
|
+
* @internal
|
|
509
|
+
*/
|
|
510
|
+
readonly "~types"?: {
|
|
511
|
+
readonly input: TInput$1;
|
|
512
|
+
readonly output: TOutput$1;
|
|
513
|
+
readonly issue: TIssue;
|
|
514
|
+
} | undefined;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Base validation async interface.
|
|
518
|
+
*/
|
|
519
|
+
interface BaseValidationAsync<TInput$1, TOutput$1, TIssue extends BaseIssue<unknown>> extends Omit<BaseValidation<TInput$1, TOutput$1, TIssue>, "reference" | "async" | "~run"> {
|
|
520
|
+
/**
|
|
521
|
+
* The validation reference.
|
|
522
|
+
*/
|
|
523
|
+
readonly reference: (...args: any[]) => BaseValidation<any, any, BaseIssue<unknown>> | BaseValidationAsync<any, any, BaseIssue<unknown>>;
|
|
524
|
+
/**
|
|
525
|
+
* Whether it's async.
|
|
526
|
+
*/
|
|
527
|
+
readonly async: true;
|
|
528
|
+
/**
|
|
529
|
+
* Validates known input values.
|
|
530
|
+
*
|
|
531
|
+
* @param dataset The input dataset.
|
|
532
|
+
* @param config The configuration.
|
|
533
|
+
*
|
|
534
|
+
* @returns The output dataset.
|
|
535
|
+
*
|
|
536
|
+
* @internal
|
|
537
|
+
*/
|
|
538
|
+
readonly "~run": (dataset: OutputDataset<TInput$1, BaseIssue<unknown>>, config: Config<BaseIssue<unknown>>) => Promise<OutputDataset<TOutput$1, BaseIssue<unknown> | TIssue>>;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Infer output type.
|
|
542
|
+
*/
|
|
543
|
+
type InferOutput<TItem$1 extends BaseSchema<unknown, unknown, BaseIssue<unknown>> | BaseSchemaAsync<unknown, unknown, BaseIssue<unknown>> | BaseValidation<any, unknown, BaseIssue<unknown>> | BaseValidationAsync<any, unknown, BaseIssue<unknown>> | BaseTransformation<any, unknown, BaseIssue<unknown>> | BaseTransformationAsync<any, unknown, BaseIssue<unknown>> | BaseMetadata<any>> = NonNullable<TItem$1["~types"]>["output"];
|
|
544
|
+
/**
|
|
545
|
+
* Constructs a type that is maybe readonly.
|
|
546
|
+
*/
|
|
547
|
+
type MaybeReadonly<TValue$1> = TValue$1 | Readonly<TValue$1>;
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/types/other.d.ts
|
|
550
|
+
/**
|
|
551
|
+
* Error message type.
|
|
552
|
+
*/
|
|
553
|
+
type ErrorMessage<TIssue extends BaseIssue<unknown>> = ((issue: TIssue) => string) | string;
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region src/types/issue.d.ts
|
|
556
|
+
/**
|
|
557
|
+
* Array path item interface.
|
|
558
|
+
*/
|
|
559
|
+
interface ArrayPathItem {
|
|
560
|
+
/**
|
|
561
|
+
* The path item type.
|
|
562
|
+
*/
|
|
563
|
+
readonly type: "array";
|
|
564
|
+
/**
|
|
565
|
+
* The path item origin.
|
|
566
|
+
*/
|
|
567
|
+
readonly origin: "value";
|
|
568
|
+
/**
|
|
569
|
+
* The path item input.
|
|
570
|
+
*/
|
|
571
|
+
readonly input: MaybeReadonly<unknown[]>;
|
|
572
|
+
/**
|
|
573
|
+
* The path item key.
|
|
574
|
+
*/
|
|
575
|
+
readonly key: number;
|
|
576
|
+
/**
|
|
577
|
+
* The path item value.
|
|
578
|
+
*/
|
|
579
|
+
readonly value: unknown;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Map path item interface.
|
|
583
|
+
*/
|
|
584
|
+
interface MapPathItem {
|
|
585
|
+
/**
|
|
586
|
+
* The path item type.
|
|
587
|
+
*/
|
|
588
|
+
readonly type: "map";
|
|
589
|
+
/**
|
|
590
|
+
* The path item origin.
|
|
591
|
+
*/
|
|
592
|
+
readonly origin: "key" | "value";
|
|
593
|
+
/**
|
|
594
|
+
* The path item input.
|
|
595
|
+
*/
|
|
596
|
+
readonly input: Map<unknown, unknown>;
|
|
597
|
+
/**
|
|
598
|
+
* The path item key.
|
|
599
|
+
*/
|
|
600
|
+
readonly key: unknown;
|
|
601
|
+
/**
|
|
602
|
+
* The path item value.
|
|
603
|
+
*/
|
|
604
|
+
readonly value: unknown;
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Object path item interface.
|
|
608
|
+
*/
|
|
609
|
+
interface ObjectPathItem {
|
|
610
|
+
/**
|
|
611
|
+
* The path item type.
|
|
612
|
+
*/
|
|
613
|
+
readonly type: "object";
|
|
614
|
+
/**
|
|
615
|
+
* The path item origin.
|
|
616
|
+
*/
|
|
617
|
+
readonly origin: "key" | "value";
|
|
618
|
+
/**
|
|
619
|
+
* The path item input.
|
|
620
|
+
*/
|
|
621
|
+
readonly input: Record<string, unknown>;
|
|
622
|
+
/**
|
|
623
|
+
* The path item key.
|
|
624
|
+
*/
|
|
625
|
+
readonly key: string;
|
|
626
|
+
/**
|
|
627
|
+
* The path item value.
|
|
628
|
+
*/
|
|
629
|
+
readonly value: unknown;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Set path item interface.
|
|
633
|
+
*/
|
|
634
|
+
interface SetPathItem {
|
|
635
|
+
/**
|
|
636
|
+
* The path item type.
|
|
637
|
+
*/
|
|
638
|
+
readonly type: "set";
|
|
639
|
+
/**
|
|
640
|
+
* The path item origin.
|
|
641
|
+
*/
|
|
642
|
+
readonly origin: "value";
|
|
643
|
+
/**
|
|
644
|
+
* The path item input.
|
|
645
|
+
*/
|
|
646
|
+
readonly input: Set<unknown>;
|
|
647
|
+
/**
|
|
648
|
+
* The path item key.
|
|
649
|
+
*/
|
|
650
|
+
readonly key: null;
|
|
651
|
+
/**
|
|
652
|
+
* The path item key.
|
|
653
|
+
*/
|
|
654
|
+
readonly value: unknown;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Unknown path item interface.
|
|
658
|
+
*/
|
|
659
|
+
interface UnknownPathItem {
|
|
660
|
+
/**
|
|
661
|
+
* The path item type.
|
|
662
|
+
*/
|
|
663
|
+
readonly type: "unknown";
|
|
664
|
+
/**
|
|
665
|
+
* The path item origin.
|
|
666
|
+
*/
|
|
667
|
+
readonly origin: "key" | "value";
|
|
668
|
+
/**
|
|
669
|
+
* The path item input.
|
|
670
|
+
*/
|
|
671
|
+
readonly input: unknown;
|
|
672
|
+
/**
|
|
673
|
+
* The path item key.
|
|
674
|
+
*/
|
|
675
|
+
readonly key: unknown;
|
|
676
|
+
/**
|
|
677
|
+
* The path item value.
|
|
678
|
+
*/
|
|
679
|
+
readonly value: unknown;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Issue path item type.
|
|
683
|
+
*/
|
|
684
|
+
type IssuePathItem = ArrayPathItem | MapPathItem | ObjectPathItem | SetPathItem | UnknownPathItem;
|
|
685
|
+
/**
|
|
686
|
+
* Base issue interface.
|
|
687
|
+
*/
|
|
688
|
+
interface BaseIssue<TInput$1> extends Config<BaseIssue<TInput$1>> {
|
|
689
|
+
/**
|
|
690
|
+
* The issue kind.
|
|
691
|
+
*/
|
|
692
|
+
readonly kind: "schema" | "validation" | "transformation";
|
|
693
|
+
/**
|
|
694
|
+
* The issue type.
|
|
695
|
+
*/
|
|
696
|
+
readonly type: string;
|
|
697
|
+
/**
|
|
698
|
+
* The raw input data.
|
|
699
|
+
*/
|
|
700
|
+
readonly input: TInput$1;
|
|
701
|
+
/**
|
|
702
|
+
* The expected property.
|
|
703
|
+
*/
|
|
704
|
+
readonly expected: string | null;
|
|
705
|
+
/**
|
|
706
|
+
* The received property.
|
|
707
|
+
*/
|
|
708
|
+
readonly received: string;
|
|
709
|
+
/**
|
|
710
|
+
* The error message.
|
|
711
|
+
*/
|
|
712
|
+
readonly message: string;
|
|
713
|
+
/**
|
|
714
|
+
* The input requirement.
|
|
715
|
+
*/
|
|
716
|
+
readonly requirement?: unknown | undefined;
|
|
717
|
+
/**
|
|
718
|
+
* The issue path.
|
|
719
|
+
*/
|
|
720
|
+
readonly path?: [IssuePathItem, ...IssuePathItem[]] | undefined;
|
|
721
|
+
/**
|
|
722
|
+
* The sub issues.
|
|
723
|
+
*/
|
|
724
|
+
readonly issues?: [BaseIssue<TInput$1>, ...BaseIssue<TInput$1>[]] | undefined;
|
|
725
|
+
}
|
|
726
|
+
//#endregion
|
|
727
|
+
//#region src/types/config.d.ts
|
|
728
|
+
/**
|
|
729
|
+
* Config interface.
|
|
730
|
+
*/
|
|
731
|
+
interface Config<TIssue extends BaseIssue<unknown>> {
|
|
732
|
+
/**
|
|
733
|
+
* The selected language.
|
|
734
|
+
*/
|
|
735
|
+
readonly lang?: string | undefined;
|
|
736
|
+
/**
|
|
737
|
+
* The error message.
|
|
738
|
+
*/
|
|
739
|
+
readonly message?: ErrorMessage<TIssue> | undefined;
|
|
740
|
+
/**
|
|
741
|
+
* Whether it should be aborted early.
|
|
742
|
+
*/
|
|
743
|
+
readonly abortEarly?: boolean | undefined;
|
|
744
|
+
/**
|
|
745
|
+
* Whether a pipe should be aborted early.
|
|
746
|
+
*/
|
|
747
|
+
readonly abortPipeEarly?: boolean | undefined;
|
|
748
|
+
}
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region ../core/dist/types-deBCDA4_.d.mts
|
|
751
|
+
//#region src/config/types.d.ts
|
|
752
|
+
type ModelSize = 'large' | 'medium' | 'small';
|
|
753
|
+
interface RunnerCacheConfig {
|
|
754
|
+
enabled?: boolean;
|
|
755
|
+
location?: string;
|
|
756
|
+
}
|
|
757
|
+
interface RunnerConfig {
|
|
758
|
+
/** Retries after the initial attempt for replay-safe agent failures. @default 2 */
|
|
759
|
+
agentRetries?: number;
|
|
760
|
+
cache?: boolean | RunnerCacheConfig;
|
|
761
|
+
ruleConcurrency?: number;
|
|
762
|
+
stats?: boolean | RunnerStatsConfig;
|
|
763
|
+
timeoutMs?: number;
|
|
764
|
+
}
|
|
765
|
+
interface RunnerStatsConfig {
|
|
766
|
+
enabled?: boolean;
|
|
767
|
+
location?: string;
|
|
768
|
+
retentionMonths?: number;
|
|
769
|
+
}
|
|
770
|
+
//#endregion
|
|
771
|
+
//#region src/models/types.d.ts
|
|
772
|
+
interface ModelRequirement {
|
|
773
|
+
capabilities?: string[];
|
|
774
|
+
minContextWindow?: number;
|
|
775
|
+
params?: Record<string, unknown>;
|
|
776
|
+
size?: ModelSize;
|
|
777
|
+
}
|
|
778
|
+
interface ResolvedModel {
|
|
779
|
+
aliases: string[];
|
|
780
|
+
capabilities: string[];
|
|
781
|
+
contextWindow?: number;
|
|
782
|
+
id: string;
|
|
783
|
+
name: string;
|
|
784
|
+
params: Record<string, unknown>;
|
|
785
|
+
provider: ResolvedProvider;
|
|
786
|
+
size?: ModelSize;
|
|
787
|
+
}
|
|
788
|
+
interface ResolvedProvider {
|
|
789
|
+
endpoint: string;
|
|
790
|
+
headers: Record<string, string>;
|
|
791
|
+
id: string;
|
|
792
|
+
type: 'openai-compatible';
|
|
793
|
+
}
|
|
794
|
+
//#endregion
|
|
795
|
+
//#region src/agent/types.d.ts
|
|
796
|
+
type AgentAdapter = (request: AgentRequest) => Promise<AgentResult>;
|
|
797
|
+
interface AgentRequest {
|
|
798
|
+
instructions: string;
|
|
799
|
+
model: ResolvedModel;
|
|
800
|
+
prompt: string;
|
|
801
|
+
signal?: AbortSignal;
|
|
802
|
+
tools: AgentTool[];
|
|
803
|
+
}
|
|
804
|
+
interface AgentResult {
|
|
805
|
+
answer: string;
|
|
806
|
+
usage?: AgentUsage;
|
|
807
|
+
}
|
|
808
|
+
/** Agent-agnostic tool definition. Each adapter translates it to its framework's tool format. */
|
|
809
|
+
interface AgentTool {
|
|
810
|
+
description: string;
|
|
811
|
+
execute: (input: unknown) => Promise<unknown> | unknown;
|
|
812
|
+
name: string;
|
|
813
|
+
parameters: Record<string, unknown>;
|
|
814
|
+
}
|
|
815
|
+
interface AgentUsage {
|
|
816
|
+
inputTokens?: number;
|
|
817
|
+
outputTokens?: number;
|
|
818
|
+
totalTokens?: number;
|
|
819
|
+
}
|
|
820
|
+
type AlintConfigExtends = AlintConfigInput | string;
|
|
821
|
+
type AlintConfigInput = AlintConfigItem | readonly AlintConfigInput[];
|
|
822
|
+
interface AlintConfigItem {
|
|
823
|
+
agent?: AgentAdapter;
|
|
824
|
+
basePath?: string;
|
|
825
|
+
directories?: readonly (readonly string[] | string)[];
|
|
826
|
+
extends?: readonly AlintConfigExtends[];
|
|
827
|
+
files?: readonly (readonly string[] | string)[];
|
|
828
|
+
ignore?: IgnoreConfig;
|
|
829
|
+
ignores?: readonly string[];
|
|
830
|
+
language?: string;
|
|
831
|
+
languageOptions?: Record<string, unknown>;
|
|
832
|
+
linterOptions?: AlintLinterOptions;
|
|
833
|
+
name?: string;
|
|
834
|
+
plugins?: Record<string, PluginDefinition>;
|
|
835
|
+
processor?: ProcessorDefinition | string;
|
|
836
|
+
rules?: Record<string, RuleConfigEntry>;
|
|
837
|
+
runner?: RunnerConfig;
|
|
838
|
+
settings?: Record<string, unknown>;
|
|
839
|
+
}
|
|
840
|
+
interface AlintLinterOptions {
|
|
841
|
+
noInlineConfig?: boolean;
|
|
842
|
+
/**
|
|
843
|
+
* How the run reports files it lints that no language claimed, so they were handled as plain
|
|
844
|
+
* text. Defaults to `'warn'`. An explicit `language: 'plaintext'` pin means plain text was the
|
|
845
|
+
* intent, so pinned files are never reported.
|
|
846
|
+
*/
|
|
847
|
+
reportUnregisteredLanguages?: RuleSeverity;
|
|
848
|
+
reportUnusedDisableDirectives?: RuleSeverity;
|
|
849
|
+
}
|
|
850
|
+
type Awaitable<T> = Promise<T> | T;
|
|
851
|
+
interface DiagnosticDescriptor {
|
|
852
|
+
evidence?: unknown;
|
|
853
|
+
filePath?: string;
|
|
854
|
+
loc?: DiagnosticLocation;
|
|
855
|
+
message: string;
|
|
856
|
+
}
|
|
857
|
+
interface DiagnosticLocation {
|
|
858
|
+
end?: {
|
|
859
|
+
column: number;
|
|
860
|
+
line: number;
|
|
861
|
+
};
|
|
862
|
+
start: {
|
|
863
|
+
column: number;
|
|
864
|
+
line: number;
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
interface DirectoryTarget {
|
|
868
|
+
kind: 'directory';
|
|
869
|
+
path: string;
|
|
870
|
+
}
|
|
871
|
+
interface IgnoreConfig {
|
|
872
|
+
gitignore?: boolean;
|
|
873
|
+
}
|
|
874
|
+
interface LanguageDefinition {
|
|
875
|
+
extensions?: readonly string[];
|
|
876
|
+
extract: (file: SourceFile$1, context: LanguageContext) => Awaitable<SourceTarget$1[]>;
|
|
877
|
+
/**
|
|
878
|
+
* The language's id: what a config pins through `language:`, what a rule's `languages` lists, and
|
|
879
|
+
* what every target it extracts reports. The registry is keyed by it, so two packs cannot claim
|
|
880
|
+
* the same one.
|
|
881
|
+
*
|
|
882
|
+
* Use the identifier editors already use — `go`, `python`, `rust`, `typescript`, `plaintext` —
|
|
883
|
+
* rather than inventing a spelling. Anyone can register a language, so the set is open by
|
|
884
|
+
* definition and only a shared convention keeps one language from arriving under three names.
|
|
885
|
+
*
|
|
886
|
+
* NOTICE: the list is VS Code's. The Language Server Protocol shares it for the languages it
|
|
887
|
+
* covers, but its table has no entry for plain text, so `plaintext` comes from VS Code alone.
|
|
888
|
+
* https://code.visualstudio.com/docs/languages/identifiers
|
|
889
|
+
* https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentItem
|
|
890
|
+
*/
|
|
891
|
+
name: string;
|
|
892
|
+
}
|
|
893
|
+
interface PluginDefinition<Rules extends Record<string, RuleDefinition<any>> = Record<string, RuleDefinition<any>>> {
|
|
894
|
+
configs?: Record<string, AlintConfigInput>;
|
|
895
|
+
languages?: Record<string, LanguageDefinition>;
|
|
896
|
+
processors?: Record<string, ProcessorDefinition>;
|
|
897
|
+
rules?: Rules;
|
|
898
|
+
}
|
|
899
|
+
interface ProcessorDefinition {
|
|
900
|
+
postprocess?: (diagnostics: DiagnosticDescriptor[], context: ProcessorPostprocessContext) => Awaitable<DiagnosticDescriptor[]>;
|
|
901
|
+
preprocess: (file: SourceFile$1, context: ProcessorContext) => Awaitable<ProcessedSource[]>;
|
|
902
|
+
}
|
|
903
|
+
interface ProjectFileEntry extends BaseSourceFile {
|
|
904
|
+
targetCount: number;
|
|
905
|
+
}
|
|
906
|
+
interface ProjectTarget {
|
|
907
|
+
files: readonly ProjectFileEntry[];
|
|
908
|
+
kind: 'project';
|
|
909
|
+
root: string;
|
|
910
|
+
targets: readonly ProjectTargetEntry[];
|
|
911
|
+
}
|
|
912
|
+
interface ProjectTargetEntry {
|
|
913
|
+
filePath: string;
|
|
914
|
+
identity: string;
|
|
915
|
+
kind: string;
|
|
916
|
+
name?: string;
|
|
917
|
+
range?: SourceRange;
|
|
918
|
+
}
|
|
919
|
+
type RuleCacheConfig = boolean | {
|
|
920
|
+
level?: 'target';
|
|
921
|
+
};
|
|
922
|
+
type RuleConfigEntry<Options extends readonly unknown[] = readonly []> = readonly [RuleSeverity, ...Partial<Options>] | RuleSeverity;
|
|
923
|
+
interface RuleContext<Options extends readonly unknown[] = readonly []> {
|
|
924
|
+
agent?: AgentAdapter;
|
|
925
|
+
cwd: string;
|
|
926
|
+
id: string;
|
|
927
|
+
localId: string;
|
|
928
|
+
logger: {
|
|
929
|
+
debug: (...args: unknown[]) => void;
|
|
930
|
+
};
|
|
931
|
+
metering: {
|
|
932
|
+
recordUsage: (usage: RuleInferenceUsageRecord) => void;
|
|
933
|
+
};
|
|
934
|
+
model: (selector?: ModelRequirement | string) => Promise<ResolvedModel>;
|
|
935
|
+
options: Options;
|
|
936
|
+
outputLanguage?: string;
|
|
937
|
+
report: (diagnostic: DiagnosticDescriptor) => void;
|
|
938
|
+
settings: Record<string, unknown>;
|
|
939
|
+
/**
|
|
940
|
+
* Cancels the run. Forward it to anything long-running a rule starts, so cancelling stops
|
|
941
|
+
* the work instead of letting it finish and bill.
|
|
942
|
+
*
|
|
943
|
+
* `ctx.agent` already injects it, and `generateStructured` accepts it as `signal`.
|
|
944
|
+
*/
|
|
945
|
+
signal?: AbortSignal;
|
|
946
|
+
src: SourceRuntime;
|
|
947
|
+
}
|
|
948
|
+
interface RuleDefinition<OptionsSchema extends RuleOptionsSchema = []> {
|
|
949
|
+
cache?: RuleCacheConfig;
|
|
950
|
+
/** Additional stable rule inputs, such as imported prompts, that invalidate cached results when changed. */
|
|
951
|
+
cacheKey?: unknown;
|
|
952
|
+
create: (context: RuleContext<RuleOptionsOutput<OptionsSchema>>) => RuleHandlers;
|
|
953
|
+
/**
|
|
954
|
+
* Which languages this rule reads. Omitting it opts out of extraction: the rule still receives
|
|
955
|
+
* file targets, but never the function and class targets a language produces.
|
|
956
|
+
*
|
|
957
|
+
* It does not choose how a file is parsed. A config's `language:` pin, or the extension, settles
|
|
958
|
+
* that before any rule is consulted. Directory and project targets ignore it too: they index a
|
|
959
|
+
* tree rather than come from a language.
|
|
960
|
+
*/
|
|
961
|
+
languages?: RuleLanguages;
|
|
962
|
+
model?: ModelRequirement;
|
|
963
|
+
options?: OptionsSchema;
|
|
964
|
+
}
|
|
965
|
+
type RuleHandlers = RuleSpecializedHandlers | RuleWithHandler;
|
|
966
|
+
interface RuleInferenceUsageRecord {
|
|
967
|
+
filePath?: string;
|
|
968
|
+
inputTokens?: number;
|
|
969
|
+
metadata?: unknown;
|
|
970
|
+
modelId: string;
|
|
971
|
+
outputTokens?: number;
|
|
972
|
+
providerId: string;
|
|
973
|
+
ruleId?: string;
|
|
974
|
+
totalTokens?: number;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* - `'any'` — every registered language, and never a failure. A rule that works from `FunctionInfo`
|
|
978
|
+
* alone wants this: a language pack the user installs later is covered without a new release.
|
|
979
|
+
* - A list of language ids — `LanguageDefinition.name` values such as `go` or `typescript`, never
|
|
980
|
+
* file extensions. The rule handles exactly these. Files of other languages are skipped
|
|
981
|
+
* rather than failed, so one plugin can carry rules for several languages behind one `files:`
|
|
982
|
+
* glob. If a listed language is not registered at all the run fails, because a rule scoped to a
|
|
983
|
+
* language nothing provides would otherwise skip every file in silence.
|
|
984
|
+
* - `{ ids: string[], skipMissing?: boolean }` — the same scoping, but an unregistered id can be
|
|
985
|
+
* skipped instead of failing. For a plugin whose rules span languages a given user may not have installed.
|
|
986
|
+
*/
|
|
987
|
+
type RuleLanguages = 'any' | readonly string[] | {
|
|
988
|
+
/** Language ids this rule applies to. */
|
|
989
|
+
ids: readonly string[];
|
|
990
|
+
/** Whether to skip unregistered languages instead of failing. */
|
|
991
|
+
skipMissing?: boolean;
|
|
992
|
+
};
|
|
993
|
+
type RuleOptionsOutput<OptionsSchema extends RuleOptionsSchema> = { readonly [Index in keyof OptionsSchema]: InferOutput<OptionsSchema[Index]>; };
|
|
994
|
+
type RuleOptionsSchema = readonly GenericSchema[];
|
|
995
|
+
type RuleSeverity = 'error' | 'off' | 'warn';
|
|
996
|
+
interface RuleSpecializedHandlers {
|
|
997
|
+
onTargetClass?: (target: ClassTarget) => Awaitable<void>;
|
|
998
|
+
onTargetDirectory?: (target: DirectoryTarget) => Awaitable<void>;
|
|
999
|
+
onTargetFile?: (target: FileTarget) => Awaitable<void>;
|
|
1000
|
+
onTargetFunction?: (target: FunctionTarget) => Awaitable<void>;
|
|
1001
|
+
onTargetProject?: (target: ProjectTarget) => Awaitable<void>;
|
|
1002
|
+
onTargetWith?: never;
|
|
1003
|
+
}
|
|
1004
|
+
interface RuleWithHandler {
|
|
1005
|
+
onTargetClass?: never;
|
|
1006
|
+
onTargetDirectory?: never;
|
|
1007
|
+
onTargetFile?: never;
|
|
1008
|
+
onTargetFunction?: never;
|
|
1009
|
+
onTargetProject?: never;
|
|
1010
|
+
onTargetWith: (target: Target) => Awaitable<void>;
|
|
1011
|
+
}
|
|
1012
|
+
type Target = DirectoryTarget | PlannedSourceTarget | ProjectTarget;
|
|
1013
|
+
//#endregion
|
|
1014
|
+
//#region src/extract.d.ts
|
|
1015
|
+
/**
|
|
1016
|
+
* One file target carrying every call site, then one function target per function, each with the
|
|
1017
|
+
* `FunctionInfo` a consumer would otherwise need its own parser to work out.
|
|
1018
|
+
*
|
|
1019
|
+
* The language comes from the file rather than a second argument, because every target carries that
|
|
1020
|
+
* same file and the two could then disagree. Pass the file through `withLanguage` first.
|
|
1021
|
+
*/
|
|
1022
|
+
declare function extractTargets(file: SourceFile): Promise<SourceTarget[]>;
|
|
1023
|
+
//#endregion
|
|
1024
|
+
//#region src/index.d.ts
|
|
1025
|
+
declare const goLanguage: LanguageDefinition;
|
|
1026
|
+
declare const pythonLanguage: LanguageDefinition;
|
|
1027
|
+
declare const rustLanguage: LanguageDefinition;
|
|
1028
|
+
/**
|
|
1029
|
+
* A plugin that declares languages and nothing else: no rules, no processors.
|
|
1030
|
+
*
|
|
1031
|
+
* The alias a config registers it under does not matter, because languages register under their own
|
|
1032
|
+
* names. Once registered, they serve every plugin's rules, not just this one's.
|
|
1033
|
+
*/
|
|
1034
|
+
declare const languagesPlugin: PluginDefinition<Record<string, RuleDefinition<any>>>;
|
|
1035
|
+
//#endregion
|
|
1036
|
+
export { languagesPlugin as default, languagesPlugin, extractTargets, goLanguage, pythonLanguage, rustLanguage };
|