Skip to content

fix(node): add valueless Node CLI flags to boolean options - #2042

Merged
webpro merged 2 commits into
webpro-nl:mainfrom
shoutoutuoadi325:node-boolean-flags
Sep 15, 2026
Merged

webpro merged 2 commits into
webpro-nl:mainfrom
shoutoutuoadi325:node-boolean-flags

Conversation

@shoutoutuoadi325

Copy link
Copy Markdown
Contributor

The Jest ESM guide recommends running Jest like this:

"test": "node --experimental-vm-modules node_modules/.bin/jest"

Knip reported jest as an unused devDependency for such a script. --experimental-vm-modules is a valueless flag, but it was missing from the Node plugin's boolean options, so the parser consumed node_modules/.bin/jest as its value and the binary was never attributed to the dependency.

This adds a few more documented valueless Node CLI flags to the list: --enable-source-maps, --experimental-detect-module, --experimental-json-modules, --experimental-vm-modules, --expose-gc and --openssl-legacy-provider.

Copilot AI lite review requested due to automatic review settings September 15, 2026 02:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Regression tests do not cover three newly added boolean flags.

Pull request overview

Updates Node CLI parsing so valueless flags do not consume the following Jest executable.

Changes:

  • Registers six additional Node boolean flags.
  • Adds regression tests for representative flag combinations.
File summaries
File Summary
packages/knip/test/util/get-inputs-from-scripts.test.ts Tests executable detection after representative flags; three added flags remain untested.
packages/knip/src/plugins/node/index.ts Registers additional valueless Node CLI flags.
Review details

Suppressed comments (1)

packages/knip/test/util/get-inputs-from-scripts.test.ts:85

  • This regression coverage only exercises --experimental-vm-modules, --enable-source-maps, and --expose-gc; the newly added --experimental-detect-module, --experimental-json-modules, and --openssl-legacy-provider entries are untested. Include the remaining flags here (or add separate cases) so a typo or accidental removal of any new boolean option is caught.
  t('node --enable-source-maps --expose-gc node_modules/.bin/exec', [toBinary('node'), toBinary('exec')]);
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/knip@2042
npm i https://pkg.pr.new/@knip/language-server@2042
npm i https://pkg.pr.new/@knip/mcp@2042

commit: 0c16ae8

@webpro
webpro merged commit 4c67685 into webpro-nl:main Sep 15, 2026
32 checks passed
@webpro

webpro commented Sep 15, 2026

Copy link
Copy Markdown
Member

Thank you! 🙏

@webpro

webpro commented Sep 16, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.36.0. See Release 6.36.0 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants