Skip to content

Apply the fix flags in the quick fix that removes exports - #2427

Merged
webpro merged 1 commit into
webpro-nl:mainfrom
everton-dgn:fix/remove-export-quick-fix-flags
Nov 19, 2026
Merged

webpro merged 1 commit into
webpro-nl:mainfrom
everton-dgn:fix/remove-export-quick-fix-flags

Conversation

@everton-dgn

Copy link
Copy Markdown
Contributor

The quick fix that removes an unused export or enum member deletes only the range of each fix. In zotero-mcp, Knip reports EmbeddingService and other names this barrel re-exports as unused, and removing EmbeddingService leaves a line with just , in the list, a syntax error. That happens to 20 quick fixes in the file, and to 15 of the 48 on the fix and fix-members fixtures that --fix is tested against, such as removing Fourth from export { Four as Fourth, Five as Fifth } or North from its enum. None do with this change.

createRemoveExportEdit ignored the flags that come with each fix. It now applies them with the same removeExport as --fix, exported from knip/session, and returns one edit for the changed range. Same kind of fix as #2033 for dependencies.

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 0d80737

@webpro webpro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Sharing the core remover with the quick fix is the right direction: export lists and enum members no longer come out malformed, such as the leading comma left in a multi-line re-export.

One follow-up, here or in a separate PR: when the removed export was the file's last import or export, the CLI --fix leaves export {} so the file stays a module, and the quick fix does not. That gap already exists on main for export const, and this adds the list form. Moving that check next to removeExport and calling it from the code action would cover both.

@webpro
webpro merged commit 5221793 into webpro-nl:main Nov 19, 2026
33 checks passed
@webpro

webpro commented Nov 20, 2026

Copy link
Copy Markdown
Member

🚀 This pull request is included in v6.47.0. See Release 6.47.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.

2 participants