Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused exports & dead code (using Knip) #56817

Merged
merged 30 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
75f0167
Add knip + config
webpro Dec 17, 2023
da6a095
Run knip, remove dead code or ignore
jakebailey Apr 17, 2024
3528eca
Update knip.jsonc
jakebailey Apr 18, 2024
ec75854
Update knip, fixes destructured member access issue
webpro Apr 18, 2024
0f5e5cb
Update comments around `@knipgore` tags
webpro Apr 24, 2024
7e80b15
Update knip
webpro Apr 24, 2024
ba6a906
Ignore new `@internal` exports
webpro Apr 24, 2024
072b0dd
Restore `isAnyImportOrRequireStatement` and `importSymbols`
webpro May 6, 2024
0954bc1
`@knipignore` all unused `moveToFile` exports
webpro May 6, 2024
6fedf6b
Remove unused file
webpro May 6, 2024
eea3ac4
Update knip
webpro May 6, 2024
546e32c
Merge branch 'main' into remove-unused-exports
webpro Jun 15, 2024
ed20a19
Remove unused exports after merging in main
webpro Jun 15, 2024
99ec0ec
Remove unused file
webpro Jun 15, 2024
ed0f92d
Update knip
webpro Jun 15, 2024
737641a
Remove `diff` from ignored deps
webpro Jun 15, 2024
bf8aeda
Remove unused imports
webpro Jun 15, 2024
5055d9f
Accept new baseline
webpro Jun 15, 2024
459eec7
Format w/ dprint
webpro Jun 15, 2024
b4c2ad3
Remove exports in moveToFile.ts
webpro Jun 17, 2024
1ab651d
Update knip
webpro Jun 19, 2024
182d352
Restore internal tag on importSymbols
jakebailey Jun 19, 2024
628c3f5
Merge branch 'main' into pr-56817
jakebailey Jun 19, 2024
a185775
missing baseline
jakebailey Jun 19, 2024
c012de6
Update knip
webpro Jun 25, 2024
96aabf7
Update knip
webpro Jun 27, 2024
deec4eb
Merge branch 'main' into remove-unused-exports
webpro Jun 27, 2024
f2953d2
Revert bad merge
jakebailey Jun 27, 2024
94e129f
Remove unnecessary `@knignore` tags
webpro Jun 27, 2024
6de0207
Restore comment I accidentally removed
jakebailey Jun 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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