我有一个功能层应用程序,我正在编写一个jshint gulp任务。
这是一项艰巨的任务:
jshint : {
options : {
reporter : require("jshint-stylish"),
force : true
},
all : ["Gruntfile.js", "develop/modules/**/*.js", "develop/components/**/*.js"]
},
我的.jshintrc
文件:
{
"curly" : true,
"eqeqeq": true,
"forin" : true,
"globals" : {
"angular" : false, <-- is not defined
"module" : false,
"console" : false <-- Is not defined
},
"latedef" : true,
"maxerr" : 150,
"undef": true,
"unused": true,
"strict": true
}
但是在项目上调用任务时的输出是:
C:\Users\jason\Desktop\work\QAngular\angular>grunt jshint
Running "jshint:all" (jshint) task
develop/modules/login/login.js
line 1 col 1 Use the function form of "use strict".
line 3 col 1 'angular' is not defined.
line 12 col 13 'console' is not defined.
line 20 col 21 'angular' is not defined.
line 21 col 34 'angular' is not defined.
line 27 col 29 'console' is not defined.
line 31 col 29 'console' is not defined.
根据文档,globals
中的.jshintrc
设置应该处理此问题。不是。有没有我错过的可能性
答案 0 :(得分:1)
grunt-contrib-jshint
默认情况下不使用.jshintrc
,您必须通过将jshint.options.jshintrc
设置为true
或文件路径来明确要求它( https://www.npmjs.com/package/grunt-contrib-jshint#jshintrc):
jshint : {
options : {
jshintrc: true,
reporter : require("jshint-stylish"),
force : true
},
all : ["Gruntfile.js", "develop/modules/**/*.js", "develop/components/**/*.js"]
},