wikimedia / eslint-plugin-no-jquery

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

utils.isjQuery: Improve `Identifier` detection #283

Closed edg2s closed 2 years ago

edg2s commented 2 years ago

Previously testing $div in foo($div) would return false as it assumed that if $div's parent node was a CallExpression, that $div was the node being invoked, and so only returned true iff the jQuery constructor was detected.

Add in a node.parent.calleee = node check to fix this.

Add some extra unit tests to variable-pattern, although none of these excercise the new check.

codecov[bot] commented 2 years ago

Codecov Report

Merging #283 (4ff6aae) into master (3ab0b0b) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #283   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          101       101           
  Lines          583       583           
=========================================
  Hits           583       583           
Impacted Files Coverage Δ
src/rules/variable-pattern.js 100.00% <ø> (ø)
src/utils.js 100.00% <100.00%> (ø)