项目地址:Sublime-JSHint
安装
Ctrl+Shift+P
orCmd+Shift+P
in Linux/Windows/OS X输入 install, 选择 Package Control: Install Package
输入 js gutter, 选择 JSHint Gutter
配置
Ctrl+Shift+P
orCmd+Shift+P
输入 jshint, 选择
Set node Path
然后找到你的系统,并把node.exe地址填入即可
像这样:
{
// Simply using `node` without specifying a path sometimes doesn't work :(
// https://github.com/victorporof/Sublime-JSHint#oh-noez-command-not-found
// http://nodejs.org/#download
"node_path": {
"windows": "C:/nodejs/node.exe",
"linux": "/usr/bin/nodejs",
"osx": "/usr/local/bin/node"
},
// Automatically lint on edit (Sublime Text 3 only).
// 如设置true会在编辑时运行jshint
"lint_on_edit": false,
// Configurable duration before re-linting.
// 设置编辑后间隔多久才运行jshint
"lint_on_edit_timeout": 1,
// Automatically lint when a file is loaded.
// 如设置true会在加载后运行jshint
"lint_on_load": false,
// Automatically lint when a file is saved.
// 如设置true会在保存后运行jshint
"lint_on_save": true,
// Highlight problematic regions when selected.
"highlight_selected_regions": true,
// Log the settings passed to JSHint from `.jshintrc`.
// 是否打印.jshintrc配置到控制台
"print_diagnostics": false
}
使用
可多种方式,当然如果在JSHint
设置了lint_on_save
为true
将会在保存后自动运行。
右键 -> JSHint -> Lint Code
Ctrl+Shift+P
,输入jshint
回车