/
.eslintrc.js
185 lines (182 loc) · 4.69 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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const tsconfig = require("./tsconfig.json");
const {
compilerOptions: { paths },
} = tsconfig;
const pathGroupsOverrides = [
{
group: "external",
pattern: "react",
position: "before",
},
{
group: "internal",
pattern: "/*",
position: "before",
},
{
group: "internal",
pattern: "@i",
position: "after",
},
{
group: "object",
pattern: "@m/*",
position: "after",
},
{
group: "object",
pattern: "./*.scss",
position: "after",
},
];
module.exports = {
extends: [
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
"plugin:prettier/recommended",
],
ignorePatterns: ["node_modules/*", "build/*"],
overrides: [
{
files: ["*.ts", "*.tsx"],
parserOptions: {
project: ["./tsconfig.json"],
},
rules: {
"@typescript-eslint/prefer-includes": "warn",
"@typescript-eslint/prefer-reduce-type-parameter": "warn",
},
},
{
extends: ["plugin:jest/recommended", "plugin:jest-dom/recommended", "plugin:testing-library/react"],
files: ["**/tests/**/*.[jt]s?(x)", "**/?(*.)+(test).[jt]s?(x)"],
},
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: "module",
},
plugins: ["jest", "jest-dom", "testing-library", "sort-destructure-keys", "sort-keys", "typescript-sort-keys"],
rules: {
"@typescript-eslint/array-type": [
"error",
{
default: "array",
},
],
"@typescript-eslint/consistent-indexed-object-style": ["warn", "record"],
"@typescript-eslint/consistent-type-assertions": [
"warn",
{
assertionStyle: "as",
},
],
"@typescript-eslint/consistent-type-imports": [
"warn",
{
prefer: "type-imports",
},
],
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/member-delimiter-style": "warn",
"@typescript-eslint/method-signature-style": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/sort-type-union-intersection-members": "warn",
"arrow-body-style": ["error", "as-needed"],
"import/newline-after-import": "error",
"import/no-cycle": "warn",
"import/no-named-as-default": "off",
"import/no-unresolved": "off",
"import/order": [
"warn",
{
alphabetize: {
caseInsensitive: true,
order: "asc",
},
groups: ["builtin", "external", "internal", "index", "parent", "sibling"],
pathGroups: [
...Object.keys(paths)
.filter((path) => !pathGroupsOverrides.find((pathGroup) => pathGroup.pattern === path))
.map((path) => ({
group: "internal",
pattern: path,
})),
...pathGroupsOverrides,
],
pathGroupsExcludedImportTypes: [...pathGroupsOverrides.map((pathGroup) => pathGroup.pattern)],
warnOnUnassignedImports: true,
},
],
"no-use-before-define": "error",
"object-shorthand": "error",
"prefer-destructuring": [
"error",
{
array: true,
object: true,
},
{
enforceForRenamedProperties: true,
},
],
"prefer-template": "warn",
"react/destructuring-assignment": ["error", "always"],
"react/function-component-definition": [
"error",
{
namedComponents: "arrow-function",
unnamedComponents: "arrow-function",
},
],
"react/jsx-boolean-value": "error",
"react/jsx-fragments": "error",
"react/jsx-sort-props": [
"error",
{
ignoreCase: true,
reservedFirst: true,
},
],
"react/no-array-index-key": "warn",
"sort-destructure-keys/sort-destructure-keys": [2, { caseSensitive: false }],
"sort-imports": [
"warn",
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
"sort-keys/sort-keys-fix": [
"error",
"asc",
{
caseSensitive: false,
natural: true,
},
],
"typescript-sort-keys/interface": ["error", "asc", { caseSensitive: false, natural: true, requiredFirst: true }],
"typescript-sort-keys/string-enum": ["error", "asc", { caseSensitive: false, natural: true }],
},
settings: {
"import/resolver": {
typescript: {
alwaysTryTypes: true,
project: "./tsconfig.json",
},
},
react: {
version: "detect",
},
},
};