Skip to content
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

💡 ignoreImportsUsedInFiles: [] #782

Open
tizmagik opened this issue Sep 16, 2024 · 0 comments
Open

💡 ignoreImportsUsedInFiles: [] #782

tizmagik opened this issue Sep 16, 2024 · 0 comments
Labels
feature request Feature request

Comments

@tizmagik
Copy link

Suggest an idea for this project

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.

@tizmagik tizmagik added the feature request Feature request label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request
Projects
None yet
Development

No branches or pull requests

1 participant