-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
159 lines (150 loc) · 4.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
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
// @ts-check
import js from "@eslint/js";
// @ts-expect-error eslint-plugin-import is not typed
import _import from "eslint-plugin-import";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import simpleImportSort from "eslint-plugin-simple-import-sort";
import { readFileSync } from "fs";
import ts from "typescript-eslint";
const ignores = readFileSync(".prettierignore", "utf8")
.split("\n")
.map(line => line.trim())
.filter(line => !!line);
export default ts.config(
{ ignores },
js.configs.recommended,
...ts.configs.recommendedTypeChecked,
...ts.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ["**/*.{ts,tsx,js,jsx}"],
rules: {
"no-console": ["warn", { allow: ["debug", "info", "warn", "error"] }],
},
},
{
files: ["**/*.{ts,tsx}"],
rules: {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-empty-object-type": "off",
"@typescript-eslint/consistent-type-imports": [
"warn",
{
fixStyle: "inline-type-imports",
},
],
"@typescript-eslint/consistent-type-exports": [
"warn",
{
fixMixedExportsWithInlineTypeSpecifier: true,
},
],
},
},
{
files: ["**/*.{js,jsx}"],
...ts.configs.disableTypeChecked,
},
{
files: ["**/*.{js,jsx,ts,tsx}"],
..._import.flatConfigs.recommended,
..._import.flatConfigs.typescript,
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: {
"simple-import-sort": simpleImportSort,
import: _import,
},
rules: {
"simple-import-sort/imports": [
"warn",
{
groups: [
// == Side effect imports
["^\\u0000"],
// == Node.js builtins prefixed with `node:`
["^node:"],
// == Packages
// Things that start with a letter (or digit or underscore), or `@`
// followed by a letter
["^@?\\w"],
// == Absolute imports and other imports such as Vue-style `@/foo`
// Anything not matched in another group.
["^~icons"],
["^"],
// == Relative imports
// (Anything that starts with a dot.)
["^\\."],
// == Fontsource fonts
["^\\u0000@fontsource"],
// == CSS modules
["\\.module\\.css$", "\\.css$"],
],
},
],
"simple-import-sort/exports": "warn",
"import/no-unresolved": "off",
"import/first": "warn",
"import/newline-after-import": "warn",
"import/consistent-type-specifier-style": ["warn", "prefer-inline"],
"import/namespace": "off",
},
},
{
files: ["**/*.{js,jsx,ts,tsx}"],
// @ts-expect-error react.configs.flat should not be undefined
...react.configs.flat.recommended,
settings: {
react: {
version: "detect",
},
},
plugins: {
"react-refresh": reactRefresh,
},
rules: {
"react/react-in-jsx-scope": "off",
"react/jsx-no-undef": "off",
"react/prop-types": "off",
"react-refresh/only-export-components": "warn",
},
},
{
files: ["**/*.{js,jsx,ts,tsx}"],
plugins: {
"react-hooks": reactHooks,
},
// @ts-expect-error react-hooks is not typed
rules: {
...reactHooks.configs.recommended.rules,
"react-hooks/exhaustive-deps": [
"warn",
{
additionalHooks: "(useDidUpdate|useShallowEffect)",
},
],
},
},
);