Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsText ¶
IsText reports whether a significant prefix of s looks like correct UTF-8; that is, if it is likely that s is human-readable text.
see godoc: https://github.com/golang/tools/blob/gopls/v0.3.3/godoc/util/util.go#L38-L56
func MustCompileIgnoreLines ¶
MustCompileIgnoreLines compiles the ignore lines and throws a panic if it fails
Types ¶
type Config ¶
type Config struct { // AutoFix sets if the linter should try to fix the error AutoFix bool `yaml:"autofix"` Verbose bool `yaml:"verbose"` // Ignore uses the gitignore syntax the select which files or folders to ignore Ignore []string `yaml:"ignore"` // Rules contains configuration specific for each rule Rules RulesConfig `yaml:"rules"` }
Config represents a Rule configuration
func NewConfigFromFile ¶
NewConfigFromFile returns a new Config
func NewDefaultConfig ¶
func NewDefaultConfig() Config
type EndOfFileConfig ¶
type EndOfFileConfig struct { Enable bool `yaml:"enable"` DisableAutofix bool `yaml:"disable-autofix"` // Ignore uses the gitignore syntax the select which files or folders to ignore Ignore []string `yaml:"ignore"` SingleNewLine bool `yaml:"single-new-line"` }
EndOfFileConfig config for the End of File rule
type EndOfFileRule ¶
type EndOfFileRule struct { Rule // If SingleNewLine is true, the EndOfFileRule expects that files end strictly in a // single newline character. SingleNewLine bool }
EndOfFileRule checks if the file ends in a newline character, or `\n`. It can be configured to check if it ends strictly in a single newline or in any number of newline characters.
type Linter ¶
type Linter interface { GetName() string // Lint performs the lint operation. // // valid: if true, the file is valid, the linting check has passed // fix: if true, the linter will return a "fixed" copy of the file Lint([]byte) (valid bool, fix []byte) ShouldIgnore(path string) bool }
Linter exposes the lint method
func NewEndOfFileRule ¶
NewEndOfFileRule returns a new EndOfFileRule
type Rule ¶
type Rule struct { Config Name string Description string // AutoFix sets if the linter should try to fix the error; if false, this Rule should // only return if the text is valid or not when the lint method is called; otherwise // the lint method should return a fixed copy of the data, to pass the linting rule AutoFix bool // ignore uses the gitignore syntax the select which files or folders to ignore Ignore *gitignore.GitIgnore }
Rule represents a linting rule
func (Rule) ShouldIgnore ¶
ShouldIgnore decides if the file should be ignored based on the Ignore configuration
type RulesConfig ¶
type RulesConfig struct {
EndOfFile EndOfFileConfig `yaml:"end-of-file"`
}
RulesConfig is the map of configs which includes all rules