问题
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.
回答1:
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:
- Commit noise.
- "Breaks" text editors. See this related question's answers at Programmers.SE
- And finally, Jeff Atwood's blog post Whitespace: The Silent Killer
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.
来源:https://stackoverflow.com/questions/19711921/configuring-sublimelinter-to-ignore-trailing-whitespace