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

Allow marking a whole directory of exports as @internal via knip config file #553

Open
camjackson opened this issue Mar 17, 2024 · 0 comments
Labels
feature request Feature request

Comments

@camjackson
Copy link

Context

In short:

  • My project contains dozens of test helper functions for things like constructing test data, and mocking dependencies
  • When running knip in --production mode:
    • A test helper should be marked as dead code if it is not used anywhere at all
    • A test helper should not be marked as dead code if it is only called from test code

As discussed previously on discord (link to original message, link to subsequent thread), the above requirements can be met by the @internal tag. However, given that:

  1. I'm not currently using JS/TSDoc; and
  2. I have many of these helpers; and
  3. They are all located in a single directory;

I would much prefer to mark the whole directory as being "internal" rather than tagging each export individually in the code.

Proposal

Similar to how the knip config file allows me to ignore files, I would like to mark files/directories as internal via the config file. E.g.

// knip.ts

const knipConfig = {
  ignore: [
    'src/someExceptionalFile.ts',
  ],
  internal: [
    'src/testHelpers/',
  ],
};

export default knipConfig;

This would be equivalent to adding the @internal tag to everything that's exported from that module or directory.

@camjackson camjackson added the feature request Feature request label Mar 17, 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