当前位置: 首页 > 后端技术 > Node.js

Eslint规则

时间:2023-04-03 15:27:08 Node.js

"no-alert":0,//禁止使用alert确认提示"no-array-constructor":2,//禁止使用数组构造函数"no-bitwise":0,//禁止使用bitwiseoperators"no-caller":1,//禁止使用arguments.caller或arguments.callee"no-catch-shadow":2,//禁止使用与外部作用域变量同名的catch子句参数"no-class-assign":2,//禁止给类赋值"no-cond-assign":2,//禁止在条件表达式中使用赋值语句"no-console":2,//禁止使用控制台"no-cond-assign":2,//禁止修改const声明的变量"no-constant-condition":2,//禁止在条件中使用常量表达式if(true)if(1)"no-continue":0,//禁止使用continue"no-control-regex":2,//禁止在正则表达式中使用控制字符"no-debugger":2,//禁止useofdebugger"no-delete-var":2,//不能为var声明变量usethedeleteoperator"no-div-regex":1,//不能使用看起来像除法/=foo/的正则表达式no-dupe-keys":2,//创建对象字面量时不要允许键重复{a:1,a:1}"no-dupe-args":2,//函数参数不能重复"no-duplicate-case":2,//switch中的case标签不能重复"no-else-return":2,//如果if语句中有return,后面不能跟else语句"no-empty":2,//块语句中的内容不能为空"no-empty-character-class":2,//正则表达式中的[]内容不能为空"no-empty-label":2,//禁止使用空标签"no-eq-null":2,//禁止使用==或!=operator"no-eval":1,//禁止使用eval"no-ex-assign":2,//禁止在catch语句中赋值异常参数"no-extend-native":2,//禁止扩展原生对象"no-extra-bind":2,//禁止不必要的函数绑定"no-extra-boolean-cast":2,//禁止不必要的bool转换"no-extra-parens":2,//禁止不必要的括号"no-extra-semi":2,//禁止多余的冒号"no-fallthrough":1,//禁止开关穿透"no-floating-decimal":2,//禁止在浮点数中省略0.53."no-func-assign":2,//禁止重复函数声明"no-implicit-coercion":1,//禁止隐式转换"no-implied-eval":2,//禁止使用隐式eval"no-inline-comments":0,//禁止使用内联注释"no-inner-declarations":[2,"functions"],//禁止使用声明(variablesorfunctions)inblockstatements"no-invalid-regexp":2,//禁止无效的正则表达式"no-invalid-this":2,//禁止无效的this,只能在构造函数、类和对象中使用literals"no-irregular-whitespace":2,//不能有不规则的空格"no-iterator":2,//禁止使用__iterator__属性"no-label-var":2,//标签名不能是同var声明的变量名"no-labels":2,//禁止标签声明"no-lone-blocks":2,//禁止不必要的嵌套块"no-lonely-if":2,//禁止onlyifstatementintheelsestatement"no-loop-func":1,//禁止在循环中使用函数(如果没有引用外部变量,不需要闭包)"no-mixed-requires":[0,false],//声明"no-mixed-spaces-and-tabs"时声明类型不能混用:[2,false],//禁止混用tabs和空格"linebreak-style":[0,"windows"],//换行样式"no-multi-spaces":1,//不能使用额外空格"no-multi-str":2,//字符串不能使用\newline"no-multiple-empty-lines":[1,{"max":2}],//空行最多不能超过2行"no-native-reassign":2,//Nativeobjectscannotberewrite"no-negated-in-lhs":2,//in运算符左边不能有任何!"no-nested-ternary":0,//禁止嵌套三元运算"no-new":1,//嵌套三元禁止操作New在构造实例后不赋值"no-new-func":1,//禁止使用newFunction"no-new-object":2,//禁止使用newObject()"no-new-require":2,//禁止使用newrequire"no-new-wrappers":2,//禁止使用new创建wrapper实例,newStringnewBooleannewNumber"no-obj-calls":2,//不能调用内置的全局对象,如Math()JSON()"no-octal":2,//禁止使用八进制数"no-octal-escape":2,//禁止使用八进制转义序列"no-param-reassign":2,//禁止重新分配参数"no-path-concat":0,//不能使用__dirname或__filename进行路径拼接innode"no-plusplus":0,//禁止使用++,--"no-process-env":0,//禁止使用process.env"no-process-exit":0,//禁止使用process.exit()"no-proto":2,//禁止使用__proto__属性"no-redeclare":2,//不要重新声明变量"no-regex-spaces":2,//不要在正则表达式字面量中使用多个空格/foobar/"no-restricted-modules":0,//如果指定模块被禁用,使用"no-return-assign"时会报错":1,//返回语句中不能有赋值表达式"no-script-url":0,//禁止使用javascript:void(0)"no-self-compare":2,//不能比较自己“无序列”:0,//禁止逗号运算符"no-shadow":2,//外部作用域中的变量不能与其包含的作用域中的变量或参数同名"no-shadow-restricted-names":2,//严格模式下指定的受限标识符在声明时不能作为变量名"no-spaced-func":2,//调用函数时函数名和()之间不能有空格"no-sparse-arrays":2,//禁止稀疏数组,[1,,2]"no-sync":0,//nodejs禁止同步方法"no-ternary":0,//禁止使用三元operators"no-trailing-spaces":1,//行尾后没有空格"no-this-before-super":0,//调用super()前不能使用this或super"no-throw-literal":2,//禁止抛出字面量错误throw"error";"no-undef":1,//不能有未定义的变量"no-undef-init":2,//变量在初始化时不能直接赋值给undefined"no-undefined":2,//不能使用undefined"no-unexpected-multiline":2,//避免多行表达式"no-underscore-dangle":1,//标识符不能以_开头或结尾"no-unneeded-ternary":2,//禁止不必要的嵌套varisYes=答案===1?true:false;"no-unreachable":2,//不能有不能执行的代码"no-unused-expressions":2,//禁止无用的表达式"no-unused-vars":[2,{"vars":"all","args":"after-used"}],//没有声明未使用的变量或参数"no-use-before-define":2,//不能使用"no-useless-call"beforeundefined:2,//禁止不必要的调用,应用"no-void":2,//禁用void运算符"no-var":0,//禁用var,替换为let和const"no-warning-comments":[1,{“之三ms":["todo","fixme","xxx"],"location":"start"}],//不能有警告提示"no-with":2,//disablewith"array-bracket-spacing":[2,"never"],//非空数组是否允许有多余空格"arrow-parens":0,//箭头函数用括号括起来"arrow-spacing":0,//=>前后括号"accessor-pairs":0,//在对象中使用getter/setter"block-scoped-var":0,//在块语句中使用var"brace-style":[1,"1tbs"],//大括号样式"callback-return":1,//"驼峰式"以避免多次调用回调:2,//强制驼峰式命名"comma-dangle":[2,"never"],//对象字面量项末尾不能有逗号"comma-spacing":0,//逗号前后的空格"comma-style":[2,"last"],//逗号样式,换行时在行首或行尾"complexity":[0,11],//循环复杂度"computed-property-spacing":[0,"never"],//是否允许计算键名ornot"consistent-return":0,//是否允许在return后省略"consistent-this":[2,"that"],//thisalias"constructor-super":0,//非派生类不能调用super,派生类必须调用super"curly":[2,"all"],//必须在if(){}中使用{}"default-case":2,//Switch语句必须有default"dot-location"attheend:0,//对象访问器的位置,换行时是行首还是行尾"dot-notation":[0,{"allowKeywords":true}],//避免不必要的方括号"eol-last":0,//文件以单个换行符结尾"eqeqeq":2,//必须使用同余"func-names":0,//函数表达式必须有名称“功能STyle":[0,"declaration"],//函数式风格,规定只能使用函数声明/函数表达式"generator-star-spacing":0,//生成器函数前后的空格*"guard-for-in":0,//forin循环需要用if语句过滤"handle-callback-err":0,//nodejs处理错误"id-length":0,//变量名长度"indent":[2,4],//缩进样式"init-declarations":0,//声明时必须赋初值"key-spacing":[0,{"beforeColon":false,"afterColon":true}],//对象字面量中冒号前后的空格"lines-around-comment":0,//行前后注释"max-depth":[0,4],//Nestedblockdepth"max-len":[0,80,4],//字符串的最大长度"max-nested-callbacks":[0,2],//回调的嵌套深度"max-params":[0,3],//函数最多只能有3个参数"max-statements":[0,10],//函数"new-cap"最多有几条语句:2,//第一行函数名必须用new方法调用,第一行小写必须调用"new-parens"没有new:2,//new时必须加括号"newline-after-var":2,//变量声明后是否需要空行"object-curly-spacing":[0,"never"],//花括号中是否允许有不必要的空格"object-shorthand":0,//强制对象字面量缩写语法"one-var":1,//连续声明"operator-assignment":[0,"always"],//赋值运算符+=-=what"operator-linebreak":[2,"after"],//换行时运算符在行尾还是行首"padded-blocks":0,//行首和行尾是否需要空行在块语句中"prefer-const":0,//首选const"prefer-spread":0,//首选扩展操作"prefer-reflect":0,//Reflect的首选方法"quotes":[1,"single"],//引用类型``""''"quote-props":[2,"always"],//对象字面量中的属性名是否强制双引号"radix":2,//parseInt必须指定第二个参数"id-match":0,//名称检测"require-yield":0,//generator函数必须有yield"semi":[2,"always"],//语句强制分号结束"semi-spacing":[0,{"before":false,"after":true}],//分号前后的空格"sort-vars":0,//声明变量时排序"space-after-keywords":[0,"always"],//关键字后是否需要空格"space-before-blocks":[0,"always"],//不换行开始的块{前面不要有空格"space-before-function-paren":[0,"always"],//不要有空格定义函数时括号前"space-in-parens":[0,"never"],//括号内是否应该有空格"space-infix-ops":0,//是否应该有spacesaroundtheinfixoperator"space-return-throw-case":2,//是否要在returnthrowcase后加空格"space-unary-ops":[0,{"words":true,"nonwords":false}],//一元运算符前后是否加空格加空格"spaced-comment":0,//注释样式是否有空格?"strict":2,//使用严格模式"use-isnan":2,//比较时禁止使用NaN,只能使用isNaN()"valid-jsdoc":0,//jsdoc规则"valid-typeof":2,//必须使用合法的typeof值"vars-on-top":2,//var必须放在作用域内Top"wrap-iife":[2,"inside"],//括号样式ofimmediatefunctionexpression"wrap-regex":0,//正则表达式字面量用括号括起来"yoda":[2,"never"]//禁止Yoda条件