-
-
Notifications
You must be signed in to change notification settings - Fork 202
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
feat: add dependency-cruiser plugin #911
Conversation
commit: |
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.
Awesome! Love that you also did the args
thing :)
const config = ['.dependency-cruiser.{js,cjs,mjs,json}']; | ||
|
||
const args = { | ||
binaries: ['depcruise'], |
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.
looks like they have many: https://github.com/sverweij/dependency-cruiser/blob/c48aca959c9c9c1b1068c6d85cd4ed368de10d27/package.json#L74-L80
any chance you could add those as well?
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, added the relevant ones
binaries: ['depcruise'], | ||
alias: { config: ['c'] }, | ||
string: ['config'], | ||
config: true, |
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.
setting config: true
is a shorthand that sets the alias
and string
options as well:
knip/packages/knip/src/types/args.ts
Lines 59 to 69 in 5a77dcc
/** | |
* Define arguments that contain config file path. | |
* Usually you'll want to set aliases too. Use `true` for shorthand to set `alias` + `string` + `config` | |
* | |
* @example `config: ["p"]` for e.g. `tsc -p tsconfig.lib.json` | |
* | |
* @example `config: true` for e.g. `tsup --config tsup.client.json` | |
* | |
* @default undefined | |
*/ | |
config?: ConfigArg; |
just a heads-up, no need to change if you prefer explicit
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.
Nice, I didn't know that
|
||
// Check that dependencies are properly detected | ||
assert(issues.devDependencies['package.json']['dependency-cruiser']); | ||
assert(issues.binaries['package.json']['depcruise']); |
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 usually do is add the most minimal package in an actual node_modules
folder with e.g. { "name": "dependency-cruiser", "bin": { ... } }
in package.json
and an empty index.js
- that way, Knip does the full machinery and there should be no issues left (random example: https://github.com/webpro-nl/knip/tree/main/packages/knip/fixtures/plugins/angular/node_modules/@angular/cli).
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.
That's awesome. I was a bit lost working on the test
@webpro Is there an option to colocate tests and fixtures? It was a bit annoying how far they were in the file structure when working on the test. I'm happy to open a PR moving it around |
Gotcha. I can relate, but overall this structure is very convenient to me. |
Thanks for taking care of that. Was a bit busy this week |
🚀 This pull request is included in v5.42.1. See Release 5.42.1 for release notes. Using Knip in a commercial project? Please consider becoming a sponsor. |
No worries, was tiny change. Thanks again for the PR! |
Fixes: #907