-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.mjs
111 lines (101 loc) · 3.31 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
import prettier from "eslint-config-prettier";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintReact from "eslint-plugin-react";
import eslintReactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
// Override type, the analyzer misses eslint-plugin-react's flat configs
/** @type {typeof eslintReact.configs} */
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const eslintReactConfigsFlat = eslintReact.configs.flat;
// eslint-plugin-react-hooks specifies an incorrect value for `plugins`
const eslintReactHooksFlat = {
recommended: {
plugins: { "react-hooks": eslintReactHooks },
rules: eslintReactHooks.configs.recommended.rules,
},
};
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintReactConfigsFlat.recommended,
eslintReactConfigsFlat["jsx-runtime"],
eslintReactHooksFlat.recommended,
prettier,
{
plugins: {
"@typescript-eslint": tseslint.plugin,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
"react-refresh": reactRefresh,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
projectService: {
allowDefaultProject: ["*.mjs", "src/d3Sankey/*.js"],
defaultProject: "tsconfig.json",
},
tsconfigRootDir: import.meta.dirname,
},
},
settings: {
react: {
version: "detect",
},
},
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"no-constant-condition": "warn",
"no-debugger": "warn",
"prefer-const": ["warn", { destructuring: "all" }],
"react/jsx-curly-brace-presence": "warn",
"react/jsx-uses-vars": "warn",
"react/jsx-uses-react": "warn",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/restrict-template-expressions": [
"error",
{ allowNumber: true, allowBoolean: true, },
],
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/prefer-promise-reject-errors": [
"error",
{ allowEmptyReject: true },
],
"@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/no-redeclare": "warn",
"default-case": "off", // superseded by @typescript-eslint/switch-exhaustiveness-check
"@typescript-eslint/switch-exhaustiveness-check": [
"error",
{
allowDefaultCaseForExhaustiveSwitch: false,
requireDefaultForNonUnion: true,
},
],
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": [
"warn",
{ functions: false, variables: false },
],
"no-unused-expressions": "off",
"@typescript-eslint/no-unused-expressions": [
"error",
{
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
},
],
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{ args: "none", ignoreRestSiblings: true },
],
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "warn",
"react/prop-types": "off",
},
}
);