Reputation:
According to this documentation trailing whitespace seems to have been removed. How can I enforce whitespace checking while not using a feature that's been deprecated like "white": true
?
Upvotes: 6
Views: 6656
Reputation: 9714
As this excerpt:
JSHint will not error if you have these options in your config or your files, it will simply ignore Them.
So you It can still use, but if you set the option to true
.
jshint 2.5.0
The following options were removed: nomen, onevar, passfail, white, gcl, smarttabs, trailing. In addition to that, indent no longer provides warnings about indentation levels. You can still use it to set your tab-width but it will be used only for character locations in other warnings. JSHint won't error if you have these options in your config or your files; it will simply ignore them.
Jshint 2.5.0: https://github.com/jshint/jshint/releases/tag/2.5.0
Jshint 2.5.1: https://github.com/jshint/jshint/releases/tag/2.5.1
An alternative solution is to use notepad++, whenever you finish editing a code you can use the following:
Edit > Blank Operations > Trim Trailing Space
The result is something like this:
[SPACE]if (something) {[SPACE]
to [SPACE]if (something) {
Note:
[SPACE]
is only one example (replace by whitespace)
You can also configure notepad++ to replace tabs with spaces when you type, configure like this:
Settings > Preferences > Tab Settings
and select "normal" (or other), tabs will be replaced with 4 spaces when you press tab in an edition.
This way you need not worry about this update "jshint" and can use it without fear of blanks.
I recommend keeping two versions of your code, the "development version" and the "production version".
The development version should be the whole original code commented and unsing only by the team collaborating with the project, a good tool to keep the project (in case of open-source) would be the https://github.com
The production version should be compacted your original code (without comments and unnecessary spaces), a tool for this would be: http://jscompress.com/
Upvotes: 2
Reputation: 165941
As other answers have stated, this functionality has been removed in JSHint 2.5.0, along with various other legacy features that were basically just leftovers from the original JSLint fork.
Whitespace linting is still a valuable tool though. It can be really annoying when diffs are polluted with endless whitespace changes because of some erroneous text editor setting that the committer forgot to switch off. The tool best suited to this job now in my opinion is JSCS which provides validation of a wide range of style choices.
This separation leaves JSHint to analyse the code itself for potential problems, and JSCS to analyse the way the code is presented. I use both alongside each other in most projects now. The JSCS rule used to prevent trailing white space is disallowTrailingWhitespace
.
Upvotes: 8
Reputation: 2049
I suggest you use multistr which will catch whitespace where it really hurts.
multistr
This option suppresses warnings about multi-line strings. Multi-line strings can be dangerous in JavaScript because all hell breaks loose if you accidentally put a whitespace in between the escape character () and a new line.
Upvotes: 1