美的项目前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

151 lines
4.9 KiB

module.exports = {
"root": true,
"env": {
"browser": true
},
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@babel/eslint-parser",
"ecmaVersion": 2020,
"sourceType": "module"
},
extends: [
// "eslint-config-md-js",
// "eslint-config-md-vue2",
// 加入 Vue 推荐的规则配置
'plugin:vue/recommended',
],
rules: {
// 关闭多行属性间必须换行的规则
'vue/new-line-between-multi-line-attributes': 'off',
// 关闭Vue模板缩进检查(关键:解决模板中的缩进提示)
'vue/html-indent': 'off',
// 强制使用分号(默认)
'semi': ['warn', 'always'],
// 警告但不报错(提醒清理)
'no-console': 'warn',
// 单行标签属性个数
'vue/max-attributes-per-line': ['warn', {
'singleline': 10,
'multiline': {
'max': 10,
'allowFirstLine': false
}
}],
// 关闭v-html的XSS风险提示
'vue/no-v-html': 'off',
// 关闭属性必须使用连字符命名的规则
'vue/attribute-hyphenation': 'off',
// 关闭组件选项顺序校验规则
'vue/order-in-components': 'off',
// 关闭 Vue 属性顺序强制校验规则
'vue/attributes-order': 'off',
// 允许单行里展示标签和文本
'vue/singleline-html-element-content-newline': 'off',
// 要求使用严格相等(!==/===)
eqeqeq: ['error', 'always'],
// 允许在 <template v-for> 的子元素上使用 key(而非 template 标签本身)
'vue/no-v-for-template-key-on-child': 'off',
// 关闭 "$slots" 属性应作为函数使用的提示 好像没效果
'vue/no-deprecated-slot-attribute': 'off',
'vue/html-self-closing': [
'error',
{
html: {
void: 'always', // HTML 空标签始终自闭合
normal: 'never', // 普通标签不自闭合
component: 'always', // 组件始终自闭合
},
},
],
'vue/html-closing-bracket-spacing': [
'error',
{
selfClosingTag: 'always', // 自闭合标签斜杠前必须有空格
},
],
// 插值语法内必须要有空格 {{ 1 }} 这种
'vue/mustache-interpolation-spacing': ['error', 'always'],
// 禁止使用var,要求用let/const
'no-var': 'error',
// 新增:未修改的变量必须用const,修改的用let
'prefer-const': [
'error',
{
// 允许对解构赋值中的变量使用let(可选配置)
destructuring: 'any',
// 忽略for循环中的初始化变量(如for(let i=0;...))
ignoreReadBeforeAssign: false
}
],
// if条件后必须有大括号
curly: ['error', 'all'],
// Props必须设置默认值
'vue/require-default-prop': 'error',
// Props必须定义类型
'vue/require-prop-types': 'error',
// 关闭 $listeners 弃用警告(适用于 Vue 2 项目)
'vue/no-deprecated-dollar-listeners-api': 'off',
// 禁止访问Object原型方法(如hasOwnProperty)------------- 没效果
'no-prototype-builtins': 'error',
// 禁止定义但未使用的变量
'no-unused-vars': 'error',
// 关闭 slot-scope 弃用警告
'vue/no-deprecated-slot-scope-attribute': 'off',
// 关闭 .native 修饰符弃用警告
'vue/no-deprecated-v-on-native-modifier': 'off',
// 关闭组件名必须多单词的规则
'vue/multi-word-component-names': 'off',
// 关闭计算属性中意外副作用的提示
'vue/no-side-effects-in-computed-properties': 'off',
// 关闭组件已注册但未使用的提示
'vue/no-unused-components': 'off',
// 关闭属性应至少定义其类型的提示(针对 Vue 组件 props 类型检查)
'vue/require-prop-type-constructor': 'off',
// 禁止不必要的转义字符
'no-useless-escape': 'error',
// 限制函数复杂度(默认最大10)
complexity: ['error', 10],
// 允许使用 $on, $off, $once(Vue 3 中已废弃的事件 API)
'vue/no-deprecated-events-api': 'off',
// 允许使用过滤器(Vue 3 中已废弃)
'vue/no-deprecated-filter': 'off',
// 允许以属性形式使用 $slots(Vue 3 中建议作为函数使用)
'vue/no-deprecated-slot-scope-attribute': 'off',
'vue/no-deprecated-dollar-scopedslots-api': 'off',
'vue/require-slots-as-functions': 'off',
},
}