javascript 如何配置 jshint 不给我错误“之前断行错误”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8549394/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 03:46:44  来源:igfitidea点击:

How do I configure jshint to not give me the error "Bad line breaking before"?

javascriptjshint

提问by fent

It's giving me the error "Bad line breaking before ','" because I have code like the following

它给了我错误“在','之前断行”,因为我有如下代码

var one = 1
  , two = 2
  , three = 3
  ;

If I put the ,at the end of the line instead of the beginning of the next, it doesn't complain. But I want to code this way. Is there a way I can make it not show this warning?

如果我把 放在,行尾而不是下一行的开头,它不会抱怨。但我想以这种方式编码。有没有办法让它不显示这个警告?

I looked though JSHint's optionsbut there isn't anything pertaining to this error.

我查看了JSHint 的选项,但没有任何与此错误有关的内容。

采纳答案by zappan

As mentioned in the comments of the laxbreakanswer, laxcommaoption should actually be used for this particular situation (it has been implemented in the meantime). See http://jshint.com/docs/options/for details.

正如laxbreak答案的评论中所提到的,laxcomma选项实际上应该用于这种特殊情况(同时已实施)。有关详细信息,请参阅http://jshint.com/docs/options/

回答by kubetz

laxbreak = trueis the option to set.

laxbreak = true是要设置的选项。

You can find the option on the main page of JSHint site as "About unsafe line breaks".

您可以在 JSHint 站点的主页上找到“关于不安全换行符”的选项