Question

When I use SublimeLinter for Sublime Text 2 with javascript it shows the red exclamation icon whenever there is a trailing whitespace, which shouldn't be a problem with javascript.

I did a bit of research and found that I could add the code below to the package user settings (SublimeLinter.sublime-settings) per the error codes found here: https://github.com/jcrocholl/pep8/blob/master/pep8.py

{
  "pep8_ignore": [ "E200", "W200", "200" ]
}

But for some reason the error icons still show.

Was it helpful?

Solution

You're looking in the wrong place - PEP8 is for Python code checking. SublimeLinter by default uses JSHint to lint JavaScript files. In this case, you can use this SublimeLinter config to silence the JavaScript trailing whitespace warnings:

{
    "jshint_options": {
        "trailing": false
    }
}

See JSHint Options#trailing


But honestly, this is not the ideal way to go. Trailing whitespace is pure evil. Why, you may ask? Well a couple reasons off the top of my head:

Hence, I'd suggest trimming trailing whitespace automatically. In ST2, go to Preferences -> Settings - User and add this config:

{
    "trim_trailing_white_space_on_save": true
}

This way, the trailing whitespaces are automatically removed upon the first Ctrl/Cmd+S, and not just for JavaScript, but any language you code in.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top