解决:grunt-contrib-jshint插件支持es6 syntax的问题

grunt-contrib-jshint默认是不支持es6 syntax的。
所以如果在被检查的代码中使用es6的新特性,那么就会报错。
比如下面的报错信息就是由于用到es6的新特性

39 |class orgstructure_manage{
^ 'class' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).

  • 如何解决:修改jshint配置
 jshint:{
	 options: {
         esversion: 6
      }
}

文档出处:

esversion
This option is used to specify the ECMAScript version to which the code must adhere. It can assume one of the following values:
3 - If you need your program to be executable in older browsers—such as Internet Explorer 6/7/8/9—and other legacy JavaScript environments
5 - To enable syntax first defined in the ECMAScript 5.1 specification. This includes allowing reserved keywords as object properties.
6 - To tell JSHint that your code uses ECMAScript 6 specific syntax. Note that not all browsers implement them.

文档链接:
http://jshint.com/docs/options/#esversion

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值