Skip to content

Commit e7d1c53

Browse files
authored
chore: QA tool to detect missing dependencies (#344)
use `knip` to test for missing dependencies. since the `import/no-extraneous-dependencies` eslint rule is not working. --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent ba8bdb7 commit e7d1c53

File tree

4 files changed

+346
-3
lines changed

4 files changed

+346
-3
lines changed

.github/workflows/nodejs.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,30 @@ jobs:
133133
- name: test
134134
run: yarn run test:lint
135135

136+
test-dependencies:
137+
name: test lint
138+
runs-on: ubuntu-latest
139+
timeout-minutes: 10
140+
steps:
141+
- name: Checkout
142+
# see https://github.com/actions/checkout
143+
uses: actions/checkout@v4
144+
- run: mkdir -p ${{ env.REPORTS_DIR }}
145+
- name: Setup Node.js ${{ matrix.node-version }}
146+
# see https://github.com/actions/setup-node
147+
uses: actions/setup-node@v4
148+
with:
149+
node-version: ${{ env.NODE_ACTIVE_LTS }}
150+
# cache: 'yarn'
151+
- name: Setup yarn
152+
run: corepack enable yarn
153+
- name: Setup subject
154+
run: yarn install --immutable
155+
- name: build
156+
run: yarn run build:gbti
157+
- name: test
158+
run: yarn run test:dependencies
159+
136160
test-licenses:
137161
needs: [ 'build' ]
138162
name: test licenses

knip.jsonc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@5/schema-jsonc.json",
3+
"entry": [
4+
"src/plugin.ts!",
5+
"bin/**!",
6+
"index.js!"
7+
],
8+
"project": [
9+
"src/**!",
10+
"bin/**!",
11+
"tests/**",
12+
"!tests/_data/testbeds/**"
13+
],
14+
"ignore": [
15+
"tools/**"
16+
],
17+
"ignoreDependencies": [
18+
// needed to force the installation of the optional dependency of a 3rd party package:
19+
"xmlbuilder2"
20+
]
21+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"extract-zip": "^2.0.1",
8787
"fast-glob": "^3.3.2",
8888
"globals": "^16.0.0",
89+
"knip": "5.61.3",
8990
"mkdirp": "^3.0.1",
9091
"mocha": "11.7.1",
9192
"neostandard": "0.12.2",
@@ -147,6 +148,7 @@
147148
"test:standard": "eslint .",
148149
"test:lint": "tsc --noEmit",
149150
"test:node": "c8 mocha -p",
151+
"test:dependencies": "knip --include dependencies,unlisted,unresolved --production",
150152
"cs-fix": "eslint --fix .",
151153
"dogfooding": "node $PROJECT_CWD/bin/cyclonedx-yarn-cli.js"
152154
},

0 commit comments

Comments
 (0)