sudo npm install jshint -g
Command + Shift + P, 安裝JSHint Gutter 和JSHintcss
在項目根目錄下添加.jshintrc文件 內容以下node
{ "curly": true, // true: Require {} for every new block or scope "eqeqeq": true, // true: Require triple equals (===) for comparison "immed": true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());` "latedef": true, // true: Require variables/functions to be defined before being used "newcap": true, // true: Require capitalization of all constructor functions e.g. `new F()` "noarg": true, // true: Prohibit use of `arguments.caller` and `arguments.callee` "sub": true, // true: Prohibit use of empty blocks "undef": true, // true: Require all non-global variables to be declared (prevents global leaks) "boss": true, // true: Require all defined variables be used "eqnull": true, // true: Requires all functions run in ES5 Strict Mode "es3": true, // {int} Max number of formal params allowed per function "node": true, // {int} Max depth of nested blocks (within functions) "-W117": true // {int} Max number statements per function }
4. 實現實時保存build檢查, Command + Shift + P , 安裝SublimeOnSaveBuild
shell
5. 設置 Preferences > Package Settings > SublimeOnSaveBuild > Settings - Usernpm
{ "filename_filter": "\\.(css|js|json)$", "build_on_save": 1 // 1開啓 0 關閉 }
6. 添加自定義build Tools > Build System > New Build Systemjson
{ "selector": "source.js", "cmd": ["jshint", "$file", "--reporter", "$packages/JSHint/reporter.js"], "file_regex": "JSHint: (.+)\\]", "line_regex": "(\\d+),(\\d+):(.*)$", "osx": { "path" : "/usr/local/share/npm/bin:/usr/local/bin:/opt/local/bin" }, "windows" : { "cmd": ["jshint", "$file", "--reporter", "$packages\\JSHint\\reporter.js"] } }
7. 保存文件 起個容易記的 而後 去編輯一下js或者json文件 看一下效果
windows