forked from athenekilta/ilmomasiina
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.eslintrc.js
134 lines (134 loc) · 4.46 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
module.exports = {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"packages/ilmomasiina-models/tsconfig.json",
"packages/ilmomasiina-components/tsconfig.json",
"packages/ilmomasiina-frontend/tsconfig.json",
"packages/ilmomasiina-backend/tsconfig.json"
],
"tsconfigRootDir": __dirname,
// https://github.com/typescript-eslint/typescript-eslint/issues/2094
"EXPERIMENTAL_useSourceOfProjectReferenceRedirect": true
},
"ignorePatterns": [
"**/node_modules/**",
"**/dist/**",
"**/build/**",
".eslintrc.js",
"jest.config.js",
"*.svg",
"*.png",
"*.scss",
"*.json"
],
"settings": {
"react": {
"pragma": "React",
"version": "16.12"
},
},
"extends": [
"airbnb",
"airbnb/hooks",
"airbnb-typescript",
"prettier"
],
"plugins": [
"@typescript-eslint",
"promise",
"simple-import-sort",
"jest"
],
"env": {
"browser": true
},
"rules": {
// To allow grouping of class members - especially for Models.
"@typescript-eslint/lines-between-class-members": "off",
// Doesn't increase code quality with redux.
"@typescript-eslint/default-param-last": "off",
// Allow i++ in for loops.
"no-plusplus": ["error", { allowForLoopAfterthoughts: true }],
// We are targeting ES5 or higher.
"radix": ["error", "as-needed"],
// ...I know what I'm doing.
"no-control-regex": "off",
// In some cases, especially if you want to comment the logic, it's much
// clearer to write it like a binary tree:
// if { if { } else { } } else { if { } else { } }
"no-lonely-if": "off",
// Not usable with formik.
"react/jsx-props-no-spreading": "off",
// TypeScript validates prop types, no need for this.
"react/require-default-props": "off",
// Definitely a valid performance concern, but implementing this correctly is
// a giant PITA - the default config ignores arrow functions but they don't solve
// the problem at all, and useCallback is just plain ugly.
"react/jsx-no-bind": "off",
// Add any custom hooks here
"react-hooks/exhaustive-deps": ["error", {
additionalHooks: "useAbortableEffect|useAbortablePromise",
}],
// Prefer arrow functions to functions expressions, as that's what was done
// when this rule was introduced.
"react/function-component-definition": ["error", {
namedComponents: ["function-declaration", "arrow-function"],
unnamedComponents: "arrow-function",
}],
// Allow dev deps in test files.
"import/no-extraneous-dependencies": ["error", {
devDependencies: [
"**/test/**",
"**/vite.config.ts",
"**/vitest.config.ts",
"**/.eslintrc.js"
],
}],
// Sort imports: React first, then npm packages, then local files, then CSS.
"simple-import-sort/imports": [
"error",
{
"groups": [
["^react$"],
["^@?\\w"],
// Anything that does not start with a dot.
["^[^.]"],
// Anything that starts with a dot, or is from one of our packages.
["^@tietokilta/", "^"],
// Css
["css$"]
]
}
],
// Prevent imports from "src/...". VS Code adds these automatically, but they
// break when compiled.
"no-restricted-imports": [
"error",
{
"patterns": [{
group: ["src/*"],
message: "This import will break when compiled by tsc. Use a relative path instead, or \"../src/\" in test files."
}],
},
],
// Removing for..of loops from this rule. Vite already targets modern browsers, so for..of doesn't require
// transpilation. Array.forEach doesn't work at all with async.
// Modified from https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js
"no-restricted-syntax": [
"error",
{
"selector": "ForInStatement",
"message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array."
},
{
"selector": "LabeledStatement",
"message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand."
},
{
"selector": "WithStatement",
"message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize."
}
],
}
};