-
-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy patheslint.config.mjs
207 lines (195 loc) · 6.86 KB
/
eslint.config.mjs
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
// @ts-check
import eslint from "@eslint/js"
// TODO: Remove this when the lib adds type declarations.
// @ts-ignore
import importPlugin from "eslint-plugin-import"
import prettier from "eslint-config-prettier"
import react from "eslint-plugin-react"
// TODO: Remove this when the lib adds type declarations.
// https://github.com/facebook/react/issues/30119
// @ts-ignore
import reactHooks from "eslint-plugin-react-hooks"
import reactRefresh from "eslint-plugin-react-refresh"
import tseslint from "typescript-eslint"
export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
// @ts-ignore
react.configs.flat.recommended,
// @ts-ignore
react.configs.flat["jsx-runtime"],
{
files: [
// TODO: Apply to all React files when we move off class components,
// since they are not supported.
"adminSiteClient/**/*.tsx",
"explorerAdminClient/**/*.tsx",
"packages/@ourworldindata/components/src/**/*.tsx",
"site/**/*.tsx",
],
plugins: {
"react-refresh": reactRefresh,
},
rules: {
"react-refresh/only-export-components": [
"error",
{ allowConstantExport: true },
],
},
},
{
plugins: {
// They don't have a compatible flat config at the moment. Update to
// a flat one when they do.
"react-hooks": reactHooks,
},
languageOptions: {
parserOptions: {
project: "./tsconfig.eslint.json",
},
},
settings: {
"import/resolver": {
typescript: true,
node: true,
},
react: {
version: "detect",
},
},
rules: {
...reactHooks.configs.recommended.rules,
"@typescript-eslint/consistent-type-exports": [
"warn",
{
fixMixedExportsWithInlineTypeSpecifier: true,
},
],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-for-in-array": "warn",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/restrict-plus-operands": "warn",
eqeqeq: "warn",
"import/named": "off",
"import/namespace": "off",
"import/default": "off",
"import/no-named-as-default-member": "off",
"import/no-unresolved": "off",
"no-console": [
"warn",
{
allow: ["warn", "error"],
},
],
"prefer-const": [
"warn",
{
destructuring: "all",
},
],
"react/display-name": "warn",
"react/jsx-key": "warn",
"react/jsx-no-target-blank": [
"warn",
{
allowReferrer: true,
},
],
"react/no-render-return-value": "warn",
"react/no-unescaped-entities": [
"warn",
{
forbid: [">", "}"],
},
],
"react/prop-types": "warn",
"@typescript-eslint/no-floating-promises": "error",
"no-constant-binary-expression": "error",
},
},
{
files: [
"adminSiteClient/**/*",
"adminSiteServer/**/*",
"baker/**/*",
"db/**/*",
"devTools/**/*",
"functions/**/*",
"explorerAdminClient/**/*",
"explorerAdminServer/**/*",
"settings/**/*",
],
rules: {
"no-console": "off",
},
},
{
files: [
"db/**/*",
"packages/@ourworldindata/core-table/**/*",
"packages/@ourworldindata/grapher/src/axis/**/*",
"packages/@ourworldindata/grapher/src/barCharts/**/*",
"packages/@ourworldindata/grapher/src/bodyDiv/**/*",
"packages/@ourworldindata/grapher/src/captionedChart/**/*",
"packages/@ourworldindata/grapher/src/chart/**/*",
"packages/@ourworldindata/grapher/src/color/**/*",
"packages/@ourworldindata/grapher/src/controls/**/*",
"packages/@ourworldindata/grapher/src/core/**/*",
"packages/@ourworldindata/grapher/src/dataTable/**/*",
"packages/@ourworldindata/grapher/src/facetChart/**/*",
"packages/@ourworldindata/grapher/src/footer/**/*",
"packages/@ourworldindata/grapher/src/header/**/*",
"packages/@ourworldindata/grapher/src/lineCharts/**/*",
"packages/@ourworldindata/grapher/src/loadingIndicator/**/*",
"packages/@ourworldindata/grapher/src/mapCharts/**/*",
"packages/@ourworldindata/grapher/src/noDataModal/**/*",
"packages/@ourworldindata/grapher/src/scatterCharts/**/*",
"packages/@ourworldindata/grapher/src/selection/**/*",
"packages/@ourworldindata/grapher/src/stackedCharts/**/*",
"packages/@ourworldindata/grapher/src/timeline/**/*",
"packages/@ourworldindata/grapher/src/tooltip/**/*",
"packages/@ourworldindata/grapher/src/verticalColorLegend/**/*",
"packages/@ourworldindata/utils/**/*",
"packages/@ourworldindata/utils/src/persistable/**/*",
"settings/**/*",
],
rules: {
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/explicit-module-boundary-types": "warn",
},
},
prettier,
{
ignores: [
"**/.*",
"**/*.cjs",
"**/*.js",
"**/dist/",
"**/jest.config.js",
"**/knexfile.ts",
"bakedSite/**/*",
"coverage/**/*",
"devtools/**/*",
"eslint.config.mjs",
"itsJustJavascript/**/*",
"localBake/**/*",
"packages/@ourworldindata/*/dist/",
"packages/@ourworldindata/grapher/tsup.config.bundled_*.mjs",
"vite.*.mjs",
],
}
)