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