linter

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyRuleFixes

func ApplyRuleFixes[M LintMessage](code string, diagnostics []M) (string, []M, bool)

func RunLinterInProgram added in v0.1.9

func RunLinterInProgram(program *compiler.Program, allowFiles []string, allowDirs []string, skipFiles []string, getRulesForFile RuleHandler, typeCheck bool, onDiagnostic DiagnosticHandler, typeInfoFiles map[string]struct{}, fileFilter func(string) bool) int32

RunLinterInProgram lints files in a single Program. Files are filtered through skipFiles, allowFiles/allowDirs, and the optional fileFilter before rule execution. fileFilter is a caller-supplied predicate covering any reason to skip a file — used for multi-config ownership-based deduplication and for config `ignores` patterns. Files it rejects are excluded from rule diagnostics, type-check diagnostics, and the returned linted-file count. Pass nil to lint all files.

Types

type ConfiguredRule

type ConfiguredRule struct {
	Name             string
	Settings         map[string]interface{}
	Severity         rule.DiagnosticSeverity
	RequiresTypeInfo bool
	Run              func(ctx rule.RuleContext) rule.RuleListeners
}

func FilterNonTypeAwareRules added in v0.4.0

func FilterNonTypeAwareRules(rules []ConfiguredRule) []ConfiguredRule

FilterNonTypeAwareRules returns only rules that do not require type information.

type DiagnosticHandler added in v0.1.9

type DiagnosticHandler = func(diagnostic rule.RuleDiagnostic)

type LintMessage

type LintMessage interface {
	Fixes() []rule.RuleFix
}

type LintResult added in v0.5.0

type LintResult struct {
	LintedFileCount int32
	ExecutedRules   map[string]struct{}
}

LintResult holds the outcome of a RunLinter invocation.

func RunLinter

func RunLinter(programs []*compiler.Program, singleThreaded bool, allowFiles []string, allowDirs []string, excludedPaths []string, getRulesForFile RuleHandler, typeCheck bool, onDiagnostic DiagnosticHandler, typeInfoFiles map[string]struct{}, fileFilters []func(string) bool) (*LintResult, error)

RunLinter runs all configured rules across the given programs in parallel.

  • allowFiles: if non-nil, only lint files in this list; nil = all files
  • allowDirs: if non-nil, also lint files under these dirs (OR with allowFiles)
  • typeInfoFiles: files with type info; gap files not in this set skip type-aware rules
  • fileFilters: optional per-program skip predicates (parallel to programs). Each filter covers any caller-specific reason to skip a file — multi-config ownership deduplication and config `ignores` exclusion are both composed in here by the caller. nil or missing entries = no filter (process all).

type RuleHandler added in v0.1.9

type RuleHandler = func(sourceFile *ast.SourceFile) []ConfiguredRule

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL