Enforce using the node: protocol for imports to node built-in modules #378
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
From the changeset:
Previously we disabled the rule because it hadn't yet been backported to being supported in
require()
s in node 14 yet, but now it has been. Also, Jest supports it now.Why this rule:
It makes it easy to distinguish between builtin modules and modules from npm. There are over 40 builtin modules and it is hard to keep track of them. If you see code like
require('inspector')
you might look for the documentation on npm before realizing that you are actually referencing the node builtin module.The
node:
prefix makes it unambiguous which modules are node's builtin modules.