Configuring SublimeLinter to ignore trailing whitespace

两盒软妹~` 提交于 2019-12-24 02:13:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!