-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patheslint.config.js
More file actions
82 lines (81 loc) · 2.65 KB
/
eslint.config.js
File metadata and controls
82 lines (81 loc) · 2.65 KB
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
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";
import importPlugin from "eslint-plugin-import";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
importPlugin.flatConfigs.recommended,
],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
settings: {
"import/resolver": {
// eslint-import-resolver-alias 可以解决绝对路径的问题
alias: {
map: [
["", "./public"], // <-- this line
["@", "./src"], // <-- this line
],
extensions: [".js", ".jsx", ".ts", ".tsx", ".svg"],
},
},
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
// 分号
semi: ["error", "always"],
"import/default": "off",
"import/order": [
"error",
{
// 对导入模块进行分组,分组排序规则如下
groups: [
"builtin", // 内置模块
"external", // 外部模块
"parent", // 父节点依赖
"sibling", // 兄弟依赖
"internal", // 内部引用
"index", // index文件
"type", //类型文件
"unknown", // 未知依赖
],
//通过路径自定义分组
pathGroups: [
{
pattern: "@/**", // 把@开头的应用放在external分组后面
group: "external",
position: "after", // 定义组的位置,after、before
},
{
pattern: "react*", // 在规定的组中选其一,index、sibling、parent、internal、external、builtin、object、type、unknown
group: "builtin",
position: "before",
},
],
// 是否开启独特组,用于区分自定义规则分组和其他规则分组
distinctGroup: true,
// 每个分组之间换行
"newlines-between": "always",
// 相同分组排列规则 按字母升序排序
alphabetize: { order: "asc", caseInsensitive: true },
},
],
},
},
eslintPluginPrettierRecommended
);