ly-front/.eslintrc.js

44 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2025-03-31 15:26:29 +00:00
module.exports = {
// 根目录的 ESLint 配置
root: true,
// 指定代码运行环境
env: {
node: true // 在 Node.js 环境中运行
},
// 继承的规则配置
extends: [
"plugin:vue/essential", // 使用 Vue.js 的必要规则
// "eslint:recommended", // 使用 ESLint 推荐的规则
"plugin:prettier/recommended" // 使用 Prettier 插件推荐的规则
],
// 解析器选项配置
parserOptions: {
parser: "@babel/eslint-parser" // 使用 Babel 解析器
},
// 自定义的规则配置
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off", // 生产环境下警告使用 console
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", // 生产环境下警告使用 debugger
"linebreak-style": "off", // 关闭换行风格检查
"comma-dangle": ["error", "never"], // 禁止尾随逗号
"prettier/prettier": ["error", { endOfLine: "auto" }] // 添加 Prettier 的换行符风格配置
},
// 针对特定文件的覆盖配置
overrides: [
{
files: [
"**/__tests__/*.{j,t}s?(x)", // 匹配 __tests__ 目录下的 js、ts、jsx、tsx 文件
"**/tests/unit/**/*.spec.{j,t}s?(x)" // 匹配 tests/unit 目录下的 spec 文件
],
env: {
jest: true // 在这些文件中启用 Jest 环境
}
}
]
};