【发布时间】:2023-09-24 20:31:01
【问题描述】:
在我们的 angularjs 项目中,在 gulp3 升级到 4 之后,当我运行时:gulp lint
C:\filepath>gulp lint
[12:59:30] Using gulpfile ~\filepath\gulpfile.js
[12:59:30] Starting 'lint'...
app\js\app.config.js: line 4, col 1, Use the function form of "use strict".
1 error
Illegal space before opening round brace at C:\filepath\app\js\app.config.js :
7 |angular
8 | .module('test')
9 | .config(['localStorageServiceProvider', function (localStorageServiceProvider) {
C:\filepath>gulp lint
[12:59:30] Using gulpfile ~\filepath\gulpfile.js
[12:59:30] Starting 'lint'...
app\js\app.config.js: line 4, col 1, Use the function form of "use strict".
1 error
Illegal space before opening round brace at C:\filepath\app\js\app.config.js :
7 |angular
8 | .module('test')
9 | .config(['localStorageServiceProvider', function (localStorageServiceProvider) {
我无法弄清楚,之前一切正常。只有在 gulp 升级到最新版本之后,构建才会失败。谁能帮我解决这个问题。
我也关注了这个链接:How can I suppress the JSHint "JSCS: Illegal Space" warnings in Visual Studio 2013?。
根据上面的链接,我尝试在 .jshintrc 文件中添加以下行:
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningCurlyBrace": false
},
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": false
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": false
}
继上一个之后抛出更多错误:
6 code style errors found.
app\js\app.module.js: line 0, col 0, Bad option: 'requireSpacesInAnonymousFunctionExpression'.
app\js\app.module.js: line 0, col 0, Bad option: 'disallowSpacesInNamedFunctionExpression'.
app\js\app.module.js: line 0, col 0, Bad option: 'disallowSpacesInFunctionDeclaration'.
app\js\app.module.js: line 4, col 1, Use the function form of "use strict".
我需要的是:
我的编辑器 webstorm 自动为对齐应用空间,如下所述:
function (localStorageServiceProvider) // with space
但是,应该是:
function(localStorageServiceProvider) // without space
我需要在 .jshintrc 文件或任何其他修复的地方应用什么规则?
【问题讨论】:
标签: javascript angularjs gulp jshint lint