-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.cjs
197 lines (173 loc) · 4.98 KB
/
.eslintrc.cjs
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
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
],
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'react',
'jsx-a11y',
],
env: {
browser: true,
node: true,
es6: true,
},
settings: {
react: {
version: '17.0.2',
},
},
parserOptions: {
project: './config/tsconfig.base.json'
},
rules: {
indent: 'off', // Compatibility problems with TypeScript
'@typescript-eslint/indent': [
'error',
2,
{
SwitchCase: 1,
flatTernaryExpressions: true,
// Template literal indentation is screwy, as is indentation inside
// type parameter lists. Ignore for now.
ignoredNodes: [
'TemplateLiteral *',
'TSTypeParameterDeclaration *',
'TSTypeParameterInstantiation *',
],
},
],
// I like Haskell.
'@typescript-eslint/explicit-function-return-type': 'off',
// Good idea in theory, not really workable in practice.
'@typescript-eslint/no-explicit-any': 'off',
// `type` is fine.
'@typescript-eslint/prefer-interface': 'off',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': 'warn',
'linebreak-style': [
'error',
'unix',
],
quotes: [
'error',
'single',
{
avoidEscape: true,
allowTemplateLiterals: true,
},
],
semi: [
'error',
'always',
],
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
},
],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
],
// This project includes a lot of server or Node-only components, where it's
// okay to log.
'no-console': 'off',
// The default rules are a little bit too picky and don't allow you to use
// the banned types even if you know what you're doing. Especially for React
// code it's useful to use `{}` to indicate "no properties".
'@typescript-eslint/ban-types': [
'error',
{
extendDefaults: true,
types: {
Function: false,
Object: false,
'{}': false,
object: false,
},
},
],
'@typescript-eslint/explicit-module-boundary-types': [
'warn',
{
// I'm not a *fan* of exporting functions with `any` parameters, but
// sometimes it's necessary.
allowArgumentsExplicitlyTypedAsAny: true,
},
],
'require-await': 'error',
// Warning rather than error because externally typed libraries may trigger
// this rule.
'@typescript-eslint/await-thenable': 'warn',
// The default rule is a bit too strict, to the point where it becomes hard
// to throw together log messages and the like. Sometimes embedded numbers,
// booleans and the like are desirable.
'@typescript-eslint/restrict-template-expressions': [
'warn',
{
allowBoolean: true,
allowNumber: true,
allowNullish: true,
allowAny: true,
}
],
// There are too many third-party libraries with sloppy typings that we
// can't really make this a hard error, as nice as the rule is.
'@typescript-eslint/no-unsafe-assignment': 'warn',
// There are many situations where unbound methods are desirable, e.g. in
// objects with helper functions that are supposed to be used that way even
// if the TS typings don't reveal it.
'@typescript-eslint/unbound-method': 'warn',
// The following rules interfere with various TypeScript features.
'no-undef': 'off', // Taken care of by the type system.
'no-dupe-class-members': 'off', // Conflicts with overloading.
// We have a type system.
'react/prop-types': 'off',
// New JSX transform automatically adds the appropriate imports, and does
// not import React from 'react'.
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
'jsx-quotes': [
'error',
'prefer-single',
],
'jsx-a11y/label-has-associated-control': [
'error',
{
controlComponents: [
'TextInput',
'NumberInput',
'Select'
],
},
],
// This rule is deprecated and should not be used.
'jsx-a11y/label-has-for': 'off',
},
overrides: [
{
files: ['*.d.ts'],
rules: {
// Need to allow things like `declare class X` followed by `declare namespace X`.
'no-redeclare': 'off',
// Everything in a .d.ts file is assumed to be public.
'@typescript-eslint/explicit-member-accessibility': 'off'
},
},
],
};