Repository navigation
Conversation
Only used by its own test since the showcase refactor (#10023). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…isted) validateAuthorsMap() was an exact copy of validateAuthorsMapInput(), and only tests used it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…AI-assisted) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ma (AI-assisted) DEFAULT_OPTIONS was only used by tests. Using it in the schema, like the other plugins do, keeps the tested defaults and the real defaults in sync. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-ideal-image fork (AI-assisted) - MediaWithDefaults: never imported - Commented-out getScreenWidth(), supportsWebp() and fetchLoader() - Commented-out tests, and the test import they left unused Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No test reads these fixture sites: - docs bad-id-site: unused since the docs plugin refactor (#3245) - docs bad-slug-on-doc-home-site: unused since the docs plugin refactor (#3245) - utils vcs simple-site: added with the VCS API (#11512), never read Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…AI-assisted) Added with the flat TOC refactor (#6729), but no theme ever used it: themes use useFilteredAndTreeifiedTOC. Only its own test called it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ssisted) These CSS module classes are not used by any component anymore, and the React MDX docs page imported a CSS module it doesn't use since the MDX v2 docs rewrite (#8941). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The active nav link is styled with the activeStyle prop since the plugin was released (#3392), so the CSS module class was never applied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on key (AI-assisted) theme.docs.DocCard.categoryDescription was replaced by the .plurals key in #9851, but the Icelandic translation (#9928) still declared the old key, and the new key was untranslated. Move the translation to the plurals key: "atriði" is the same in singular and plural. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e files (AI-assisted) The update script only logs an error for these stale localized messages, so they can remain unnoticed for a long time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…AI-assisted) - jest/vendor: removed with the Vitest migration (#12010) - templates/facebook: removed in #9026 - website/docusaurus.config.js: now a TypeScript file (#9317) - docusaurus-migrate: removed in #9400 - website/netlifyDeployPreview: removed in #4447 - .cache-loader: cache-loader was removed with Webpack 5 (#4089) - .svg: a typo for the *.svg pattern right below - commented-out website/i18n/fr gitignore negations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(AI-assisted) - plugin-svgr: @svgr/core is only used by tests (@svgr/webpack depends on it) - theme-classic: react-router-dom is only used by tests, theme components use @docusaurus/router Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es (AI-assisted) - New lint:knip:production check: Knip production mode ignores the tests, so it reports the exports and dependencies of published packages that only tests use. Exports also used in their own file are not reported: functions are often exported only to be tested. - Fail on Knip configuration hints, so that the config doesn't accumulate useless entries, and remove the 3 existing ones. - Don't treat the internal modules of the react-ideal-image fork as theme component entries, so that Knip reports the unused ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
|
Size Change: -718 B (-0.01%) Total Size: 12.1 MB 📦 View Changed
ℹ️ View Unchanged
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify project configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
|
Size Change: -718 B (-0.01%) Total Size: 12.1 MB 📦 View Changed
ℹ️ View Unchanged
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warning
Do not merge. This is a validation PR: it removes all the dead code found in one place so that CI checks everything at once. Each commit is self-contained, and will become its own standalone PR once approved.
Motivation
Find the dead code of the repository, check that removing it is safe, and prevent new dead code.
Knip already runs in CI, so the remaining dead code hides in Knip's blind spots. I combined:
--production+ignoreExportsUsedInFile(code only kept alive by tests, the main technique of TkDodo's talk),--include-entry-exports, namespace members, duplicates@theme/*declarations, test fixtures, snapshots, translation keys, plugin options, static assets, tooling config paths, ESLint globs, workflow scripts@typescript-eslint/no-unnecessary-conditionrun (dead branches)Removed in this PR
One commit per future standalone PR:
toggleListItemutil + its testvalidateAuthorsMap()validateAuthorsMapInput(), only used by testsCategoryMetadataFilenameBaseconstantDEFAULT_OPTIONSused in the schemaMediaWithDefaults+ commented-outgetScreenWidth,supportsWebp,fetchLoader, and commented-out testsbad-id-site,bad-slug-on-doc-home-site, utilsvcs/__tests__/__fixtures__/simple-siteuseTreeifiedTOC()hook/internal.activeCSS classactiveStyleprop does it since #3392theme.docs.DocCard.categoryDescriptionkey.pluralsin #9851. Review: I moved its translation to the untranslated plurals key (1 atriði|{count} atriði)emojiUtils,useTOCHighlight, sidebars validation,contentTitledebugconsole.logjest/vendor(cspell, oxfmt, stylelint),templates/facebook(ESLint),website/docusaurus.config.js(oxfmt),docusaurus-migrate(Vitest),website/netlifyDeployPreview+.cache-loader(gitignore),.svgoxfmt pattern typo@svgr/core(plugin-svgr) andreact-router-dom(theme-classic) moved todevDependenciesPreventing new dead code
lint:knip:productionCI check (production mode, scoped topackages/*) reporting exports and dependencies only used by tests. Fail on Knip config hints (and remove the 3 existing ones). Stop treating the ideal-image fork internals as theme entriesI checked that the new Knip config catches a planted test-only export and a planted test-only dependency, and the re-added
MediaWithDefaults.Needs a decision (not in this PR)
Wildcard
./lib/*and./src/*package exports: Knip's biggest blind spotplugin-content-docs,plugin-content-blog,theme-live-codeblockandtheme-mermaidexport./lib/*and./src/*, added for Jest 28 (#7243). They make every file a public entry, so Knip never reports their unused exports. Without them, Knip findsCategoryMetadataFilenameBase(removed above), ~20 unnecessaryexportkeywords, and 2Schemaexports. Removing them is a breaking change for deep imports (our ownwebsite/_dogfooding/docs-tests-sidebars.jsimports@docusaurus/plugin-content-docs/lib/sidebars/types). The blogmarkdownLoader.tswould then need a Knip entry.Public API exports unused by the monorepo
Undocumented, removing them is breaking:
@docusaurus/theme-common:listStorageKeys(since fix(v2): fail-safe usage of browser storage (localStorage/sessionStorage) when access is denied #4501)@docusaurus/utils-common:addSuffix(only tests)@docusaurus/theme-common/internalre-exports that no theme imports (the hooks themselves are used internally):useTitleFormatter,useLocationChange,useHistoryPopHandler,useScrollController,useSmoothScrollTo, anduseHistorySelector(also exported by the public entry)Exports of
@docusaurus/utils,plugin-content-docs/clientanddocusaurus-typesonly used internally are probably used by third-party plugins: I'd keep them.Low-value leftovers
website/static/img/slash-introducing.png,img/meta_opensource_logo.svg. Public URLs, maybe hot-linked: I'd keep themconst DEBUG = false(utils/src/moduleUtils.ts),const disableOptimization = false(core/src/server/brokenLinks.ts). Intentional, I'd keep thempropTypesin the ideal-image fork (Media,IdealImage): they document props, duplicated byplugin-ideal-image.d.tsgroupBy()polyfill of theme-common (TODO 2025: replace by std Object.groupBy),Object.groupByis now Baseline Widely AvailableChecked, nothing to remove
Details
@theme/*imports, routes or MDX. Alldeclare module '@theme/*'have an implementation,module-type-aliasesmatches the core exports.snapfilesfilesglobs: all usedTODO Docusaurus v4markers are planned removals (DocSearch v3...), not dead codeno-unnecessary-condition: ~70 hits, nearly all defensive checks of untyped user input. Not dead code, and too noisy for CIminifyFunctions.tsis loaded by path in worker processes)Methodology notes and side findings
cli.test.tsof the docs plugin contains a literal NUL byte (an invalid"foo\0bar"version name in an inline snapshot), so ripgrep/grep silently skip it as a binary file. It madesite-with-custom-i18n-pathlook unused, but removing it failed the tests: that fixture is kept.admin/test-bad-package/README.mdxchecksReactVersiontwice, so its React DOM version check never runs (the second check should useReactDOMVersion).__fixtures__aren't covered by any of our tools: I used one-off scripts. Not worth a permanent check IMHO.Test Plan
Locally: packages build, all tests (only the 2 known sandbox-only
/tmpfailures ofwriteRedirectFiles.test.ts, same asmain),typecheck:tests, website typecheck,pnpm lint(including both Knip checks). This PR: full CI, Argos (CSS changes must produce no visual diff).Argos results: no screenshot changes. The
styles.csstext snapshot changed as expected: the removed CSS rules, plus a reorder of theme-classic code block and inline TOC rules inside the same@layer docusaurus.theme-classic, because the MDX/React docs page doesn't import its CSS module anymore. These rules target different elements, so the order doesn't matter, and the screenshots confirm it.Test links
Deploy preview: https://deploy-preview-12751--docusaurus-2.netlify.app/ (website CSS cleanup: home, MDX and React docs, debug panel)
🤖 Generated with Claude Code (AI-assisted)