Skip to content

Improve Knip configuration for monorepo setup #3884

@KJ7LNW

Description

@KJ7LNW

This issue references the discussion in PR #3810 about improving our Knip configuration for the monorepo setup.

@webpro (who is the primary Knip developer) suggested the following configuration which would be more effective for our monorepo structure:

{
"$schema": "https://unpkg.com/knip@latest/schema.json",
"workspaces": {
".": {
"entry": ["src/extension.ts", "src/workers/countTokens.ts", "src/**/__tests__/**/*{b,B}enchmark.ts"],
"project": ["src/**/*.ts"]
},
"webview-ui": {
"entry": ["src/index.tsx"],
"project": ["src/**/*.{ts,tsx}"]
}
},
"ignore": ["**/__mocks__/**"]
}

Key points from @webpro:

  1. In a monorepo, the top-level entry and project options are not effective and should be in the root workspace config at workspaces["."]
  2. Using --debug can help see the "Included workspace configs" that Knip uses
  3. The ignore option in the config can be removed entirely after installing [email protected] or later

This configuration would help resolve issues like the one encountered with src/utils/storageUtils.ts being flagged incorrectly.

cc: @webpro @cte

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions