Skip to content

Commit

Permalink
Re-format markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 3, 2023
1 parent 2e7f099 commit 122ccc1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 26 deletions.
50 changes: 34 additions & 16 deletions README.md
Expand Up @@ -80,7 +80,9 @@ For updates or questions, come hang out in [The Knip Barn (Discord)][10], or fol

### Installation

npm install -D knip
```
npm install -D knip
```

Knip supports LTS versions of Node.js, and currently requires at least Node.js v16.17 or v18.6.

Expand Down Expand Up @@ -445,7 +447,9 @@ In a more fine-grained manner, you can also ignore only specific issue types:

When a repository is self-contained or private, you may want to include entry files when reporting unused exports:

knip --include-entry-exports
```
knip --include-entry-exports
```

Knip will also report unused exports in entry source files and scripts (such as those referenced in `package.json`). But
not in entry and configuration files from plugins, such as `next.config.js` or `src/routes/+page.svelte`.
Expand Down Expand Up @@ -587,12 +591,16 @@ Alternatively, they can be added to the configuration (e.g. `"exclude": ["depend

Use `--include` to report only specific issue types (the following example commands do the same):

knip --include files --include dependencies
knip --include files,dependencies
```
knip --include files --include dependencies
knip --include files,dependencies
```

Use `--exclude` to ignore reports you're not interested in:

knip --include files --exclude classMembers,enumMembers
```
knip --include files --exclude classMembers,enumMembers
```

Use `--dependencies` or `--exports` as shortcuts to combine groups of related types.

Expand Down Expand Up @@ -660,7 +668,8 @@ Knip takes the following JSDoc/TSDoc tags into account:

## Command Line Options

$ npx knip --help
```
$ npx knip --help
✂️ Find unused files, dependencies and exports in your JavaScript and TypeScript projects
Usage: knip [options]
Expand Down Expand Up @@ -704,6 +713,7 @@ Knip takes the following JSDoc/TSDoc tags into account:
$ knip --debug --debug-file-filter '(specific|particular)-module'
More documentation and bug reports: https://github.com/webpro/knip
```

## Potential boost with `--no-gitignore`

Expand Down Expand Up @@ -739,33 +749,41 @@ Below some similar commands to get another idea of what Knip does in comparison:

The following commands are similar:

depcheck
knip --dependencies
```
depcheck
knip --dependencies
```

### unimported

The following commands are similar:

unimported
knip --production --dependencies --include files
```
unimported
knip --production --dependencies --include files
```

Also see [production mode][25].

### ts-unused-exports

The following commands are similar:

ts-unused-exports
knip --include exports,types,nsExports,nsTypes
knip --exports # Adds unused enum and class members
```
ts-unused-exports
knip --include exports,types,nsExports,nsTypes
knip --exports # Adds unused enum and class members
```

### ts-prune

The following commands are similar:

ts-prune
knip --include exports,types
knip --exports # Adds unused exports/types in namespaces and unused enum/class members
```
ts-prune
knip --include exports,types
knip --exports # Adds unused exports/types in namespaces and unused enum/class members
```

## Projects using Knip

Expand Down
22 changes: 12 additions & 10 deletions docs/writing-a-plugin.md
Expand Up @@ -108,15 +108,17 @@ automatically added to [`ENTRY_FILE_PATTERNS`][12].

The `findDependencies` function should do three things:

1. Load and execute the provided configuration file.
2. Find dependencies referenced in this configuration.
3. Return an array of the dependencies.
1. Load and execute the provided configuration file.
2. Find dependencies referenced in this configuration.
3. Return an array of the dependencies.

For example, you are using Cool Linter in your project, and running Knip results in some false positives:

Unused dependencies (2)
@cool-linter/awesome-addon
@cool-linter/priority-plugin
```
Unused dependencies (2)
@cool-linter/awesome-addon
@cool-linter/priority-plugin
```

This is incorrect, since you have `cool-linter.config.json` that references those dependencies!

Expand Down Expand Up @@ -204,10 +206,10 @@ Cool Linter does not require such files, so we can remove them from our plugin.

Let's update the tests to verify our plugin implementation is working correctly.

1. Let's save the example `cool-linter.config.json` in the fixtures directory. Create the file in your IDE, and save it
at `fixtures/plugins/cool-linter/cool-linter.config.json`.
1. Let's save the example `cool-linter.config.json` in the fixtures directory. Create the file in your IDE, and save it
at `fixtures/plugins/cool-linter/cool-linter.config.json`.

2. Update the test at `tests/plugins/cool-linter.test.ts`:
2. Update the test at `tests/plugins/cool-linter.test.ts`:

```ts
test('Find dependencies in cool-linter configuration (json)', async () => {
Expand All @@ -219,7 +221,7 @@ test('Find dependencies in cool-linter configuration (json)', async () => {

This verifies the dependencies in `cool-linter.config.json` are correctly returned to the Knip program.

3. Run the test:
3. Run the test:

```sh
npx tsx tests/plugins/cool-linter.test.ts
Expand Down

0 comments on commit 122ccc1

Please sign in to comment.