Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move_var should be configurable #17

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

move_var should be configurable #17

yuxel opened this issue Feb 2, 2011 · 10 comments

Comments

@yuxel
Copy link

yuxel commented Feb 2, 2011

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

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

@douglascrockford
Copy link
Collaborator

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

@yuxel
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

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

@ghost
Copy link

ghost commented Feb 21, 2011

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

@douglascrockford
Copy link
Collaborator

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.

@ghost
Copy link

ghost commented Feb 21, 2011

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
Copy link
Collaborator

I am sorry I hurt your feelings.

@timdown
Copy link

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
Copy link
Collaborator

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants