-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
39 lines (35 loc) · 989 Bytes
/
eslint.config.mjs
File metadata and controls
39 lines (35 loc) · 989 Bytes
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
import js from "@eslint/js";
import globals from "globals";
import eslintConfigPrettier from "eslint-config-prettier";
export default [
// 核心规则集
js.configs.recommended,
// Node.js 环境配置
{
files: ["**/*.js"],
languageOptions: {
ecmaVersion: "latest", // ES2024 支持
sourceType: "script", // Node.js 默认模块类型
globals: {
...globals.node, // 注入 Node.js 全局变量(如 process、module)
__dirname: "readonly", // 补充 CommonJS 特有全局变量
__filename: "readonly",
},
},
rules: {
"no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
"prefer-const": "error",
},
},
// 测试文件特殊配置
{
files: ["**/*.test.js"],
languageOptions: {
globals: {
...globals.jest, // 注入 Jest 测试框架全局变量(如 describe、test)
},
},
},
// Prettier 集成(必须置于最后)
eslintConfigPrettier,
];