-
Notifications
You must be signed in to change notification settings - Fork 22
/
eslint.config.mjs
98 lines (94 loc) · 2.85 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
import js from "@eslint/js";
import vueEslintPlugin from "eslint-plugin-vue";
import importPlugin from "eslint-plugin-import";
import stylisticEslintPlugin from "@stylistic/eslint-plugin";
import vueTsEslintConfig from "@vue/eslint-config-typescript";
import globals from "globals";
export default [
js.configs.recommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
...vueEslintPlugin.configs["flat/recommended"],
...vueTsEslintConfig(),
{
plugins: {
"@stylistic": stylisticEslintPlugin
},
rules: {
"camelcase": "warn",
"no-warning-comments": "warn",
"no-console": ["warn", { allow: [ "warn", "error" ] }],
"no-var": "error",
"no-undef": "off", // ts 和 vue lang="ts" 中,eslint 无法识别全局类型定义,所以关闭。仅靠 ts 就能检查未定义的变量
"prefer-const": "warn",
"@stylistic/indent": ["error", 2],
"@stylistic/keyword-spacing": "error",
"@stylistic/key-spacing": "error",
"@stylistic/no-trailing-spaces": "error",
"@stylistic/linebreak-style": ["error", "unix"],
"@stylistic/quotes": ["error", "double"],
"@stylistic/function-call-spacing": "error",
"@stylistic/semi": "error",
"@stylistic/no-multiple-empty-lines": ["warn", { max: 1 }],
"@stylistic/object-curly-spacing": ["error", "always"],
"@stylistic/arrow-spacing": "error",
"@stylistic/block-spacing": "error",
"@stylistic/brace-style": "error",
"@stylistic/comma-dangle": "error",
"@stylistic/no-multi-spaces": "error",
"@stylistic/comma-spacing": "error",
"@stylistic/switch-colon-spacing": "error",
"@stylistic/type-annotation-spacing": "error",
"@stylistic/space-before-blocks": "error",
"@stylistic/space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"@stylistic/space-in-parens": "error",
"@stylistic/space-infix-ops": "error",
"@stylistic/spaced-comment": "error",
"@typescript-eslint/no-explicit-any": "off"
},
settings: {
"import/resolver": {
"typescript": true
}
}
},
{
files: ["**/*.vue"],
rules: {
"vue/multi-word-component-names": "off",
"vue/component-name-in-template-casing": ["error", "kebab-case", { "registeredComponentsOnly": true }],
"vue/max-attributes-per-line": ["error", { "singleline": { "max": 3 } }]
}
},
{
files: ["config/*.js"],
rules: {
"@typescript-eslint/no-require-imports": "off"
}
},
{
files: ["**/*.{js,mjs,cjs}"],
rules: {
"no-undef": "error"
}
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
ignores: [
"dist/*",
".swc/*",
".github/*"
]
}
];