vue 的ESlint .eslintrc.js 文件 常用配置和注释

2022年6月11日13:25:46
module.exports={
  root:true,
  env:{
    browser:true,
    es6:true,
    node:true},

  globals:{
    AMap:true,
    Cesium:true,
    layer:true,
    $:true,
    turf:true},extends:[//继承 vue 的标准特性'plugin:vue/essential','eslint:recommended',//避免与 prettier 冲突'plugin:prettier/recommended'],

  parserOptions:{
    ecmaVersion:2016,
    sourceType:'module',
    parser:'babel-eslint'},

  rules:{// 强制使用一致的缩进
    indent:[2,2,{
        SwitchCase:1}],// 强制使用骆驼拼写法命名约定
    camelcase:2,
    semi:[2,'never'],
    quotes:[2,'single',{'avoidEscape':true}],// 禁止没使用的变量'no-unused-vars':2,// 避免使用不必要的括号'no-extra-parens':1,// 禁用行尾分号'no-extra-semi':2,// 禁用行尾空格'no-trailing-spaces':2,// 对象中禁止出现重复的key'no-dupe-keys':2,// 强制对象赋值引用使用点形式'dot-notation':2,// 魔术数字'no-magic-numbers':['warn',{
        ignoreArrayIndexes:true}],// 禁止对 String,Number 和 Boolean 使用 new 操作符'no-new-wrappers':2,// 自我赋值'no-self-assign':1,// 数组使用一致的空格'array-bracket-spacing':1,// 强制把变量的使用限制在其定义的作用域范围内'block-scoped-var':2,'block-spacing':2,// 强制使用let或const 不能使用var'no-var':2,// 要求对象字面量简写语法'object-shorthand':1,// 要求构造函数首字母大写 (要求调用 new 操作符时有首字母大小的函数,允许调用首字母大写的函数时没有 new 操作符。)'new-cap':[2,{
        newIsCap:true,
        capIsNew:false}],// 强制一行的最大长度'max-len':[1,200],// 强制 function 块最多允许的的语句数量'max-statements':[1,200],// 强制回调函数最大嵌套深度 5层'max-nested-callbacks':[1,5],// 控制逗号前后的空格'comma-spacing':[2,{
        before:false,
        after:true}],'arrow-body-style':0,// 要求箭头函数的参数使用圆括号'arrow-parens':[1,'as-needed',{requireForBlockBody:true}],// 禁止重新声明变量'no-redeclare':2,// if return之后没必要使用else'no-else-return':1,// 禁止使用弱等于
    eqeqeq:2,'comma-dangle':['error','never'],// 花开括号样式// 'brace-style': [2, 'tbs'],'callback-return':2,'computed-property-spacing':[2,'never'],'dot-location':[2,'property'],'vue/html-self-closing':0,'vue/max-attributes-per-line':0,'vue/attribute-hyphenation':0,'vue/require-default-prop':0,// 此处关闭prettier的规则提示'prettier/prettier':'off',}}
  • 作者:淋雨一直走~
  • 原文链接:https://blog.csdn.net/qq_41579192/article/details/116291624
    更新时间:2022年6月11日13:25:46 ,共 1711 字。