-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Build: Use Knip for project linting #29111
Conversation
Initial results are lengthy but useful. Took quite a few samples and this list is actionable if you'd ask me. What do you think? Should the issues be dealt with in this PR too? Perhaps that's a bit much, but let's discuss. Here's the starting point: Unused files (25)
Unused dependencies (152)
Unused devDependencies (42)
Referenced optional peerDependencies (6)
Unlisted dependencies (28)
Unlisted binaries (71)
Unresolved imports (9)
Unused exports (275)
Unused exported types (146)
Unused exported enum members (8)
Duplicate exports (4)
|
Going to make a new "github-collapsible" reporter for output like this btw 😅 |
1511e46
to
9f15da5
Compare
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 84236d8. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
Damn that's a lot of dirt to cleanup! 😅 I can't verify all of it, but a big portion of this looks good and really useful list!
|
Good! Knip isn't perfect and there will be false positives, but I think, say, 90% accuracy is way more useful than not using Knip at all.
I think the end goal is to have CI fail if Knip finds something. We're not there yet, and as it's a bit much I guess there should be a plan first. Depending on things like project/team organization, available resources, time, etc.:
I'll hit you up on Discord so we can discuss further if you'd like. Btw there's a Knip GitHub Action (3rd party).
In general, if both the root and the descendent workspace list a dependency, and the dependency is referenced only in the descendent workspace, it'll be reported as unused in the root workspace. That said, dependencies for a specific workspace can be ignored like so:
|
Nice! Then my suggestion is to add this to the CircleCI configuration with Will you add the CI step and then this might be ready for review? |
bb851c7
to
438a4e6
Compare
438a4e6
to
01cca67
Compare
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.
5 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings
for (const configKey of Object.keys(baseConfig.workspaces)) { | ||
if (match([wsDir], configKey)) { | ||
const manifest = await import(join(baseDir, wsDir, 'package.json')); | ||
const configEntries = (config.workspaces[configKey].entry as string[]) ?? []; |
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.
logic: This line assumes config.workspaces[configKey].entry is always defined. Add a check to ensure it exists before casting.
Closes #29106
What I did
package.json#bundler
entries as entry pathsChecklist for Contributors
Manual testing
Documentation
N/A?
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Greptile Summary
This PR introduces Knip, a tool for identifying unused files and exports, to the Storybook project with custom configuration.
scripts/knip.config.ts
with project-specific settings and dynamic bundler entry detectionnormal
,merged
,daily
) after thebuild
jobknip
script to rootpackage.json
andcode/package.json
for easy executionknip
dependency inscripts/package.json
for development purposes