Core types shared by the library, the linters, and the config file.
The types a linter author needs are re-exported by lint. The rest are internal to the runner and the config macro.
Types
Check[S] = object run*: proc (ast: PNode; settings: S): seq[Finding] defaults*: S ## Used when a config declares the check without settings.
- One check declared by a linter, bound to its settings type. Source Edit
Finding = object line*: int col*: int msg*: string
- What a check returns. Deliberately carries no severity, no label, and no file path: the runner stamps those. Source Edit
Step = object label*: string ignoredPatterns*: seq[string] checks*: seq[StepSetting]
- One declared step block. Source Edit
StepSetting = object name*: string severity*: Severity run*: proc (ast: PNode): seq[Finding]
- Runtime form of one check entry: the check plus its settings, type-erased at the last moment. Source Edit
Procs
proc addCheck[S](linter: Linter; run: proc (ast: PNode; settings: S): seq[Finding]; defaults: S = default(S)): Check[S]
-
Used by linter modules to declare one check, its settings type, and the settings to use when a config does not provide any.
The check has no name of its own: a config refers to it by the identifier it binds the result to, and that identifier is what the report shows.
Source Edit