dgraham / eslint-plugin-jquery

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

Improve rule for $.toggle #37

Closed the-stas closed 5 years ago

the-stas commented 5 years ago

On our project we usually prepend DOM related variables with double dollar sign "$$" for better readability and searchability. But in that case this "no-jquery" plugin show error for toggle method of classList. https://developer.mozilla.org/en-US/docs/Web/API/Element/classList#Methods Something like this:

$$container.classList.toggle( SOME_CLASS );

and in console we have an error that toggle not allowed, but it is native JS method of classList property of DOM element.

I think it would be nice to improve the plugin to not detect classList.toggle() as jQuery.

Also I might try to fix it by myself with the help of some core devs :)

Thank you in advance!

the-stas commented 5 years ago

Hello @dgraham, @brendo, @mislav !

Can you please look into it when you will have some time.

Thanks!

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

the-stas commented 5 years ago

@edg2s Thank you! We will check it out!