Skip to content

TypeScript and JavaScript docs drift

Rimfe parses each changed .ts, .tsx and .js file without running it and records what a reader could notice: exported functions and types with their parameters, HTTP routes, Commander and yargs options, zod config keys, env vars and package.json fields. When one changes, the docs sections that name it are checked and a stale line gets a finding.

Updated

What Rimfe reads

Files ending in .ts, .mts, .cts, .tsx, .js, .jsx, .mjs and .cjs are parsed into facts. A pull request is compared fact by fact between its base and head: added, removed, renamed, a changed signature or default, a new deprecation.

SurfaceWhat is read
ExportsFunctions, classes, interfaces, type aliases, enums with their members, namespaces and re-exports, from ESM export and CommonJS module.exports. Parameters keep their types, defaults and optional marks. Class members marked private, protected or # are internal.
RoutesCalls such as app.get("/orders/:id", handler) in Express, Fastify, Hono, Koa and Elysia files, Fastify route({ method, url }), Next.js app/**/route.ts exports such as GET, and pages/api handlers.
CLICommander .command(), .option() and .requiredOption() with placeholders and defaults, cac, and yargs .option() with describe, default and deprecated. The bin field of package.json.
Configzod z.object fields, nested objects included: type, .default(), optional, and a deprecation note in .describe().
Env varsprocess.env.X, import.meta.env.X, Bun.env.X and Deno.env.get("X"), with a fallback after ?? or || read as the default. Names in .env.example too.
Packagepackage.json scripts as npm run commands, main, types, exports, dependencies and peer dependencies.
DeprecationsA JSDoc @deprecated tag on any exported name.

Example: a zod default changes

docs/configuration.mdx says retries defaults to 3. Rimfe posts a Docs conflict on that line, quoting it beside the schema change, with a suggested edit that sets the value to 5.

src/config.ts
- retries: z.number().int().default(3),+ retries: z.number().int().default(5),

Example: an export is renamed

The README still opens with createClient({ apiKey }). The finding reads: Outdated code sample: README.md line 12 uses createClient, renamed in this pull request. A TypeScript export matches JavaScript snippets too.

src/client.ts
- export function createClient(options: ClientOptions): Client {+ export function connect(options: ClientOptions): Client {

Example: an env var is renamed

docs/deploy.md tells readers to set ACME_TOKEN. After this change no code reads that name, so the page gets a Broken reference finding. That check needs no AI model, and on a pull request it reports only references the pull request broke.

src/auth.ts
- const token = process.env.ACME_TOKEN;+ const token = process.env.ACME_API_KEY ?? "";

Docs tools beside TypeScript

Docusaurus, Nextra, VitePress, Starlight and Fumadocs all build from Markdown or MDX files, and Rimfe reads those files in the same repository or in a separate docs repository. Many libraries keep their reference in the README, which is in scope by default. Pages that TypeDoc generates and commits should stay out of scope, since the next build rewrites them.

Set up a TypeScript repository

Map source folders to the pages that describe them, so those pages are read first. docsIgnorePaths keeps generated API pages out of the review. surface adds env vars and flags to docs coverage. The file applies when Documentation scope is set to .rimfe.json at the PR base. In a monorepo, each package can carry its own file.

.rimfe.json
{  "$schema": "https://rimfe.com/schema/rimfe.json",  "docsGlobs": ["README.md", "docs/**/*.{md,mdx}"],  "docsIgnorePaths": ["docs/api/**"],  "codeMappings": [    { "source": "src/config/**", "target": "docs/configuration.mdx" },    { "source": "src/cli/**", "target": "docs/cli/" }  ],  "surface": ["ACME_API_KEY", "--port"]}

Limits

  • Code is parsed, never run or type-checked. A route path, flag or env var name built at runtime is not resolved.
  • A prefix mounted with app.use("/v1", router) is not joined to the routes inside that router.
  • A return type that comes only from inference has nothing declared to compare. A new optional parameter or a type-only change does not make a snippet outdated.
  • Tests (.test and .spec files, __tests__/, test/, tests/, fixtures/), dist/, build/ and node_modules/ are skipped, as are files over 1 MB, files with a line over 5,000 characters and files whose header says they are generated.

Try it on your next pull request.

Free for public repositories, with unlimited members.

Start free with GitHub