forked from gajus/eslint-config-canonical
-
Notifications
You must be signed in to change notification settings - Fork 0
/
typescript.js
216 lines (215 loc) · 6.25 KB
/
typescript.js
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// TODO add .d.ts files
// {
// files: ['*.d.ts'],
// rules: {
// '@typescript-eslint/consistent-type-definitions': 0,
// '@typescript-eslint/no-empty-interface': 0,
// '@typescript-eslint/no-shadow': 0,
// 'no-var': 0,
// 'vars-on-top': 0,
// },
// }
module.exports.recommended = {
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: require('@typescript-eslint/parser'),
parserOptions: {
project: true,
},
},
plugins: {
'@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
canonical: require('eslint-plugin-canonical'),
},
rules: {
'@typescript-eslint/adjacent-overload-signatures': 2,
'@typescript-eslint/array-type': [
2,
{
default: 'array-simple',
},
],
'@typescript-eslint/ban-ts-comment': [
2,
{
'ts-check': true,
'ts-expect-error': 'allow-with-description',
'ts-ignore': false,
'ts-nocheck': false,
},
],
'@typescript-eslint/ban-tslint-comment': 2,
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/class-literal-property-style': [2, 'fields'],
'@typescript-eslint/consistent-indexed-object-style': 0,
'@typescript-eslint/consistent-type-assertions': [
2,
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'allow',
},
],
'@typescript-eslint/consistent-type-definitions': [2, 'type'],
'@typescript-eslint/consistent-type-imports': [
2,
{
prefer: 'type-imports',
},
],
'@typescript-eslint/default-param-last': 2,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/member-delimiter-style': [
2,
{
multiline: {
delimiter: 'comma',
requireLast: true,
},
overrides: {
interface: {
multiline: {
delimiter: 'semi',
requireLast: true,
},
},
},
singleline: {
delimiter: 'comma',
requireLast: true,
},
},
],
'@typescript-eslint/member-ordering': 0,
'@typescript-eslint/method-signature-style': [2, 'property'],
'@typescript-eslint/naming-convention': [
2,
{
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
selector: 'variable',
},
],
'@typescript-eslint/no-confusing-non-null-assertion': 2,
'@typescript-eslint/no-dynamic-delete': 2,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-empty-interface': [
'error',
{
allowSingleExtends: false,
},
],
'@typescript-eslint/no-explicit-any': [
2,
{
ignoreRestArgs: true,
},
],
'@typescript-eslint/no-extra-non-null-assertion': 2,
'@typescript-eslint/no-extraneous-class': 2,
'@typescript-eslint/no-inferrable-types': [
2,
{
ignoreParameters: true,
ignoreProperties: true,
},
],
'@typescript-eslint/no-invalid-void-type': [
2,
{
allowAsThisParameter: true,
allowInGenericTypeArguments: true,
},
],
'@typescript-eslint/no-misused-new': 2,
'@typescript-eslint/no-namespace': [
2,
{
allowDeclarations: true,
},
],
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 2,
'@typescript-eslint/no-non-null-asserted-optional-chain': 2,
'@typescript-eslint/no-non-null-assertion': 2,
'@typescript-eslint/no-parameter-properties': 0,
'@typescript-eslint/no-require-imports': 2,
'@typescript-eslint/no-restricted-imports': 0,
'@typescript-eslint/no-this-alias': [
2,
{
allowDestructuring: true,
allowedNames: ['self'],
},
],
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 0,
'@typescript-eslint/no-unnecessary-condition': 0,
'@typescript-eslint/no-unnecessary-type-arguments': 0,
'@typescript-eslint/no-unnecessary-type-assertion': 0,
'@typescript-eslint/no-unnecessary-type-constraint': 2,
'@typescript-eslint/no-unsafe-argument': 0,
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/no-var-requires': 2,
'@typescript-eslint/non-nullable-type-assertion-style': 0,
'@typescript-eslint/object-curly-spacing': [2, 'never'],
'@typescript-eslint/prefer-as-const': 2,
'@typescript-eslint/prefer-enum-initializers': 2,
'@typescript-eslint/prefer-for-of': 2,
'@typescript-eslint/prefer-function-type': 2,
'@typescript-eslint/prefer-literal-enum-member': 2,
'@typescript-eslint/prefer-namespace-keyword': 2,
'@typescript-eslint/prefer-readonly-parameter-types': 0,
'@typescript-eslint/prefer-ts-expect-error': 2,
'@typescript-eslint/restrict-plus-operands': 0,
'@typescript-eslint/restrict-template-expressions': 0,
'@typescript-eslint/strict-boolean-expressions': 0,
'@typescript-eslint/triple-slash-reference': [
2,
{
lib: 'never',
path: 'never',
types: 'never',
},
],
'@typescript-eslint/type-annotation-spacing': 2,
'@typescript-eslint/typedef': 0,
'@typescript-eslint/unified-signatures': 2,
'canonical/prefer-inline-type-import': 2,
'default-param-last': 0,
'import/no-dynamic-require': 0,
'jsdoc/require-property-type': 0,
'n/global-require': 0,
'n/no-missing-import': 0,
'no-duplicate-imports': 0,
'no-undef': 0,
'no-use-before-define': 0,
'spaced-comment': [
2,
'always',
{
markers: ['/'],
},
],
...require('./typescript-compatibility').recommended.rules,
},
settings: {
'import/extensions': ['.ts', '.tsx'],
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
extensions: ['.ts', '.tsx'],
},
},
jsdoc: {
mode: 'typescript',
},
node: {
tryExtensions: ['.ts', '.tsx', '.js', '.json'],
},
},
};