-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
195 lines (187 loc) · 5.56 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
/**
* @typedef {import("eslint").Linter.Config} ESLintConfig
*/
/** @type {ESLintConfig} */
module.exports = {
root: true,
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:eslint-comments/recommended",
"plugin:prettier/recommended",
],
env: {
es2020: true,
},
globals: {
console: "readonly",
},
overrides: [
{
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:import/typescript",
],
files: ["*.ts"],
plugins: ["@typescript-eslint/eslint-plugin"],
parserOptions: {
project: "tsconfig.json",
},
rules: {
"@typescript-eslint/array-type": ["error", { default: "generic" }],
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-inferrable-types": [
"error",
{
ignoreParameters: true,
ignoreProperties: true,
},
],
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"@typescript-eslint/prefer-includes": "warn",
"@typescript-eslint/prefer-literal-enum-member": [
"error",
{ allowBitwiseExpressions: true },
],
"@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/prefer-optional-chain": "warn",
// "@typescript-eslint/prefer-readonly-parameter-types": "warn",
"@typescript-eslint/prefer-string-starts-ends-with": "warn",
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
// TS verifies these.
"consistent-return": "off",
"no-dupe-class-members": "off",
"no-unused-vars": "off",
"import/no-anonymous-default-export": [
"error",
{
allowAnonymousClass: false,
allowAnonymousFunction: false,
allowArray: false,
allowArrowFunction: false,
allowCallExpression: false,
allowLiteral: false,
allowObject: true,
},
],
},
},
{
extends: ["plugin:jest/recommended", "plugin:jest/style"],
files: ["**/__tests__/**"],
plugins: ["jest"],
rules: {
"import/no-extraneous-dependencies": "off",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/valid-expect": "error",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-console": "off",
},
},
{
files: ["scripts/**", ".eslintrc.cjs", "jest.config.mjs", "rollup.config.mjs"],
env: {
node: true,
},
rules: {
"no-console": "off",
},
},
],
parser: "@typescript-eslint/parser",
parserOptions: {
sourceType: "module",
},
plugins: ["import"],
rules: {
"eslint-comments/disable-enable-pair": ["error", { allowWholeFile: true }],
"eslint-comments/no-unused-disable": "error",
"import/extensions": ["error", "never", { pattern: { json: "always" } }],
"import/no-absolute-path": "error",
"import/no-duplicates": "error",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: [
"**/__tests__/**",
"scripts/**",
".eslintrc.cjs",
"jest.config(.*)?.mjs",
"rollup.config.mjs",
],
},
],
"import/no-unresolved": "error",
"import/order": [
"error",
{
alphabetize: {
order: "asc",
},
groups: ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"],
"newlines-between": "always",
},
],
eqeqeq: ["error", "always", { null: "ignore" }],
"no-array-constructor": "error",
"no-caller": "error",
"no-console": ["warn", { allow: ["warn", "error", "time", "timeEnd", "timeStamp"] }],
"no-eval": "error",
"no-extend-native": "warn",
"no-extra-bind": "warn",
"no-floating-decimal": "error",
"no-implied-eval": "error",
"no-label-var": "warn",
"no-labels": ["error", { allowLoop: true, allowSwitch: true }],
"no-multi-str": "error",
"no-new": "warn",
"no-new-func": "error",
"no-new-object": "warn",
"no-new-wrappers": "warn",
"no-octal-escape": "warn",
"no-proto": "error",
"no-restricted-globals": [
"error",
{
name: "global",
message: "Use `globalThis` instead.",
},
],
"no-restricted-imports": [
"error",
{
name: "fs",
message: "Use `graceful-fs` instead.",
},
],
"no-self-compare": "warn",
"no-sequences": "warn",
"no-throw-literal": "error",
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-var": "error",
"object-shorthand": "error",
"operator-assignment": ["warn", "always"],
"prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
"prefer-const": "error",
"prefer-rest-params": "warn",
"prefer-spread": "warn",
"prefer-template": "error",
quotes: ["error", "double", { allowTemplateLiterals: true, avoidEscape: false }],
radix: "warn",
"sort-imports": ["error", { ignoreDeclarationSort: true }],
},
settings: {
"import/resolver": {
typescript: {},
},
},
};