142 lines
3.8 KiB
JavaScript
142 lines
3.8 KiB
JavaScript
module.exports = {
|
||
root: true,
|
||
env: {
|
||
browser: true,
|
||
es2021: true,
|
||
node: true,
|
||
},
|
||
parser: "vue-eslint-parser",
|
||
extends: [
|
||
// https://eslint.vuejs.org/user-guide/#usage
|
||
"plugin:vue/vue3-recommended",
|
||
"./.eslintrc-auto-import.json",
|
||
"prettier",
|
||
"plugin:@typescript-eslint/recommended",
|
||
"plugin:prettier/recommended",
|
||
],
|
||
parserOptions: {
|
||
ecmaVersion: "latest",
|
||
sourceType: "module",
|
||
parser: "@typescript-eslint/parser",
|
||
project: "./tsconfig.*?.json",
|
||
createDefaultProgram: false,
|
||
extraFileExtensions: [".vue"],
|
||
},
|
||
plugins: ["vue", "@typescript-eslint"],
|
||
rules: {
|
||
// 禁止使用 var,用 let 和 const 代替
|
||
"no-var": "error",
|
||
|
||
// 在 Vue 的 v-for 循环中要求使用 :key
|
||
"vue/require-v-for-key": "error", // vue的for循环是否必须有key
|
||
|
||
// 关闭 Vue 组件名必须多字的规则
|
||
"vue/multi-word-component-names": "off",
|
||
|
||
// 关闭 Vue 的 v-model 中的参数规则
|
||
"vue/no-v-model-argument": "off",
|
||
|
||
// Vue 的 setup() 函数必须使用的变量规则
|
||
"vue/script-setup-uses-vars": "error",
|
||
|
||
// 关闭 Vue 组件名的保留规则
|
||
"vue/no-reserved-component-names": "off",
|
||
|
||
// 关闭 Vue 事件名的命名规则
|
||
"vue/custom-event-name-casing": "off",
|
||
|
||
// 关闭 Vue 属性的顺序规则
|
||
"vue/attributes-order": "off",
|
||
|
||
// 关闭一个文件只能有一个组件规则
|
||
"vue/one-component-per-file": "off",
|
||
|
||
// 关闭 HTML 标签闭合换行规则
|
||
"vue/html-closing-bracket-newline": "off",
|
||
|
||
// 关闭 HTML 属性每行最大数量规则
|
||
"vue/max-attributes-per-line": "off",
|
||
|
||
// 关闭多行 HTML 元素内容的规则
|
||
"vue/multiline-html-element-content-newline": "off",
|
||
|
||
// 关闭单行 HTML 元素内容的规则
|
||
"vue/singleline-html-element-content-newline": "off",
|
||
|
||
// 关闭 HTML 属性连字符的规则
|
||
"vue/attribute-hyphenation": "off",
|
||
|
||
// 关闭要求 Vue 默认属性的规则
|
||
"vue/require-default-prop": "off",
|
||
|
||
// 关闭要求 Vue 显式触发事件的规则
|
||
"vue/require-explicit-emits": "off",
|
||
|
||
// HTML 标签自闭合规则
|
||
"vue/html-self-closing": [
|
||
"error",
|
||
{
|
||
html: {
|
||
void: "always", // 自闭合标签必须自闭合
|
||
normal: "never", // 普通标签不得自闭合
|
||
component: "always", // 组件标签必须自闭合
|
||
},
|
||
svg: "always",
|
||
math: "always",
|
||
},
|
||
],
|
||
|
||
// 警告空方法检查
|
||
"@typescript-eslint/no-empty-function": "warn",
|
||
|
||
// 关闭 any 类型的警告
|
||
"@typescript-eslint/no-explicit-any": "off",
|
||
|
||
// 关闭使用 @ts-ignore 的警告
|
||
"@typescript-eslint/ban-ts-ignore": "off",
|
||
|
||
// 关闭使用 @ts-comment 的警告
|
||
"@typescript-eslint/ban-ts-comment": "off",
|
||
|
||
// 关闭一些特定类型的警告
|
||
"@typescript-eslint/ban-types": "off",
|
||
|
||
// 关闭函数返回类型的警告
|
||
"@typescript-eslint/explicit-function-return-type": "off",
|
||
|
||
// 关闭 any 类型的警告
|
||
"@typescript-eslint/no-explicit-any": "off",
|
||
|
||
// 关闭使用 require 的警告
|
||
"@typescript-eslint/no-var-requires": "off",
|
||
|
||
// 关闭使用尚未定义的变量的警告
|
||
"@typescript-eslint/no-use-before-define": "off",
|
||
|
||
// 关闭模块导出类型的警告
|
||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||
|
||
// 未使用的变量的警告
|
||
"@typescript-eslint/no-unused-vars": "warn",
|
||
|
||
// Prettier 配置
|
||
"prettier/prettier": [
|
||
"error",
|
||
{
|
||
useTabs: false, // 不使用制表符
|
||
},
|
||
],
|
||
},
|
||
// eslint不能对html文件生效
|
||
overrides: [
|
||
{
|
||
files: ["*.html"],
|
||
processor: "vue/.vue",
|
||
},
|
||
],
|
||
// https://eslint.org/docs/latest/use/configure/language-options#specifying-globals
|
||
globals: {
|
||
OptionType: "readonly",
|
||
},
|
||
};
|