-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Assume jQuery (or assume $) #16
Comments
Ideally I would like to see a more generic solution such as a comma-separated list of pre-defined global variables (i.e. you can't assume "jQuery" or "$" for jQuery in no conflict mode, YAHOO, etc.). JSLint supports this via the text box right at the bottom of the options panel. |
Assume jQUery would require syncing to jQUery versions. Would a user-defined global identifiers table fit your needs? |
I would think so, yes. As long as I don't run my code through and get back 30 errors that $ isn't defined. I would think any global vars from other libraries would have the same issue. |
mikeh, you can add pre-defined globals using /_global ... */ syntax. So, for jQuery it will be GarrettS, does jQuery exposes anything but $ and jQuery to the global scope? And those two variables don't change from version to version. I agree about adding jQuery globals as an environment. |
THe behavior of jQuery changes from versions. And so if jQuery isn't expected to be anything other than a global function, then why limit the feature of "add a global function" to be hardwired as "add a global function named jQuery"? I really can't see why it the feature needs to be tied to jQuery. And why not allow the user to add any number of global identifiers? |
You can already add any number of global identifiers using the |
Also, the option is going to be opt-in so it won't affect anybody by default. |
If the goal is to warn user about problems in code, then warning about the usage of a global identifier jQuery would go much further towards that goal. |
In general, I'd say it's up to the user to define their globals at the top. If the browser environment is selected, we could reveal a few checkboxes for jQuery, Dojo, YUI, that augment the |
Anton and Paul, I think you guys are on the right track. A few options for the most common libraries would be nice. Paul, what syntax would we use to define our globals at the top of our files? |
As I described above, you can already use |
ah, gotcha, sorry. I think your comment here is spot on though: having the option to turn those on as environment options would be sweet as to not have to put it in every file. |
Added jQuery predefined globals (closed by f3b6594) |
Implemented in f3b6594. |
This option (user supplied list of assumed global variables) is still not available on web page jshint.com :( |
It is there: http://cl.ly/3t1a3U122x1l1m0B0r2m |
Oh, sorry. I was actually concerned about possibility of user-supplied list of global identifier. Original jslint.com have a input field, which allow you to add any assumed global variabled. It is missing at jshint.com. |
You can provide the list of globals by putting |
Crude guard against infinite expansion. Closes jshint#16
I'd love to see an option to assume jQuery (or another library using $) is available.
Chances are good that code being run through JSHint might use the $ function that has been defined in another file somewhere, and it would be nice to have it as an option to turn off the errors from $ being undefined.
The text was updated successfully, but these errors were encountered: