Skip to content

Commit

Permalink
Remove unused exports & dead code (using Knip) (#56817)
Browse files Browse the repository at this point in the history
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
  • Loading branch information
webpro and jakebailey authored Jun 27, 2024
1 parent f7833b2 commit 752135e
Show file tree
Hide file tree
Showing 45 changed files with 1,238 additions and 683 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ jobs:
- name: Linter
run: npm run lint

knip:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: '*'
check-latest: true
- run: npm ci

- name: Unused exports
run: npm run knip

format:
runs-on: ubuntu-latest

Expand Down
7 changes: 7 additions & 0 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ export const checkFormat = task({
run: () => exec(process.execPath, ["node_modules/dprint/bin.js", "check"], { ignoreStdout: true }),
});

export const knip = task({
name: "knip",
description: "Runs knip.",
dependencies: [generateDiagnostics],
run: () => exec(process.execPath, ["node_modules/knip/bin/knip.js", "--tags=+internal,-knipignore", "--exclude=duplicates,enumMembers", ...(cmdLineOptions.fix ? ["--fix"] : [])]),
});

const { main: cancellationToken, watch: watchCancellationToken } = entrypointBuildTask({
name: "cancellation-token",
project: "src/cancellationToken",
Expand Down
38 changes: 38 additions & 0 deletions knip.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"includeEntryExports": true,
"entry": [
"Herebyfile.mjs",
"src/cancellationToken/cancellationToken.ts",
"src/testRunner/_namespaces/Harness.ts",
"src/tsc/tsc.ts",
"src/tsserver/server.ts",
"src/typescript/typescript.ts",
"src/typingsInstaller/nodeTypingsInstaller.ts",
"src/watchGuard/watchGuard.ts",

"src/testRunner/tests.ts",
"src/testRunner/_namespaces/Harness.ts",

// The rest of the entry files, mostly to track used dependencies:
".eslint-plugin-local.cjs",
".gulp.js",
"scripts/eslint/{rules,tests}/*.cjs",
"scripts/*.{cjs,mjs}"
],
"project": [
"src/**",
"scripts/**",
"!src/lib/**/*.d.ts"
],
"ignore": [
"scripts/failed-tests.d.cts"
],
"ignoreDependencies": ["c8", "eslint-formatter-autolinkable-stylish", "mocha-fivemat-progress-reporter"],
"ignoreExportsUsedInFile": {
"enum": true,
"interface": true,
"type": true
},
"mocha": false
}
Loading

0 comments on commit 752135e

Please sign in to comment.