下面是在sublime上配置jshint代码检查的详细步骤。
1、安装nodejs。下载地址:http://nodejs.org/download/
2、在控制台安装jshint:$ npm install jshint -g
3、在sublime安装sublimelinter
4、在sublime安装jshint
5、配置sublimelinter:preference-package setting-sublimelinter-user
{
"sublimelinter": "save-only",
"jshint_options":
{
// To fix column positions for JSHint errors you may want to add `"indent": 1` to your
// **User** "jshint_options". This issue affects users with tabs for indentation.
// This fix was reverted due to a conflict with using the `"white": true` option.
// "indent": 1,
// 设置 JS 执行环境为浏览器
"browser": true,
// 加载 jQuery 的全局变量(jQuery、$)
"jquery": true,
//禁止下划线的变量名
"nomen":true,
// 行尾不要分号,false表示强制需要分号结尾
"asi": false,
"white":true,
// 其他全局变量,我用了 SeaJS
"predef": [
"define",
"seajs",
"console"
]
},
"sublimelinter_executable_map":
{
"javascript":"C:/Program Files/nodejs/node.exe",
"css":"C:/Program Files/nodejs/node.exe"
}
}