eslint-config-alloy
Version:
AlloyTeam ESLint 规则
1,146 lines • 98 kB
JSON
{
"for-direction": {
"name": "for-direction",
"value": "error",
"description": "禁止 for 循环出现方向错误的循环,比如 for (i = 0; i < 10; i--)",
"category": "Possible Errors",
"comments": "/**\n * 禁止 for 循环出现方向错误的循环,比如 for (i = 0; i < 10; i--)\n * @category Possible Errors\n */"
},
"getter-return": {
"name": "getter-return",
"value": ["error", { "allowImplicit": false }],
"description": "getter 必须有返回值,并且禁止返回空,比如 return;",
"category": "Possible Errors",
"comments": "/**\n * getter 必须有返回值,并且禁止返回空,比如 return;\n * @category Possible Errors\n */"
},
"no-await-in-loop": {
"name": "no-await-in-loop",
"value": "off",
"description": "禁止将 await 写在循环里,因为这样就无法同时发送多个异步请求了",
"category": "Possible Errors",
"comments": "/**\n * 禁止将 await 写在循环里,因为这样就无法同时发送多个异步请求了\n * @category Possible Errors\n * @reason 要求太严格了,有时需要在循环中写 await\n */",
"reason": "要求太严格了,有时需要在循环中写 await"
},
"no-compare-neg-zero": {
"name": "no-compare-neg-zero",
"value": "error",
"description": "禁止与负零进行比较",
"category": "Possible Errors",
"comments": "/**\n * 禁止与负零进行比较\n * @category Possible Errors\n */"
},
"no-cond-assign": {
"name": "no-cond-assign",
"value": ["error", "except-parens"],
"description": "禁止在测试表达式中使用赋值语句,除非这个赋值语句被括号包起来了",
"category": "Possible Errors",
"comments": "/**\n * 禁止在测试表达式中使用赋值语句,除非这个赋值语句被括号包起来了\n * @category Possible Errors\n */"
},
"no-console": {
"name": "no-console",
"value": "off",
"description": "禁止使用 console",
"category": "Possible Errors",
"comments": "/**\n * 禁止使用 console\n * @category Possible Errors\n * @reason console 的使用很常见\n */",
"reason": "console 的使用很常见"
},
"no-constant-condition": {
"name": "no-constant-condition",
"value": ["error", { "checkLoops": false }],
"description": "禁止将常量作为分支条件判断中的测试表达式,但允许作为循环条件判断中的测试表达式",
"category": "Possible Errors",
"comments": "/**\n * 禁止将常量作为分支条件判断中的测试表达式,但允许作为循环条件判断中的测试表达式\n * @category Possible Errors\n */"
},
"no-control-regex": {
"name": "no-control-regex",
"value": "off",
"description": "禁止在正则表达式中出现 Ctrl 键的 ASCII 表示,即禁止使用 /\\x1f/",
"category": "Possible Errors",
"comments": "/**\n * 禁止在正则表达式中出现 Ctrl 键的 ASCII 表示,即禁止使用 /\\x1f/\n * @category Possible Errors\n * @reason 几乎不会遇到这种场景\n */",
"reason": "几乎不会遇到这种场景"
},
"no-debugger": {
"name": "no-debugger",
"value": "error",
"description": "禁止使用 debugger",
"category": "Possible Errors",
"comments": "/**\n * 禁止使用 debugger\n * @category Possible Errors\n * @fixable\n */",
"fixable": true
},
"no-dupe-args": {
"name": "no-dupe-args",
"value": "error",
"description": "禁止在函数参数中出现重复名称的参数",
"category": "Possible Errors",
"comments": "/**\n * 禁止在函数参数中出现重复名称的参数\n * @category Possible Errors\n */"
},
"no-dupe-keys": {
"name": "no-dupe-keys",
"value": "error",
"description": "禁止在对象字面量中出现重复名称的键名",
"category": "Possible Errors",
"comments": "/**\n * 禁止在对象字面量中出现重复名称的键名\n * @category Possible Errors\n */"
},
"no-duplicate-case": {
"name": "no-duplicate-case",
"value": "error",
"description": "禁止在 switch 语句中出现重复测试表达式的 case",
"category": "Possible Errors",
"comments": "/**\n * 禁止在 switch 语句中出现重复测试表达式的 case\n * @category Possible Errors\n */"
},
"no-empty": {
"name": "no-empty",
"value": ["error", { "allowEmptyCatch": true }],
"description": "禁止出现空代码块,允许 catch 为空代码块",
"category": "Possible Errors",
"comments": "/**\n * 禁止出现空代码块,允许 catch 为空代码块\n * @category Possible Errors\n */"
},
"no-empty-character-class": {
"name": "no-empty-character-class",
"value": "error",
"description": "禁止在正则表达式中使用空的字符集 []",
"category": "Possible Errors",
"comments": "/**\n * 禁止在正则表达式中使用空的字符集 []\n * @category Possible Errors\n */"
},
"no-ex-assign": {
"name": "no-ex-assign",
"value": "error",
"description": "禁止将 catch 的第一个参数 error 重新赋值",
"category": "Possible Errors",
"comments": "/**\n * 禁止将 catch 的第一个参数 error 重新赋值\n * @category Possible Errors\n */"
},
"no-extra-boolean-cast": {
"name": "no-extra-boolean-cast",
"value": "error",
"description": "禁止不必要的布尔类型转换,比如 !! 或 Boolean",
"category": "Possible Errors",
"comments": "/**\n * 禁止不必要的布尔类型转换,比如 !! 或 Boolean\n * @category Possible Errors\n * @fixable\n */",
"fixable": true
},
"no-extra-parens": {
"name": "no-extra-parens",
"value": ["error", "functions"],
"description": "禁止函数表达式中出现多余的括号,比如 let foo = (function () { return 1 })",
"category": "Possible Errors",
"comments": "/**\n * 禁止函数表达式中出现多余的括号,比如 let foo = (function () { return 1 })\n * @category Possible Errors\n * @fixable\n */",
"fixable": true
},
"no-extra-semi": {
"name": "no-extra-semi",
"value": "error",
"description": "禁止出现多余的分号",
"category": "Possible Errors",
"comments": "/**\n * 禁止出现多余的分号\n * @category Possible Errors\n * @fixable\n */",
"fixable": true
},
"no-func-assign": {
"name": "no-func-assign",
"value": "error",
"description": "禁止将一个函数声明重新赋值,如:",
"category": "Possible Errors",
"comments": "/**\n * 禁止将一个函数声明重新赋值,如:\n * @category Possible Errors\n */"
},
"no-inner-declarations": {
"name": "no-inner-declarations",
"value": ["error", "both"],
"description": "禁止在 if 代码块内出现函数声明",
"category": "Possible Errors",
"comments": "/**\n * 禁止在 if 代码块内出现函数声明\n * @category Possible Errors\n */"
},
"no-invalid-regexp": {
"name": "no-invalid-regexp",
"value": "error",
"description": "禁止在 RegExp 构造函数中出现非法的正则表达式",
"category": "Possible Errors",
"comments": "/**\n * 禁止在 RegExp 构造函数中出现非法的正则表达式\n * @category Possible Errors\n */"
},
"no-irregular-whitespace": {
"name": "no-irregular-whitespace",
"value": [
"error",
{
"skipStrings": true,
"skipComments": false,
"skipRegExps": true,
"skipTemplates": true
}
],
"description": "禁止使用特殊空白符(比如全角空格),除非是出现在字符串、正则表达式或模版字符串中",
"category": "Possible Errors",
"comments": "/**\n * 禁止使用特殊空白符(比如全角空格),除非是出现在字符串、正则表达式或模版字符串中\n * @category Possible Errors\n */"
},
"no-obj-calls": {
"name": "no-obj-calls",
"value": "error",
"description": "禁止将 Math, JSON 或 Reflect 直接作为函数调用",
"category": "Possible Errors",
"comments": "/**\n * 禁止将 Math, JSON 或 Reflect 直接作为函数调用\n * @category Possible Errors\n */"
},
"no-prototype-builtins": {
"name": "no-prototype-builtins",
"value": "off",
"description": "禁止使用 hasOwnProperty, isPrototypeOf 或 propertyIsEnumerable",
"category": "Possible Errors",
"comments": "/**\n * 禁止使用 hasOwnProperty, isPrototypeOf 或 propertyIsEnumerable\n * @category Possible Errors\n * @reason hasOwnProperty 比较常用\n */",
"reason": "hasOwnProperty 比较常用"
},
"no-regex-spaces": {
"name": "no-regex-spaces",
"value": "error",
"description": "禁止在正则表达式中出现连续的空格,必须使用 /foo {3}bar/ 代替",
"category": "Possible Errors",
"comments": "/**\n * 禁止在正则表达式中出现连续的空格,必须使用 /foo {3}bar/ 代替\n * @category Possible Errors\n * @fixable\n */",
"fixable": true
},
"no-sparse-arrays": {
"name": "no-sparse-arrays",
"value": "error",
"description": "禁止在数组中出现连续的逗号,如 let foo = [,,]",
"category": "Possible Errors",
"comments": "/**\n * 禁止在数组中出现连续的逗号,如 let foo = [,,]\n * @category Possible Errors\n */"
},
"no-template-curly-in-string": {
"name": "no-template-curly-in-string",
"value": "error",
"description": "禁止在普通字符串中出现模版字符串里的变量形式,如 'Hello ${name}!'",
"category": "Possible Errors",
"comments": "/**\n * 禁止在普通字符串中出现模版字符串里的变量形式,如 'Hello ${name}!'\n * @category Possible Errors\n */"
},
"no-unexpected-multiline": {
"name": "no-unexpected-multiline",
"value": "error",
"description": "禁止出现难以理解的多行表达式",
"category": "Possible Errors",
"comments": "/**\n * 禁止出现难以理解的多行表达式\n * @category Possible Errors\n */"
},
"no-unreachable": {
"name": "no-unreachable",
"value": "error",
"description": "禁止在 return, throw, break 或 continue 之后还有代码",
"category": "Possible Errors",
"comments": "/**\n * 禁止在 return, throw, break 或 continue 之后还有代码\n * @category Possible Errors\n */"
},
"no-unsafe-finally": {
"name": "no-unsafe-finally",
"value": "error",
"description": "禁止在 finally 中出现 return, throw, break 或 continue",
"category": "Possible Errors",
"comments": "/**\n * 禁止在 finally 中出现 return, throw, break 或 continue\n * @category Possible Errors\n */"
},
"no-unsafe-negation": {
"name": "no-unsafe-negation",
"value": "error",
"description": "禁止在 in 或 instanceof 操作符的左侧使用感叹号,如 if (!key in object)",
"category": "Possible Errors",
"comments": "/**\n * 禁止在 in 或 instanceof 操作符的左侧使用感叹号,如 if (!key in object)\n * @category Possible Errors\n * @fixable\n */",
"fixable": true
},
"use-isnan": {
"name": "use-isnan",
"value": "error",
"description": "必须使用 isNaN(foo) 而不是 foo === NaN",
"category": "Possible Errors",
"comments": "/**\n * 必须使用 isNaN(foo) 而不是 foo === NaN\n * @category Possible Errors\n */"
},
"valid-typeof": {
"name": "valid-typeof",
"value": "error",
"description": "typeof 表达式比较的对象必须是 'undefined', 'object', 'boolean', 'number', 'string', 'function' 或 'symbol'",
"category": "Possible Errors",
"comments": "/**\n * typeof 表达式比较的对象必须是 'undefined', 'object', 'boolean', 'number', 'string', 'function' 或 'symbol'\n * @category Possible Errors\n */"
},
"accessor-pairs": {
"name": "accessor-pairs",
"value": ["error", { "setWithoutGet": true, "getWithoutSet": false }],
"description": "setter 必须有对应的 getter,getter 可以没有对应的 setter",
"category": "Best Practices",
"comments": "/**\n * setter 必须有对应的 getter,getter 可以没有对应的 setter\n * @category Best Practices\n */"
},
"array-callback-return": {
"name": "array-callback-return",
"value": "error",
"description": "数组的方法除了 forEach 之外,回调函数必须有返回值",
"category": "Best Practices",
"comments": "/**\n * 数组的方法除了 forEach 之外,回调函数必须有返回值\n * @category Best Practices\n */"
},
"block-scoped-var": {
"name": "block-scoped-var",
"value": "error",
"description": "将 var 定义的变量视为块作用域,禁止在块外使用",
"category": "Best Practices",
"comments": "/**\n * 将 var 定义的变量视为块作用域,禁止在块外使用\n * @category Best Practices\n */"
},
"class-methods-use-this": {
"name": "class-methods-use-this",
"value": "off",
"description": "在类的非静态方法中,必须存在对 this 的引用",
"category": "Best Practices",
"comments": "/**\n * 在类的非静态方法中,必须存在对 this 的引用\n * @category Best Practices\n * @reason 太严格了\n */",
"reason": "太严格了"
},
"complexity": {
"name": "complexity",
"value": ["error", { "max": 20 }],
"description": "禁止函数的循环复杂度超过 20,https://en.wikipedia.org/wiki/Cyclomatic_complexity",
"category": "Best Practices",
"comments": "/**\n * 禁止函数的循环复杂度超过 20,https://en.wikipedia.org/wiki/Cyclomatic_complexity\n * @category Best Practices\n */"
},
"consistent-return": {
"name": "consistent-return",
"value": "off",
"description": "禁止函数在不同分支返回不同类型的值",
"category": "Best Practices",
"comments": "/**\n * 禁止函数在不同分支返回不同类型的值\n * @category Best Practices\n * @reason 太严格了\n */",
"reason": "太严格了"
},
"curly": {
"name": "curly",
"value": ["error", "multi-line", "consistent"],
"description": "if 后面必须要有 {,除非是单行 if",
"category": "Best Practices",
"comments": "/**\n * if 后面必须要有 {,除非是单行 if\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"default-case": {
"name": "default-case",
"value": "off",
"description": "switch 语句必须有 default",
"category": "Best Practices",
"comments": "/**\n * switch 语句必须有 default\n * @category Best Practices\n * @reason 太严格了\n */",
"reason": "太严格了"
},
"dot-location": {
"name": "dot-location",
"value": ["error", "property"],
"description": "链式调用的时候,点号必须放在第二行开头处,禁止放在第一行结尾处",
"category": "Best Practices",
"comments": "/**\n * 链式调用的时候,点号必须放在第二行开头处,禁止放在第一行结尾处\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"dot-notation": {
"name": "dot-notation",
"value": "off",
"description": "禁止出现 foo['bar'],必须写成 foo.bar",
"category": "Best Practices",
"comments": "/**\n * 禁止出现 foo['bar'],必须写成 foo.bar\n * @category Best Practices\n * @reason 当需要写一系列属性的时候,可以更统一\n * @fixable\n */",
"reason": "当需要写一系列属性的时候,可以更统一",
"fixable": true
},
"eqeqeq": {
"name": "eqeqeq",
"value": ["error", "always", { "null": "ignore" }],
"description": "必须使用 === 或 !==,禁止使用 == 或 !=,与 null 比较时除外",
"category": "Best Practices",
"comments": "/**\n * 必须使用 === 或 !==,禁止使用 == 或 !=,与 null 比较时除外\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"guard-for-in": {
"name": "guard-for-in",
"value": "error",
"description": "for in 内部必须有 hasOwnProperty",
"category": "Best Practices",
"comments": "/**\n * for in 内部必须有 hasOwnProperty\n * @category Best Practices\n */"
},
"no-alert": {
"name": "no-alert",
"value": "off",
"description": "禁止使用 alert",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 alert\n * @category Best Practices\n * @reason alert 很常用\n */",
"reason": "alert 很常用"
},
"no-caller": {
"name": "no-caller",
"value": "error",
"description": "禁止使用 caller 或 callee",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 caller 或 callee\n * @category Best Practices\n */"
},
"no-case-declarations": {
"name": "no-case-declarations",
"value": "error",
"description": "switch 的 case 内有变量定义的时候,必须使用大括号将 case 内变成一个代码块",
"category": "Best Practices",
"comments": "/**\n * switch 的 case 内有变量定义的时候,必须使用大括号将 case 内变成一个代码块\n * @category Best Practices\n */"
},
"no-div-regex": {
"name": "no-div-regex",
"value": "off",
"description": "禁止在正则表达式中出现形似除法操作符的开头,如 let a = /=foo/",
"category": "Best Practices",
"comments": "/**\n * 禁止在正则表达式中出现形似除法操作符的开头,如 let a = /=foo/\n * @category Best Practices\n * @reason 有代码高亮的话,在阅读这种代码时,也完全不会产生歧义或理解上的困难\n */",
"reason": "有代码高亮的话,在阅读这种代码时,也完全不会产生歧义或理解上的困难"
},
"no-else-return": {
"name": "no-else-return",
"value": "off",
"description": "禁止在 else 内使用 return,必须改为提前结束",
"category": "Best Practices",
"comments": "/**\n * 禁止在 else 内使用 return,必须改为提前结束\n * @category Best Practices\n * @reason else 中使用 return 可以使代码结构更清晰\n * @fixable\n */",
"reason": "else 中使用 return 可以使代码结构更清晰",
"fixable": true
},
"no-empty-function": {
"name": "no-empty-function",
"value": ["error", { "allow": ["functions", "arrowFunctions"] }],
"description": "不允许有空函数,除非是将一个空函数设置为某个项的默认值",
"category": "Best Practices",
"comments": "/**\n * 不允许有空函数,除非是将一个空函数设置为某个项的默认值\n * @category Best Practices\n */"
},
"no-empty-pattern": {
"name": "no-empty-pattern",
"value": "error",
"description": "禁止解构中出现空 {} 或 []",
"category": "Best Practices",
"comments": "/**\n * 禁止解构中出现空 {} 或 []\n * @category Best Practices\n */"
},
"no-eq-null": {
"name": "no-eq-null",
"value": "off",
"description": "禁止使用 foo == null 或 foo != null,必须使用 foo === null 或 foo !== null",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 foo == null 或 foo != null,必须使用 foo === null 或 foo !== null\n * @category Best Practices\n * @reason foo == null 用于判断 foo 不是 undefined 并且不是 null,比较常用,故允许此写法\n */",
"reason": "foo == null 用于判断 foo 不是 undefined 并且不是 null,比较常用,故允许此写法"
},
"no-eval": {
"name": "no-eval",
"value": "error",
"description": "禁止使用 eval",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 eval\n * @category Best Practices\n */"
},
"no-extend-native": {
"name": "no-extend-native",
"value": "error",
"description": "禁止修改原生对象",
"category": "Best Practices",
"comments": "/**\n * 禁止修改原生对象\n * @category Best Practices\n */"
},
"no-extra-bind": {
"name": "no-extra-bind",
"value": "error",
"description": "禁止出现没必要的 bind",
"category": "Best Practices",
"comments": "/**\n * 禁止出现没必要的 bind\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"no-extra-label": {
"name": "no-extra-label",
"value": "error",
"description": "禁止出现没必要的 label",
"category": "Best Practices",
"comments": "/**\n * 禁止出现没必要的 label\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"no-fallthrough": {
"name": "no-fallthrough",
"value": "error",
"description": "switch 的 case 内必须有 break, return 或 throw",
"category": "Best Practices",
"comments": "/**\n * switch 的 case 内必须有 break, return 或 throw\n * @category Best Practices\n */"
},
"no-floating-decimal": {
"name": "no-floating-decimal",
"value": "error",
"description": "表示小数时,禁止省略 0,比如 .5",
"category": "Best Practices",
"comments": "/**\n * 表示小数时,禁止省略 0,比如 .5\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"no-global-assign": {
"name": "no-global-assign",
"value": "error",
"description": "禁止对全局变量赋值",
"category": "Best Practices",
"comments": "/**\n * 禁止对全局变量赋值\n * @category Best Practices\n */"
},
"no-implicit-coercion": {
"name": "no-implicit-coercion",
"value": ["error", { "allow": ["!!"] }],
"description": "禁止使用 !! ~ 等难以理解的运算符,仅允许使用 !!",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 !! ~ 等难以理解的运算符,仅允许使用 !!\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"no-implicit-globals": {
"name": "no-implicit-globals",
"value": "error",
"description": "禁止在全局作用域下定义变量或申明函数",
"category": "Best Practices",
"comments": "/**\n * 禁止在全局作用域下定义变量或申明函数\n * @category Best Practices\n */"
},
"no-implied-eval": {
"name": "no-implied-eval",
"value": "error",
"description": "禁止在 setTimeout 或 setInterval 中传入字符串,如 setTimeout('alert(\"Hi!\")', 100);",
"category": "Best Practices",
"comments": "/**\n * 禁止在 setTimeout 或 setInterval 中传入字符串,如 setTimeout('alert(\"Hi!\")', 100);\n * @category Best Practices\n */"
},
"no-invalid-this": {
"name": "no-invalid-this",
"value": "off",
"description": "禁止在类之外的地方使用 this",
"category": "Best Practices",
"comments": "/**\n * 禁止在类之外的地方使用 this\n * @category Best Practices\n * @reason this 的使用很灵活,事件回调中可以表示当前元素,函数也可以先用 this,等以后被调用的时候再 call\n */",
"reason": "this 的使用很灵活,事件回调中可以表示当前元素,函数也可以先用 this,等以后被调用的时候再 call"
},
"no-iterator": {
"name": "no-iterator",
"value": "error",
"description": "禁止使用 __iterator__",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 __iterator__\n * @category Best Practices\n */"
},
"no-labels": {
"name": "no-labels",
"value": "error",
"description": "禁止使用 label",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 label\n * @category Best Practices\n */"
},
"no-lone-blocks": {
"name": "no-lone-blocks",
"value": "error",
"description": "禁止使用没必要的 {} 作为代码块",
"category": "Best Practices",
"comments": "/**\n * 禁止使用没必要的 {} 作为代码块\n * @category Best Practices\n */"
},
"no-loop-func": {
"name": "no-loop-func",
"value": "error",
"description": "禁止在循环内的函数中出现循环体条件语句中定义的变量",
"category": "Best Practices",
"comments": "/**\n * 禁止在循环内的函数中出现循环体条件语句中定义的变量\n * @category Best Practices\n */"
},
"no-magic-numbers": {
"name": "no-magic-numbers",
"value": "off",
"description": "禁止使用 magic numbers",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 magic numbers\n * @category Best Practices\n * @reason 太严格了\n */",
"reason": "太严格了"
},
"no-multi-spaces": {
"name": "no-multi-spaces",
"value": [
"error",
{
"ignoreEOLComments": true,
"exceptions": {
"Property": true,
"BinaryExpression": false,
"VariableDeclarator": true,
"ImportDeclaration": true
}
}
],
"description": "禁止出现连续的多个空格,除非是注释前,或对齐对象的属性、变量定义、import 等",
"category": "Best Practices",
"comments": "/**\n * 禁止出现连续的多个空格,除非是注释前,或对齐对象的属性、变量定义、import 等\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"no-multi-str": {
"name": "no-multi-str",
"value": "error",
"description": "禁止使用 \\ 来换行字符串",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 \\ 来换行字符串\n * @category Best Practices\n */"
},
"no-new": {
"name": "no-new",
"value": "error",
"description": "禁止直接 new 一个类而不赋值",
"category": "Best Practices",
"comments": "/**\n * 禁止直接 new 一个类而不赋值\n * @category Best Practices\n */"
},
"no-new-func": {
"name": "no-new-func",
"value": "error",
"description": "禁止使用 new Function,比如 let x = new Function(\"a\", \"b\", \"return a + b\");",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 new Function,比如 let x = new Function(\"a\", \"b\", \"return a + b\");\n * @category Best Practices\n */"
},
"no-new-wrappers": {
"name": "no-new-wrappers",
"value": "error",
"description": "禁止使用 new 来生成 String, Number 或 Boolean",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 new 来生成 String, Number 或 Boolean\n * @category Best Practices\n */"
},
"no-octal": {
"name": "no-octal",
"value": "error",
"description": "禁止使用 0 开头的数字表示八进制数",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 0 开头的数字表示八进制数\n * @category Best Practices\n */"
},
"no-octal-escape": {
"name": "no-octal-escape",
"value": "error",
"description": "禁止使用八进制的转义符",
"category": "Best Practices",
"comments": "/**\n * 禁止使用八进制的转义符\n * @category Best Practices\n */"
},
"no-param-reassign": {
"name": "no-param-reassign",
"value": "error",
"description": "禁止对函数的参数重新赋值",
"category": "Best Practices",
"comments": "/**\n * 禁止对函数的参数重新赋值\n * @category Best Practices\n */"
},
"no-proto": {
"name": "no-proto",
"value": "error",
"description": "禁止使用 __proto__",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 __proto__\n * @category Best Practices\n */"
},
"no-redeclare": {
"name": "no-redeclare",
"value": "error",
"description": "禁止重复定义变量",
"category": "Best Practices",
"comments": "/**\n * 禁止重复定义变量\n * @category Best Practices\n */"
},
"no-restricted-properties": {
"name": "no-restricted-properties",
"value": "off",
"description": "禁止使用指定的对象属性",
"category": "Best Practices",
"comments": "/**\n * 禁止使用指定的对象属性\n * @category Best Practices\n * @reason 它用于限制某个具体的 api 不能使用\n */",
"reason": "它用于限制某个具体的 api 不能使用"
},
"no-return-assign": {
"name": "no-return-assign",
"value": ["error", "always"],
"description": "禁止在 return 语句里赋值",
"category": "Best Practices",
"comments": "/**\n * 禁止在 return 语句里赋值\n * @category Best Practices\n */"
},
"no-return-await": {
"name": "no-return-await",
"value": "error",
"description": "禁止在 return 语句里使用 await",
"category": "Best Practices",
"comments": "/**\n * 禁止在 return 语句里使用 await\n * @category Best Practices\n */"
},
"no-script-url": {
"name": "no-script-url",
"value": "error",
"description": "禁止出现 location.href = 'javascript:void(0)';",
"category": "Best Practices",
"comments": "/**\n * 禁止出现 location.href = 'javascript:void(0)';\n * @category Best Practices\n */"
},
"no-self-assign": {
"name": "no-self-assign",
"value": "error",
"description": "禁止将自己赋值给自己",
"category": "Best Practices",
"comments": "/**\n * 禁止将自己赋值给自己\n * @category Best Practices\n */"
},
"no-self-compare": {
"name": "no-self-compare",
"value": "error",
"description": "禁止将自己与自己比较",
"category": "Best Practices",
"comments": "/**\n * 禁止将自己与自己比较\n * @category Best Practices\n */"
},
"no-sequences": {
"name": "no-sequences",
"value": "error",
"description": "禁止使用逗号操作符",
"category": "Best Practices",
"comments": "/**\n * 禁止使用逗号操作符\n * @category Best Practices\n */"
},
"no-throw-literal": {
"name": "no-throw-literal",
"value": "error",
"description": "禁止 throw 字面量,必须 throw 一个 Error 对象",
"category": "Best Practices",
"comments": "/**\n * 禁止 throw 字面量,必须 throw 一个 Error 对象\n * @category Best Practices\n */"
},
"no-unmodified-loop-condition": {
"name": "no-unmodified-loop-condition",
"value": "error",
"description": "循环内必须对循环条件的变量有修改",
"category": "Best Practices",
"comments": "/**\n * 循环内必须对循环条件的变量有修改\n * @category Best Practices\n */"
},
"no-unused-expressions": {
"name": "no-unused-expressions",
"value": [
"error",
{ "allowShortCircuit": true, "allowTernary": true, "allowTaggedTemplates": true }
],
"description": "禁止无用的表达式",
"category": "Best Practices",
"comments": "/**\n * 禁止无用的表达式\n * @category Best Practices\n */"
},
"no-unused-labels": {
"name": "no-unused-labels",
"value": "error",
"description": "禁止出现没用的 label",
"category": "Best Practices",
"comments": "/**\n * 禁止出现没用的 label\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"no-useless-call": {
"name": "no-useless-call",
"value": "error",
"description": "禁止出现没必要的 call 或 apply",
"category": "Best Practices",
"comments": "/**\n * 禁止出现没必要的 call 或 apply\n * @category Best Practices\n */"
},
"no-useless-concat": {
"name": "no-useless-concat",
"value": "error",
"description": "禁止出现没必要的字符串连接",
"category": "Best Practices",
"comments": "/**\n * 禁止出现没必要的字符串连接\n * @category Best Practices\n */"
},
"no-useless-escape": {
"name": "no-useless-escape",
"value": "off",
"description": "禁止出现没必要的转义",
"category": "Best Practices",
"comments": "/**\n * 禁止出现没必要的转义\n * @category Best Practices\n * @reason 转义可以使代码更易懂\n */",
"reason": "转义可以使代码更易懂"
},
"no-useless-return": {
"name": "no-useless-return",
"value": "off",
"description": "禁止没必要的 return",
"category": "Best Practices",
"comments": "/**\n * 禁止没必要的 return\n * @category Best Practices\n * @reason 没必要限制 return\n * @fixable\n */",
"reason": "没必要限制 return",
"fixable": true
},
"no-void": {
"name": "no-void",
"value": "error",
"description": "禁止使用 void",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 void\n * @category Best Practices\n */"
},
"no-warning-comments": {
"name": "no-warning-comments",
"value": "off",
"description": "禁止注释中出现 TODO 和 FIXME",
"category": "Best Practices",
"comments": "/**\n * 禁止注释中出现 TODO 和 FIXME\n * @category Best Practices\n * @reason TODO 很常用\n */",
"reason": "TODO 很常用"
},
"no-with": {
"name": "no-with",
"value": "error",
"description": "禁止使用 with",
"category": "Best Practices",
"comments": "/**\n * 禁止使用 with\n * @category Best Practices\n */"
},
"prefer-promise-reject-errors": {
"name": "prefer-promise-reject-errors",
"value": "error",
"description": "Promise 的 reject 中必须传入 Error 对象,而不是字面量",
"category": "Best Practices",
"comments": "/**\n * Promise 的 reject 中必须传入 Error 对象,而不是字面量\n * @category Best Practices\n */"
},
"radix": {
"name": "radix",
"value": "error",
"description": "parseInt 必须传入第二个参数",
"category": "Best Practices",
"comments": "/**\n * parseInt 必须传入第二个参数\n * @category Best Practices\n */"
},
"require-await": {
"name": "require-await",
"value": "off",
"description": "async 函数中必须存在 await 语句",
"category": "Best Practices",
"comments": "/**\n * async 函数中必须存在 await 语句\n * @category Best Practices\n * @reason async function 中没有 await 的写法很常见,比如 koa 的示例中就有这种用法\n */",
"reason": "async function 中没有 await 的写法很常见,比如 koa 的示例中就有这种用法"
},
"vars-on-top": {
"name": "vars-on-top",
"value": "off",
"description": "var 必须在作用域的最前面",
"category": "Best Practices",
"comments": "/**\n * var 必须在作用域的最前面\n * @category Best Practices\n * @reason var 不在最前面也是很常见的用法\n */",
"reason": "var 不在最前面也是很常见的用法"
},
"wrap-iife": {
"name": "wrap-iife",
"value": ["error", "inside", { "functionPrototypeMethods": true }],
"description": "立即执行的函数必须符合如下格式 (function () { alert('Hello') })()",
"category": "Best Practices",
"comments": "/**\n * 立即执行的函数必须符合如下格式 (function () { alert('Hello') })()\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"yoda": {
"name": "yoda",
"value": ["error", "never", { "onlyEquality": true }],
"description": "必须使用 if (foo === 5) 而不是 if (5 === foo)",
"category": "Best Practices",
"comments": "/**\n * 必须使用 if (foo === 5) 而不是 if (5 === foo)\n * @category Best Practices\n * @fixable\n */",
"fixable": true
},
"strict": {
"name": "strict",
"value": ["error", "never"],
"description": "禁止使用 'strict';",
"category": "Strict Mode",
"comments": "/**\n * 禁止使用 'strict';\n * @category Strict Mode\n * @fixable\n */",
"fixable": true
},
"init-declarations": {
"name": "init-declarations",
"value": "off",
"description": "变量必须在定义的时候赋值",
"category": "Variables",
"comments": "/**\n * 变量必须在定义的时候赋值\n * @category Variables\n * @reason 先定义后赋值很常见\n */",
"reason": "先定义后赋值很常见"
},
"no-delete-var": {
"name": "no-delete-var",
"value": "error",
"description": "禁止使用 delete",
"category": "Variables",
"comments": "/**\n * 禁止使用 delete\n * @category Variables\n */"
},
"no-label-var": {
"name": "no-label-var",
"value": "error",
"description": "禁止 label 名称与定义过的变量重复",
"category": "Variables",
"comments": "/**\n * 禁止 label 名称与定义过的变量重复\n * @category Variables\n */"
},
"no-restricted-globals": {
"name": "no-restricted-globals",
"value": "off",
"description": "禁止使用指定的全局变量",
"category": "Variables",
"comments": "/**\n * 禁止使用指定的全局变量\n * @category Variables\n * @reason 它用于限制某个具体的变量名不能使用\n */",
"reason": "它用于限制某个具体的变量名不能使用"
},
"no-shadow": {
"name": "no-shadow",
"value": "off",
"description": "禁止变量名与上层作用域内的定义过的变量重复",
"category": "Variables",
"comments": "/**\n * 禁止变量名与上层作用域内的定义过的变量重复\n * @category Variables\n * @reason 很多时候函数的形参和传参是同名的\n */",
"reason": "很多时候函数的形参和传参是同名的"
},
"no-shadow-restricted-names": {
"name": "no-shadow-restricted-names",
"value": "error",
"description": "禁止使用保留字作为变量名",
"category": "Variables",
"comments": "/**\n * 禁止使用保留字作为变量名\n * @category Variables\n */"
},
"no-undef": {
"name": "no-undef",
"value": ["error", { "typeof": false }],
"description": "禁止使用未定义的变量",
"category": "Variables",
"comments": "/**\n * 禁止使用未定义的变量\n * @category Variables\n */"
},
"no-undef-init": {
"name": "no-undef-init",
"value": "error",
"description": "禁止将 undefined 赋值给变量",
"category": "Variables",
"comments": "/**\n * 禁止将 undefined 赋值给变量\n * @category Variables\n * @fixable\n */",
"fixable": true
},
"no-undefined": {
"name": "no-undefined",
"value": "error",
"description": "禁止对 undefined 重新赋值",
"category": "Variables",
"comments": "/**\n * 禁止对 undefined 重新赋值\n * @category Variables\n */"
},
"no-unused-vars": {
"name": "no-unused-vars",
"value": [
"error",
{ "vars": "all", "args": "none", "caughtErrors": "none", "ignoreRestSiblings": true }
],
"description": "定义过的变量必须使用",
"category": "Variables",
"comments": "/**\n * 定义过的变量必须使用\n * @category Variables\n */"
},
"no-use-before-define": {
"name": "no-use-before-define",
"value": ["error", { "functions": false, "classes": false, "variables": false }],
"description": "变量必须先定义后使用",
"category": "Variables",
"comments": "/**\n * 变量必须先定义后使用\n * @category Variables\n */"
},
"callback-return": {
"name": "callback-return",
"value": "off",
"description": "callback 之后必须立即 return",
"category": "Node.js and CommonJS",
"comments": "/**\n * callback 之后必须立即 return\n * @category Node.js and CommonJS\n * @reason Limitations 太多了\n */",
"reason": "Limitations 太多了"
},
"global-require": {
"name": "global-require",
"value": "off",
"description": "require 必须在全局作用域下",
"category": "Node.js and CommonJS",
"comments": "/**\n * require 必须在全局作用域下\n * @category Node.js and CommonJS\n * @reason 条件加载很常见\n */",
"reason": "条件加载很常见"
},
"handle-callback-err": {
"name": "handle-callback-err",
"value": "error",
"description": "callback 中的 error 必须被处理",
"category": "Node.js and CommonJS",
"comments": "/**\n * callback 中的 error 必须被处理\n * @category Node.js and CommonJS\n */"
},
"no-buffer-constructor": {
"name": "no-buffer-constructor",
"value": "error",
"description": "禁止直接使用 Buffer",
"category": "Node.js and CommonJS",
"comments": "/**\n * 禁止直接使用 Buffer\n * @category Node.js and CommonJS\n */"
},
"no-mixed-requires": {
"name": "no-mixed-requires",
"value": "off",
"description": "相同类型的 require 必须放在一起",
"category": "Node.js and CommonJS",
"comments": "/**\n * 相同类型的 require 必须放在一起\n * @category Node.js and CommonJS\n * @reason 太严格了\n */",
"reason": "太严格了"
},
"no-new-require": {
"name": "no-new-require",
"value": "error",
"description": "禁止直接 new require('foo')",
"category": "Node.js and CommonJS",
"comments": "/**\n * 禁止直接 new require('foo')\n * @category Node.js and CommonJS\n */"
},
"no-path-concat": {
"name": "no-path-concat",
"value": "error",
"description": "禁止对 __dirname 或 __filename 使用字符串连接",
"category": "Node.js and CommonJS",
"comments": "/**\n * 禁止对 __dirname 或 __filename 使用字符串连接\n * @category Node.js and CommonJS\n */"
},
"no-process-env": {
"name": "no-process-env",
"value": "off",
"description": "禁止使用 process.env.NODE_ENV",
"category": "Node.js and CommonJS",
"comments": "/**\n * 禁止使用 process.env.NODE_ENV\n * @category Node.js and CommonJS\n * @reason 使用很常见\n */",
"reason": "使用很常见"
},
"no-process-exit": {
"name": "no-process-exit",
"value": "off",
"description": "禁止使用 process.exit(0)",
"category": "Node.js and CommonJS",
"comments": "/**\n * 禁止使用 process.exit(0)\n * @category Node.js and CommonJS\n * @reason 使用很常见\n */",
"reason": "使用很常见"
},
"no-restricted-modules": {
"name": "no-restricted-modules",
"value": "off",
"description": "禁止使用指定的模块",
"category": "Node.js and CommonJS",
"comments": "/**\n * 禁止使用指定的模块\n * @category Node.js and CommonJS\n * @reason 它用于限制某个具体的模块不能使用\n */",
"reason": "它用于限制某个具体的模块不能使用"
},
"no-sync": {
"name": "no-sync",
"value": "off",
"description": "禁止使用 node 中的同步的方法,比如 fs.readFileSync",
"category": "Node.js and CommonJS",
"comments": "/**\n * 禁止使用 node 中的同步的方法,比如 fs.readFileSync\n * @category Node.js and CommonJS\n * @reason 使用很常见\n */",
"reason": "使用很常见"
},
"array-bracket-newline": {
"name": "array-bracket-newline",
"value": "off",
"description": "配置数组的中括号内前后的换行格式",
"category": "Stylistic Issues",
"comments": "/**\n * 配置数组的中括号内前后的换行格式\n * @category Stylistic Issues\n * @reason 配置项无法配制成想要的样子\n * @fixable\n */",
"reason": "配置项无法配制成想要的样子",
"fixable": true
},
"array-bracket-spacing": {
"name": "array-bracket-spacing",
"value": ["error", "never"],
"description": "数组的括号内的前后禁止有空格",
"category": "Stylistic Issues",
"comments": "/**\n * 数组的括号内的前后禁止有空格\n * @category Stylistic Issues\n * @fixable\n */",
"fixable": true
},
"array-element-newline": {
"name": "array-element-newline",
"value": "off",
"description": "配置数组的元素之间的换行格式",
"category": "Stylistic Issues",
"comments": "/**\n * 配置数组的元素之间的换行格式\n * @category Stylistic Issues\n * @reason 允许一行包含多个元素,方便大数量的数组的书写\n * @fixable\n */",
"reason": "允许一行包含多个元素,方便大数量的数组的书写",
"fixable": true
},
"block-spacing": {
"name": "block-spacing",
"value": ["error", "always"],
"description": "代码块如果在一行内,那么大括号内的首尾必须有空格,比如 function () { alert('Hello') }",
"category": "Stylistic Issues",
"comments": "/**\n * 代码块如果在一行内,那么大括号内的首尾必须有空格,比如 function () { alert('Hello') }\n * @category Stylistic Issues\n * @fixable\n */",
"fixable": true
},
"brace-style": {
"name": "brace-style",
"value": "off",
"description": "if 与 else 的大括号风格必须一致",
"category": "Stylistic Issues",
"comments": "/**\n * if 与 else 的大括号风格必须一致\n * @category Stylistic Issues\n * @reason else 代码块可能前面需要有一行注释\n * @fixable\n */",
"reason": "else 代码块可能前面需要有一行注释",
"fixable": true
},
"camelcase": {
"name": "camelcase",
"value": "off",
"description": "变量名必须是 camelcase 风格的",
"category": "Stylistic Issues",
"comments": "/**\n * 变量名必须是 camelcase 风格的\n * @category Stylistic Issues\n * @reason 很多 api 或文件名都不是 camelcase\n */",
"reason": "很多 api 或文件名都不是 camelcase"
},
"capitalized-comments": {
"name": "capitalized-comments",
"value": "off",
"description": "注释的首字母必须大写",
"category": "Stylistic Issues",
"comments": "/**\n * 注释的首字母必须大写\n * @category Stylistic Issues\n * @reason 没必要限制\n * @fixable\n */",
"reason": "没必要限制",
"fixable": true
},
"comma-dangle": {
"name": "comma-dangle",
"value": "off",
"description": "对象的最后一个属性末尾必须有逗号",
"category": "Stylistic Issues",
"comments": "/**\n * 对象的最后一个属性末尾必须有逗号\n * @category Stylistic Issues\n * @reason 没必要限制\n * @fixable\n */",
"reason": "没必要限制",
"fixable": true
},
"comma-spacing": {
"name": "comma-spacing",
"value": ["error", { "before": false, "after": true }],
"description": "逗号前禁止有空格,逗号后必须要有空格",
"category": "Stylistic Issues",
"comments": "/**\n * 逗号前禁止有空格,逗号后必须要有空格\n * @category Stylistic Issues\n * @fixable\n */",
"fixable": true
},
"comma-style": {
"name": "comma-style",
"value": ["error", "last"],
"description": "禁止在行首写逗号",
"category": "Stylistic Issues",
"comments": "/**\n * 禁止在行首写逗号\n * @category Stylistic Issues\n * @fixable\n */",
"fixable": true
},
"computed-property-spacing": {
"name": "computed-property-spacing",
"value": ["error", "never"],
"description": "用作对象的计算属性时,中括号内的首尾禁止有空格",
"category": "Stylistic Issues",
"comments": "/**\n * 用作对象的计算属性时,中括号内的首尾禁止有空格\n * @category Stylistic Issues\n * @fixable\n */",
"fixable": true
},
"consistent-this": {
"name": "consistent-this",
"value": "off",
"description": "限制 this 的别名",
"category": "Stylistic Issues",
"comments": "/**\n * 限制 this 的别名\n * @category Stylistic Issues\n * @reason 没必要限制\n */",
"reason": "没必要限制"
},
"eol-last": {
"name": "eol-last",
"value": "off",
"description": "文件最后一行必须有一个空行",
"category": "Stylistic Issues",
"comments": "/**\n * 文件最后一行必须有一个空行\n * @category Stylistic Issues\n * @reason 没必要限制\n * @fixable\n */",
"reason": "没必要限制",
"fixable": true
},
"func-call-spacing": {
"name": "func-call-spacing",
"value": ["error", "never"],
"description": "函数名和执行它的括号之间禁止有空格",
"category": "Stylistic Issues",
"comments": "/**\n * 函数名和执行它的括号之间禁止有空格\n * @category Stylistic Issues\n * @fixable\n */",
"fixable": true
},
"func-name-matching": {
"name": "func-name-matching",
"value": ["error", "always", { "includeCommonJSModuleExports": false }],
"description": "函数赋值给变量的时候,函数名必须与变量名一致",
"category": "Stylistic Issues",
"comments": "/**\n * 函数赋值给变量的时候,函数名必须与变量名一致\n * @category Stylistic Issues\n */"
},
"func-names": {
"name": "func-names",
"value": "off",
"description": "函数必须有名字",
"category": "Stylistic Issues",
"comments": "/**\n * 函数必须有名字\n * @category Stylistic Issues\n * @reason 没必要限制\n */",
"reason": "没必要限制"
},
"func-style": {
"name": "func-style",
"value": "off",
"description": "必须只使用函数声明或只使用函数表达式",
"category": "Stylistic Issues",
"comments": "/**\n * 必须只使用函数声明或只使用函数表达式\n * @category Stylistic Issues\n * @reason 没必要限制\n */",
"reason": "没必要限制"
},
"id-blacklist": {
"name": "id-blacklist",
"value": "off",
"description": "禁止使用指定的标识符",
"category": "Stylistic Issues",
"comments": "/**\n * 禁止使用指定的标识符\n * @category Stylistic Issues\n * @reason 它用于限制某个具体的标识符不能使用\n */",
"reason": "它用于限制某个具体的标识符不能使用"
},
"id-length": {
"name": "id-length",
"value": "off",
"description": "限制变量名长度",
"category": "Stylistic Issues",
"comments": "/**\n * 限制变量名长度\n * @category Stylistic Issues\n * @reason 没必要限制变量名长度\n */",
"reason": "没必要限制变量名长度"
},
"id-match": {
"name": "id-match",
"value": "off",
"description": "限制变量名必须匹配指定的正则表达式",
"category": "Stylistic Issues",
"comments": "/**\n * 限制变量名必须匹配指定的正则表达式\n * @category Stylistic Issues\n * @reason 没必要限制变量名\n */",
"reason": "没必要限制变量名"
},
"indent": {
"name": "indent",
"value": ["error", 4, { "SwitchCase": 1, "flatTernaryExpressions": true }],
"description": "一个缩进必须用四个空格替代",
"category": "Stylistic Issues",
"comments": "/**\n * 一个缩进必须用四个空格替代\n * @category Stylistic Issues\n * @fixable\n */",
"fixable": true
},
"jsx-quotes": {
"name": "jsx-quotes",
"value": ["error", "prefer-double"],
"description": "jsx 中的属性必须用双引号",
"category": "Stylistic Issues",
"comments": "/**\n * jsx 中的属性必须用双引号\n * @category Stylistic Issues\n * @fixable\n */",
"fixable": true
},
"key-spacing": {
"name": "key-spacing",
"value": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }],
"description": "对象字面量中冒号前面禁止有空格,后面必须有空格",
"cate