Skip to content

move_var should be configurable #17

Closed
yuxel opened this Issue Feb 2, 2011 · 10 comments

4 participants

@yuxel
yuxel commented Feb 2, 2011

Hi,
Is it possible, to make this check configurable?

"Move 'var' declarations to the top of the function."

@douglascrockford
Owner

It is possible, but it would be stupid. Scope confusion is a problem in this language.

@yuxel
yuxel commented Feb 2, 2011

Thanks for your answer,
It's stupid, but we have lots of for(var i =....) statements and it tooks too much time for us to refactor our code.
So, I'll be appretiated if you can make it configurable.

@douglascrockford
Owner

The purpose of JSLint is to inform you of weaknesses in your code. If you do not want that information, don't use it.

@yuxel
yuxel commented Feb 2, 2011

erm, sorry if I'm disturbing you but, lots of checks for these "weaknesses" can be toggled by a configuration parameter, and I want move_var parameter also to be configured by a parameter.

Regards

Osman

@kitcambridge

All JavaScript interpreters automatically hoist variable and function declarations. This is a feature of the language, not a coding weakness.

@douglascrockford
Owner

You can write all the crappy code you want. I don't care, because you don't work for me. The purpose of JSLint is not to make you feel good about your bad choices. It is to help you conform to a more reliable subset of the language.

@kitcambridge

I don't see how something that is clearly documented in the ECMAScript specification can be unreliable. On the contrary, it is a legitimate coding practice. You're absolutely correct that you shouldn't care about my code, but, at the same time, JSLint should not be lying to developers by falsely claiming that a certain practice is bad. Just because my code does not conform to your pedantic style does not mean that it is bad or crappy.

@douglascrockford
Owner

I am sorry I hurt your feelings.

@timdown
timdown commented Jun 16, 2011

Douglas, there are other experienced and thoughtful JavaScript developers that have opinions that are not the same as yours. I am fully aware of your very valid reasons for putting all var statements at the top of a function, but there are also valid reasons (such as readability) for not doing so. I and others who fully understand the issues choose not to adhere to your preferred var style and therefore cannot currently use JSLint.

I appreciate your efforts and am grateful for JSLint, but it would be more useful if you gave the people who use it a little more credit and allowed them to choose which stylistic variations they consider to be tolerable. The default options make your opinions plain enough.

@douglascrockford
Owner

The research that I did when developing JSLint showed that there were good reasons in this language to declare variables before that they are used. In some future edition, when let forms respect block scope, my advice will change to never use var.

If you have any evidence that violation of JSLint's rules produces programs that are provably more reliable and cruft-resistant, then I will implement your suggestion.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.