Repository navigation
Description
Finding
docusaurus.config.ts (lines ~44-50) defines an inline markdown.preprocessor function:
preprocessor: ({ fileContent, filePath }) =>
path.resolve(filePath) === importedReadmePath
? fileContent.replace(
/(\]\(|\]:\s*)(\/(?:docs|analyses)\/[^\s)#?]+)\.md(?=$|[\s)#?])/g,
'$1$2/',
)
: fileContent,This strips .md from site-absolute /docs/... and /analyses/... links when
Docusaurus imports the root README.md (consumed by src/pages/index.mdx). It
has no test coverage:
- Unit:
lib/**/*.test.mts(thetest:unitscript) has no test file for
docusaurus.config.ts; this function isn't exercised anywhere. - End-to-end: this repo has no e2e/integration suite (no playwright/cypress
directories; CI is limited toformat-check.yml,link-check.yml,
spell-check.yml).
Covered by neither unit nor end-to-end tests.
Why this can't be fixed with a drop-in unit test: the function is inlined in
docusaurus.config.ts, which imports ./lib/getBuildContext and
./lib/remarkRewriteLinks without file extensions. That resolves fine through
Docusaurus's own webpack bundler, but is unresolvable under this repo's own
node --experimental-strip-types --test runner (reproduced locally:
ERR_MODULE_NOT_FOUND importing docusaurus.config.ts directly). Testing the
regex in isolation requires first extracting it into its own lib/ module (with
extension-qualified imports, matching the convention #389 establishes) — a
production-code change, which is outside the quality agent's scope (tests only,
no refactors).
Recommendation
- Extract the regex-rewrite logic out of
docusaurus.config.tsinto a small,
named function inlib/(e.g.lib/rewriteReadmeLinks.ts), imported back
intodocusaurus.config.tswith an explicit.tsextension. - Once extracted, a straightforward unit test under
lib/**/*.test.mtscan
cover both branches (matchingimportedReadmePath, and the pass-through
case) plus the regex's edge cases (fragment/query suffixes, non-docs/analyses
paths, trailing content on the same line).
Priority
- Impact: low — the function affects exactly one import path (root README.md import)
- Effort: medium — requires a small production-code extraction before tests can be added
Filed by quality agent (hold-gated mode)
🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 4b1f800
— hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88
Activity