what to do about jslint?
Colin Clark
colinbdclark at gmail.com
Thu Feb 10 03:25:22 UTC 2011
Hi Justin,
This seems like a pretty comprehensive list of our options. There is a part of me that wants to argue for #3. We know programmers coming from C-like languages tend to get tripped up by JavaScript's unusual scoping rules, and defining all variables at the top of a scope helps serve as a reminder.
On the other hand, it's a pretty cumbersome technique. It makes refactoring harder because code isn't grouped together as closely, and it brings the risk that developers will accidentally omit var statements, causing unintentional global leakage.
I'm people will have some strong opinions about these options. If someone is interested in volunteering to do #1, I'd support it. Crockford has helped us out a lot, so we might as well lend him a hand with this little bug in JSLint.
Thoughts?
Colin
On 2011-02-09, at 5:40 PM, Justin Obara wrote:
> You may recall from a past dev meeting Michelle mentioning that jslint no longer has any tolerance for var's in for loops.
>
> For instance this would no longer be acceptable.
>
> for (var i = 0; i < 5; i++) {
> //do something five times
> }
>
> The biggest problem that this poses to us is that, jslint does not allow you to scan past it, and provides no means of ignoring it.
>
> We still need to lint our code though. Here are some options we have.
>
> 1) Fork ( https://github.com/douglascrockford/JSLint ). Make the necessary changes and send a pull request.
>
> 2) Move the var out of the for loop and place it just above.
>
> var = i;
> for (i = 0; i < 5; i++) {
> // do something five times
> }
>
> 3) we could also take up the practice of moving all of the var's to the top of every function
---
Colin Clark
Technical Lead, Fluid Project
http://fluidproject.org
More information about the fluid-work
mailing list