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
require node: prefixes for Node.js builtins #1080
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
pkg:lavamoat-viz
Changes in package lavamoat-viz
pkg:lavamoat-perf
Changes in package lavamoat-perf
pkg:lavamoat-core
Changes in package lavamoat-core
pkg:@lavamoat/aa
Changes in package @lavamoat/aa
pkg:@lavamoat/allow-scripts
Changes in package @lavamoat/allow-scripts
pkg:lavamoat-browserify
Changes in package lavamoat-browserify
pkg:lavamoat-tofu
Changes in package lavamoat-tofu
pkg:@lavamoat/webpack
Changes in package @lavamoat/webpack
pkg:@lavamoat/lavapack
Changes in package @lavamoat/lavapack
pkg:survey
Changes in package survey
labels
Mar 8, 2024
boneskull
force-pushed
the
boneskull/require-builtins-eslint
branch
from
March 8, 2024 20:46
cbca721
to
07bf941
Compare
I made this because I don't want to feel compelled to add suggestions on other people's PRs to change it. 😄 |
boneskull
force-pushed
the
boneskull/require-builtins-eslint
branch
3 times, most recently
from
March 8, 2024 22:06
5c41b7b
to
c7b3a89
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. Join @boneskull and the rest of your teammates on Graphite |
boneskull
force-pushed
the
boneskull/require-builtins-eslint
branch
from
March 11, 2024 23:57
c7b3a89
to
734ab44
Compare
legobeat
approved these changes
Mar 12, 2024
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.
lgtm
boneskull
force-pushed
the
boneskull/require-builtins-eslint
branch
from
March 12, 2024 20:13
734ab44
to
13fe60c
Compare
This adds a rule which requires all `require()`s or `import`s use the `node:` prefix when requesting builtins. `node:`-prefixed builtins better illustrate intent and reduce the risk of erroneously pulling in 3rd-party packges.
This change adds the `node:` prefix to (almost) all `require()` calls of Node.js builtins. Two places were special cases: 1. In `viz`, old Webpack does not understand the `node:` prefix; this had to be exempted from the rule. 2. In `tofu`, I added another test to assert both prefixed and non-prefixed builtin references work as expected. Note that test fixture projects are ignored by ESLint; they have not been changed.
boneskull
force-pushed
the
boneskull/require-builtins-eslint
branch
from
March 12, 2024 21:26
13fe60c
to
5da2c26
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
pkg:@lavamoat/aa
Changes in package @lavamoat/aa
pkg:@lavamoat/allow-scripts
Changes in package @lavamoat/allow-scripts
pkg:@lavamoat/lavapack
Changes in package @lavamoat/lavapack
pkg:@lavamoat/webpack
Changes in package @lavamoat/webpack
pkg:lavamoat-browserify
Changes in package lavamoat-browserify
pkg:lavamoat-core
Changes in package lavamoat-core
pkg:lavamoat-perf
Changes in package lavamoat-perf
pkg:lavamoat-tofu
Changes in package lavamoat-tofu
pkg:lavamoat-viz
Changes in package lavamoat-viz
pkg:survey
Changes in package survey
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.
This PR adds a plugin (eslint-plugin-node-import) which provides a rule to require the
node:
prefix whenimport
-ing orrequire
-ing Node.js builtins.node:
-prefixed builtins better illustrate intent and reduce the risk of erroneously pulling in 3rd-party packages.The second commit updates the codebase (done via
eslint --fix
) to use thenode:
prefix where appropriate: