Esc

comark-linter

Vite Doctor

Lint a project's Markdown as part of Vite Doctor, with one code per rule.

Setup

comark-linter/doctor is a Vite Doctor extension. Vite Doctor loads extensions from an executable config, so register it in doctor.config.ts:

// doctor.config.ts
import comark from "comark-linter/doctor";
import { defineDoctorConfig } from "vite-doctor/config";

export default defineDoctorConfig({
  extends: ["comark/recommended"],
  extensions: [comark({ components: ["duck-count"] })],
});
ts
pnpm vite-doctor . --config doctor.config.ts
sh

It runs whenever the extension is registered, and the comark/recommended preset turns every rule on. It needs vite-doctor 0.1 or later.

Options

It takes the same plugins and components as the command line's config, plus two of its own:

Option
include The Markdown to check, relative to the project root. Default **/*.{md,mdc}.
exclude Globs to skip. Default **/node_modules/** and **/dist/**.

This site lints its own pages this way. Its docs/build.ts renders a few components itself, so the config names them:

// doctor.config.ts
export default defineDoctorConfig({
  extends: ["comark/recommended"],
  extensions: [
    comark({
      include: "docs/pages/**/*.md",
      components: ["cards", "example", "examples", "hero", "matrix"],
    }),
  ],
});
ts

Codes

Each rule reports with its own code, and the code links to the rule's entry on the overview. Frontmatter Comark can't read and unsafe URLs are errors; the rest are warnings.

Code Rule Severity
COMARK0001 comark/unclosed-block warning
COMARK0002 comark/unknown-component warning
COMARK0003 comark/malformed-attributes warning
COMARK0004 comark/broken-anchor warning
COMARK0005 comark/invalid-frontmatter error
COMARK0006 comark/plugin-issue warning
COMARK0007 comark/unsafe-url error