dev: sorts deprecated linters at the end of lists (#4642)
This commit is contained in:
parent
5f9277dbc9
commit
ad70a8884b
@ -2,6 +2,7 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -106,8 +107,20 @@ func (c *helpCommand) printPresets() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printLinters(lcs []*linter.Config) {
|
func printLinters(lcs []*linter.Config) {
|
||||||
sort.Slice(lcs, func(i, j int) bool {
|
slices.SortFunc(lcs, func(a, b *linter.Config) int {
|
||||||
return lcs[i].Name() < lcs[j].Name()
|
if a.IsDeprecated() && b.IsDeprecated() {
|
||||||
|
return strings.Compare(a.Name(), b.Name())
|
||||||
|
}
|
||||||
|
|
||||||
|
if a.IsDeprecated() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if b.IsDeprecated() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Compare(a.Name(), b.Name())
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, lc := range lcs {
|
for _, lc := range lcs {
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
@ -53,6 +54,22 @@ func getLintersListMarkdown(enabled bool) string {
|
|||||||
return neededLcs[i].Name < neededLcs[j].Name
|
return neededLcs[i].Name < neededLcs[j].Name
|
||||||
})
|
})
|
||||||
|
|
||||||
|
slices.SortFunc(neededLcs, func(a, b *types.LinterWrapper) int {
|
||||||
|
if a.IsDeprecated() && b.IsDeprecated() {
|
||||||
|
return strings.Compare(a.Name, b.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
if a.IsDeprecated() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if b.IsDeprecated() {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Compare(a.Name, b.Name)
|
||||||
|
})
|
||||||
|
|
||||||
lines := []string{
|
lines := []string{
|
||||||
"|Name|Description|Presets|AutoFix|Since|",
|
"|Name|Description|Presets|AutoFix|Since|",
|
||||||
"|---|---|---|---|---|---|",
|
"|---|---|---|---|---|---|",
|
||||||
|
@ -45,3 +45,7 @@ type LinterWrapper struct {
|
|||||||
Since string `json:"since,omitempty"`
|
Since string `json:"since,omitempty"`
|
||||||
Deprecation *Deprecation `json:"deprecation,omitempty"`
|
Deprecation *Deprecation `json:"deprecation,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *LinterWrapper) IsDeprecated() bool {
|
||||||
|
return l.Deprecation != nil
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user