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

来源:互联网 发布:淘宝渠道管理在哪里 编辑:程序博客网 时间:2024/06/05 08:43
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

原创粉丝点击