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

💡 Provide configuration helper functions for JS/TS usage #843

Closed
ben-eb opened this issue Nov 21, 2024 · 1 comment
Closed

💡 Provide configuration helper functions for JS/TS usage #843

ben-eb opened this issue Nov 21, 2024 · 1 comment
Labels
feature request Feature request

Comments

@ben-eb
Copy link
Contributor

ben-eb commented Nov 21, 2024

Suggest an idea for this project

Hello 👋

Firstly thanks for your work on this project, it's been super useful and has helped a lot with some recent refactoring work I've done. 🎉

One thing I noticed with the configuration is that it can be a little difficult to scan with the magic ! suffix used for denoting a production entry file. So I found myself writing a couple of helper functions:

import type { KnipConfig } from 'knip';

const config: KnipConfig = {
    entry: [
        production('services/**/index.ts'),
        development('services/**/integration.ts'),
    ],
};

export default config;

function production(file: string): string {
    return `${file}!`;
}

function development(file: string): string {
    return file;
}

Even though these functions are not so complex I find that the "tag" applied to the string makes the configuration much more self-documenting. A new developer to the project will most likely wonder what ! means at the end of a file glob and spend some time looking for this in the documentation.

I was wondering if you would be amenable to adding these helpers to the project itself? Perhaps a not function could work for a leading ! too, though I think !path/to/files/*.ts is much more of a standard pattern these days. 🙂

Thanks!

@ben-eb ben-eb added the feature request Feature request label Nov 21, 2024
@webpro
Copy link
Collaborator

webpro commented Nov 27, 2024

Thanks @ben-eb! To be honest I'm not really in favor of adding this. Since Knip offers a way to author configuration in TypeScript and as you point out such functions are not so complex to write. Now you can name and use them however you prefer.

@webpro webpro closed this as not planned Won't fix, can't repro, duplicate, stale Nov 27, 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

2 participants