Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-commonjs] do not report conditional require in a if statement #1439

Open
wants to merge 2 commits into
base: master
from

Conversation

@Pessimistress
Copy link

commented Aug 4, 2019

for #1437

Currently:

  1. if (typeof window !== "undefined") require("x") is reported by default
  2. if (typeof window !== "undefined") { require("x") } is never reported (scope)
  3. typeof window !== "undefined" && require("x") is never reported (conditional require)

After this PR, all cases will be treated the same (as conditional requires). A follow up PR will add an option for users to configure whether conditional requires should be reported.

@coveralls

This comment has been minimized.

Copy link

commented Aug 4, 2019

Coverage Status

Coverage increased (+2.6%) to 97.902% when pulling 654dc10 on Pessimistress:no-commonjs-conditional-require into ebcf17c on benmosher:master.

@Pessimistress Pessimistress force-pushed the Pessimistress:no-commonjs-conditional-require branch from a7c63d9 to 654dc10 Aug 4, 2019

@Pessimistress Pessimistress changed the title [no-commonjs] report conditional require in a if block [no-commonjs] do not report conditional require in a if statement Aug 4, 2019

@ljharb
Copy link
Collaborator

left a comment

I think that the option may need to be added first, so that those who are relying on these warnings have an existing solution to enable them.

@Pessimistress

This comment has been minimized.

Copy link
Author

commented Aug 5, 2019

I have no idea how to add the option without making these changes... Do you mind if I just add it in the same PR?

@Pessimistress

This comment has been minimized.

Copy link
Author

commented Aug 5, 2019

those who are relying on these warnings have an existing solution to enable them

I highly doubt if anyone is relying on these warnings. The only breaking change is that if (typeof window !== "undefined") require("x") is no longer reported. Considering if (typeof window !== "undefined") { require("x") } was never reported, I consider the existing behavior already broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.