-
Notifications
You must be signed in to change notification settings - Fork 7
/
eslint.config.js
78 lines (77 loc) · 2.08 KB
/
eslint.config.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
// @ts-check
import globals from "globals";
import eslint from "@eslint/js";
import tsEslint from "typescript-eslint";
import prettierConfig from "eslint-config-prettier";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import testingLibrary from "eslint-plugin-testing-library";
export default tsEslint.config(
{
ignores: ["dist/*", "eslint.config.js"],
},
eslint.configs.recommended,
...tsEslint.configs.recommendedTypeChecked,
...tsEslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
prettierConfig,
react.configs.flat.recommended,
react.configs.flat["jsx-runtime"],
{
settings: {
react: {
version: "detect", // React version. "detect" automatically picks the version you have installed.
},
linkComponents: [
{ name: "Link", linkAttribute: "to" }, // allows specifying multiple properties if necessary
],
},
},
{
files: ["**/*.{ts,tsx}"],
plugins: {
// @ts-expect-error: react hooks not ready
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
// @ts-expect-error: react hooks not ready
rules: {
...reactHooks.configs.recommended.rules,
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
"react-refresh/only-export-components": "warn",
},
},
{
files: [
"**/__tests__/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[jt]s?(x)",
"**/test.utils.tsx",
],
languageOptions: {
globals: {
...globals.jest,
},
},
...testingLibrary.configs["flat/react"],
rules: {
"react-refresh/only-export-components": "off",
},
},
);