Skip to content

Commit c652bda

Browse files
chore: introduce knip (#174)
* chore: add knip + config * chore: simplify glob pattern for eslint markdown override * chore: remove ts-prune & replace workflow * chore: add dependencies to ignore (until Knip has related plugins) * chore: remove unused yargs package * chore: add markdownlint to ignored dependencies * chore: enable production mode in knip's config * Sorting, and removed yargs * Add knip to cspell.json * chore: remove dependencies now having plugins in Knip config * docs: replace ts-prune with knip * Fix lint * Updated docs and setup script * Bump knip and ignore eslint-plugin-markdown * Simplify output knip.jsonc Co-authored-by: Josh Goldberg <[email protected]>
1 parent 80e0a78 commit c652bda

File tree

10 files changed

+857
-276
lines changed

10 files changed

+857
-276
lines changed

.github/DEVELOPMENT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ It should be applied automatically when you save files in VS Code or make a Git
3131
This package includes several forms of linting to enforce consistent code quality and styling.
3232
Each should be shown in VS Code, and can be run manually on the command-line:
3333

34-
- `pnpm lint` ([ESLint](https://eslint.org) with [typescript-eslint](https://typescript-eslint.io)): Lints JavaScript and TypeScript source files
34+
- `pnpm lint:knip` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports
3535
- `pnpm lint:md` ([Markdownlint](https://github.com/DavidAnson/markdownlint)): Checks Markdown source files
3636
- `pnpm lint:package` ([npm-package-json-lint](https://npmpackagejsonlint.org/)): Lints the `package.json` file
3737
- `pnpm lint:packages` ([pnpm-deduplicate](https://github.com/ocavue/pnpm-deduplicate)): Deduplicates packages in the `pnpm-lock.yml` file
38-
- `pnpm lint:prune` ([ts-prune](https://github.com/nadeesha/ts-prune)): Detects unused exports in TypeScript source files
3938
- `pnpm lint:spelling` ([cspell](https://cspell.org)): Spell checks across all source files
39+
- `pnpm lint` ([ESLint](https://eslint.org) with [typescript-eslint](https://typescript-eslint.io)): Lints JavaScript and TypeScript source files
4040

4141
## Testing
4242

@@ -47,7 +47,7 @@ You can run it locally on the command-line:
4747
pnpm run test
4848
```
4949

50-
Add the `--coverage` flat to compute test coverage and place reports in the `coverage/` directory:
50+
Add the `--coverage` flag to compute test coverage and place reports in the `coverage/` directory:
5151

5252
```shell
5353
pnpm run test --coverage
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint Prune
1+
name: Lint Knip
22

33
on:
44
push:
@@ -7,9 +7,9 @@ on:
77
pull_request:
88

99
jobs:
10-
prune:
10+
knip:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v3
1414
- uses: ./.github/actions/prepare
15-
- run: pnpm lint:prune
15+
- run: pnpm lint:knip

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ jobs:
6464
checks: [
6565
{ context: "build" },
6666
{ context: "compliance" },
67+
{ context: "knip" },
6768
{ context: "lint" },
6869
{ context: "markdown" },
6970
{ context: "package" },
7071
{ context: "packages" },
7172
{ context: "prettier" },
72-
{ context: "prune" },
7373
{ context: "spelling" },
7474
{ context: "test" },
7575
],

.ts-prunerc

Lines changed: 0 additions & 4 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ It sets up the following tooling for you:
3333

3434
- [**All Contributors**](https://allcontributors.org): Tracks various kinds of contributions and displays them in a nicely formatted table in the README.md.
3535
- [**ESLint**](https://eslint.org): Static analysis for JavaScript code, configured with [typescript-eslint](https://typescript-eslint.io) for TypeScript code and other general-use plugins.
36+
- [**Knip**](https://github.com/webpro/knip): Detects unused files, dependencies, and code exports.
3637
- [**Markdownlint**](https://github.com/DavidAnson/markdownlint): Static analysis for Markdown code.
3738
- [**pnpm**](https://pnpm.io): Disk-efficient package manager alternative.
3839
- [**PR Compliance Action**](https://github.com/mtfoley/pr-compliance-action): Checks PRs for compliance on chore such as addressing a linked issue and proper title formatting.
3940
- [**Prettier**](https://prettier.io): Opinionated formatting for code, run on file save and as a Git commit hook via [husky](https://typicode.github.io/husky) and [lint-staged](https://github.com/okonet/lint-staged).
4041
- [**release-it**](https://github.com/release-it/release-it): Generates changelogs, bumps the package version, and publishes to GitHub and npm based on [conventional commits](https://www.conventionalcommits.org).
4142
- [**Renovate**](https://docs.renovatebot.com): Keeps dependencies up-to-date with PRs, configured to wait a few days after each update for safety.
42-
- [**ts-prune**](https://github.com/nadeesha/ts-prune): Unused exports detection for TypeScript code.
4343
- [**TypeScript**](https://typescriptlang.org): A typed superset of JavaScript, configured with strict compiler options.
4444
- [**Vitest**](https://vitest.dev): Fast unit tests, configured with coverage tracking.
4545

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"contributorsrc",
1717
"conventionalcommits",
1818
"infile",
19+
"knip",
1920
"lcov",
2021
"quickstart",
2122
"wontfix"

knip.jsonc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@next/schema.json",
3+
"entry": ["src/index.ts!", "script/setup*.js"],
4+
"project": ["src/**/*.ts!", "script/**/*.js"],
5+
6+
"ignoreDependencies": [
7+
// Remove when Knip understands ESLint overrides > extends:
8+
"eslint-plugin-markdown",
9+
// Remove when Knip extends the release-it plugin to pluck binaries from hooks:
10+
"should-semantic-release"
11+
]
12+
}

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"@typescript-eslint/parser": "^5.48.2",
77
"@vitest/coverage-istanbul": "^0.27.2",
88
"chalk": "^5.2.0",
9-
"cspell": "^6.19.0",
9+
"cspell": "^6.19.1",
1010
"enquirer": "^2.3.6",
1111
"eslint": "^8.32.0",
1212
"eslint-config-prettier": "^8.6.0",
@@ -21,6 +21,7 @@
2121
"eslint-plugin-vitest": "^0.0.29",
2222
"husky": "^8.0.3",
2323
"jsonc-eslint-parser": "^2.1.0",
24+
"knip": "1.9.0",
2425
"lint-staged": "^13.1.0",
2526
"markdownlint": "^0.27.0",
2627
"markdownlint-cli": "^0.33.0",
@@ -33,10 +34,8 @@
3334
"replace-in-file": "^6.3.5",
3435
"sentences-per-line": "^0.2.1",
3536
"should-semantic-release": "^0.0.1",
36-
"ts-prune": "^0.10.3",
3737
"typescript": "^4.9.4",
38-
"vitest": "^0.27.2",
39-
"yargs": "^17.6.2"
38+
"vitest": "^0.27.2"
4039
},
4140
"engines": {
4241
"node": ">=18"
@@ -57,10 +56,10 @@
5756
"format": "prettier \"**/*\" --ignore-unknown",
5857
"format:write": "pnpm format --write",
5958
"lint": "eslint . --max-warnings 0 --report-unused-disable-directives",
59+
"lint:knip": "knip",
6060
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
6161
"lint:package": "npmPkgJsonLint .",
6262
"lint:packages": "pnpm-deduplicate --list",
63-
"lint:prune": "ts-prune",
6463
"lint:spelling": "cspell \"**\" \".github/**/*\"",
6564
"prepare": "husky install",
6665
"setup": "npx --yes zx --quiet script/setup.js",

0 commit comments

Comments
 (0)