It would be great to be able to specify specific files that shouldn't count as "usage" for a particular export.
In one of my projects, if the import is used in a particular file, we don't want it to count as it actually being used because it's a common place to import a long list of them to add some meta data/behavior, but it doesn't mean it will actually be used in the application code.
For example, deleting that specific file and re-running Knip would report the export as unused and that is the sort of the behavior we're looking for.
generated.ts
/* Generate file with a bunch of exports */
export FOO1 = "123";
export FOO2 = "456";
// ...
meta-function.ts
/* Common place to import all of them and register some meta behavior */
import { FOO1, FOO2 } from './generated.ts';
meta(FOO1, FOO2);
app.ts
/* App code */
import {FOO1} from './generated.ts';
doWork(FOO1);
We don't want FOO2
to be counted as used since it's not referenced by App code.
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