.jshintrc是JSHint的一种配置方式。这种方式允许你每个项目有不同的配置文件,只需要将文件放在项目根目录即可。
.jshintrc 配置选项
bitwise
是否禁用位运算符
camelcase
是否要求变量都使用驼峰命名
curly
是否要求循环或者条件语句必须使用花括号包围
设置为true, 则无论单行多行,都不能省略花括号
eqeqeq
是否强制使用严格等号
设置为true,禁止使用 == 和 != ,强制使用 === 和 !==
forin
是否要求for–in 语句过滤原型链上的对象
strict
“global” – 全局层面的严格模式”use strict”;
“implied” – 文件里面使用”use strict”;
false – 禁止使用严格模式;
true – 函数上面必须使用一个”use strict”;
freeze
是否禁止重写原生对象(Array, Date等)的原型链
immed
是否要求自执行的方法使用括号括起
indent
设置代码缩进长度
latedef
是否要求变量在使用之前声明
newcap
是否要求构造函数大写
noarg
是否禁止使用 arguments.callee 和 arguments.caller
noempty
是否空的代码块
nonbsp
是否不换行的空格
nonew
是否禁止直接使用new调用构造函数(不赋值给任何对象)
plusplus
是否禁止使用 ++ 或 — 运算符
quotmark
字符串引号
true– 代码字符串禁止单引号双引号混用
“single”–只允许单引号
“double”–只允许双引号
undef
是否提示未定义的变量
trailing
是否禁止字符串以空格加斜杠的形式来换行
debug
是否对debugger语句给出警告
funcscope
允许在控制体内定义变量而在外部使用
function test() {
if (true) {
var x = 0;
}
x += 1; // No warning when funcscope:true
}
laxcomma
是否允许逗号开头的编码样式
var obj = {
name: 'Anton'
, handle: 'valueof'
, role: 'SW Engineer'
};
loopfunc
是否允许在循环语句中产生函数
onevar
每个函数是否只允许使用一个 var 定义变量
unused
是否提示未使用的变量
我使用的 .jshintrc 配置文件
{
"es5": true,
"node": true,
"bitwise": false,
"camelcase": false,
"curly": false,
"eqeqeq": false,
"forin": true,
"strict": false,
"freeze": true,
"immed": true,
"indent": 4,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": false,
"nonbsp": true,
"nonew": true,
"plusplus": false,
"undef": true,
"trailing": true,
"debug": false,
"funcscope": true,
"laxcomma": false,
"loopfunc": true,
"onevar": false,
"unused": true,
"browser": true,
"globals": {
"$": false,
"jquery": false
}
}
搞前端必须知道.jshintrc 是什么?
猜你喜欢
转载自blog.csdn.net/u013373006/article/details/98044122
今日推荐
周排行