Skip to content

Commit

Permalink
feat(ci): Add knip, remove depcheck (#140)
Browse files Browse the repository at this point in the history
Adds a (kind of lame) initial configuration for
[knip](https://github.com/webpro/knip), which replaces depcheck. By
default, this will report on a lot of useful stuff, so may require
further tuning/configuration as we learn how to use it preoperly.

(While getting this PR ready, `knip` actually complained to me after I
`yarn remove`'d `depcheck` but _before_ I updated the GH workflow to use
`knip` instead of `depcheck`. It was able to detect that without
`depcheck` installed, there was no such binary named `depcheck`
available in the package, which we were still referencing in the GH
workflow -- kind of wild!!)
  • Loading branch information
jophish authored Nov 2, 2023
1 parent 4d0bc95 commit bc22e99
Show file tree
Hide file tree
Showing 6 changed files with 876 additions and 319 deletions.
3 changes: 0 additions & 3 deletions .depcheckrc

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
- run: yarn typecheck
- run: yarn format:check
- run: yarn lint
depcheck:
name: Depcheck
knip:
name: Knip
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -44,7 +44,7 @@ jobs:
node-version: '18'
check-latest: true
- run: yarn
- run: yarn depcheck
- run: yarn knip
test:
name: Test
runs-on: ubuntu-latest
Expand Down
5 changes: 5 additions & 0 deletions .knip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"entry": ["src/index.ts"],
"project": ["src/**/*/.ts"],
"ignoreDependencies": ["@types/jest", "@valora/prettier-config"]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ This project uses [ESLint](https://eslint.org/) for linting. That is configured

We use [Prettier](https://prettier.io) for auto-formatting. It's recommended to install an editor plugin (like the [VSCode Prettier plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)) to get auto-formatting on save. There's also a `yarn format` script you can run to format all files in the project.

## Dependency Checking
## Dependency / Unused Code Checking

This project uses [depcheck](https://github.com/depcheck/depcheck) for checking dependency use. It's configured in [`.depcheckrc`](.depcheckrc).
This project uses [knip](https://github.com/webpro/knip) for checking both unused dependencies and code within the repo. This tool can catch a *lot* of stuff, including unused dependencies, functions, types, unnecessary/duplicate exports, unused class/enum members, etc. It's configured in [`.knip.json`](.knip.json).

## Scripts

Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
"lint:fix": "yarn lint --fix",
"format": "prettier --log-level error --write .",
"format:check": "prettier --check .",
"depcheck": "depcheck",
"test": "jest",
"test:watch": "yarn test --watch",
"test:ci": "yarn test --ci --coverage",
"supercheck": "yarn format && yarn lint:fix && yarn typecheck && yarn depcheck && yarn test",
"supercheck": "yarn format && yarn lint:fix && yarn typecheck && yarn knip && yarn test",
"example": "ts-node ./scripts/example.ts",
"deploy": "echo 'Deployed!'"
"deploy": "echo 'Deployed!'",
"knip": "knip"
},
"devDependencies": {
"@types/jest": "^29.5.6",
"@types/shelljs": "^0.8.14",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@valora/eslint-config-typescript": "^1.0.2",
"@valora/prettier-config": "^0.0.1",
"depcheck": "^1.4.7",
"eslint": "^8.48.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.0.0",
"jest": "^29.7.0",
"knip": "^2.38.6",
"prettier": "^3.0.3",
"shelljs": "^0.8.5",
"ts-jest": "^29.1.1",
Expand Down
Loading

0 comments on commit bc22e99

Please sign in to comment.