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

Issues are not reported in monorepo when workspaces are setup in knip.json #722

Closed
vubogovich opened this issue Jul 10, 2024 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@vubogovich
Copy link

Our monorepo consists of independent packages and does not use npm workspaces yet. As a result, it and requires npm install for each of the package separately. We have setup prettier and eslint in the root package and typescript is configurated independently.

knip is installed on the root package and knip.json has the following content:

{
  "$schema": "https://unpkg.com/knip@5/schema.json",
  "workspaces": {
    "packages/*": {}
  }
}

However, knip reports issues only in the root package. knip --workspace packages/shared suggested in the docs didn't help.

The issues were unused dependency and file unused.ts. Very nice template for reproductions 👍 here is my version.

Thanks a lot for very useful tool! I used it in the normal repo and enjoyed a lot ❤️

@vubogovich vubogovich added the bug Something isn't working label Jul 10, 2024
@webpro
Copy link
Member

webpro commented Jul 10, 2024

If yup is listed in both root and shared package, seems it's unused in root. Expected behavior?

@vubogovich
Copy link
Author

If yup is listed in both root and shared package, seems it's unused in root. Expected behavior?

Expected behavior is all issues from all packages are reported.

It does not matter what dependency, now replaced yup with zod in packages/shared in my example. Both of them unused but only root one is reported. When yup is removed from the root, knip says all good so it ignores packages/shared having unused file and dependency.

@webpro webpro closed this as completed in ca03fd8 Jul 11, 2024
@webpro
Copy link
Member

webpro commented Jul 11, 2024

Sorry, maybe checking that from phone late at night wasn't the best idea.

Non-glob additional workspace names were indeed not added properly (e.g. just "packages/*": {} seems to work fine).

Thanks for the report!

@webpro
Copy link
Member

webpro commented Jul 11, 2024

🚀 This issue has been resolved in v5.25.2. See Release 5.25.2 for release notes.

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

@vubogovich
Copy link
Author

Interesting that I had an issue with the glob workspace name in 5.25.1 but the new version 5.25.2 works like a charm 🥇
Thanks a lot for the prompt solution!

@webpro
Copy link
Member

webpro commented Jul 12, 2024

Thanks @vubogovich!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants