dgraham / eslint-plugin-jquery

Disallow jQuery functions with native equivalents.
MIT License
209 stars 22 forks source link

Inspections can detect jQuery if the jQuery collection was stored in a member variable #33

Open stof opened 5 years ago

stof commented 5 years ago

Our existing jQuery-based code has some of cases where it uses this.$element to store a reference to a jQuery objects. Our convention is that any variable (or property of our object) with a name starting with $ contains a jQuery object.

Is there a way to make the plugin recognize those as jQuery usages ?

Berkmann18 commented 5 years ago

That's a great thing, the issue with this is that non-jQuery frameworks like VueJS, Angular (I think) use the $something pattern (usually as a property of a (global) variable) so this might get in the way, although I'm fairly sure it can be avoided.

stof commented 5 years ago

well, making it configurable in the plugin (to require opting in for the more complete detection) would be fine with me. But I don't think this is possible currently.

edg2s commented 5 years ago

Note that we have fixed this issue our maintained fork: https://github.com/wikimedia/eslint-plugin-no-jquery/blob/master/rules/utils.js#L32