-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.yaml
184 lines (157 loc) · 4.64 KB
/
.eslintrc.yaml
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
# yaml-language-server: $schema=http://json.schemastore.org/eslintrc
env:
es2021: true
browser: true
node: true
jasmine: true
extends:
- 'eslint:recommended'
ignorePatterns:
- bazel-out/
- dist/
- external/
parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: 12
sourceType: module
project: true
plugins:
- '@typescript-eslint'
rules:
indent:
- error
- 4
- SwitchCase: 1
linebreak-style:
- error
- unix
quotes:
- error
- single
- allowTemplateLiterals: true
semi:
- error
- always
no-constant-condition:
- error
- checkLoops: false # `while (true) { /* ... */ }` is ok.
no-unused-vars:
- error
- argsIgnorePattern: "^_"
destructuredArrayIgnorePattern: "^_"
# Deliberately _not_ setting `varsIgnorePattern`, since that benefits from
# an explicit ignore comment instead of a load-bearing `_`.
# Enable TypeScript rules only for `*.[cm]?ts` files.
overrides:
- files:
- "**/*.ts"
- "**/*.d.ts"
- "**/*.mts"
- "**/*.d.mts"
- "**/*.cts"
- "**/*.d.cts"
- "**/*.tsx"
extends:
- 'plugin:@typescript-eslint/strict-type-checked'
- 'plugin:@typescript-eslint/stylistic-type-checked'
rules:
# TypeScript already disallows duplicated class members and sometimes allows
# it (ex. method overrides).
no-dupe-class-members:
- off
# TypeScript already disallows undeclared variables.
no-undef:
- off
# Use `T[]` for simple types, `Array<T>` for complicated ones because in
# `(Long & Complicated | Expression)[]` it's really easy to miss the `[]`.
'@typescript-eslint/array-type':
- error
- default: 'array-simple'
# Restricts `${expr}` to make sure `expr` prints something meaningful (ex.
# not '[object Object]').
'@typescript-eslint/restrict-template-expressions':
- error
-
# Primitive values print as expected, so they are allowed.
allowBoolean: true
allowNumber: true
# The point of `any` is to not deal with this.
allowAny: true
# `never` only happens for debug purposes.
allowNever: true
'@typescript-eslint/no-unnecessary-condition':
- error
- allowConstantLoopConditions: true # `while (true) {}` is ok.
'@typescript-eslint/no-floating-promises':
- error
-
# `async` IIFE exists *only* to create a floating promise.
ignoreIIFE: true
'@typescript-eslint/no-non-null-assertion':
- error
'@typescript-eslint/no-empty-function':
- error
'@typescript-eslint/no-inferrable-types':
- error
'@typescript-eslint/no-namespace':
- error
# Allow in `declare module` or `declare global` which is occasionally
# useful for declaration merging (ex. `JSX.IntrinsicElements`).
- allowDeclarations: true
'@typescript-eslint/no-explicit-any':
- off
# `noImplicitAny` is good enough, we don't need more safety here. They
# basically break `any` types to be effectively unusable and we can't
# entirely avoid them due to library and platform types.
'@typescript-eslint/no-unsafe-argument':
- off
'@typescript-eslint/no-unsafe-assignment':
- off
'@typescript-eslint/no-unsafe-call':
- off
'@typescript-eslint/no-unsafe-member-access':
- off
'@typescript-eslint/no-unsafe-return':
- off
# `async` functions are often required to match return function signatures,
# even if they don't actually do `async` work. I'm not too worried about
# accidentally leaving an `async` function which could have been synchronous
# and having that lead to serious negative effects.
'@typescript-eslint/require-await':
- off
'@typescript-eslint/no-unused-vars':
- error
- argsIgnorePattern: "^_"
destructuredArrayIgnorePattern: "^_"
# Deliberately _not_ setting `varsIgnorePattern`, since that benefits from
# an explicit ignore comment instead of a load-bearing `_`.
- files:
- "**/*_test.ts"
- "**/test.ts"
- "**/*_test.mts"
- "**/test.mts"
- "**/*_test.cts"
- "**/test.cts"
- "**/*_test.tsx"
- "**/test.tsx"
- "**/*_test_cases.ts"
- "**/test_cases.ts"
- "**/*_test_cases.mts"
- "**/test_cases.mts"
- "**/*_test_cases.cts"
- "**/test_cases.cts"
- "**/*_test_cases.tsx"
- "**/test_cases.tsx"
rules:
# Disable non-null assertions in test files.
'@typescript-eslint/no-non-null-assertion':
- off
# Turn off rules dependent on `strictNullChecks` for examples with that option
# disabled.
- files:
- examples/tsconfig/**
rules:
'@typescript-eslint/no-unnecessary-condition':
- off
'@typescript-eslint/prefer-nullish-coalescing':
- off