10

I'm using SublimeLintern package, but I'm experiencing some issues. I would like to toggle that "laxcomma" warning that appears each time I save my files: I do prefer putting my commas at the beginning of each row

{
  "item1": val1
  ,"item2": val2
  ,"item3": val3
}

Hence, I tried to look for some piece of documentation that explained how to enable or disable each check. I bumped into this that should explain what I need. So, my SublimeLinter.sublime-settings is now like this:

{
    "jshint_options": {
        "laxcomma": false
    }
}

but it doesn't seem to be working. I still see that bothering warning! What's wrong with my settings?

Bertuz
  • 2,390
  • 3
  • 25
  • 50
  • Have you looked at lines 284 and 285 of `/Packages/SublimeLinter/sublimelinter/modules/libs/jshint/jshint.js`? You might want to set `laxbreak` and `laxcomma` to `false`. – AGS Sep 19 '13 at 01:58
  • Yep! I've tried both, but nothing happens – Bertuz Sep 19 '13 at 10:42
  • 1
    May you try this out on your SBT2 `sublimelinter.sublime-settings` file and tell me if it works properly? In case it works: may you paste a gist here? Thanks – Bertuz Sep 19 '13 at 10:44
  • Is this still relevant? I do get warning for comma at the beginning of each line rather than end! But code seems to work fine on pretty much all browsers! – Sushil Lakra Aug 27 '21 at 07:22

2 Answers2

4

Bizarre. For me, the issue was that I had a .jshintrc file in the local directory of my project. Despite the fact that laxcomma wasn't being overridden there EITHER, apparently it just completely overrides your jshint_options (or maybe it does a top-level extend and doesn't recursively merge the config objects...)

The solution was to add (to the local .jshintrc file):

"laxcomma": true

mikermcneil
  • 11,141
  • 5
  • 43
  • 70
  • 2
    And in a simple command you can do bash$:> `echo '"laxcomma": true' >> ~/.jshintrc` – aemonge Apr 28 '14 at 14:13
  • doesn't work for me. maybe i need to restart webstorm? – chovy Jan 29 '15 at 05:06
  • @chovy yeah maybe quit out of it completely and open it again-- my solution isn't necessarily a surefire fix for your situation, since it does seem that this stuff is a bit editor-dependent – mikermcneil Jan 29 '15 at 09:02
  • 1
    My project had more than one version of this file. :) – chovy Jan 29 '15 at 20:33
1

The word "lax" means not strict or severe; if you want to put your commas at the beginning of each line, try setting "laxcomma" to true:

{
    "jshint_options": {
        "laxcomma": true
    }
}
Cody Codes
  • 27
  • 1
  • 1
    this is part of my .sublime-project content `"jshint_options": { "laxcomma": true }` I tried with both `true` and `false` but nothing happens, this is the message I get after saving my file: 'comma warnings can be turned off with 'laxcomma'; bad line breaking before ',' I don't know the cause of that _bad line breaking_ actually. – Bertuz Oct 01 '13 at 20:39
  • Correct for 'The word "lax" means not strict or severe' –  Sep 09 '15 at 21:56