What should I do with trailing space in JSHint 2.5.0?

Accordingly , the trailing space documentation seems to be deleted. How can I force spaces to be checked without using a function that is deprecated like "white": true ?

+6
source share
3 answers

As reported in other answers, this functionality was removed in JSHint 2.5.0 along with various other deprecated functions, which were mostly the remnants of the original JSLint fork.

Whitespace is still a valuable tool. This can be very annoying when diffs are contaminated with endless space changes due to some erroneous text editor settings that the committer forgot to turn off. The tool that is most suitable for this job is now, in my opinion, JSCS , which provides verification of a wide range of style options.

This separation leaves JSHint to analyze the code itself for potential problems, and AOS to analyze the way code is presented. In most projects, I use both sides of each other. The AOC rule used to prevent spaces is disallowTrailingWhitespace .

+8
source

Like this passage:

JSHint will not be an error if you have these options in your configuration or your files, it will simply ignore them.

So you can still use, but if you set the parameter to true .

jshint 2.5.0

The following parameters have been deleted: nomen, onevar, passfail, white, gcl, smarttabs, trailing. In addition to this, indentation no longer provides warning about indentation levels. You can still use it to set the tab width, but it will only be used to position characters in other warnings. JSHint will not be an error if you have these parameters in your config or your files; he simply ignores 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

Alternative solution:

An alternative solution is to use notepad ++ , whenever you finish editing the code, you can use the following:

Edit > Blank Operations > Trim Trailing Space

The result looks something like this:

[SPACE]if (something) {[SPACE] to [SPACE]if (something) {

Note: [SPACE] is just one example (replace with a space)

You can also configure notepad ++ to replace tabs with spaces during input, configure as follows:

Settings > Preferences > Tab Settings and select "normal" (or another), the tabs will be replaced by 4 spaces when you click the tab in the editor.

Thus, you do not need to worry about this jshint update and use it without fear of spaces.

What to use in production code:

I recommend storing two versions of your code, the "development version" and the "production version."

The development version should have all the source code, commented out and not related only to the team collaborating with the project, a good tool for saving the project (in the case of open source) is https://github.com

The production version should be compressed by your source code (without comments and unnecessary spaces), a tool for this would be: http://jscompress.com/

+2
source

I suggest you use multistr, which will catch spaces where it really hurts.

multistr
This option suppresses multi-line string warnings. Multi-line strings can be dangerous in JavaScript because all hell breaks if you accidentally put a space between the escape character () and the new line.

+1
source

Source: https://habr.com/ru/post/969597/


All Articles