Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 7, 2023
1 parent 3277795 commit 925e2f6
Showing 1 changed file with 13 additions and 24 deletions.
37 changes: 13 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,35 +311,28 @@ unused or missing.
Other configuration files use `require` or `import` statements to use dependencies, so they don't need special handing
and can be analyzed like any other source file. That's why these configuration files are also used as `entry` files.

#### Override plugin configuration
#### Plugin configuration

Usually, no custom configuration is required for plugins, but if your project uses custom file locations then Knip
allows you to override any defaults. Let's take Cypress for example. By default it uses `cypress.config.js`, but your
project uses `config/cypress.js`. Also, the default pattern for test files is `cypress/e2e/**/*.cy.js`, but your project
has them at `e2e-tests/*.spec.ts`. Here's how to configure this:
Is a plugin not behaving as expected? There are a few options to modify its behavior:

```json
{
"cypress": {
"entry": ["config/cypress.js", "e2e-tests/*.spec.js"]
}
}
```

When overriding any plugin's configuration, the options object is fully replaced. Look at the plugin's page to find the
default configuration and use that as a basis. Here's another example to override the test file pattern for Vitest:
- Disable a plugin by setting its value to `false` (.e.g `"webpack": false`)
- Force-enable a plugin by setting its value to `true`
- Override a plugin's `config` or `entry` location, for example:

```json
{
"vitest": {
"config": ["vitest.config.ts"],
"entry": ["**/*.vitest.ts"]
"mocha": {
"config": "config/mocha.config.js",
"entry": ["**/*.spec.js"]
}
}
```

This plugin configuration can be set on root and workspace level. If set on root level, it can be disabled on workspace
level by setting it to `false` there.
It's rarely necessary to override the `entry` patterns, since plugins also read custom test file patterns from the
tooling configuration (e.g. from the `include` option for Vitest or `testMatch` for Playwright).

Plugin configuration can be set on root and workspace level. If enabled on root level, it can be disabled on workspace
level by setting it to `false` there, and vice versa.

#### Multi-project repositories

Expand All @@ -355,10 +348,6 @@ own Cypress configuration and test files. In that case, we could configure the C
}
```

#### Disable a plugin

In case a plugin causes issues, it can be disabled by using `false` as its value (e.g. `"webpack": false`).

#### Create a new plugin

Getting false positives because a plugin is missing? Want to help out? Please read more at [writing a plugin][47]. This
Expand Down

0 comments on commit 925e2f6

Please sign in to comment.