Javascript 如何消除错误:在jsrc处打开圆支撑之前存在非法空格?

Javascript 如何消除错误:在jsrc处打开圆支撑之前存在非法空格?,javascript,angularjs,gulp,jshint,lint,Javascript,Angularjs,Gulp,Jshint,Lint,在我们的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 b

在我们的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) {
我不知道,早些时候一切正常。只有在狼吞虎咽升级到最新版本后,构建才会失败。谁能帮我一下吗

我还跟踪了以下链接:

根据上面的链接,我尝试在.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".
我需要的是:

My Editor webstorm自动为路线应用空间,如下所述:

function (localStorageServiceProvider) // with space
但是,它应该是:

function(localStorageServiceProvider) // without space

我需要在.jshintrc文件或修复…?的任何其他地方应用的确切规则是什么?

如果您愿意,可以将Webstorm配置为不插入空格。我这里没有Webstorm,但在IntelliJ IDEA(相同的底层IDE)中,该选项处于

首选项
->
编辑器
->
代码样式
->
Javascript
->
函数表达式中括号前的空格
->


需要配置的lint规则有:

"requireSpacesInAnonymousFunctionExpression": {
    "beforeOpeningRoundBrace": true,
    "beforeOpeningCurlyBrace": true
}


我在
.jscrc
文件中添加了:
“excludeFiles”:[“***”]
.jscrc
文件的最终版本如下所示:

{
  "preset": "google",
  "fileExtensions": [ ".js" ],

  "maximumLineLength": 120,
  "validateIndentation": 4,

  "disallowSpacesInAnonymousFunctionExpression": null,

  "excludeFiles": ["**/*"]
}

非常感谢您的回复@CupawnTae。但有这么多的文件,我们并没有面对这样的问题,直到今天。有100多人在我们的项目中工作,我不能说他们要改变webstorm中的设置,这听起来有点不对劲。我还面临着一个错误:
行在C:\filepath\somanyfiles.js
中最多只能包含120个字符。如果您对jshint global suppression有任何帮助,我们将不胜感激,并再次感谢您。错误:
2错误filepath\file.js:第0行,第0列,错误选项:“RequirespacesInonnamousFunctionExpression”。filepath\file.js:第0行,第0列,错误选项:“requireSpacesInFunctionExpression”你必须加载这些规则。你可以在这里找到规则:现在你不需要任何东西了。最好干脆把jshint全部扔掉。
{
  "preset": "google",
  "fileExtensions": [ ".js" ],

  "maximumLineLength": 120,
  "validateIndentation": 4,

  "disallowSpacesInAnonymousFunctionExpression": null,

  "excludeFiles": ["**/*"]
}