eslint.config.js
1.58 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
import { defineConfig } from "eslint/config";
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintPluginPrettier from "eslint-plugin-prettier";
import eslintPluginVue from "eslint-plugin-vue";
import vueParser from "vue-eslint-parser";
import globals from "globals";
import eslintConfigPrettier from "eslint-config-prettier/flat";
import { rules } from "eslint-config-prettier";
const ignores = ["**/dist/**", "**/node_modules/**", ".*", "scripts/**", "**/*.d.ts", "**/*.md"];
export default defineConfig(
{
// 通用配置
ignores, // 忽略项
extends: [eslint.configs.recommended, ...tseslint.configs.recommended, eslintConfigPrettier], // 继承规则
plugins: {
prettier: eslintPluginPrettier
// vue: eslintPluginVue,
},
languageOptions: {
ecmaVersion: "latest", //ecma版本
sourceType: "module", //es模块
parser: tseslint.parser // 使用 TypeScript 解析器
},
rules: {
"no-var": "error", //禁用var,使用let或const代替
...rules
}
},
//前端配置
{
ignores,
files: ["apps/frontend/**/*.{ts,js,tsx,jsx,vue}", "packages/**/*.{ts,js,tsx,jsx,vue}"],
extends: [...eslintPluginVue.configs["flat/recommended"], eslintConfigPrettier],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tseslint.parser
},
globals: {
...globals.browser
}
}
},
// 后端配置
{
ignores,
files: ["apps/backend/**/*.{ts,js}"],
languageOptions: {
globals: {
...globals.node
}
}
}
);