Documentation ¶
Overview ¶
Package eclint is a set of linters to for the EditorConfig rules
Index ¶
- Constants
- func ConsumeFilesContext(ctx context.Context, log logr.Logger, filesChan <-chan string, ...) ([]string, error)
- func GitLsFiles(log logr.Logger, path string) ([]string, error)
- func GitLsFilesContext(ctx context.Context, path string) (<-chan string, <-chan error)
- func Lint(filename string, log logr.Logger) []error
- func LintWithDefinition(d *editorconfig.Definition, filename string, log logr.Logger) []error
- func ListFiles(log logr.Logger, args ...string) ([]string, error)deprecated
- func ListFilesContext(ctx context.Context, log logr.Logger, 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(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)deprecated
- 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" )
const DefaultTabWidth = 8
DefaultTabWidth sets the width of a tab used when counting the line length
Variables ¶
This section is empty.
Functions ¶
func ConsumeFilesContext ¶ added in v0.1.2
func ConsumeFilesContext( ctx context.Context, log logr.Logger, filesChan <-chan string, errChan <-chan error, ) ([]string, error)
ConsumeFilesContext is the helper function that consumes the files channel.
func GitLsFiles ¶ added in v0.0.5
GitLsFiles returns the list of file based on what is in the git index.
func GitLsFilesContext ¶ added in v0.1.2
AsyncGitLsFiles 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.
Future work: use go-cmd for async call
func LintWithDefinition ¶ added in v0.0.18
LintWithDefinition does the hard work of validating the given file.
func ListFilesContext ¶ added in v0.1.2
func ListFilesContext(ctx context.Context, log logr.Logger, args ...string) (<-chan string, <-chan error)
ListFilesContext lists the files in an asynchronous fashion
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 OverrideDefinitionUsingPrefix ¶ added in v0.0.21
OverrideDefinitionUsingPrefix is an helper that takes the prefixed values.
It replaces thoses 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
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