-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Improve knip reports by using a single config with workspaces #28491
base: master
Are you sure you want to change the base?
Conversation
Changed Packages
|
1862ff0
to
845e2b7
Compare
This only includes a changeset for repo-tools, as I'm only changing the knip-report files in the other packages. Given that those are not exposed on npm, I don't rev those packages. Actually addressing the unused deps would be in follow-up PRs. CC @freben, we quickly talked about the knip false-positives on discord. Not quite yet at the point where there are none, but much closer. |
PS: the following packages don't have reports at all yet, not sure if it's good to add them in this PR:
|
entry: [ | ||
'dev/index.{ts,tsx}', | ||
'src/index.{ts,tsx}', | ||
'src/alpha.{ts,tsx}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to generate this based on the actual package.json files. Some packages have MANY entrypoints (notably backend-defaults).
Regarding extensions, we're adding more in #19855
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entrypoints work, I just cross-checked backend-defaults.
This fixes alpha, we only have two packages (I think), which don't expose an existing src/alpha.ts
:
grep -L ./alpha `ls p*/*/src/alpha.ts|sed -e s'|src/alpha.ts|package.json|'`
packages/cli/package.json
plugins/scaffolder-backend-module-sentry/package.json
The scaffolder one is empty, not sure about the cli one?
This won't cover the dev
directories for the dev server, though.
I tested dropping src/index.{ts,tsx}
, but that triggered more false positives. I didn't dig in deep, but repo-tools is one of them. It only exposes the dist cjs, which one may not have. This might need some more dedicated research.
Re extensions, is that the right PR? That's 2023?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh no I meant #28308
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant with the entrypoints is, does it understand that for example this file is an entirely separate entrypoint too, and that any dependencies it uses need to be taken into account as well, in addition to the root index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, excerpt from running knip --debug:
[packages/backend-defaults] Finding package.json entry paths
{
patterns: [
'packages/backend-defaults/package.json',
'packages/backend-defaults/src/entrypoints/userInfo/index.ts',
'packages/backend-defaults/src/entrypoints/urlReader/index.ts',
'packages/backend-defaults/src/entrypoints/scheduler/index.ts',
'packages/backend-defaults/src/entrypoints/rootLogger/index.ts',
'packages/backend-defaults/src/entrypoints/rootLifecycle/index.ts',
'packages/backend-defaults/src/entrypoints/rootHttpRouter/index.ts',
'packages/backend-defaults/src/entrypoints/rootHealth/index.ts',
'packages/backend-defaults/src/entrypoints/rootConfig/index.ts',
'packages/backend-defaults/src/entrypoints/permissions/index.ts',
'packages/backend-defaults/src/entrypoints/permissionsRegistry/index.ts',
'packages/backend-defaults/src/entrypoints/logger/index.ts',
'packages/backend-defaults/src/entrypoints/lifecycle/index.ts',
'packages/backend-defaults/src/entrypoints/httpRouter/index.ts',
'packages/backend-defaults/src/entrypoints/httpAuth/index.ts',
'packages/backend-defaults/src/entrypoints/discovery/index.ts',
'packages/backend-defaults/src/entrypoints/database/index.ts',
'packages/backend-defaults/src/entrypoints/cache/index.ts',
'packages/backend-defaults/src/entrypoints/auth/index.ts',
'packages/backend-defaults/src/index.ts'
],
...
paths: [
'/Users/54717/src/backstage/backstage/packages/backend-defaults/package.json',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/userInfo/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/urlReader/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/scheduler/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/rootLogger/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/rootLifecycle/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/rootHttpRouter/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/rootHealth/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/rootConfig/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/permissions/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/permissionsRegistry/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/logger/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/lifecycle/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/httpRouter/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/httpAuth/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/discovery/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/database/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/cache/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/entrypoints/auth/index.ts',
'/Users/54717/src/backstage/backstage/packages/backend-defaults/src/index.ts'
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rebased this ontop of #28308 now that that's merged, and I needed some adjustment for the tests.
Otherwise, this works like expected, I think.
|
||
| Name | Location | Severity | | ||
| :----------------- | :-------------------------------- | :------- | | ||
| @internal/frontend | src/app/createExtensionTester.tsx | error | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be neat to not list the internal ones. They are marked as such in package.json, which is a better way of detect them than by name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this is something we need to discuss. This might be a topic to bring up with the knip folks upstream.
I wonder if a mono-repo and "private": true,
in package.json would be enough of a signal. Though, looking at https://github.com/search?q=repo%3Awebpro-nl%2Fknip+private+path%3A%2F%5Epackages%5C%2Fknip%5C%2Ffixtures%5C%2F%2F&type=code it seems that that signal is already used in their test fixtures.
The
"backstage": {
"role": "web-library",
"inline": true
},
part would only be available to plugins, which need to be upstream. And I don't see a way to extend ignored dependencies from those. Another thing to check.
Should I just add something name-based for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's the Backstage specific "online" concept I meant indeed.
Maybe let's leave it as a future improvement. It's still a lot better than before either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with a regexp on the name for now.
7578146
to
8e0de41
Compare
Also move the dependency from the workspace into repo-tools. The run with a configured workspace is slower, so I had to bump the timeout. Signed-off-by: Axel Hecht <axel@pike.org>
Also remove a stray one Signed-off-by: Axel Hecht <axel@pike.org>
Let's figure out later what triggers those Signed-off-by: Axel Hecht <axel@pike.org>
Signed-off-by: Axel Hecht <axel@pike.org>
Signed-off-by: Axel Hecht <axel@pike.org>
Using just the naming convention for now. Signed-off-by: Axel Hecht <axel@pike.org>
Canon uses a different setup for storybook Signed-off-by: Axel Hecht <axel@pike.org>
Signed-off-by: Axel Hecht <axel@pike.org>
8e0de41
to
7e5fa38
Compare
I back-filled the missing reports now, too. Only canon is not done, because that has a storybook setup that differs from the rest, so I'd recommend that to be done in a follow-up. @freben , this should be ready for another look. |
Also move the dependency from the workspace into repo-tools.
The run with a configured workspace is slower, so I had to bump the timeout.
Hey, I just made a Pull Request!
✔️ Checklist
Signed-off-by
line in the message. (more info)