Sublime Text 3中SublimeLinter的使用

关于Sublime  Text 2中的SublimeLinter的使用网上多如牛毛,基本上不会遇到什么问题,简单的讲一下关于Sublime Text 3中遇到的问题:

1.通过package control(cmd+shift+p),搜索SublimeLinter,安装,如果按照网上的配置是没法进行JS和CSS校验的;

2.安装jshint,csslint,SublimeLinter在Text 3中自己本身演变成了一个框架,关于各个语言校验的集合,关于各种语言的校验又拆成对应的小模块:

(需要安装node,如果没有安装的可以参考本人之前的文章)

安装jshint:

npm install -g jshint

安装csslint:

npm install -g csslint

3.这个时候不要急于配置,还需要两个对应的插件SublimeLinter-jshint以及SublimeLinter-csslint,如果没有出错的话,这个时候是有对应的JS和CSS警告以及提示的;

4.配置可选项,SublimeLinter向下兼容,配置选项参考网上前辈的配置:

{
    "sublimelinter": "save-only",
    "sublimelinter_popup_errors_on_save": true,
    "sublimelinter_executable_map": {
        "javascript": "http://www.cnblogs.com/xiaofeixiang/",
        "css": "http://www.cnblogs.com/xiaofeixiang/"
    },
    "jshint_options": {
        "strict": false,
        "quotmark": "single", //只能使用单引号
        "noarg": true,
        "noempty": true, //不允许使用空语句块{}
        "eqeqeq": false, //!==和===检查
        "undef": true,
        "curly": true, //值为true时,不能省略循环和条件语句后的大括号
        "forin": true, //for in hasOwnPropery检查
        "devel": true,
        "jquery": true,
        "browser": true,
        "wsh": true,
        "evil": true,
        "unused": "vars", //形参和变量未使用检查
        "latedef": true, //先定义变量,后使用
        "globals": {
            "grunt": true,
            "module": true,
            "window": true,
            "jQuery": true,
            "$": true,
            "global": true,
            "document": true,
            "console": true,
            "setTimeout": true,
            "setInterval": true
        }
    },
    "csslint_options": {
        "adjoining-classes": false,
        "box-sizing": false,
        "box-model": false,
        "compatible-vendor-prefixes": false,
        "floats": false,
        "font-sizes": false,
        "gradients": false,
        "important": false,
        "known-properties": false,
        "outline-none": false,
        "qualified-headings": false,
        "regex-selectors": false,
        "shorthand": false,
        "text-indent": false,
        "unique-headings": false,
        "universal-selector": false,
        "unqualified-attributes": false
    }
}

5.如果对于SublimeLinter有兴趣可以参考官网:http://www.sublimelinter.com/en/latest/

posted @ 2015-10-03 17:29  Fly_Elephant  阅读(2766)  评论(0编辑  收藏  举报