Instead of a JSON file, you can use a JavaScript or TypeScript file for a dynamic configuration and type annotations:
import type { KnipConfig } from 'knip'; const config: KnipConfig = { entry: ['src/index.ts'], project: ['src/**/*.ts'],}; export default config;
/** @type {import('knip').KnipConfig} */const config = { entry: ['src/index.ts'], project: ['src/**/*.ts'],}; export default config;
You can export a regular or async function that returns the configuration object as well:
import type { KnipConfig } from 'knip'; const config = async (): Promise<KnipConfig> => { const items = await fetchRepoInfo(); return { entry: ['src/index.ts', ...items], project: ['src/**/*.ts'], };}; export default config;
const config = async () => ({ entry: ['src/index.ts'], project: ['src/**/*.ts'],}); export default config;
ISC License © 2024 Lars Kappert