43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
module.exports = {
|
||
// 标记为根配置文件(ESLint 将停止在父目录中查找其他配置)
|
||
root: true,
|
||
|
||
// 指定代码运行环境
|
||
env: {
|
||
node: true, // Node.js 全局变量和作用域
|
||
es6: true // 启用 ES6 语法(不包括 ES6 全局变量,需要设置 parserOptions.ecmaVersion)
|
||
},
|
||
|
||
// 继承的规则配置
|
||
extends: [
|
||
'eslint:recommended', // ESLint 官方推荐规则
|
||
'plugin:vue/vue3-recommended', // Vue 3 官方推荐规则
|
||
'plugin:@typescript-eslint/recommended', // TypeScript 推荐规则
|
||
'prettier' // 禁用与 Prettier 冲突的 ESLint 规则
|
||
],
|
||
|
||
// 指定 Vue 文件解析器
|
||
parser: 'vue-eslint-parser',
|
||
|
||
// 解析器选项
|
||
parserOptions: {
|
||
parser: '@typescript-eslint/parser', // 解析 TypeScript
|
||
sourceType: 'module', // 使用 ES 模块语法
|
||
ecmaVersion: 2020 // 支持 ES2020 语法
|
||
},
|
||
|
||
// 使用的插件
|
||
plugins: [
|
||
'vue', // Vue 语法支持
|
||
'@typescript-eslint', // TypeScript 支持
|
||
'prettier' // Prettier 集成
|
||
],
|
||
|
||
// 自定义规则配置
|
||
rules: {
|
||
'prettier/prettier': 'error', // 将 Prettier 的格式化问题报为错误
|
||
'vue/multi-word-component-names': 'off', // 关闭 Vue 组件多单词命名要求
|
||
'@typescript-eslint/no-explicit-any': 'off' // 允许使用 any 类型
|
||
}
|
||
};
|