This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
forked from con2/konsti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
219 lines (204 loc) · 6.98 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: [
"eslint-plugin-ban",
"eslint-plugin-compat",
"eslint-plugin-vitest",
"eslint-plugin-prettier",
"eslint-plugin-promise",
"eslint-plugin-import",
"@typescript-eslint",
"eslint-plugin-unicorn",
"eslint-plugin-deprecation",
],
extends: [
"eslint-config-prettier",
"plugin:eslint-plugin-eslint-comments/recommended",
"plugin:eslint-plugin-vitest/recommended",
"plugin:eslint-plugin-promise/recommended",
"plugin:eslint-plugin-import/errors",
"plugin:eslint-plugin-import/typescript",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/stylistic-type-checked",
],
env: {
es2021: true,
},
parserOptions: {
sourceType: "module",
impliedStrict: true,
tsconfigRootDir: __dirname,
project: true,
},
settings: {
"import/resolver": {
typescript: { alwaysTryTypes: true },
},
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/internal-regex": "shared",
},
rules: {
// eslint
"no-param-reassign": "error",
"no-console": "error",
"object-shorthand": "error",
"no-restricted-syntax": [
"error",
{
selector: "ThrowStatement", // We don't throw errors!
message: "Return Result<T,Err> instead of throwing errors",
},
{
selector: "MemberExpression[property.name='format']",
message: "Import from timeFormatter.ts or use dayjs().toISOString",
},
],
"no-else-return": "error",
curly: "error",
"array-callback-return": "off",
"no-shadow": "off", // Required by @typescript-eslint/no-shadow
// eslint-plugin-prettier
"prettier/prettier": "error",
// eslint-plugin-import
"import/no-unused-modules": ["error", { unusedExports: true }],
"import/no-unresolved": "off",
"import/order": ["error", { groups: ["builtin", "external"] }],
"import/no-namespace": [
"error",
{
ignore: [
"groupAssignPlayers",
"padgAssignPlayers",
"randomAssignPlayers",
"signupTimes",
],
},
], // Don't want to use namespace imports, ignore files that need vi.spyon
"import/namespace": "off", // Don't want to use namespace imports
// eslint-plugin-vitest
"vitest/no-disabled-tests": "error",
"vitest/no-focused-tests": "error",
"vitest/prefer-to-be": "off", // Don't want this
// eslint-plugin-eslint-comments
"eslint-comments/no-unused-disable": "error",
// @typescript-eslint
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/require-array-sort-compare": [
"error",
{ ignoreStringArrays: true },
],
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/naming-convention": [
"error",
{
selector: "interface",
format: ["PascalCase"],
},
],
"@typescript-eslint/no-unused-vars": [
"error",
{ vars: "all", args: "all", argsIgnorePattern: "^_" },
],
"@typescript-eslint/no-restricted-imports": [
"error",
{
paths: [
{
name: "react",
importNames: ["default"],
message: "Please use named imports, e.g. { useEffect }",
},
],
patterns: [
{
group: ["../*"],
message: "Relative import (../) not allowed, use absolute import",
},
],
},
],
"@typescript-eslint/ban-types": [
"off",
{
extendDefaults: false,
types: {
String: {
message: "Use string instead",
fixWith: "string",
},
Boolean: {
message: "Use boolean instead",
fixWith: "boolean",
},
Number: {
message: "Use number instead",
fixWith: "number",
},
Symbol: {
message: "Use symbol instead",
fixWith: "symbol",
},
BigInt: {
message: "Use bigint instead",
fixWith: "bigint",
},
Function: {
message:
"The `Function` type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with `new`.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.",
},
Object: {
message:
'The `Object` type actually means "any non-nullish value", so it is marginally better than `unknown`.\n- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.\n- If you want a type meaning "any value", you probably want `unknown` instead.',
},
"{}": {
message:
'`{}` actually means "any non-nullish value".\n- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.\n- If you want a type meaning "any value", you probably want `unknown` instead.',
},
},
},
],
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description",
"ts-ignore": true,
"ts-nocheck": true,
"ts-check": false,
minimumDescriptionLength: 3,
},
],
"@typescript-eslint/array-type": [
"error",
{
default: "array-simple",
},
],
"@typescript-eslint/strict-boolean-expressions": "off", // Forces unwanted code style
"@typescript-eslint/restrict-template-expressions": "off", // Requires typing catch(e) every time
"@typescript-eslint/restrict-plus-operands": "off", // Doesn't support dynamic object occurance counting
"@typescript-eslint/key-spacing": "off", // Formatting handled by prettier
// eslint-plugin-ban
"ban/ban": [
"error",
{ name: "useDispatch", message: "Please use useAppDispatch()" },
{ name: "useSelector", message: "Please use useAppSelector()" },
],
// eslint-plugin-deprecation
"deprecation/deprecation": "error",
// TODO: Enable these rules
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/consistent-type-imports": "off", // Tooling lacking, try again once TS 5.0 is released: https://devblogs.microsoft.com/typescript/announcing-typescript-5-0-beta/#verbatimmodulesyntax
},
};