Skip to content

How to use --exclude? #366

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

Closed
gajus opened this issue Nov 27, 2023 · 5 comments
Closed

How to use --exclude? #366

gajus opened this issue Nov 27, 2023 · 5 comments
Labels
discussion Discussion

Comments

@gajus
Copy link

gajus commented Nov 27, 2023

Based on the description, I would expect this to not include type error:

$ knip --production --strict --ignore-internal --exclude type
Analyzing workspace ....
Unused exported types (1)
OrganizationExternalLink  type  src/contra-api/types.ts:2091:13
  --include                Report only provided issue type(s), can be comma-separated or repeated (1)
  --exclude                Exclude provided issue type(s) from report, can be comma-separated or repeated (1)

For context, we are running knip twice as follows:

knip && knip --production --strict --ignore-internal

and the issue is that the second run detects unused types that are contained in production files, but are only used in tests, therefore causing unused export type errors. It appears that the correct way to fix this is to just ignore unused export types in production build

@gajus gajus added the discussion Discussion label Nov 27, 2023
@webpro
Copy link
Member

webpro commented Nov 27, 2023

Are you missing an s at the end of --exclude types?

@gajus
Copy link
Author

gajus commented Nov 27, 2023

That's probably why.

so... few suggestions for improvement here:

  • should throw an error if unknown exclude member provided
  • should align error messages with the type names
    • i.e. would expect that OrganizationExternalLink type src/contra-api/types.ts:2091:13 says "types"

@webpro
Copy link
Member

webpro commented Nov 27, 2023

should throw an error if unknown exclude member provided

Thanks for the suggestion, I like this idea.

should align error messages with the type names
i.e. would expect that OrganizationExternalLink type src/contra-api/types.ts:2091:13 says "types"

Although I understand your reasoning, they're not the same thing. The types issue group consists of type, interface and enum. The violation is about a single instance. Totally agree should definitely be documented more clearly!

@gajus
Copy link
Author

gajus commented Nov 27, 2023

Makes sense. Thank you for considering and for the explanation

@webpro webpro closed this as completed in 4e42ff8 Nov 28, 2023
@webpro
Copy link
Member

webpro commented Nov 28, 2023

🚀 This issue has been resolved in v3.1.0. See Release 3.1.0 for release notes.

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

No branches or pull requests

2 participants