-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslintTypes.d.ts
146 lines (133 loc) · 4.3 KB
/
eslintTypes.d.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* eslint-disable @typescript-eslint/prefer-literal-enum-member */
/* eslint-disable no-bitwise */
/* eslint-disable @typescript-eslint/prefer-enum-initializers */
/* eslint-disable @typescript-eslint/member-ordering */
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-unused-vars */
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/naming-convention-utils/types.ts
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/rules/naming-convention-utils/enums.ts
export 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?: MatchRegex | string;
}
interface MatchRegex {
regex: string;
match: boolean;
}
enum PredefinedFormats {
camelCase = 1,
strictCamelCase,
PascalCase,
StrictPascalCase,
snake_case,
UPPER_CASE,
}
type PredefinedFormatsString = keyof typeof PredefinedFormats;
enum UnderscoreOptions {
forbid = 1,
allow,
require,
// special cases as it's common practice to use double underscore
requireDouble,
allowDouble,
allowSingleOrDouble,
}
type UnderscoreOptionsString = keyof typeof UnderscoreOptions;
enum Selectors {
// variableLike
variable = 1 << 0,
function = 1 << 1,
parameter = 1 << 2,
// memberLike
parameterProperty = 1 << 3,
classicAccessor = 1 << 4,
enumMember = 1 << 5,
classMethod = 1 << 6,
objectLiteralMethod = 1 << 7,
typeMethod = 1 << 8,
classProperty = 1 << 9,
objectLiteralProperty = 1 << 10,
typeProperty = 1 << 11,
autoAccessor = 1 << 12,
// typeLike
class = 1 << 13,
interface = 1 << 14,
typeAlias = 1 << 15,
enum = 1 << 16,
typeParameter = 1 << 17,
// other
import = 1 << 18,
}
type SelectorsString = keyof typeof Selectors;
enum MetaSelectors {
default = -1,
variableLike = 0 | Selectors.variable | Selectors.function | Selectors.parameter,
memberLike = 0 |
Selectors.classProperty |
Selectors.objectLiteralProperty |
Selectors.typeProperty |
Selectors.parameterProperty |
Selectors.enumMember |
Selectors.classMethod |
Selectors.objectLiteralMethod |
Selectors.typeMethod |
Selectors.classicAccessor |
Selectors.autoAccessor,
typeLike = 0 | Selectors.class | Selectors.interface | Selectors.typeAlias | Selectors.enum | Selectors.typeParameter,
method = 0 | Selectors.classMethod | Selectors.objectLiteralMethod | Selectors.typeMethod,
property = 0 | Selectors.classProperty | Selectors.objectLiteralProperty | Selectors.typeProperty,
accessor = 0 | Selectors.classicAccessor | Selectors.autoAccessor,
}
type MetaSelectorsString = keyof typeof MetaSelectors;
type IndividualAndMetaSelectorsString = MetaSelectorsString | SelectorsString;
enum Modifiers {
// const variable
const = 1 << 0,
// readonly members
readonly = 1 << 1,
// static members
static = 1 << 2,
// member accessibility
public = 1 << 3,
protected = 1 << 4,
private = 1 << 5,
"#private" = 1 << 6,
abstract = 1 << 7,
// destructured variable
destructured = 1 << 8,
// variables declared in the top-level scope
global = 1 << 9,
// things that are exported
exported = 1 << 10,
// things that are unused
unused = 1 << 11,
// properties that require quoting
requiresQuotes = 1 << 12,
// class members that are overridden
override = 1 << 13,
// class methods, object function properties, or functions that are async via the `async` keyword
async = 1 << 14,
// default imports
default = 1 << 15,
// namespace imports
namespace = 1 << 16,
}
type ModifiersString = keyof typeof Modifiers;
enum TypeModifiers {
boolean = 1 << 17,
string = 1 << 18,
number = 1 << 19,
function = 1 << 20,
array = 1 << 21,
}
type TypeModifiersString = keyof typeof TypeModifiers;