You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Shouldn't this type of usage be excluded from this rule since globalThis.matchMedia will crash with a TypeError: globalThis.matchMedia is not a function?
The above example is also a common use case in apps that run on both server and client, to check that the browser environment exists before running browser-specific code. globalThis isn't going to work for those use cases.
The text was updated successfully, but these errors were encountered:
This is a faulty check. You can no longer make this assumption, regardless of this rule. The correct way is to test the individual functions. I think this rule is doing you a favor by leading you to a better pattern.
I just upgraded my version of the plugin to
56.0.0
and started getting lint errors for theprefer-global-this
rule on code like this:Shouldn't this type of usage be excluded from this rule since
globalThis.matchMedia
will crash with aTypeError: globalThis.matchMedia is not a function
?The above example is also a common use case in apps that run on both server and client, to check that the browser environment exists before running browser-specific code.
globalThis
isn't going to work for those use cases.The text was updated successfully, but these errors were encountered: