// ESLint 配置文件遵循 commonJS 的导出规则,所导出的对象就是 ESLint 的配置对象 // 文档:https://eslint.bootcss.com/docs/user-guide/configuring module.exports = { root: true, // 表示当前目录即为根目录,ESLint 规则将被限制到该目录下 // 声明之后 webstorm 不会报出未引用错误 globals: { defineProps: 'readonly', defineEmits: 'readonly', defineExpose: 'readonly' }, // env 表示启用 ESLint 检测的环境 env: { node: true, // 在`node`环境下启动 ESLint 检测 browser: true, // 在`浏览器`环境下启动 ESLint 检测 es2021: true // 支持ECMA2021语法 }, // ESLint 中基础配置需要继承的配置 extends: [ 'plugin:vue/vue3-essential', '@vue/standard', '@vue/typescript/recommended', // 解决 eslint 与 prettier 冲突 'plugin:prettier/recommended', 'prettier' ], // 解析器 parserOptions: { ecmaVersion: 'latest', // 支持解析ECMA最新语法 默认设置为 3,5(默认), 你可以使用 6、7、8、9 或 10 来指定你想要使用的 ECMAScript 版本。你也可以用使用年份命名的版本号指定为 2015(同 6),2016(同 7),或 2017(同 8)或 2018(同 9)或 2019 (same as 10) parser: '@typescript-eslint/parser', // 解析 ts sourceType: 'module' // 设置为 "script" (默认) 或 "module"(如果你的代码是 ECMAScript 模块)。 }, // 需要修改的启用规则及其各自的错误级别 /** * 错误级别分为三种: * "off" 或 0 - 关闭规则 * "warn" 或 1 - 开启规则,使用警告级别的错误:warn (不会导致程序退出) * "error" 或 2 - 开启规则,使用错误级别的错误:error (当被触发的时候,程序会退出) */ rules: { 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'prettier/prettier': 'off', // 关闭 prettier 格式警告 'vue/multi-word-component-names': 'off', // 关闭组件名不能为单个单词检测 /* ts类型检测 */ '@typescript-eslint/no-explicit-any': 'off', // 关闭类型不能为 any 检测 '@typescript-eslint/no-non-null-assertion': 'off', // 关闭静止非空断言检测 'no-tabs': 'off' // 关闭注释带有 tab 符号检测 } }