-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Proposed rule: required-modules #4021
Copy link
Copy link
Closed
Labels
archived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionevaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusionThe team will evaluate this issue to decide whether it meets the criteria for inclusionfeatureThis change adds a new feature to ESLintThis change adds a new feature to ESLintruleRelates to ESLint's core rulesRelates to ESLint's core rules
Metadata
Metadata
Assignees
Labels
archived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionevaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusionThe team will evaluate this issue to decide whether it meets the criteria for inclusionfeatureThis change adds a new feature to ESLintThis change adds a new feature to ESLintruleRelates to ESLint's core rulesRelates to ESLint's core rules
When does this rule warn? Please describe and show example code:
The rule will warn if a file fails to require the CommonJS modules specified. This is a Node.js-specific rule. It is the flip side of the existing
no-restricted-modulesrule.Is this rule preventing an error or is it stylistic?
This is stylistic.
Why is this rule a candidate for inclusion instead of creating a custom rule?
It is being proposed in Node.js core as a way to confirm that all test files load a particular module that checks for variable leaks and could conceivably do other runtime checks. It would be perfectly fine for Node.js to have it as a custom rule only, but it seems like something that is generally applicable.
Are you willing to create the rule yourself?
Yes. This rule is currently being proposed for Node.js core in nodejs/node#3157 with the implementation currently at https://github.com/Trott/io.js/blob/eslint-require-common/tools/eslint-rules/require-modules.js. (The current implementation is susceptible to false negatives, but that is something that can likely be fixed pretty easily. And if not, it may be acceptable anyway. I'm pretty sure the current implementation is sufficient for the Node project's purposes.)