webpro-nl / knip

βœ‚οΈ Find unused files, dependencies and exports in your JavaScript and TypeScript projects. Knip it before you ship it!
https://knip.dev
ISC License
7.03k stars 174 forks source link

πŸ› List of unused files is not sorted by path #817

Closed kachkaev closed 3 weeks ago

kachkaev commented 3 weeks ago

Prerequisites

Reproduction url

https://codesandbox.io/p/devbox/mrk95r?migrateFrom=7cy572

Reproduction access

Description of the issue

πŸ‘‹ @webpro, glad to see the project rolling! I just configured knip in a new monorepo and noticed that the list of unused files was not sorted by path. As you can see from the reproduction,

a/b/d.ts
a/y.ts
a/z.ts
b/a/42.ts
b/x.ts
b/y.ts
c.ts

gets printed by pnpm knip as:

c.ts
a/y.ts
a/z.ts
b/x.ts
b/y.ts
a/b/d.ts πŸ‘ˆ  πŸ‘€ 
b/a/42.ts

It’d be great if the list was sorted in some consistent way. In the project I am trying to lint I get output like this:

apps/foo/src/modules/...
apps/foo/src/modules/...
apps/foo/src/components/...
apps/foo/src/components/...
apps/foo/src/modules/...
apps/foo/src/components/...
apps/foo/src/components/...
...
packages/p4/src/helpers.ts
packages/p1/src/helpers.ts
packages/p3/src/helpers.ts
packages/p2/src/helpers.ts
...

Unsorted workspace names and intermixed modules/components are not the end of the world. But it would help if sibling files were shown next to each other so that it was a bit easier to review them.

Hope that it won’t be too hard to fix this problem because unused files are printed synchronously at the end of the analysis rather than on the fly.

Thanks for knip, it’s very useful!

webpro commented 3 weeks ago

Kinda surprised we didn't do this yet :) Starting out with a simple sort tho:

a.js
b/d.ts
c.js
webpro commented 3 weeks ago

:rocket: This issue has been resolved in v5.34.3. See Release 5.34.3 for release notes.

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