-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
226 lines (225 loc) · 6.15 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
220
221
222
223
224
225
226
/* eslint-disable i18next/no-literal-string */
const DETECT_CSS_REGEX = /\S+:\s+[^\n]+;/
const DETECT_PX_REGEX = /^\d+px$/
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
"plugin:i18next/recommended",
"plugin:jsx-a11y/recommended",
"plugin:react-hooks/recommended",
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["react", "@typescript-eslint", "import", "eslint-custom-rules"],
settings: {
react: {
version: "detect",
},
},
rules: {
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"no-unused-vars": "off",
// unused vars are allowed if they start with an underscore
"@typescript-eslint/no-unused-vars": [
"warn",
{
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
},
],
"no-restricted-imports": [
"error",
{
paths: [
{
name: "@mui/material",
importNames: ["Grid"],
message: "Don't use Grid from @material-ui. Please use either css flexbox or css grid.",
},
{
name: "@mui/material/Grid",
importNames: ["default"],
message: "Don't use Grid from @material-ui. Please use either css flexbox or css grid.",
},
{
name: "@mui/material",
importNames: ["Container"],
message:
"Don't use Container from @material-ui. Please use Centered from shared-module.",
},
{
name: "@mui/material/Container",
importNames: ["default"],
message:
"Don't use Container from @material-ui. Please use Centered from shared-module.",
},
{
name: "@mui/material",
importNames: ["Typography"],
message: "Don't use Typography from @material-ui. Please use p, h1, h2, h3...",
},
{
name: "@mui/material/Typography",
importNames: ["default"],
message: "Don't use Typography from @material-ui. Please use p, h1, h2, h3...",
},
{
name: "@mui/material",
importNames: ["Button"],
message: "Don't use Button from @material-ui. Please use Button from shared-module.",
},
{
name: "@mui/material/Button",
importNames: ["default"],
message: "Don't use Button from @material-ui. Please use Button from shared-module.",
},
{
name: "@mui/styles",
importNames: ["withStyles"],
message: "Don't use withStyles from @material-ui. Please use emotion.js.",
},
{
name: "@mui/styles/withStyles",
importNames: ["default"],
message: "Don't use withStyles from @material-ui. Please use emotion.js.",
},
{
name: "@emotion/react",
importNames: ["css"],
message: 'Use this instead: import { css } from "@emotion/css"',
},
{
name: "@tanstack/react-query",
importNames: ["useMutation"],
message:
"Don't use useMutation from react-query. Please use useToastMutation from shared-module",
},
],
},
],
"eslint-custom-rules/ban-ts-ignore-without-comment": "error",
"eslint-custom-rules/no-material-ui-grid-component": "error",
"react/forbid-component-props": [
"error",
{
forbid: [
{
propName: "style",
message:
"Use emotion.js instead of the style prop\nE.g. className={css`font-size: 28px;`}",
},
],
},
],
"react/forbid-dom-props": [
"error",
{
forbid: [
{
propName: "style",
message:
"Use emotion.js instead of the style prop\nE.g. className={css`font-size: 28px;`}",
},
],
},
],
"@typescript-eslint/ban-ts-comment": "off",
"sort-imports": [
"error",
{
ignoreCase: true,
ignoreDeclarationSort: true,
},
],
"import/order": [
"error",
{
alphabetize: {
order: "asc",
},
groups: [["builtin", "external"], "parent", "sibling", "index"],
"newlines-between": "always",
},
],
// Shared module will have unresolved import.
"import/no-unresolved": "off",
"import/no-named-as-default": "off",
"i18next/no-literal-string": [
"error",
{
validateTemplate: true,
// only add attributes here that are guranteed to never contain traslatable strings
ignoreAttribute: [
"variant",
"size",
"href",
"severity",
"navVariant",
"aria-labelledby",
"aria-describedby",
"url",
"labelId",
"defaultLanguage",
"color",
"labelPlacement",
"role",
"aria-hidden",
"maxWidth",
"transform",
"viewBox",
"testPlaceholder",
"sidebarPosition",
"buttonSize",
],
ignore: [DETECT_CSS_REGEX, DETECT_PX_REGEX],
ignoreCallee: [
"div",
"useQuery",
"useQueryParameter",
"get",
"post",
"put",
"delete",
"create",
"styled",
"css",
"register",
"setValue",
"getValues",
"watch",
"useMediaQuery",
],
ignoreProperty: ["type"],
},
],
curly: "error",
},
overrides: [
{
files: ["system-tests/**/*"],
rules: {
"i18next/no-literal-string": "off",
},
},
],
}