简体   繁体   中英

Vim jshint error “bad line breaking before ','”

I use jshint.vim and in the code like below I get an error "bad line breaking before ','"

var a = 5
  , b = 10;

How can I fix this? I found this question , but I'm not sure how can I use it to fix the problem in Vim. Is there any config file (except .vimrc) where I can set laxbreak or laxcomma ?

Yes. I often use a leading comma style, and set the following preferences inside ~/.jshintrc :

{  
//...other prefs
laxcomma  : true,
laxbreak  : true,
//... other prefs
}

If you don't already have a .jshintrc, those two settings enclosed in braces a la JSON will probably do the trick.

I'm not sure about global configurations for the vim implementation, you'd have to consult the docs for that implementation, but you can put

/*jshint laxcomma:true */

at the top of your source files to set this on a per-file basis

Update

Looks like for the vim implementation you can set the config file using a global variable:

https://github.com/walm/jshint.vim/pull/3

You can then just create a json file and set laxcomma:true in it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM