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
inline replacement of JSLint with JSHint, fixes #10692 #602
Conversation
Why on Earth do we have that many changes? Some of these re-arranging do not seem to make a lot of sense. |
jaubourg, I included pull 602 and 601 in case we weren't prepared for the undef changes. The reason we need to rearrange is that static code analyzer need named functions to be declared before they are used. They also require vars to be at least declared as such before they are used. If we DON'T want to check that all of our variables are defined before we use them, then undef: true is not for us. However, without it, nothing is going to tell you when you accidentally forget to declare a var inside a closure and it's promoted to global scope. I know @dmethvin recently had a bug with events that would have been avoided if we were using undef:true. The tradeoff is there for evaluation. |
And if you think these changes are superfluous, just wait till you see what I have to do to get onevar: true to pass. ;-) |
I knew this would require a lot of changes, but I'm ok with that. What is the size difference after this change? Is there any? uglify hoists anyway so I'm not sure it would actually make a difference. |
@@ -15,6 +15,7 @@ window.jQuery = window.$ = jQuery; | |||
// file names, and jQuery is normally delivered in a lowercase file name. | |||
// Do this after creating the global so that if an AMD module wants to call | |||
// noConflict to hide this version of jQuery, it will work. | |||
/*global define:true */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not include comments like this. We can add define to the predef list in jshint-check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, but this is the way in code to indicate without having to modify the lint check. But I'm fine either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to modify the lint check than to include non-contextual comments in the code.
@timmywil, I'll get a size diff shortly. |
Yeah, I guess I see it as contextual and relevant. It says: we know Anyway, I'll defer to your preference. Do you also want me to move Sent Via Mobile: Please excuse my grammar, tone, and punctuation. My On Nov 16, 2011, at 10:54 AM, timmywil
|
My thinking:
I would remove any jshint comments that have been added and instead adjust the options. |
Fair enough. I'll make those changes and give a new size diff soon Sent Via Mobile: Please excuse my grammar, tone, and punctuation. My On Nov 16, 2011, at 8:18 PM, timmywil
|
OK, so made those changes, and just ran a new size diff. Want to laugh? jQuery Size - compared to last make |
@timmywil, after those commits I just made, the only special cases in jshint-check.js are:
So, I understand you don't want the global-style comments in code, but as far as expecting a The reason why I think this is different from the global one, is that in the case of globals, you're right, you can check on a case by case basis the global variable being assumed and ignore it, but if we have a blanket ignore on switch statement fall throughs, we'll won't be able to automate the catching of that mistake. What do you think? |
When I am writing C code I use a /* falls through */ comment, it's a |
@mikesherov: I'm fine with /* falls through */. As for the special cases, I didn't mean add to the accepted errors. For jshint, we can define a variable in the options called predef, which is an array of variable names that are expected to be global. I keep a list in my global .jshintrc:
So I imagine something like this in the jshint-check. @dmethvin: rwaldron and I already looked at that switch. I think it's best to leave it and add the comment. The codepath is not actually used in Chrome so perf is not an issue. |
…0692. also, still needs to wait on this sizzle PR: jquery/sizzle#82
We'll move to undef:true and onevar:true later, MAYBE.