Documentation
¶
Overview ¶
Package engine discovers files, runs rules in parallel, applies inline suppression, and applies fixes or renders diffs.
Index ¶
- func ApplyEdits(src []byte, edits []rule.TextEdit) ([]byte, error)
- func Format(doc *document.Document) []byte
- func UnifiedDiff(path string, before, after []byte) string
- type Engine
- func (e *Engine) Fix(ctx context.Context, paths []string, unsafe, dryRun bool) ([]string, error)
- func (e *Engine) MarkdownFiles(paths []string) ([]string, error)
- func (e *Engine) Restrict(names []string) error
- func (e *Engine) Run(ctx context.Context, paths []string) (*Result, error)
- func (e *Engine) UseCache(c *cache.Cache, version, configHash string)
- type Result
- type Suppressor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyEdits ¶
ApplyEdits returns src with every edit applied. Edits must not overlap; they are applied last-to-first so earlier offsets stay valid during splicing.
func Format ¶
Format applies the deterministic, idempotent whitespace pass: it collapses 3+ consecutive blank lines (outside fenced code) to one, ensures a single trailing newline, applies the always-safe structural fixes, and aligns the columns of well-formed GFM tables. The structural fixes include no-trailing-spaces' targeted strip of a single stray trailing space and of a whitespace-only line; a deliberate two-space hard line break is never touched (the rule does not flag it) and an ambiguous 3+ run is left for a human.
func UnifiedDiff ¶
UnifiedDiff renders a unified diff of before vs after for one file.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine holds the resolved active rule set and config.
func New ¶
New resolves the active rules: built-ins filtered by enable/disable/default, plus compiled declarative rules from the config `custom:` block.
func (*Engine) Fix ¶
Fix lints, applies safe (and optionally unsafe) fixes per file, and either writes the files (dryRun=false) or returns them without writing. It returns the list of changed paths.
func (*Engine) MarkdownFiles ¶
MarkdownFiles returns the discovered markdown file paths under paths.
func (*Engine) Restrict ¶ added in v0.5.0
Restrict limits the active rules to those named, so `lint --rule X` reports or fixes only X. It errors on a name that is not an active rule (unknown, or disabled by config). Custom rule ids are matched too.
type Suppressor ¶
type Suppressor struct {
// contains filtered or unexported fields
}
Suppressor matches findings against inline doclint-disable directives and tracks which directives went unused.
func NewSuppressor ¶
func NewSuppressor(doc *document.Document) *Suppressor
NewSuppressor scans a document for suppression directives.
func (*Suppressor) Suppressed ¶
func (s *Suppressor) Suppressed(f rule.Finding) bool
Suppressed reports whether f is silenced, marking the matching directive used.
func (*Suppressor) Unused ¶
func (s *Suppressor) Unused() []rule.Finding
Unused returns findings describing directives that matched nothing.