ErrorPro / react-google-autocomplete

React components for google places API.
MIT License
462 stars 114 forks source link

Fix instanceof check #231

Closed patdx closed 5 months ago

patdx commented 5 months ago

I think there is an issue in the instanceof check.

I keep getting an warning message like this in my bundler where imported this library:

▲ [WARNING] Suspicious use of the "!" operator inside the "instanceof" operator [suspicious-boolean-not]
    .wrangler/tmp/pages-GVXi9w/bundledWorker-0.2874780651986786.mjs:31392:16:
      31392 │             if (!inputRef.current instanceof HTMLInputElement)
            │                 ~~~~~~~~~~~~~~~~~
            ╵                 (!inputRef.current)

Right now !inputRef.current is evaluated first to either true or false, and true instanceof HTMLInputElement and false instanceof HTMLInputElement would both evaluate to false, so I think this code will not trigger at all at the moment.

For extra confirmation I tried plugging it into ASTExplorer which also showed that !inputRef.current is evaluated as one unit:

image

I just created this PR in the GitHub web interface, not sure if that will suffice to be ready to merge. Let me know if you'd need anything from me. Thanks!