-
-
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] does not catch conditional require #1437
Comments
Looks like we need some failing test cases then, thanks. |
@ljharb I can open a PR to fix this. However these test cases confuse me: Is this by design? Should I add a new option if I want to strictly forbid any usage of |
Yes, if you’d like to submit 2 PRs - one for this issue, and one to disallow all usage of require - please do. |
I could theoretically fix my issue without breaking the current test cases, though shouldn't these two scenarios be treated the same? var a = c && require("b") if (c) {
require("b")
} |
Yes, in theory, but since they’re different scopes it’s not necessarily the same. |
The example here: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-commonjs.md#allow-require
cannot be reported even if
allowRequire: false
, because of this line:https://github.com/benmosher/eslint-plugin-import/blob/1edbbd03ec636469328ad59da922ed7edc8cd36d/src/rules/no-commonjs.js#L90
The context scope is
block
in this case.The text was updated successfully, but these errors were encountered: