wikimedia / eslint-plugin-no-jquery

Control allowance of certain jQuery functions, and suggest or autofix alternatives.
MIT License
32 stars 8 forks source link

Create a rule to enforce the variable naming policy #145

Closed edg2s closed 4 years ago

edg2s commented 4 years ago

Given an assignment:

var foo = $bar.find( 'a' );

if the RHS is determined to return a jQuery collection, and the LHS doesn't match the variablePattern defined in settings, then an error can be thrown.

edg2s commented 4 years ago

I'm not sure this is the best name for this rule. Suggestions welcome.

edg2s commented 4 years ago

Tested this on mw-core and found lots of things to fix: https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/540965/

Will need a couple of inline exceptions, mostly for plain arrays of jQuery collections (e.g. list[5] = $div)