forked from RetroAchievements/RAWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.yaml
175 lines (150 loc) · 4.21 KB
/
.eslintrc.yaml
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
env:
browser: true
extends:
- eslint:recommended
- plugin:prettier/recommended
- plugin:@typescript-eslint/recommended
- plugin:react/recommended
- plugin:react-hooks/recommended
- plugin:@tanstack/eslint-plugin-query/recommended
parser: "@typescript-eslint/parser"
plugins:
- "@typescript-eslint"
- simple-import-sort
- import
- jsx-a11y
- unicorn
- vitest
ignorePatterns:
- generated.d.ts
- ziggy.d.ts
settings:
# allows for tsconfig path aliases
import/resolver:
typescript: {} # this loads tsconfig.json to eslint
react:
version: detect
globals:
Atomics: readonly
SharedArrayBuffer: readonly
# very basic javascript
parserOptions:
ecmaVersion: 6
sourceType: module
rules:
# some javascript functions are used within html attributes rendered within php
no-unused-vars: off
max-len: off
# eslint doesn't like itself
prefer-destructuring: off
# yeah, we're polluting the global namespace with jquery...
no-undef: off
# ouch. refactor affected code...
no-eval: off
# let's at least have console output. at least no alerts, right? right!?
no-console: off
# ++ in for loop
no-plusplus: off
# ecmaVersion 5...
comma-dangle: off
eqeqeq: error
func-names: off
no-alert: off # still using confirm() dialog
no-else-return: error
no-loop-func: off
no-param-reassign: off
no-restricted-globals: off # still using confirm() dialog
no-return-await: error
no-shadow: off # typescript-eslint is not happy about injecting Alpine and/or utils into `window`
no-use-before-define: off
no-useless-escape: off # not so sure about regex there it seems
no-var: off
object-shorthand: error
prefer-arrow-callback: off
prefer-rest-params: off
prefer-template: off
vars-on-top: off
# sort and organize imports/exports
import/first: error
import/newline-after-import: error
import/no-duplicates: error
simple-import-sort/exports: error
simple-import-sort/imports: error
# typescript niceties
'@typescript-eslint/consistent-type-imports': error
# tailwind.config.js
global-require: off
# set up prettier as an eslint plugin
prettier/prettier:
- error
- {
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"tailwindAttributes":
[
"anchorClassName",
"baseCommandListClassName",
"containerClassName",
"gameTitleClassName",
"imgClassName",
"wrapperClassName",
],
"plugins": ["prettier-plugin-tailwindcss"]
}
# some react recommended rules are fine to avoid in typescript projects
react/display-name: off
react/jsx-no-literals: error # enforce i18n
react/jsx-no-target-blank: off # we don't support the old browsers this rule tries to protect
react/no-unescaped-entities: off
react/prop-types: off
react/react-in-jsx-scope: off
# disable some of the more aggressive unicorn rules
unicorn/filename-case: off
unicorn/no-array-callback-reference: off
unicorn/no-array-for-each: warn
unicorn/no-array-reduce: error
unicorn/no-null: off
unicorn/prefer-includes: error
unicorn/prefer-module: off
unicorn/prefer-node-protocol: off
unicorn/prefer-switch: off
# similar to pint, force a newline before return statements
newline-before-return: error
# prevent accidental imports from libraries that build the Base* components
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@inertiajs/react',
importNames: ['Head'],
message: 'Use @/common/components/SEO instead.'
},
{
name: '@inertiajs/react',
importNames: ['Link'],
message: 'Use @/common/components/InertiaLink instead.'
}
],
patterns: [
'@testing-library/react',
'@radix-ui/*',
'sonner',
'vaul',
],
},
]
# don't enforce explicit-any rule in test files or autogenerated files
overrides:
- files:
- "generated.d.ts"
- "*.test.ts"
- "*.test.tsx"
extends:
- plugin:testing-library/react
rules:
"@typescript-eslint/no-explicit-any": off
testing-library/no-dom-import: off
testing-library/no-render-in-lifecycle: off
react/jsx-no-literals: off