jshint配置.jshintrc

  1. sudo npm install jshint -g
  2. Command + Shift + P, 安装JSHint Gutter 和JSHint

  3. 在项目根目录下添加.jshintrc文件 内容如下

{
    "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

    5.  设置 Preferences > Package Settings > SublimeOnSaveBuild > Settings - User

{
    "filename_filter": "\\.(css|js|json)$",
    "build_on_save": 1 // 1开启 0 关闭
}

    6.  添加自定义build Tools > Build System > New Build System

{
    "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文件 看一下效果

转载于:https://my.oschina.net/u/923974/blog/306695

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值