Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upRemove undefined checks #9
Comments
This comment has been minimized.
This comment has been minimized.
|
This is why mocha's implicit globals are a bad idea! ;) But jokes aside, thanks for pointing out that this is an issue. I'd like JavaScript Standard Style to work out-of-the-box even when people are using mocha, and would like it to work for you! So, a couple of options to solve this:
I'm curious why you think reporting unused variables isn't a style issue - could you elaborate? |
This comment has been minimized.
This comment has been minimized.
|
Here's another example where this option saves the day: function test () {
var myVar = 'Hello, World'
console.log(myvar) // Oops, typo here - would be a runtime error, but caught by `standard`
} |
This comment has been minimized.
This comment has been minimized.
|
Actually, that last example would be caught by the
|
feross
closed this
in
ebde3e0
Jan 28, 2015
This comment has been minimized.
This comment has been minimized.
|
Okay, I remove the Defining a variable and never using it, while confusing, isn’t going to cause break at runtime like the reverse case (using an variable that was never defined) will. Cheers! |
feross
added a commit
that referenced
this issue
Jan 28, 2015
This comment has been minimized.
This comment has been minimized.
|
Relaxing the Personally, I actually feel In pbkdf2-compat I use two different test targets to avoid this situation. Adding the mocha globals might have been all that was necessary IMHO. |
This comment has been minimized.
This comment has been minimized.
|
Okay, after an in-depth discussion on IRC with folks, we've decided to:
It turns out that this rule actually does catch pretty serious errors. Case in point, it just caught this craziness in one of my own modules. We couldn't come up with a legitimate reason why an unused variable should ever stick around.
If you use mocha, you can explicitly allow |
This comment has been minimized.
This comment has been minimized.
|
These changes were released as 2.0.0, along with other improvements like adding ESLint. |
This comment has been minimized.
This comment has been minimized.
You won't find any disagreement from me whether these can help improve our code. My position was centered around two things:
That being said, I wasn't aware that I could declare globals at the top of the file via a comment. I actually really like that. Also, I didn't consider that I can just have a All in all, I'm happy to embrace it and am excited to just tell people, committers, etc to "just use standard JavaScript" :) |
This comment has been minimized.
This comment has been minimized.
|
Sweet, glad that you agree with the changes!
Actually, I think the reverse is true. If we add a rule, we have to bump the major version because we might cause someone's build to suddenly start failing. If you add |
jprichardson commentedJan 27, 2015
This breaks on global variables, specifically mocha tests (
itanddescribe). As mentioned here 91e8a41 yourjshintchecks are overzealous and defeat the purpose of this module, which states that it's for style checking.