Skip to content
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

💡 Remove related spec files when removing code #905

Open
LzxHahaha opened this issue Jan 9, 2025 · 1 comment
Open

💡 Remove related spec files when removing code #905

LzxHahaha opened this issue Jan 9, 2025 · 1 comment
Labels
feature request Feature request

Comments

@LzxHahaha
Copy link

Suggest an idea for Knip

This is the source code:

// foo.ts

export function used() {}

export function unused() {}

and the spec files:

- foo.ts
- foo.spec/
+-- used.spec.ts
+-- unused.spec.ts

When I removed the unused function by knip, I wanted also to remove the foo.spec/unused.spec.ts, but keep foo.spec/used.spec.ts

@LzxHahaha LzxHahaha added the feature request Feature request label Jan 9, 2025
@webpro
Copy link
Collaborator

webpro commented Jan 9, 2025

Does that work already if you run knip twice? Like so:

knip --production --fix
knip --fix --allow-remove-files

Edit: I guess it won't delete the file, usually *.spec.ts is an entry file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request
Projects
None yet
Development

No branches or pull requests

2 participants