-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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] add allowConditionalRequire option #1439
[no-commonjs] add allowConditionalRequire option #1439
Conversation
a7c63d9
to
654dc10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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? |
I highly doubt if anyone is relying on these warnings. The only breaking change is that |
@Pessimistress adding the option in this PR sounds fine to me. |
src/rules/no-commonjs.js
Outdated
} | ||
|
||
function validateScope(scope) { | ||
if (scope.variableScope.type === 'module') return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (scope.variableScope.type === 'module') return true |
now that the other change is done :-)
945ee6d
to
a60e5c6
Compare
Fixes #1437
Currently:
if (typeof window !== "undefined") require("x")
is reported by defaultif (typeof window !== "undefined") { require("x") }
is never reported (scope)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.