/* * @Descripttion: esLint规则手册 https://cloud.tencent.com/developer/chapter/12618 https://eslint.vuejs.org/rules/html-self-closing.html * @Descripttion:"off"或者0,不启用这个规则 "warn"或者1,出现问题会有警告 "error"或者2,出现问题会报错 * @Version: 1.0 * @Author: +C * @Date: 2021-11-22 15:37:17 * @LastEditors: +C * @LastEditTime: 2022-02-22 15:52:50 */ /* eslint-disable */ // 关闭检查开始位置 // ... // 关闭检查结束位置 /* eslint-enable */ module.exports = { "root": true,//此项是用来告诉eslint找当前配置文件不能往父级查找 "env": { "node": true }, "extends": [ "plugin:vue/recommended", "eslint:recommended" ], "rules": { /**------------------格式------------------ */ "comma-spacing": 1,//在变量声明,数组文字,对象文字,函数参数和序列中的逗号前后加上一致的间距 var foo = 1 ,bar = 2; "space-unary-ops": [1, { "words": true, "nonwords": false }], // 强制在一元操作符前后使用一致的空格 "array-bracket-spacing": [1, "never"], // 强制数组方括号中使用一致的空格 "no-mixed-spaces-and-tabs": 1, // 禁止空格和 tab 的混合缩进 "no-trailing-spaces": 1, // 禁用行尾空格 "space-before-blocks": [1, "always"], // 强制在块之前使用一致的空格 "arrow-spacing": [1, { "before": true, "after": true }],//规则在箭头函数的箭头(=>)之前/之后标准化间距样式。 "no-multiple-empty-lines": [1, { 'max': 1 }],//空行最多不能超过1行 "indent": [0, 4],//此规则强制执行一致的缩进样式。设置为2 spaces,暂时不设置 "key-spacing": [1, { "beforeColon": false, "afterColon": true }], // 对象字面量中冒号的前后空格 "no-multi-spaces": 1, // 不能用多余的空格 /**------------------变量,函数------------------ */ "no-unused-vars": [1, { "vars": "all", "args": "none" }], // 禁止出现未使用过的变量 "arrow-parens": 2,//无论参数如何,该规则都会在箭头函数参数周围加上括号 "id-match": [0, "^[a-z]+([A-Z][a-z]+)*$"],//变量,函数名匹配正则 "id-length": 0,//该规则允许您精确地定义和执行团队应该使用的变量和函数名称,定义了太多的i d等暂时放弃 "block-scoped-var": 1,//变量在定义块的外部使用时,规则会生成警告,避免变量提升的难题 "camelcase": [0, { "allow": ["aa_bb"] }],//函数名,变量名不允许"_" /**------------------注释------------------ */ "multiline-comment-style": [1, "bare-block"],//多行注释的正确格式 "valid-jsdoc": [1, { "requireParamDescription": false, "requireReturnDescription": false, "requireReturnType": false }], //规定函数块注释的格式,该规则注意:函数没有参数时,不要param "lines-around-comment": [0, { "beforeBlockComment": true }],// 块注释带换行 "line-comment-position": [0, { "position": "above" }],//行注释可以位于代码上方或旁边 above beside "no-warning-comments": [2, { "terms": ["todo", "fixme", "any other term"], "location": "anywhere" }],// 不能有警告备注 /**------------------代码风格------------------ */ "for-direction": 2,//检测时候for的死循环 "curly": 2,//不允许省略花括号 "no-implied-eval": 2,//setTimeout(),setInterval()或者execScript() 规定格式 "no-bitwise": 1,//提示:经常&或|仅仅是输入错误 "no-irregular-whitespace": 1,//不规则空格引起的错误 "consistent-return": 0,//return后面必须带值 "quotes": [0, "double"], // 强制使用一致的反勾号、双引号或单引号 "no-var": 0, //禁用var,用let和const代替 "max-depth": [0, { "max": 3 }],//控制嵌套层级 "max-lines": [0, { "max": 1000 }],//每个文件强制执行最多行数 "no-prototype-builtins": 0,//禁止state.hasOwnProperty(key) 这样判断 "css.lint.emptyRules": 0,//禁止不规则css "comma-dangle": [2, "never"], // 对象字面量项尾不能有逗号 "no-debugger": 2, // 禁止使用debugger "no-constant-condition": 2, // 禁止在条件中使用常量表达式 if(true) if(1) "no-dupe-args": 2, // 函数参数不能重复 "no-dupe-keys": 2, // 在创建对象字面量时不允许键重复 {a:1,a:1} "no-duplicate-case": 2, // switch中的case标签不能重复 "no-empty-character-class": 2, // 正则表达式中的[]内容不能为空 "no-invalid-regexp": 2, // 禁止无效的正则表达式 "no-func-assign": 2, // 禁止重复的函数声明 "valid-typeof": 2, // 必须使用合法的typeof的值 "no-unreachable": 2, // 不能有无法执行的代码 "no-unexpected-multiline": 2, // 避免多行表达式 "no-sparse-arrays": 2, // 禁止稀疏数组, [1,,2] "no-shadow-restricted-names": 2, // 严格模式中规定的限制标识符不能作为声明时的变量名使用 "no-cond-assign": 2, // 禁止在条件表达式中使用赋值语句 "no-native-reassign": 2, // 不能重写native对象 "no-else-return": 1, // 如果if语句里面有return,后面不能跟else语句 "block-scoped-var": 0, // 块语句中使用var "consistent-return": 0, // 箭头函数一定要返回值 "accessor-pairs": 2, // 在对象中使用getter/setter "dot-location": [2, "property"], // 对象访问符的位置,换行的时候在行首还是行尾 "no-lone-blocks": 2, // 禁止不必要的嵌套块 "no-labels": 2, // 禁止标签声明 "no-extend-native": 2, // 禁止扩展native对象 "no-floating-decimal": 2, // 禁止省略浮点数中的0 .5 3. "no-loop-func": 2, // 禁止在循环中使用函数(如果没有引用外部变量不形成闭包就可以) "no-new-func": 2, // 禁止使用new Function "no-self-compare": 2, // 不能比较自身 "no-sequences": 2, // 禁止使用逗号运算符 "no-throw-literal": 2, // 禁止抛出字面量错误 throw "error"; "no-return-assign": [0, "always"], // return 语句中不能有赋值表达式 "no-redeclare": [2, { "builtinGlobals": true }],// 禁止重复声明变量 "no-unused-expressions": [2, { "allowShortCircuit": true, "allowTernary": true }], // 禁止无用的表达式 "no-useless-call": 2, // 禁止不必要的call和apply "no-useless-concat": 2, "no-void": 2, // 禁用void操作符 "no-with": 2, // 禁用with "space-infix-ops": 2, // 中缀操作符周围要不要有空格 "curly": 1, // 必须使用 if(){} 中的{} /**------------------vue------------------ */ "vue/no-unused-vars": 1,//定义了没用的变量 "vue/multiline-html-element-content-newline": 2,//vue的tmp自动格式化 "vue/singleline-html-element-content-newline": 2,//vue的tmp自动格式化 "vue/padding-line-between-blocks": 2,//检测vue的 template script style隔一行 "vue/html-closing-bracket-newline": 0,//标签的收尾括号前强制执行换行 "vue/max-attributes-per-line": 0,//vue允许dom的多行属性 "vue/require-default-prop": 0,//props不允许简单定义 "vue/html-indent": [0, "tab"],//html换行规则,暂时不用 "vue/html-self-closing": 0,//HTML自闭合,暂时不用 "vue/require-prop-types": 0,//prop规范化 "vue/require-valid-default-prop": 0,//prop的default建议是个函数 "vue/no-unused-components": 1,//定义后没用的组件 "vue/no-v-html": 0,//禁止v-html }, "parserOptions": { //此项是用来指定eslint解析器的,解析器必须符合规则,babel-eslint解析器是对babel解析器的包装使其与ESLint解析 "parser": "babel-eslint" } }