Package buildifier implements processing of Starlark files via buildifier.

    Buildifier is primarily intended for Bazel files. We try to disable as much of Bazel-specific logic as possible, keeping only generally useful Starlark rules.



    This section is empty.


    View Source
    var (
    	// ErrActionableFindings is returned by Lint if there are actionable findings.
    	ErrActionableFindings = errors.New("some *.star files have linter warnings, please fix them")


    func Visit

    func Visit(loader interpreter.Loader, paths []string, v Visitor) errors.MultiError

      Visit parses Starlark files using Buildifier and calls the callback for each parsed file, in parallel.

      Collects all errors from all callbacks in a single joint multi-error.


      type Finding

      type Finding struct {
      	Path       string    `json:"path"`
      	Start      *Position `json:"start,omitempty"`
      	End        *Position `json:"end,omitempty"`
      	Category   string    `json:"string,omitempty"`
      	Message    string    `json:"message,omitempty"`
      	Actionable bool      `json:"actionable,omitempty"`

        Finding is information about one linting or formatting error.

        Implements error interface. Non-actionable findings are assumed to be non-blocking errors.

        func Lint

        func Lint(loader interpreter.Loader, paths []string, lintChecks []string) (findings []*Finding, err error)

          Lint appliers linting and formatting checks to the given files.

          Returns all findings and a non-nil error (usually a MultiError) if some findings are blocking.

          func (*Finding) Error

          func (f *Finding) Error() string

            Error returns a short summary of the finding.

            func (*Finding) Format

            func (f *Finding) Format() string

              Format returns a detailed reported that can be printed to stderr.

              type Position

              type Position struct {
              	Line   int `json:"line"`   // starting from 1
              	Column int `json:"column`  // in runes, starting from 1
              	Offset int `json:"offset"` // absolute offset in bytes

                Position indicates a position within a file.

                type Visitor

                type Visitor func(path string, body []byte, f *build.File) errors.MultiError

                  Visitor processes a parsed Starlark file, returning all errors encountered when processing it.

                  Source Files