JSLint reports an "Unexpected dangling" character in the name of an underscore prefix string

I know that some people consider having a leading underscore to imply that the variable is “private”, that such confidentiality is fictitious, and suggests that this is why JSLint reports these names with an error message.

I use Google Analytics on the website that I create. I refer to GA variables such as "_gaq."

I am trying to get my JS code to be 100% JSLint clean (I am not religious about the coding style, and it will go with Mr. Crockford's lawyer). However, I cannot do anything with Google variable names ... therefore, I think I cannot get 100% "clean".

I post here if I misunderstood the message and can do something to comply with JSLint practices.

+72
javascript jslint
Jun 14 '10 at 17:55
source share
4 answers

Ah, I have it processed ... I am transferring statements that use prefix underscores with JSLint commands to disable and then enable this error class again:

/*jslint nomen: true*/ ... statement(s) with _var ... /*jslint nomen: false*/ 
+70
Jun 14 '10 at 18:44
source share

The best way to handle this is to simply enable the "Tolerate dangling _ in identifiers" (nomen) option. See http://www.jslint.com/lint.html for more details.

+51
Feb 01 2018-12-12T00:
source share

JSLint is just a tool to improve code quality. Not fully passing his tests does not mean that your code is bad; it simply means that you are not following all the conventions set forth by its creator. Although JSLint makes very good suggestions, it is not always possible to execute all of them, especially when using another library that has not been tested against it. Instead of cluttering your source code with meaningless meta-comments, you should check your code with the option “Prevent freezing _ in identifiers” disabled, as it seems to make no sense to use this code.

+15
Jun 06 '11 at 8:40
source share

I am using JSLInt with node.js. You can pass the -nomen flag to bypass this function.

 jslint --nomen myfile.js 
+8
Aug 09 2018-12-12T00:
source share



All Articles