jshint 报告变量未定义,尽管在配置中定义了全局 属性
jshint reporting variables undefined despite globals property defined in configuration
我有一个功能层应用程序,正在为其编写一个 jshint gulp 任务。
这是 grunt 任务:
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.
根据文档,.jshintrc
中的 globals
设置应该可以处理此问题。不是。有没有我错过的可能
grunt-contrib-jshint
默认情况下 不 使用 .jshintrc
,您必须通过将 jshint.options.jshintrc
设置为 [=14= 来明确要求它] 或文件路径 (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"]
},
我有一个功能层应用程序,正在为其编写一个 jshint gulp 任务。
这是 grunt 任务:
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.
根据文档,.jshintrc
中的 globals
设置应该可以处理此问题。不是。有没有我错过的可能
grunt-contrib-jshint
默认情况下 不 使用 .jshintrc
,您必须通过将 jshint.options.jshintrc
设置为 [=14= 来明确要求它] 或文件路径 (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"]
},