Fix minor 'sg lint --help' issue(?) (#62308)

* Fix minor 'sg lint --help' issue(?)

* Address PR feedback
This commit is contained in:
Chris Smith 2024-04-30 14:49:48 -07:00 committed by GitHub
parent 2c1beefb78
commit cb54fc635a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 1603 deletions

View File

@ -109,6 +109,8 @@ var Targets = []Target{
Formatting,
}
// Formatting is set aside from Targets so that we can reference it directly.
// e.g. to include it automatically when running other linters.
var Formatting = Target{
Name: "format",
Description: "Check client code and docs for formatting errors",
@ -191,10 +193,3 @@ func bazelExec(name, args string) *linter {
func pnpmInstallFilter() pipeline.Pipeline {
return pipeline.Filter(func(line []byte) bool { return !bytes.Contains(line, []byte("warning")) })
}
// disabled can be used to mark a category or check as disabled.
func disabled(reason string) check.EnableFunc[*repo.State] {
return func(context.Context, *repo.State) error {
return errors.Newf("disabled: %s", reason)
}
}

View File

@ -80,7 +80,7 @@ sg lint --help
targets := cmd.Args().Slice()
if len(targets) == 0 {
// If no args provided, run all
// If no args provided, run all of them.
for _, t := range linters.Targets {
if lintSkipFormatCheck.Get(cmd) {
continue
@ -89,9 +89,8 @@ sg lint --help
lintTargets = append(lintTargets, t)
targets = append(targets, t.Name)
}
} else {
// Otherwise run requested set
// Otherwise run requested set.
allLintTargetsMap := make(map[string]linters.Target, len(linters.Targets))
for _, c := range linters.Targets {
allLintTargetsMap[c.Name] = c
@ -111,7 +110,7 @@ sg lint --help
lintTargets = append(lintTargets, target)
}
// If we haven't added the format target already, add it! Unless we must skip it
// If we haven't added the format target already, add it! Unless we must skip it.
if !lintSkipFormatCheck.Get(cmd) && !hasFormatTarget {
lintTargets = append(lintTargets, linters.Formatting)
targets = append(targets, linters.Formatting.Name)
@ -132,7 +131,7 @@ sg lint --help
std.Out.WriteNoticef("Running checks from targets: %s", strings.Join(targets, ", "))
return runner.Check(cmd.Context, repoState)
},
Subcommands: lintTargets(append(linters.Targets, linters.Formatting)).Commands(),
Subcommands: lintTargets(linters.Targets).Commands(),
}
type lintTargets []linters.Target

File diff suppressed because it is too large Load Diff