-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Processor.ts
87 lines (75 loc) · 2.22 KB
/
Processor.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* eslint-disable @typescript-eslint/no-namespace */
import type { Linter } from './Linter';
export namespace Processor {
export interface ProcessorMeta {
/**
* The unique name of the processor.
*/
name: string;
/**
* The a string identifying the version of the processor.
*/
version?: string;
}
export type PreProcess = (
text: string,
filename: string,
) => (string | { text: string; filename: string })[];
export type PostProcess = (
messagesList: Linter.LintMessage[][],
filename: string,
) => Linter.LintMessage[];
export interface ProcessorModule {
/**
* Information about the processor to uniquely identify it when serializing.
*/
meta?: ProcessorMeta;
/**
* The function to extract code blocks.
*/
preprocess?: PreProcess;
/**
* The function to merge messages.
*/
postprocess?: PostProcess;
/**
* If `true` then it means the processor supports autofix.
*/
supportsAutofix?: boolean;
}
/**
* A loose definition of the ParserModule type for use with configs
* This type intended to relax validation of configs so that parsers that have
* different AST types or scope managers can still be passed to configs
*
* @see {@link LooseRuleDefinition}, {@link LooseParserModule}
*/
export interface LooseProcessorModule {
/**
* Information about the processor to uniquely identify it when serializing.
*/
meta?: Partial<ProcessorMeta>;
/**
* The function to extract code blocks.
*/
/*
eslint-disable-next-line @typescript-eslint/no-explicit-any --
intentionally using `any` to allow bi-directional assignment (unknown and
never only allow unidirectional)
*/
preprocess?: (text: string, filename: string) => any;
/**
* The function to merge messages.
*/
/*
eslint-disable-next-line @typescript-eslint/no-explicit-any --
intentionally using `any` to allow bi-directional assignment (unknown and
never only allow unidirectional)
*/
postprocess?: (messagesList: any, filename: string) => any;
/**
* If `true` then it means the processor supports autofix.
*/
supportsAutofix?: boolean;
}
}