config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config loads .doclint.yaml: rule defaults/toggles, per-rule settings, ignore globs, and the declarative custom-rule block.

Index

Constants

View Source
const ConfigName = ".doclint.yaml"

ConfigName is the discovered file name.

Variables

This section is empty.

Functions

func Discover

func Discover(start string) (string, error)

Discover walks up from start looking for ConfigName; returns "" if none.

func Validate added in v0.2.2

func Validate(cfg *Config, knownRules []string) error

Validate checks a loaded config and returns the first problem as a clear, file-prefixed error. knownRules are the registered built-in rule names; custom rule IDs are added to the known set so enable/disable/settings may reference them. It runs at preflight, before the engine builds, so a malformed config fails fast with an actionable message instead of silently doing nothing.

Types

type Config

type Config struct {
	Default  string                 `yaml:"default"`
	Enable   []string               `yaml:"enable"`
	Disable  []string               `yaml:"disable"`
	Settings map[string]RuleSetting `yaml:"settings"`
	Ignore   []string               `yaml:"ignore"`
	Paths    []string               `yaml:"paths"` // default lint/fmt targets when none given on the CLI
	Custom   []CustomRule           `yaml:"custom"`

	Dir string `yaml:"-"` // directory of the config file (relative-path base)
}

Config is the parsed .doclint.yaml plus the directory it was loaded from.

func Default

func Default() *Config

Default returns the built-in config used when no file is found.

func Load

func Load(path string) (*Config, error)

Load reads and parses a config file.

type CustomRule

type CustomRule struct {
	ID         string   `yaml:"id"`
	Type       string   `yaml:"type"`
	Glob       string   `yaml:"glob"`
	Field      string   `yaml:"field"`
	Fields     []string `yaml:"fields"`
	Min        int      `yaml:"min"`
	Max        int      `yaml:"max"`
	Pattern    string   `yaml:"pattern"`
	SkipDrafts bool     `yaml:"skip_drafts"`
	Severity   string   `yaml:"severity"`
}

CustomRule is one declarative rule (mirrors rule.DeclSpec; kept decoupled so config has no dependency on package rule's internals).

type RuleSetting

type RuleSetting struct {
	Severity string `yaml:"severity"`
}

RuleSetting overrides a rule's defaults.

Jump to

Keyboard shortcuts

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