let vue3 = !!require("vue").createApp;
= {
env: {
browser: true,
es2021: true,
},
extends: vue3
? ["plugin:vue/recommended", "airbnb-base"]
: ["plugin:vue/vue3-recommended", "airbnb-base"],
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["vue"],
// 定义环境中的额外全局变量
globals: {
Vue: true,
Vuex: true,
location: true,
WeixinJSBridge: true,
wx: true,
hex_sha1: true,
getApp: true,
},
// 定义规则
rules: {
quotes: ["off"], // 取消单双引号限制
indent: ["error", 2], // 缩进
"no-new": ["off"], // 取消禁止使用new
"no-console": ["off"], // 取消禁止console
"no-param-reassign": ["off"], // 取消禁止修改函数参数
"import/no-extraneous-dependencies": ["off"], // 取消必须在中声明依赖
"max-len": ["off"], // 取消每行长度限制
"arrow-parens": ["off"], // 取消箭头函数参数必须加上括号
"no-underscore-dangle": ["off"], // 变量能否包含下划线
"no-plusplus": ["off"], // 取消不能使用 ++ 操作符
"no-restricted-globals": ["off"], // 取消禁止特定的全局变量
"vue/no-multiple-template-root": ["off"], // vue3允许tempalte没有根标签
"quote-props": [
// 需要一个对象里面保持一致 都是双引号或不要引号
"error",
"consistent",
],
"import/extensions": ["off"], // 取消import必须带文件扩展名
"vue/attribute-hyphenation": ["off"],
"vue/max-attributes-per-line": [
"error",
{
singleline: {
max: 5,
},
multiline: {
max: 1,
},
},
],
"vue/singleline-html-element-content-newline": ["off"],
"radix": ["error", "as-needed"]
},
settings: {
"import/extensions": [".js", ".ts", ".vue"],
"import/resolver": {
node: {
extensions: [".js", ".vue", ".ts"],
},
alias: {
map: [
["@", "./src"], // 支持使用@作为路径别名
],
},
},
},
};