-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.eslintrc.js
157 lines (153 loc) · 5.42 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
function* range(min, max) {
for (let num = min; num < max; num++) {
yield num
}
}
module.exports = {
env: {
es2021: true,
node: true,
},
extends: ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended"],
parser: "@typescript-eslint/parser",
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
},
parserOptions: {
ecmaVersion: 2021,
sourceType: "module",
project: ["./tsconfig.json"],
},
plugins: ["@typescript-eslint", "prefer-arrow"],
rules: {
// General ESLint rules
"arrow-body-style": ["warn", "as-needed"],
"default-case-last": "warn",
"dot-location": ["warn", "property"],
eqeqeq: "error",
"id-length": ["error", {exceptions: ["_", "$"]}],
"max-len": "off",
"max-lines": ["warn", 500],
"max-statements": ["warn", {max: 25}],
"no-else-return": "warn",
"no-empty": ["warn", {allowEmptyCatch: true}],
"no-extra-semi": "off",
"no-negated-condition": "warn",
"no-nested-ternary": "warn",
"no-unused-vars": "off",
"no-var": "warn",
"object-shorthand": "warn",
"one-var": ["warn", "never"],
"padding-line-between-statements": [
"warn",
{blankLine: "always", prev: "*", next: "return"},
{blankLine: "always", prev: ["const", "let", "var"], next: "*"},
{blankLine: "any", prev: ["const", "let", "var"], next: ["const", "let", "var"]},
{blankLine: "always", prev: "function", next: "*"},
],
"prefer-const": "warn",
"prefer-destructuring": [
"error",
{
array: false,
object: true,
},
],
"prefer-exponentiation-operator": "warn",
"prefer-object-spread": "warn",
"prefer-template": "warn",
"require-await": "warn",
"require-unicode-regexp": "warn",
"sort-imports": ["warn"],
// Typescript Rules
"@typescript-eslint/array-type": "warn",
"@typescript-eslint/consistent-indexed-object-style": ["warn", "index-signature"],
"@typescript-eslint/consistent-type-assertions": ["warn", {assertionStyle: "as"}],
"@typescript-eslint/member-ordering": "warn",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "default",
format: ["camelCase"],
},
{
selector: "variableLike",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: "property",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: "typeLike",
format: ["PascalCase"],
},
{
selector: "variable",
types: ["boolean"],
format: ["PascalCase"],
prefix: ["is", "should", "has", "can", "did", "will"],
},
{
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{
selector: "property",
format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"],
},
{
selector: "enumMember",
format: ["camelCase", "PascalCase", "snake_case", "UPPER_CASE"],
},
],
"@typescript-eslint/no-magic-numbers": [
"warn",
{
ignoreEnums: true,
ignoreNumericLiteralTypes: true,
ignoreReadonlyClassProperties: true,
ignoreArrayIndexes: true,
ignore: [...Array.from(range(-10, 11)), 16, 32, 64, 128, 256, 512],
},
],
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-optional-chain": "warn",
// Typescript extension rules
"@typescript-eslint/default-param-last": "warn",
"@typescript-eslint/dot-notation": "warn",
"@typescript-eslint/lines-between-class-members": ["warn", "always"],
"@typescript-eslint/no-dupe-class-members": "warn",
"@typescript-eslint/no-duplicate-imports": "warn",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-shadow": "warn",
"@typescript-eslint/no-unused-expressions": "warn",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-vars-experimental": "warn",
"@typescript-eslint/no-use-before-define": "warn",
// Preter arrow rules
"prefer-arrow-callback": "warn",
"prefer-arrow/prefer-arrow-functions": [
"warn",
{
disallowPrototype: true,
singleReturnOnly: false,
classPropertiesAllowed: true,
allowStandaloneDeclarations: false,
},
],
},
}