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 LintResult ¶ added in v0.5.0
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