Documentation
¶
Overview ¶
Package rule defines the Rule interface, severity/fix-safety vocabulary, and the Finding/TextEdit types every rule emits. Fixes are first-class byte-offset edits so lint --fix, fmt, and --diff all consume the same data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DeclSpec ¶
type DeclSpec struct {
ID string
Type string // required | length | not_equal | match | deny
Glob string // optional path scope (doublestar)
Field string // for required/length/match/deny
Fields []string
Min, Max int
Pattern string // for match/deny
SkipDrafts bool
Severity Severity
}
DeclSpec is one user-defined rule from the config `custom:` block.
type Example ¶ added in v0.5.0
Example is an optional before/after illustration for a rule, rendered into its generated docs page. Bad is the markdown that triggers the rule; Good is the corrected (or autofixed) form.
type Finding ¶
type Finding struct {
Rule string `json:"rule"`
Path string `json:"path"`
Line int `json:"line"`
Col int `json:"col"`
Message string `json:"message"`
Severity Severity `json:"severity"`
Safety FixSafety `json:"-"`
DocURL string `json:"-"` // documentation URL (built-in rules only)
Fixes []TextEdit `json:"-"`
}
Finding is one reported issue.
type Meta ¶
type Meta struct {
Name string
Title string // human-readable display name, shown in the docs
Description string // one line, shown by `list`
Detail string // long help, shown by `explain`
Severity Severity // default; config may override
Formats []document.Format // which formats this rule applies to
Safety FixSafety // safety of fixes this rule emits
Example Example // optional before/after for the docs page
}
Meta is a rule's static descriptor.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds rules by name in registration order.
type Rule ¶
Rule inspects a Document and reports findings.
func NewDeclarativeRule ¶
NewDeclarativeRule compiles a DeclSpec into a Rule.
type Severity ¶
type Severity int
Severity orders findings from advisory to blocking.
func ParseSeverity ¶
ParseSeverity converts a config string into a Severity.