-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc
162 lines (145 loc) · 5.18 KB
/
.eslintrc
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
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier"
],
"env": {
"node": true
},
"overrides": [
{
"files": ["test/**"],
"plugins": ["jest"],
"extends": ["plugin:jest/recommended"],
"env": {
"jest": true
}
},
{
"files": ["test/**/*.e2e-spec.ts"],
"rules": {
// We want to disable these, as they do not play well with supertest.
"jest/expect-expect": "off",
"@typescript-eslint/no-floating-promises": "off"
}
}
],
"ignorePatterns": [
"dist/*",
"coverage/*"
],
"rules": {
// Enforce T[] syntax for arrays over Array<T>.
// https://typescript-eslint.io/rules/array-type
"@typescript-eslint/array-type": [
"error",
{
"default": "array"
}
],
// Enforce function return types.
// https://typescript-eslint.io/rules/explicit-function-return-type
"@typescript-eslint/explicit-function-return-type": [
"error",
{
"allowExpressions": true,
"allowHigherOrderFunctions": true,
"allowTypedFunctionExpressions": true
}
],
// Enforce explicit return & argument types on exported functions & public class methods.
// https://typescript-eslint.io/rules/explicit-module-boundary-types
"@typescript-eslint/explicit-module-boundary-types": "error",
// Disallow explicit type declarations for numbers, strings or booleans.
// https://typescript-eslint.io/rules/no-inferrable-types
"@typescript-eslint/no-inferrable-types": [
"warn",
{
"ignoreParameters": true,
"ignoreProperties": true
}
],
// Disallow explicit `any` types. Use `unknown` instead.
// https://typescript-eslint.io/rules/no-explicit-any
"@typescript-eslint/no-explicit-any": [
"error",
{
"ignoreRestArgs": true
}
],
// Require Promise-like statements to be handled appropriately.
// https://typescript-eslint.io/rules/no-floating-promises
"@typescript-eslint/no-floating-promises": "error",
// Disable using non-null assertions as they cancel the benefits of strict null-checking mode.
// Prefer explicit null checks for safety.
// https://typescript-eslint.io/rules/no-non-null-assertion
"@typescript-eslint/no-non-null-assertion": "warn",
// Restrict use of labels and with statements.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/with
// https://eslint.org/docs/rules/no-restricted-syntax
"no-restricted-syntax": [
"error",
{
"selector": "LabeledStatement",
"message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
},
{
"selector": "WithStatement",
"message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
}
],
// Avoid unnecessary conditionals.
// https://typescript-eslint.io/rules/no-unnecessary-condition
"@typescript-eslint/no-unnecessary-condition": "error",
// Warn against unnecessary type assertions.
// https://typescript-eslint.io/rules/no-unnecessary-type-assertion
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
// Enforce no unused variables.
// https://typescript-eslint.io/rules/no-unused-vars
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
// Warn against useless class constructors.
// https://typescript-eslint.io/rules/no-useless-constructor
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "warn",
// Prefer nullish coalescing operator.
// https://typescript-eslint.io/rules/prefer-nullish-coalescing
"@typescript-eslint/prefer-nullish-coalescing": "warn",
// Prefer optional chaining operator.
// https://typescript-eslint.io/rules/prefer-optional-chain
"@typescript-eslint/prefer-optional-chain": "warn",
// Ensure all functions that return a promise are marked as async.
// https://typescript-eslint.io/rules/promise-function-async
"@typescript-eslint/promise-function-async": "error",
// Restrict template expressions to allow for string & number types only.
// Other types must be checked explicitly.
// https://typescript-eslint.io/rules/restrict-template-expressions
"@typescript-eslint/restrict-template-expressions": [
"error",
{
"allowNumber": true,
"allowBoolean": false,
"allowAny": false,
"allowNullish": false,
"allowRegExp": false
}
],
// Disallow async functions which have no await expression and do not return a promise.
// https://typescript-eslint.io/rules/require-await
"require-await": "off",
"@typescript-eslint/require-await": "error",
// Enforce covering all cases in a switch statement.
// https://typescript-eslint.io/rules/switch-exhaustiveness-check/
"@typescript-eslint/switch-exhaustiveness-check": "error"
}
}