type HintPolicy = { codes: Array<String>, levels: Array<String>, strict: Bool }
Per-code severity overrides, as parallel arrays (a code and its level word). strict ignores waivers; only strictly sets it, for unusedWaivers.
Type to search, or try , or .
8 exports, from std/hints.vyrn.
Policy for checking libraries: per-project rule levels and per-line waivers.
A rule is a code, a string this module never interprets; an input file is text with lines. std/vyx-hints uses only this public surface.
import { hint, noPolicy } from "std/hints" import { Severity } from "std/diag" export gen fn myHints(path: String) -> String { let src = match readFile(path) { Ok(t) => t, Err(e) => "" } let mut out = "" // ... find something at line 4, column 9 ... out = out + hint(noPolicy(), "my/rule", Warning, src, path, 4, 9, "say what is wrong") return out }
A project sets levels with a JSON object under the library's own top-level key, in any JSON file passed to the generator as a constant path:
{ "hints": { "a11y/img-alt": "error", "perf/img-size": "off" } }
policyOf refuses a config that does not parse or names an unknown level: a swallowed fault would report rules on while they are off.
vyrn-ignore <code> on the reported line, or on the line above it, drops that one report. The marker is plain text inside the input's own comment:
<!-- vyrn-ignore a11y/tabindex-positive: the tour sets the order --> <div tabindex="2">Start here</div>
The import graph shows the whole library.
type HintPolicy = { codes: Array<String>, levels: Array<String>, strict: Bool }
Per-code severity overrides, as parallel arrays (a code and its level word). strict ignores waivers; only strictly sets it, for unusedWaivers.
fn noPolicy() -> HintPolicy
The empty policy: no override, every rule at its default severity.
fn strictly(p: HintPolicy) -> HintPolicy
p with waivers ignored: what a rule would report. Builds the raw input of unusedWaivers.
fn policyOf(configText: String, key: String) -> Result<HintPolicy, String>
Reads a policy from the top-level key of configText.
Ok(noPolicy()) when the key is absent. Err when the document does not parse, the key is not an object of strings, or a level is not off, warning or error.
fn levelOf(p: HintPolicy, code: String, dflt: Severity) -> String
The level code runs at under p: its configured word, or the word for dflt when the project said nothing about it.
fn hint( p: HintPolicy, code: String, dflt: Severity, src: String, file: String, line: Int64, col: Int64, message: String, ) -> String
One //@diag report line, or "" when code is off or waived at line. src is the text of file; the waiver marker is read from it.
fn waived(src: String, line: Int64, code: String) -> Bool
Whether code is waived at line of src: a vyrn-ignore <code> marker on that line or on the one above it.
fn unusedWaivers(p: HintPolicy, src: String, file: String, raw: String) -> String
11 test blocks in std/hints.vyrn. CI runs all of them.
No example program imports this module.