Skip to content

Using Knip in CI

Knip is your companion during local development. But it is even more valuable in a continuous integration (CI) environment to prevent regressions over time. Knip will notify you of unused files, dependencies and exports if you forgot to remove them.

Knip will exit the process with code 1 if there are one or more issues.

GitHub Actions

Here’s an example workflow configuration for GitHub Actions:

name: Lint project
on: push
jobs:
lint:
runs-on: ubuntu-latest
name: Ubuntu/Node v20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Install dependencies
run: npm install --ignore-scripts
- name: Run knip
run: npm run knip

Notes

In CI environments, the —no-progress flag is set automatically.

ISC License © 2024 Lars Kappert