Add exceptions for __dirname and __filename in dangling underbar check. #165
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Node developers frequently interface with the
__dirname
and__filename
variables. While their globality may be tolerable via thenode
option, their usage is still considered an error due to the dangling underbar check. You must also enablenomen
to skip the check, which is undesirable.Either one lazily enables
nomen
for the entire file (permitting developers to define_private
methods), or he "temporarily" enables the option......which gets messy.
The workarounds are not good. Furthermore, node developers are stuck with this API. It's not within our power to make better nomenclature decisions.
On the Google Plus community, you have stated that the
nomen
option will be removed soon. If that were to happen today, it would be impossible for node developers to pass JSLint. That stinks. We just used an API that was given to us; we didn't do anything wrong.With these points in mind, you should consider adding a special case for tolerating the dangling underbars in the
__dirname
and__filename
variables if thenode
option is enabled. The variables should be tolerated in their entirety; not just to the extent that they are recognized as poorly-named globals. This will be more in-line with users' expectations, work into the future whennomen
goes away, and best of all free developers of silly workarounds to comply with a rule that cannot be complied with.Tests
master
currently returns the following:My branch returns the following:
If you diff the above outputs, you will find that
JSLINT
only stops reporting errors in the case of interfacing with__dirname
. Everything else remains the same. Adding this exception doesn't open up a "loophole" whereby node developers can violate good nomenclature rules by declaring a local variable called__dirname
; we still get"Read only."
.