Documentation ¶
Overview ¶
Package eclint is a set of linters to for the EditorConfig rules
Index ¶
- Constants
- Variables
- func FixWithDefinition(ctx context.Context, d *editorconfig.Definition, filename string) error
- func GitLsFilesContext(ctx context.Context, path string) (<-chan string, <-chan error)
- func Lint(ctx context.Context, filename string) []error
- func LintWithDefinition(ctx context.Context, d *editorconfig.Definition, filename string) []error
- func ListFilesContext(ctx context.Context, args ...string) (<-chan string, <-chan error)
- func MaxLineLength(maxLength int, tabWidth int, data []byte) error
- func OverrideDefinitionUsingPrefix(def *editorconfig.Definition, prefix string) error
- func PrintErrors(ctx context.Context, opt *Option, filename string, errs []error) error
- func ProbeCharsetOrBinary(ctx context.Context, r *bufio.Reader, charset string) (string, bool, error)
- func ReadLines(r io.Reader, fileSize int64, fn LineFunc) []error
- func SplitLines(data []byte, atEOF bool) (int, []byte, error)
- func WalkContext(ctx context.Context, paths ...string) (<-chan string, <-chan 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" // Latin1 is the legacy 7-bits character set. Latin1 = "latin1" )
const DefaultTabWidth = 8
DefaultTabWidth sets the width of a tab used when counting the line length.
Variables ¶
var ErrConfiguration = errors.New("configuration error")
ErrConfiguration represents an error in the editorconfig value.
var ErrNotImplemented = errors.New("not implemented yet, PRs are welcome")
ErrNotImplemented represents a missing feature.
Functions ¶
func FixWithDefinition ¶ added in v0.1.12
FixWithDefinition does the hard work of validating the given file.
func GitLsFilesContext ¶ added in v0.1.2
GitLsFilesContext returns the list of file base on what is in the git index (asynchronously).
-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 ListFilesContext ¶ added in v0.1.2
ListFilesContext lists the files in an asynchronous fashion
When its empty, it relies on `git ls-files` first, which would 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 OverrideDefinitionUsingPrefix ¶ added in v0.0.21
OverrideDefinitionUsingPrefix is an helper that takes the prefixed values.
It replaces those values into the nominal ones. That way a tool could a different set of definition than the real editor would.
func PrintErrors ¶ added in v0.0.5
PrintErrors is the rich output of the program.
func ProbeCharsetOrBinary ¶ added in v0.0.16
func ProbeCharsetOrBinary(ctx context.Context, r *bufio.Reader, charset string) (string, bool, error)
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 something 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 FixAllErrors bool ShowErrorQuantity int Exclude string 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