Skip to main content

Module lint

Module lint 

Source
Expand description

Style lint rules (L-codes) and the unified check entry point.

Three diagnostic layers feed check:

  1. syntaxcrate::parse::parse P-codes (parse-layer diagnostics)
  2. schemacrate::validate::validate V-codes (SurfDoc::validate())
  3. style — the LintRule implementations in this module (L-codes)

Rule metadata (default severity, fixability, message templates) is loaded at compile time from spec/rules.toml via include_str!. The module is wasm-clean: no filesystem access, no clock, no randomness. The spec_compliance integration test asserts that the implemented rule set and the registry match exactly.

Structs§

AppliedFix
A fix that was applied by apply_fixes.
CheckReport
Result of running all three diagnostic layers over a source string.
FixOutcome
Result of apply_fixes / apply_fixes_once.
LintConfig
Configuration for check_with: per-rule severity overrides and disabled rule ids. Applies to all three layers (P/V/L codes).
RuleMeta
Metadata for a single lint rule, loaded from spec/rules.toml.
SkippedFix
A fix that was skipped by apply_fixes.

Constants§

EXTRA_KNOWN_BLOCK_NAMES
Parser-accepted names that are deliberately NOT in spec/blocks.toml: sub-directives (column) and aliases/renderer families the parser resolves (action-items → tasks, deck/slide, deploy_urls, info-card). L020 must not flag these. The spec_compliance test asserts none of them is in blocks.toml — once the spec registers one, remove it from this list.
JSON_SCHEMA_VERSION
Version of the JSON envelope schema emitted by report_to_json / reports_to_json — and therefore by surf-lint check --format json and the wasm check_json export, which both serialize these values.
MAX_FIX_ITERATIONS
Maximum number of fix → re-check passes in apply_fixes.
PARSE_RULE_IDS
Rule ids emitted by the parse layer (src/parse.rs), pinned for the registry drift test in tests/spec_compliance.rs.

Traits§

LintRule
A single style-layer lint rule.

Functions§

all_rules
All implemented style-layer rules, in rule-id order.
apply_fixes
Apply every auto-fix at or below the requested safety tier, re-running check after each pass until no applicable fix remains (fixpoint) or MAX_FIX_ITERATIONS passes were applied.
apply_fixes_once
Single-pass variant of apply_fixes: applies at most one round of non-conflicting fixes without iterating to a fixpoint. Useful for callers that want to show intermediate states (e.g. a CLI --diff mode).
apply_fixes_with
apply_fixes with a LintConfig: disabled rules contribute no fixes, and config-suppressed diagnostics (e.g. P005 extra values) are likewise never “fixed”. Severity overrides do not change fix behaviour.
check
Run all three diagnostic layers (parse, validate, lint) over input.
check_with
check with severity overrides and disabled rules applied.
known_block_names
All block names registered in spec/blocks.toml (any status).
report_to_json
Per-file object of the surf-lint JSON envelope.
reports_to_json
Full surf-lint JSON envelope over (path, report) pairs:
rule_registry
The lint rule registry, keyed by rule id (P001, L001, …).
rule_registry_total
meta.total_rules declared in spec/rules.toml.