Skip to content

script-utils/linters/cspell-content

Spellchecks markdown that is still in memory, with the repository’s own spellcheck configuration.

The sibling of markdownlint-content.ts, for the other half of the same gap: spellcheck can only answer for what is already on disk, so a document composed during a run — the release’s changelog being the one that costs a red main — is checked by nothing until the next gate. A coined word in a release note lands on the default branch inside the release commit, and the NEXT release aborts in its second preflight step, in a repository nobody was working on.

It SHELLS OUT where the markdownlint half calls a library, and the difference has a reason rather than being an oversight. cspell does export a CLI-layer lint(fileGlobs, options, reporter) that would be the exact analogue of markdownlint-cli2’s main, but the only way to hand it content that is not on disk is a stdin:// glob, and its reader is streamConsumers.text(process.stdin) — the HOST process’s own stdin, which the release’s interactive review also uses. Reaching for it in-process would mean monkey-patching process.stdin for the whole process, so the content goes to a child’s stdin instead.

The stdin://<path> form is what makes the check the repository’s own rather than a generic one: the virtual document is attributed to a REAL path, so cspell.json beside it — its words, its dictionaries, its ignorePaths — resolves exactly as it would for the written file. A temp file outside the repository would lose all of that, which is why it is not used.

Interface Description
SpellcheckContentParams Parameters for spellcheckContent.
Function Description
spellcheckContent Spellchecks content that is not on disk, with the configuration spellcheck would have used for it.