JsLint 的安裝和使用

 JSLint 是一款Javascript驗證工具,在定位錯誤並確保基本指南得以遵循時,很是有用。若是你正在編寫專業級的javascript,應該使用 JSLint 或者相似的驗證工具(JSHint)。它幫助咱們避免了許多種bug,極大縮短了開發時間。若是你安裝了Node.js,像這樣便可安裝:javascript

npm install -g jslint

 

配置 JSlint 以及 搭建測試 demohtml

/*jslint
browser : true,  continue :  true,    devel    :  true,
indent   : 2,       maxerr    :  50,      newcap :  true,
nomen  : true,   plusplus  :  true,    regexp  :  true,
sloppy   : true,   vars        :  false,    white   :  true,
*/
var spa = (function(){
    var initModule = function ( $container ) {
            $container.html(
                '<h1 style="display:inline-block;margin:25px;">'
                 + ' hello World' 
                 + '</h1>'
            );
    };    
    return {
        initModule : initModule
    };
}());

 

使用 JSlintjava

在命令行使用 JSLint 語法以下:npm

jslint spa.js

若有如下效果出現,說明你安裝而且驗證成功了!工具

相關文章
相關標籤/搜索