Repository navigation
feat(lint): add comark-lint, a linter for Comark documents - #38
Conversation
Latest result Pull request merged. Final answersSession 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. |
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
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.
…DME and AGENTS.md
There was a problem hiding this comment.
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.tsandpackages/lint/src/source.ts. - CLI and config — Reviewed glob expansion, exit codes, config loading, and optional package discovery in
packages/lint/src/cli.tsandpackages/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-doctorupgrade. Focused build/test commands were blocked by the environment'spnpmprepare step failing to lock.git/configon a read-only filesystem.
gpt-5.6-sol | 𝕏
There was a problem hiding this comment.
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.tsassertion 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.
gpt-5.6-sol | 𝕏
comark-annotate
comark-carousel
comark-embed
comark-github-callouts
comark-include
comark-lint
comark-zoom
commit: |
There was a problem hiding this comment.
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.
gpt-5.6-sol | 𝕏
There was a problem hiding this comment.
ℹ️ 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-lintpage 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.
gpt-5.6-sol | 𝕏
|
Fixed the P1 optional-peer classification. Missing subpath imports now match Node’s absent package-root error ( |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Corrected optional-peer detection — Updated
resolveConfig()to recognize Node's package-rootERR_MODULE_NOT_FOUNDmessage 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.
gpt-5.6-sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Integrated
::diffsupport — Reviewed the mergedcomark-annotatechanges that add suggested code-change rendering, validation, Shiki preservation, and CLI coverage; the existingcomark-lintdiscovery 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.
gpt-5.6-sol | 𝕏
There was a problem hiding this comment.
✅ 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
diffcomponent 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.
gpt-5.6-sol | 𝕏

Adds
comark-lint, a new package inpackages/lintthat finds problems Comark parses through without a word.lint(source, { plugins, components })returns{ rule, line, column?, message, fix }[]and never throws.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'spluginsandcomponentsare added to theirs. Text output isfile:line:col rule message fix. It exits with 1 on any diagnostic and 2 on a file it can't read.comark-lint/doctorexports a factory that returnsdefineDoctorExtension({ name: "comark", rulePacks }). Each rule has its own code,COMARK0001toCOMARK0007, and the pack ships acomark/recommendedpreset. Files default to**/*.{md,mdc}withoutnode_modulesanddist;includeandexcludechange that.vite-doctoris 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.jsonhas noextensionskey. It also has no Markdown visitor. So the adapter's rules are manifest rules: they glob the Markdown inonProjectEnd, runlint()once per run (shared throughctx.cache), and report withrangeFromOffsets, 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
comark/unclosed-block::block with no closer. This includes a block that an outer block's closer ends early. Fenced code is skipped.comark/unknown-componentcomponentsare given.comark/malformed-attributes{after a component, a[span], a link, or an image, and a key set twice.comark/broken-anchor#fragmentthat matches no heading id or{#id}. It lists the ids the document has and suggests the closest one.comark/invalid-frontmattercomark/plugin-issuemeta.issues, the key every plugin on main appends to.comark/unsafe-urljavascript:,vbscript:, or non-imagedata:inhreforsrc. It uses a local copy of the decoding idea behind Comark's internalisUnsafeUrlValue.Position limitation
Comark gives nodes no source positions.
mdc_block_opentokens, plus the frontmatter lines Comark strips (state.parsedLines).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.12to^0.1.0, and pnpm added[email protected]tominimumReleaseAgeExcludebecause the version came out today. 0.1.0 found one new warning in the existing packages: TS0008, an unexplained type assertion atpackages/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.tsregisterscomark-lint/doctorfordocs/pages/*.md, plus the docs' owntabs,example, andpluginscomponents.pnpm run doctor, which runs inpnpm readyand in CI, now ends withpnpm run lint:docs. The docs pages had no problems, so nothing is suppressed. I confirmed that a planted::bogusfails it with COMARK0001 and COMARK0002.Also
docs/pages/lint.mdcovers usage, the rules, and the Vite Doctor setup. It is registered indocs/build.ts, and each rule heading has a{#comark000N}id that the diagnostics' docs URLs point to.package.jsondescription, andAGENTS.md. The release workflow and pkg-pr-new usepackages/*, so neither lists packages by name.comark-annotate checkis unchanged. It could delegate to comark-lint later.lint(), the built CLI, and vite-doctor'srunProjectFixture. 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-blockuses only a stack of fence openers, not a comparison withautoCloseMarkdown(src). The stack also catches an inner block that an outer closer ends, which the comparison misses.doctor-disable-next-linedoesn't reach.mdfiles, 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.pluginsandcomponentsadd to the installed packages' rather than replacing them.Before the first release
comark-lintis a new npm package. It needs a trusted publisher on npmjs.com, with workflowrelease.yamland environmentnpm, before uppt can stage it.🤖 Generated with Claude Code