linter

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package linter provides the core HTML linting orchestration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// EnabledRules lists rules to enable (empty means all)
	EnabledRules []string
	// DisabledRules lists rules to disable
	DisabledRules []string
	// RuleSeverity overrides severity for specific rules
	RuleSeverity map[string]rules.Severity
	// MinSeverity filters results to this severity or higher
	MinSeverity rules.Severity
	// IgnorePatterns are glob patterns for files to skip
	IgnorePatterns []string
	// ConfigPath is the path to the loaded config file (for debugging)
	ConfigPath string
	// Frameworks configures framework-specific attribute handling.
	Frameworks FrameworkConfig
}

Config holds linter configuration options.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a configuration with all rules enabled.

func (*Config) ErrorsOnly

func (c *Config) ErrorsOnly() *Config

ErrorsOnly configures the linter to only report errors.

func (*Config) IsRuleEnabled

func (c *Config) IsRuleEnabled(name string) bool

IsRuleEnabled checks if a rule should be run.

func (*Config) WarningsAndErrors

func (c *Config) WarningsAndErrors() *Config

WarningsAndErrors configures the linter to report warnings and errors.

type FrameworkConfig added in v0.5.0

type FrameworkConfig struct {
	// HTMX enables htmx attribute validation.
	HTMX bool
	// HTMXVersion specifies which htmx version to validate against ("2" or "4").
	// Defaults to "2" when HTMX is enabled.
	HTMXVersion string
}

FrameworkConfig configures framework-specific attribute handling.

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

Linter coordinates HTML template accessibility checking.

func New

func New(cfg *Config) *Linter

New creates a new Linter with the given configuration.

func (*Linter) LintContent

func (l *Linter) LintContent(filename string, content []byte) ([]rules.Result, error)

LintContent checks HTML content and returns any violations.

func (*Linter) LintDir

func (l *Linter) LintDir(dir string) ([]rules.Result, error)

LintDir recursively checks all HTML files in a directory.

func (*Linter) LintFile

func (l *Linter) LintFile(path string) ([]rules.Result, error)

LintFile checks a single file and returns any violations.

func (*Linter) LintFiles

func (l *Linter) LintFiles(paths []string) ([]rules.Result, error)

LintFiles checks multiple files and returns all violations.

func (*Linter) Run

func (l *Linter) Run(paths []string) (int, error)

Run executes linting and reports results.

func (*Linter) SetReporter

func (l *Linter) SetReporter(r Reporter)

SetReporter sets the output reporter.

type Reporter

type Reporter interface {
	Report(results []rules.Result) error
}

Reporter defines the interface for outputting lint results.

Jump to

Keyboard shortcuts

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