jshint常用检查规则

来源:互联网 发布:linux shell debug 编辑:程序博客网 时间:2024/05/16 07:13

curly: true/false
参数为true时 循环和条件语句必须放在{}中 /默认false

eqeqeq: true/false
参数为true时 在比较时必须使用===和!== /默认为true

forin: true/false
参数为true时 不允许forin在没有hasOwnProperty时使用 /默认为false

immed:true/false
参数为true时 不允许匿名函数立即执行,即匿名函数必须用()括起来

(function() {   // body }());

默认为flase

newcap: true/false
参数为true时 构造函数首字母必须大写/默认为false

noempty: true/false
参数为true时 不允许使用空函数

undef:true/false
参数为true时 所有局部变量必须先声明后才能使用

unused: true/false
参数为ture时 不允许变量声明后不使用

asi:true/false
参数为true时 语句结束不能缺失/默认为true

boss: true/false
参数为true时 允许在for/if/while中使用“=”赋值操作

evil:true/false
参数为true时 允许使用eval方法

eqnull: true/false
参数为true时 允许使用==null

quotmark: true/false/single/double
true:检查一致性
false:不检查
single:必须全是单引号
double:必须全是双引号

freeze: true/false
参数为true时 不允许复写原生对象的原型/默认为false

trailing: true/false
参数为true时 不允许行尾空格/默认为false

funcscope: true/false
参数为true时 允许在控制体内定义变量而在外部使用/默认为true

function test() {    if (true) {        var x = 0;    }    x += 1; }
1 0