Documentation ¶
Overview ¶
Package eclint is a set of linters to for the EditorConfig rules
Index ¶
- Constants
- func GitLsFiles(log logr.Logger, path string) ([]string, error)
- func Lint(filename string, log logr.Logger) []error
- func LintWithDefinition(def *editorconfig.Definition, filename string, log logr.Logger) []error
- func ListFiles(log logr.Logger, args ...string) ([]string, error)
- func MaxLineLength(maxLength int, tabWidth int, data []byte) error
- func PrintErrors(opt Option, filename string, errors []error) error
- func ProbeCharsetOrBinary(r *bufio.Reader, charset string, log logr.Logger) (string, bool, error)
- func ReadLines(r io.Reader, fn LineFunc) []error
- func SplitLines(data []byte, atEOF bool) (int, []byte, error)
- func Walk(log logr.Logger, paths ...string) ([]string, error)
- type LineFunc
- type Option
- type ValidationError
Constants ¶
const ( // UnsetValue is the value equivalent to an empty / unset one. UnsetValue = "unset" // TabValue is the value representing tab indentation (the ugly one) TabValue = "tab" // SpaceValue is the value representing space indentation (the good one) SpaceValue = "space" // Utf8 is the ubiquitous character set Utf8 = "utf-8" )
const DefaultTabWidth = 8
DefaultTabWidth sets the width of a tab used when counting the line length
Variables ¶
This section is empty.
Functions ¶
func GitLsFiles ¶ added in v0.0.5
GitLsFiles returns the list of file based on what is in the git index.
-z is mandatory as some repositories non-ASCII file names which creates quoted and escaped file names. This method also returns directories for any submodule there is. Submodule will be skipped afterwards and thus not checked.
func LintWithDefinition ¶ added in v0.0.18
LintWithDefinition does the hard work of validating the given file.
func ListFiles ¶ added in v0.0.5
ListFiles returns the list of files based on the input.
When its empty, it relies on `git ls-files` first, which whould fail if `git` is not present or the current working directory is not managed by it. In that case, it work the current working directory.
When args are given, it recursively walks into them.
func MaxLineLength ¶ added in v0.0.5
MaxLineLength checks the length of a given line.
It assumes UTF-8 and will count as one runes. The first byte has no prefix 0xxxxxxx, 110xxxxx, 1110xxxx, 11110xxx, 111110xx, etc. and the following byte the 10xxxxxx prefix which are skipped.
func PrintErrors ¶ added in v0.0.5
PrintErrors is the rich output of the program.
func ProbeCharsetOrBinary ¶ added in v0.0.16
ProbeCharsetOrBinary does all the probes to detect the encoding or whether it is a binary file.
func ReadLines ¶ added in v0.0.5
ReadLines consumes the reader and emit each line via the LineFunc
Line numbering starts at 0. Scanner is pretty smart an will reuse its memory structure. This is somehing we explicitly avoid by copying the content to a new slice.
func SplitLines ¶ added in v0.0.5
SplitLines works like bufio.ScanLines while keeping the line endings.
Types ¶
type LineFunc ¶ added in v0.0.5
LineFunc is the callback for a line.
It returns the line number starting from zero.
type Option ¶ added in v0.0.5
type Option struct { IsTerminal bool NoColors bool ShowAllErrors bool Summary bool ShowErrorQuantity int Exclude string Log logr.Logger Stdout io.Writer }
Option contains the environment of the program.
When ShowErrorQuantity is 0, it will show all the errors. Use ShowAllErrors false to disable this.
type ValidationError ¶ added in v0.0.6
ValidationError is a rich type containing information about the error
func (ValidationError) Error ¶ added in v0.0.6
func (e ValidationError) Error() string
Error builds the error string.
func (ValidationError) String ¶ added in v0.0.6
func (e ValidationError) String() string