I'd like to have a VS Code Task for knip that has a problemMatcher. The output format of knip isn't the best for parsing. Here's an example of what I see:
$ pnpm lint:knip
Analyzing workspace ....
Unused devDependencies (1)
ts-node package.json
Unused exports (3)
runFile function src/main.ts:10:23
runPrompt function src/main.ts:15:23
tokenToString function src/token.ts:10:17
Here's a problemMatcher
that I've written that at least matches the "Unused exports" bit:
{
"type": "npm",
"script": "lint:knip",
"label": "npm: lint:knip",
"detail": "knip",
"problemMatcher": {
"owner": "tsc",
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": [
{
"regexp": "^([^\\s].*) \\(\\d+\\)$",
"message": 1
},
{
"regexp": "([^ ]+) +([^ ]+) +([^:]+):(\\d+):(\\d+)",
"file": 3,
"line": 4,
"column": 5,
"loop": true
}
]
}
}
This works pretty well:
But it's a bit of a bummer that I had to write these regexes and that there aren't line numbers for the unused devDependencies.
So call this a feature request for a new reporter that's compatible with one of VS Code's built-in problem matchers, for example "tsc" or "eslint".
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too