/
types.ts
76 lines (69 loc) · 1.87 KB
/
types.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
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import type { MessageIds, Options } from '../naming-convention';
import type {
IndividualAndMetaSelectorsString,
MetaSelectors,
Modifiers,
ModifiersString,
PredefinedFormats,
PredefinedFormatsString,
Selectors,
SelectorsString,
TypeModifiers,
TypeModifiersString,
UnderscoreOptions,
UnderscoreOptionsString,
} from './enums';
interface MatchRegex {
regex: string;
match: boolean;
}
interface Selector {
// format options
format: PredefinedFormatsString[] | null;
custom?: MatchRegex;
leadingUnderscore?: UnderscoreOptionsString;
trailingUnderscore?: UnderscoreOptionsString;
prefix?: string[];
suffix?: string[];
// selector options
selector:
| IndividualAndMetaSelectorsString
| IndividualAndMetaSelectorsString[];
modifiers?: ModifiersString[];
types?: TypeModifiersString[];
filter?: string | MatchRegex;
}
interface NormalizedMatchRegex {
regex: RegExp;
match: boolean;
}
interface NormalizedSelector {
// format options
format: PredefinedFormats[] | null;
custom: NormalizedMatchRegex | null;
leadingUnderscore: UnderscoreOptions | null;
trailingUnderscore: UnderscoreOptions | null;
prefix: string[] | null;
suffix: string[] | null;
// selector options
selector: Selectors | MetaSelectors;
modifiers: Modifiers[] | null;
types: TypeModifiers[] | null;
filter: NormalizedMatchRegex | null;
// calculated ordering weight based on modifiers
modifierWeight: number;
}
type ValidatorFunction = (
node: TSESTree.Identifier | TSESTree.PrivateIdentifier | TSESTree.Literal,
modifiers?: Set<Modifiers>,
) => void;
type ParsedOptions = Record<SelectorsString, ValidatorFunction>;
type Context = Readonly<TSESLint.RuleContext<MessageIds, Options>>;
export type {
Context,
NormalizedSelector,
ParsedOptions,
Selector,
ValidatorFunction,
};