-
Notifications
You must be signed in to change notification settings - Fork 267
/
.eslintrc.js
205 lines (202 loc) · 7.18 KB
/
.eslintrc.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
const prettierConfig = require("./package.json").prettier;
const isFix = process.argv.includes("--fix");
module.exports = {
root: true,
ignorePatterns: ["**/*.d.ts", "**/*.js"],
env: {
node: true,
browser: false,
es2020: true,
},
parserOptions: {
ecmaVersion: 2020,
parser: require.resolve("@typescript-eslint/parser"),
project: "./tsconfig.json",
sourceType: "module",
tsconfigRootDir: __dirname,
},
plugins: ["@typescript-eslint", "prettier", "import", "promise", "unicorn", "header"],
extends: [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:promise/recommended",
"plugin:import/warnings",
"plugin:import/errors",
"plugin:import/typescript",
"prettier",
"prettier/@typescript-eslint",
],
settings: {
"import/resolver": {
[require.resolve("eslint-import-resolver-typescript")]: {},
[require.resolve("eslint-import-resolver-node")]: {},
},
},
overrides: [],
rules: {
// before adding new rules - https://github.com/prettier/eslint-plugin-prettier/issues/65
"@typescript-eslint/await-thenable": "warn",
"@typescript-eslint/dot-notation": "warn",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": [
"warn",
{
allowArgumentsExplicitlyTypedAsAny: true,
},
],
"@typescript-eslint/lines-between-class-members": "off",
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": [
"warn",
{
ignoreParameters: true,
ignoreProperties: true,
},
],
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-use-before-define": [
// function hoisting is a common, accepted pattern
"error",
{
classes: true,
functions: false,
typedefs: true,
variables: true,
},
],
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/require-await": "off",
"class-methods-use-this": "off",
"consistent-return": "off",
eqeqeq: "warn",
"header/header": [
"error",
"line",
[
" Copyright (c) Microsoft Corporation. All rights reserved.",
" Licensed under the MIT license. See LICENSE file in the project root for details.",
],
],
"import/extensions": [
"error",
"always",
{
js: "never",
jsx: "never",
mjs: "never",
ts: "never",
tsx: "never",
},
],
"import/newline-after-import": "warn",
"import/no-cycle": "off",
"import/no-extraneous-dependencies": "off",
"import/no-mutable-exports": "off",
"import/no-require": "off",
"import/no-unresolved": "off",
"import/no-useless-path-segments": "warn",
"import/order": "warn",
"import/prefer-default-export": "off",
"linebreak-style": "off",
"lines-between-class-members": "off",
"max-classes-per-file": "off",
"no-async-promise-executor": "warn",
"no-await-in-loop": "warn",
"no-else-return": "warn",
"no-empty-function": "off",
"no-extra-boolean-cast": "warn",
"no-lonely-if": "warn",
"no-nested-ternary": "warn",
"no-param-reassign": "warn",
"no-plusplus": "off",
"no-promise-executor-return": "error",
"no-restricted-globals": "warn",
"no-restricted-syntax": [
"error",
{
message:
"for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.",
selector: "ForInStatement",
},
{
message:
"Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.",
selector: "LabeledStatement",
},
{
message:
"`with` is disallowed in strict mode because it makes code impossible to predict and optimize.",
selector: "WithStatement",
},
],
"no-shadow": "off",
"no-undef-init": "error",
"no-underscore-dangle": "off",
"no-unneeded-ternary": "warn",
"no-useless-computed-key": "error",
"no-useless-escape": "warn",
"no-useless-return": "off",
"no-void": [
"error",
{
allowAsStatement: true,
},
],
"object-shorthand": "warn",
"prefer-destructuring": "off",
"prefer-template": "error",
"prettier/prettier": ["error", prettierConfig],
"promise/always-return": "off",
"promise/catch-or-return": "off",
"promise/param-names": "off",
"promise/valid-params": "warn",
"spaced-comment": [
"error",
"always",
{
markers: ["/"],
},
],
"unicorn/better-regex": "warn",
"unicorn/filename-case": [
"warn",
{
cases: {
camelCase: true, // pascalCase: true,
},
ignore: [/rn-extension\.ts/],
},
],
"unicorn/no-array-reduce": "warn",
"unicorn/no-for-loop": isFix ? "off" : "warn",
"unicorn/no-instanceof-array": "warn",
"unicorn/no-new-array": "warn",
"unicorn/no-new-buffer": "warn",
"unicorn/prefer-array-find": "warn",
"unicorn/prefer-array-index-of": "warn",
"unicorn/prefer-array-some": "warn",
"unicorn/prefer-includes": "warn",
"unicorn/prefer-ternary": isFix ? "off" : "warn",
"use-isnan": "warn",
"valid-typeof": "warn",
yoda: "warn",
},
globals: {
process: "readonly",
},
};