@stesura/format-lint
A lint for how a document is built: formatting that belongs in styles, duplicate and broken
styles, empty paragraphs used as spacing. The rules, guarantees and setup are in the
Format cleanup guide. The panel and status bar are in
@stesura/format-lint-react.
Plugin
formatLintPlugin
Recollects format suggestions a debounce after each doc change and keeps them, ranges mapped, in plugin state for the panel and the status bar. Root editors only: sub-editors’ content is part of the root doc.
| Name | Type | Default |
|---|---|---|
__0 | FormatLintPluginOptions |
FormatLintPluginOptions
Engine
The engine is pure: state in, suggestions or a transaction out. Use it without the plugin to report on an imported document or from a server.
collectFormatSuggestions
Every suggestion for the document, in pass order. Each rule sees the doc as it is; what applying one changes for another is settled at apply time.
| Name | Type | Default |
|---|---|---|
stateOrDoc | EditorState | Node | |
options | FormatLintOptions |
applyFormatSuggestionsTr
Runs the selected fixes in ONE transaction, for composing; the command,
applyFormatSuggestionsBulk, runs them in chunks. The engine
recollects pass by pass on the transaction’s doc rather than trusting
cached transforms, so ids are matched against what still applies;
the rest come back as gone. "all" applies every fixable error and
warning, plus hints only for rules named in options.rules.
| Name | Type | Default |
|---|---|---|
selection | string[] | "all" | |
options | ApplyFormatOptions |
getFormatSummary
The summary an applyFormatSuggestionsTr left on its transaction.
| Name | Type | Default |
|---|---|---|
tr | Transaction |
DEFAULT_FORMAT_LINT_OPTIONS
Defaults read off the 2026-10-19 corpus survey (docs/partially-executed/format-cleanup-plan.md, Phase 0): indent drift below 3 px is cm/twip rounding, real choices start above 6 px; mark coverage is bimodal, with almost nothing between 60% and 90%.
Categories
The panel groups rules into categories, and “Fix all” can apply only some of them through
ApplyFormatOptions.only.
FORMAT_RULE_CATEGORIES
Each rule’s category, as the panel groups them.
FORMAT_CATEGORIES
Categories in the order the panel lists them.
rulesInCategories
The rules of the given categories, e.g. for ApplyFormatOptions.only.
| Name | Type | Default |
|---|---|---|
categories | ReadonlySet<FormatCategory> |
Commands
applyFormatSuggestions
Applies suggestions in one undo step, with formatApplyOptions, in chunks on a large
document (a bulk command: dispatch it through the editor, or runBulkCommand headless). By
default refuses while track changes is on (see trackChangesBlockedReason); force
applies anyway.
| Name | Type | Default |
|---|---|---|
selection | string[] | "all" | |
options | ApplyFormatOptions |
refreshFormatSuggestions
Collects now instead of after the debounce, e.g. for a Refresh button. Not an undo step.
ignoreFormatSuggestion
Dismisses a suggestion for this document, for every collaborator.
| Name | Type | Default |
|---|---|---|
id | string |
unignoreFormatSuggestion
Brings one dismissed suggestion back.
| Name | Type | Default |
|---|---|---|
id | string |
clearFormatLintIgnore
Brings dismissed suggestions back.
getFormatLintIgnore
The doc’s dismissed suggestion ids (doc.attrs.formatLintIgnore).
| Name | Type | Default |
|---|---|---|
state | EditorState |
trackChangesBlockedReason
Why applying is refused right now: tracked formatting changes by the hundred.
| Name | Type | Default |
|---|---|---|
state | EditorState |
Agent issues
The IssueProvider that hands format-lint’s suggestions to the agent’s issue tools; pass it to
createIssueTools in @stesura/ai.
formatLintIssues
Format-lint’s suggestions, for createIssueTools. Fixes are direct (styles, lists and direct
formatting are document configuration) and, like the panel’s “apply”, refused while track
changes is on.
Types
FormatSuggestion
FormatDetail
What a finding is about, for a precise title: the one field it touches (absent when it spans several) and, for FMT-11, which of its checks found it.
| Name | Type | Default |
|---|---|---|
field | FormatField | |
kind | "field" | "near" | "cluster" | "snap" |
FormatField
A paragraph field, or a character attr FMT-21 moves into a style.
FormatCategory
How the panel groups rules, e.g. to pick what “Fix all” applies.
FormatRuleId
Rule ids, as in docs/partially-executed/format-cleanup-plan.md.
FormatSeverity
error: the document misbehaves. warning: dirtier than it needs to be.
hint: a judgement call, never applied by “apply all”.
FormatGuarantee
What a fix promises about rendering. lossless: every block renders
identically. tolerance: differs by at most the configured tolerance.
restructure: changes the document on purpose (hints only, one click each).
FormatScope
| Name | Type | Default |
|---|---|---|
kind | "document" | "styles" | "lists" | "blocks" |
FormatChanges
Dry-run summary of a fix. Counts, not transforms.