Documentation
¶
Overview ¶
Package config provides configuration file support for api-style-spec.
Configuration files are loaded from multiple locations in priority order:
- Explicit path via --config flag
- .api-style.yaml in current directory
- .api-style.yml in current directory
- api-style.yaml in current directory
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ConfigFileNames = []string{
".api-style.yaml",
".api-style.yml",
"api-style.yaml",
"api-style.yml",
".api-style.json",
"api-style.json",
}
ConfigFileNames are the supported config file names in priority order.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Profile is the style profile to use for linting.
Profile string `yaml:"profile" json:"profile"`
// Level is the target conformance level (bronze, silver, gold).
Level string `yaml:"level" json:"level"`
// Exceptions defines rule exceptions for this project.
Exceptions []ExceptionConfig `yaml:"exceptions" json:"exceptions"`
// SeverityOverrides allows changing rule severities.
// Map of rule ID to severity (error, warn, info, hint).
SeverityOverrides map[string]string `yaml:"severity-overrides" json:"severityOverrides"`
// Include defines file patterns to include in linting.
Include []string `yaml:"include" json:"include"`
// Exclude defines file patterns to exclude from linting.
Exclude []string `yaml:"exclude" json:"exclude"`
}
Config represents the api-style-spec configuration file.
func Load ¶
Load loads configuration using default search paths. Returns nil config (not an error) if no config file is found.
func LoadOrDefault ¶
LoadOrDefault loads configuration or returns default if not found.
func (*Config) ToExceptions ¶
ToExceptions converts ExceptionConfigs to types.Exception.
type ExceptionConfig ¶
type ExceptionConfig struct {
// RuleID is the rule being waived.
RuleID string `yaml:"rule" json:"rule"`
// Paths are glob patterns where the exception applies.
Paths []string `yaml:"paths" json:"paths"`
// Reason explains why this exception was granted.
Reason string `yaml:"reason" json:"reason"`
}
ExceptionConfig defines an exception in the config file.
Click to show internal directories.
Click to hide internal directories.