javascript的lint工具那么多,还是eslint比较好用啊.
有jslint, javascriptlint(jsl), 还有eslint. 貌似eslint是最受欢迎的.
安装eslint
npm i -g eslint
运行:
eslint *.js
在js目录下放一个.eslintrc.json文件, 可以对需要lint的规则做设置.下面是我复制cocos creator的配置,并做了一点修改, 忽略了末尾分号检测.
{
"extends": "eslint:recommended",
"rules": {
"comma-dangle": 0,
"no-console": 0,
"no-constant-condition": 0,
"semi": 0,
"no-unused-vars": 1
},
"env": {
"browser": true,
"node": true,
"es6": true,
"mocha": true
},
"plugins": [
],
"globals": {
"cc": false,
"CC_EDITOR": false,
"CC_DEV": false,
"CC_JSB": false,
"_ccsg": false
}
}