rule

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(r Rule)

Register adds a rule to the global registry.

func Reset

func Reset()

Reset clears the registry. Used for testing.

Types

type ConfigTarget added in v0.10.0

type ConfigTarget interface {
	IsConfigFileRule() bool
}

ConfigTarget is implemented by rules that validate the project config file (.mdsmith.yml) rather than individual Markdown files. The engine runner runs these rules once against a synthetic lint.File for the config file before per-file markdown processing; they return nil for all other file paths when configured in production mode.

type Configurable

type Configurable interface {
	ApplySettings(settings map[string]any) error
	DefaultSettings() map[string]any
}

Configurable is implemented by rules that have user-tunable settings.

type Defaultable

type Defaultable interface {
	EnabledByDefault() bool
}

Defaultable is implemented by rules that override the default enabled state in generated/runtime configs.

type FixableRule

type FixableRule interface {
	Rule
	Fix(f *lint.File) []byte
}

FixableRule is a Rule that can also auto-fix violations.

type ListMerger added in v0.7.0

type ListMerger interface {
	SettingMergeMode(key string) MergeMode
}

ListMerger is implemented by Configurable rules that opt one or more list-typed settings out of the default MergeReplace behavior. The merge function calls SettingMergeMode(key) at config-resolution time and treats unknown keys as MergeReplace.

type MergeMode added in v0.7.0

type MergeMode int

MergeMode describes how a list-typed rule setting combines across config layers (defaults, kinds, overrides).

const (
	// MergeReplace is the default: a later layer's list replaces the
	// earlier layer's list wholesale.
	MergeReplace MergeMode = iota
	// MergeAppend concatenates a later layer's list onto the earlier
	// layer's list, preserving layer-chain order.
	MergeAppend
)

type Rule

type Rule interface {
	ID() string
	Name() string
	Category() string
	Check(f *lint.File) []lint.Diagnostic
}

Rule is a single lint rule that checks a Markdown file.

func All

func All() []Rule

All returns a copy of all registered rules.

func ByID

func ByID(id string) Rule

ByID returns the registered rule with the given ID, or nil.

func ByName added in v0.7.0

func ByName(name string) Rule

ByName returns the registered rule with the given Name, or nil.

func CloneRule

func CloneRule(r Rule) Rule

CloneRule creates a deep copy of a rule. If the rule implements Configurable, the clone is produced by creating a new zero-value instance and applying the original's DefaultSettings. Otherwise it falls back to a reflect-based shallow copy of the struct.

Jump to

Keyboard shortcuts

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