Skip to content

feat(lint): add comark-lint, a linter for Comark documents - #38

Merged
vite-hub[bot] merged 11 commits into
mainfrom
feat/lint
Oct 20, 2026
Merged

vite-hub[bot] merged 11 commits into
mainfrom
feat/lint

Conversation

@onmax

@onmax onmax commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Adds comark-lint, a new package in packages/lint that finds problems Comark parses through without a word.

  • Library: lint(source, { plugins, components }) returns { rule, line, column?, message, fix }[] and never throws.
  • CLI: comark-lint <files or globs>... [--format text|json] [--config comark-lint.config.ts]. It loads the comark-plugins packages that are installed (annotate, carousel, github-callouts, and zoom) through optional dynamic imports. A config's plugins and components are added to theirs. Text output is file:line:col rule message fix. It exits with 1 on any diagnostic and 2 on a file it can't read.
  • Vite Doctor: comark-lint/doctor exports a factory that returns defineDoctorExtension({ name: "comark", rulePacks }). Each rule has its own code, COMARK0001 to COMARK0007, and the pack ships a comark/recommended preset. Files default to **/*.{md,mdc} without node_modules and dist; include and exclude change that. vite-doctor is an optional peer dependency at ^0.1.0.

Why a library and a CLI first, with a Vite Doctor adapter

In vite-doctor 0.1.0, third-party rule packs load only from an executable doctor.config.ts; doctor.config.json has no extensions key. It also has no Markdown visitor. So the adapter's rules are manifest rules: they glob the Markdown in onProjectEnd, run lint() once per run (shared through ctx.cache), and report with rangeFromOffsets, as vite-doctor's own Nuxt Content link rule does. Everyone else gets the same checks from the CLI or the library without Vite Doctor.

Rules

Rule Code Reports
comark/unclosed-block COMARK0001 A :: block with no closer. This includes a block that an outer block's closer ends early. Fenced code is skipped.
comark/unknown-component COMARK0002 A block or inline component that isn't in the components map, the name list, or HTML. It suggests the closest name. The rule is off when no components are given.
comark/malformed-attributes COMARK0003 An unclosed { after a component, a [span], a link, or an image, and a key set twice.
comark/broken-anchor COMARK0004 A #fragment that matches no heading id or {#id}. It lists the ids the document has and suggests the closest one.
comark/invalid-frontmatter COMARK0005 The YAML error and its line. The rest of the document is still checked, with the frontmatter blanked out.
comark/plugin-issue COMARK0006 Each string in meta.issues, the key every plugin on main appends to.
comark/unsafe-url COMARK0007 javascript:, vbscript:, or non-image data: in href or src. It uses a local copy of the decoding idea behind Comark's internal isUnsafeUrlValue.

Position limitation

Comark gives nodes no source positions.

  • Block components take their line from mdc_block_open tokens, plus the frontmatter lines Comark strips (state.parsedLines).
  • Inline components are searched for within their paragraph's token lines. A component that appears twice in one paragraph is matched in order.
  • Links, URLs, and the quoted values in plugin issues are found by searching the source. Fenced code and inline code are blanked out first.
  • A plugin issue goes on the block its message names (compare 2, screenshot "a.png") when the source shows where that is, and on line 1 otherwise.

Exact inline columns are out of scope.

vite-doctor bump

The catalog moves from ^0.0.12 to ^0.1.0, and pnpm added [email protected] to minimumReleaseAgeExclude because the version came out today. 0.1.0 found one new warning in the existing packages: TS0008, an unexplained type assertion at packages/annotate/src/client.ts. I fixed it with a SAFETY comment, so the bump stays and no package-local devDependency was needed.

Dogfooding

The root doctor.config.ts registers comark-lint/doctor for docs/pages/*.md, plus the docs' own tabs, example, and plugins components. pnpm run doctor, which runs in pnpm ready and in CI, now ends with pnpm run lint:docs. The docs pages had no problems, so nothing is suppressed. I confirmed that a planted ::bogus fails it with COMARK0001 and COMARK0002.

Also

  • docs/pages/lint.md covers usage, the rules, and the Vite Doctor setup. It is registered in docs/build.ts, and each rule heading has a {#comark000N} id that the diagnostics' docs URLs point to.
  • The package is listed in the root README table, the root package.json description, and AGENTS.md. The release workflow and pkg-pr-new use packages/*, so neither lists packages by name.
  • comark-annotate check is unchanged. It could delegate to comark-lint later.
  • Tests go through lint(), the built CLI, and vite-doctor's runProjectFixture. Each rule has a passing and a failing document. There are also tests for line numbers with and without frontmatter, :: inside fenced code, and comark-annotate issues passing through.

Deviations from the plan

  • comark/unclosed-block uses only a stack of fence openers, not a comparison with autoCloseMarkdown(src). The stack also catches an inner block that an outer closer ends, which the comparison misses.
  • Vite Doctor's doctor-disable-next-line doesn't reach .md files, because vite-doctor parses comments only in scripts and SFCs. comark-lint has no suppression comment of its own yet, and the docs didn't need one.
  • A config's plugins and components add to the installed packages' rather than replacing them.

Before the first release

comark-lint is a new npm package. It needs a trusted publisher on npmjs.com, with workflow release.yaml and environment npm, before uppt can stage it.

🤖 Generated with Claude Code

@vite-hub

vite-hub Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
Session Status Started Duration
Pending Completed Not started —

Latest result

Pull request merged.

Final answers

Session

Pull request merged.

Session

Waiting for GitHub merge request 390afb4d-e3f8-4b44-8f40-e546a0b492ed.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

Session

Resolved the prepared merge conflicts while preserving lint and include changes. Updated the stale lint expectation to include annotate’s `diff` component, fixing the CI failure; all 21 focused lint tests pass. Committed and pushed as 7d16906. Existing review findings are resolved; awaiting current-head checks.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 7d16906 2026-10-20T17:39:06.316Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 255c642 2026-10-20T17:29:43.506Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ 8676f85 2026-10-20T17:24:17.413Z Visit the dashboard ↗
  • Build: Success ✅

View logs ↗
No Preview URL. Enable ↗ e184332 2026-10-20T17:14:31.596Z Visit the dashboard ↗
  • Build: In progress 🔵

View logs ↗
67b0588 2026-10-20T16:27:52.196Z View logs ↗
  • Build: In progress 🔵

View logs ↗
a868c4c 2026-10-20T16:24:51.442Z View logs ↗

onmax added 4 commits October 20, 2026 18:27
The comark-lint doctor extension needs the 0.1.0 extension API.
A library (lint()), a CLI (comark-lint), and a Vite Doctor extension (comark-lint/doctor) with seven rules: unclosed blocks, unknown components, malformed attributes, broken anchors, invalid frontmatter, plugin issues, and unsafe URLs.
@onmax
onmax changed the base branch from main to fix/ci-main October 20, 2026 16:27

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

This PR has two correctness issues in the source scanners that can produce false diagnostics or hide real ones; the optional plugin loader also silently disables installed plugins when their import fails.

Reviewed changes

  • Lint library — Reviewed the seven diagnostics, Comark parsing/probe integration, source scanning, and diagnostic positioning in packages/lint/src/index.ts and packages/lint/src/source.ts.
  • CLI and config — Reviewed glob expansion, exit codes, config loading, and optional package discovery in packages/lint/src/cli.ts and packages/lint/src/config.ts.
  • Vite Doctor adapter — Reviewed manifest rule construction, shared project caching, Markdown file selection, and diagnostic range mapping in packages/lint/src/doctor.ts.
  • Integration and verification — Reviewed package exports, docs, tests, root Doctor dogfooding, and the vite-doctor upgrade. Focused build/test commands were blocked by the environment's pnpm prepare step failing to lock .git/config on a read-only filesystem.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-5.6-sol | 𝕏

Comment thread packages/lint/src/index.ts Resolved
Comment thread packages/lint/src/source.ts Resolved
Comment thread packages/lint/src/config.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new commit introduces no additional issues, but the three correctness findings from the prior review remain outstanding and still block approval.

Reviewed changes

  • Delta since the prior review — The new commit only removes the unrelated packages/annotate/src/client.ts assertion change; it does not alter the new linter, CLI, Vite Doctor adapter, package metadata, tests, or docs.
  • Outstanding prior findings — The source scanners still disagree with Comark on four-space indentation, and optional peer import failures are still silently swallowed. See the prior review's inline threads for the required fixes.

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-5.6-sol | 𝕏

@vite-hub
vite-hub Bot changed the base branch from fix/ci-main to main October 20, 2026 16:53
@pkg-pr-new

pkg-pr-new Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

comark-annotate

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-annotate@38

comark-carousel

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-carousel@38

comark-embed

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-embed@38

comark-github-callouts

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-github-callouts@38

comark-include

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-include@38

comark-lint

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-lint@38

comark-zoom

pnpm add https://pkg.pr.new/onmax/comark-plugins/comark-zoom@38

commit: 7d16906

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The scanner fixes are addressed, but optional peer discovery still fails when a package is genuinely absent, so the CLI and Doctor adapter cannot run in projects that do not install every comark plugin.

Reviewed changes

  • Corrected Markdown indentation — Restricted component, attribute, and fence recognition to Comark's valid zero-to-three-space indentation, so four-space-indented code no longer creates false diagnostics or hides real ones.
  • Narrowed optional import handling — Changed plugin discovery to rethrow unexpected module failures while attempting to ignore only missing optional peers; the missing-package classifier still needs one correction.

⚠️ Missing optional peers are still treated as fatal

resolveConfig() is intended to skip an optional plugin package that is not installed, but missing() checks for the full subpath ('comark-annotate/html'). Node's ERR_MODULE_NOT_FOUND for an absent package reports only the package name (Cannot find package 'comark-annotate'), so a normal installation without that peer is rethrown and the CLI/Doctor adapter fail before linting any file.

Technical details
# Match Node's absent-package error

## Affected sites
- `packages/lint/src/config.ts:16-20` — `missing()` requires an error message containing the import subpath, but Node reports only the package name when the package itself is absent.
- `packages/lint/src/config.ts:24-32` — the failed classification is rethrown by `resolveConfig()`.

## Required outcome
- Skip an import only when the requested optional package itself is absent; continue surfacing failures from an installed package or its dependencies.

## Suggested approach
- Compare against the package root in the missing-package case, while retaining the distinction between an absent root package and a failed dependency/module initialization.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-5.6-sol | 𝕏

Comment thread packages/lint/src/config.ts Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No new issues were introduced by this delta; the remaining optional-peer import concern is already tracked in the open review thread.

Reviewed changes

  • Registered the lint documentation — Added the comark-lint page to the docs build and linked it from the project metadata.
  • Updated project documentation — Added the package to the README and documented its usage, rules, and Vite Doctor integration.
  • Refined repository metadata — Updated the package description and repository guidance to include the linter.

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-5.6-sol | 𝕏

@vite-hub

vite-hub Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Fixed the P1 optional-peer classification. Missing subpath imports now match Node’s absent package-root error (Cannot find package 'comark-annotate'), while missing dependencies and installed-package initialization failures still rethrow.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Corrected optional-peer detection — Updated resolveConfig() to recognize Node's package-root ERR_MODULE_NOT_FOUND message for absent optional peers while continuing to rethrow failures from installed packages or their dependencies.
  • Revalidated prior fixes — Confirmed the indentation-limited block, attribute, and fence scanners remain in place and the previously raised review threads are resolved.
  • Verification — Targeted package commands were attempted, but the workspace install/prepare step was blocked by could not lock config file .git/config: Read-only file system; the matcher behavior was validated directly.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Integrated ::diff support — Reviewed the merged comark-annotate changes that add suggested code-change rendering, validation, Shiki preservation, and CLI coverage; the existing comark-lint discovery path continues to consume the package's exported plugin and component map correctly.
  • Revalidated lint behavior — Confirmed the prior indentation and optional-peer fixes remain intact at the current head, with no new lint, CLI, or Vite Doctor regression in the merge delta.
  • Verification — Targeted test commands were attempted but the workspace install/prepare step was blocked by could not lock config file .git/config: Read-only file system; review coverage and the added integration tests were inspected directly.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@vite-hub
vite-hub Bot merged commit 184a85f into main Oct 20, 2026
9 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 20, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Integrated comark-include — Reviewed the merge delta adding the new package to the README, docs build, workspace lockfile, and package discovery context.
  • Updated lint expectations — Confirmed the known component diagnostics now include annotate's exported diff component after the merge.
  • Revalidated the current head — Re-read the full PR diff and confirmed the earlier scanner and optional-peer fixes remain intact; no new behavioral regressions were found.

Pullfrog  | View workflow run | Using gpt-5.6-sol | 𝕏

@github-actions github-actions Bot mentioned this pull request Oct 24, 2026
@onmax
onmax deleted the feat/lint branch November 1, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant