eslint 校验优化

let INLINE_ELEMENTS = [
  "a",
  "abbr",
  "audio",
  "b",
  "bdi",
  "bdo",
  "canvas",
  "cite",
  "code",
  "data",
  "del",
  "dfn",
  "em",
  "i",
  "iframe",
  "ins",
  "kbd",
  "label",
  "map",
  "mark",
  "noscript",
  "object",
  "output",
  "picture",
  "q",
  "ruby",
  "s",
  "samp",
  "small",
  "span",
  "strong",
  "sub",
  "sup",
  "svg",
  "time",
  "u",
  "var",
  "video", 
  //已上为默认含有的自定义时重新添加
  "el-button",
  "el-checkbox",
  "template",
]
module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module'
  },
  env: {
    browser: true,
    node: true,
    es6: true,
  },
  globals: {
    'AMap': false,
    'AMapUI': false
  },
  extends: ['plugin:vue/recommended', 'eslint:recommended'],

  // add your custom rules here
  //it is base on https://github.com/vuejs/eslint-config-vue
  // "off"或者0    //关闭规则关闭
  // "warn"或者1    //在打开的规则作为警告(不影响退出代码)
  // "error"或者2    //把规则作为一个错误(退出代码触发时为1)
  rules: {
    // 在单行元素的内容之前和之后需要换行
    "vue/singleline-html-element-content-newline": ["error", {
      "ignoreWhenNoAttributes": true,  //当给定元素没有属性时,允许将内容放在一行中
      "ignoreWhenEmpty": true,  //.在元素没有内容时禁用报告
      "ignores": ["pre", "textarea", ...INLINE_ELEMENTS]  //配置元素名称以忽略换行符样式。默认["pre", "textarea", ...INLINE_ELEMENTS]。
    }],
    // 在多行元素的内容之前和之后需要换行
    "vue/multiline-html-element-content-newline": ["warn", {
      "ignoreWhenEmpty": true,
      "ignores": ["pre", "textarea", ...INLINE_ELEMENTS],
      "allowEmptyLines": false
    }],
    // 强制每行的最大属性数 (默认值1)修改为6
    "vue/max-attributes-per-line": ["error", {
      "singleline": 6, //标签行
      "multiline": {
        "max": 1,  //单独行
        "allowFirstLine": false
      }
    }],
    // allow paren-less arrow functions
    'arrow-parens': 0,
    // allow async-await
    'generator-star-spacing': 0,
    // allow debugger during development
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
    "no-unused-vars": [2, { 
      // 允许声明未使用变量
      "vars": "local",
      // 参数不检查
      "args": "none" 
    }],
    // 关闭语句强制分号结尾
    "semi": [0],
    //空行最多不能超过100行
    "no-multiple-empty-lines": [0, {"max": 100}],
    //关闭禁止混用tab和空格
    "no-mixed-spaces-and-tabs": [0],
    // 关闭不允许空块语句
    "no-empty": 0,
    // 关闭不允许不必要的转译字符(正则)
    "no-useless-escape": 0,
  }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值