Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion scripts/expand_website_templates/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import (
"os"
"os/exec"
"path/filepath"
"reflect"
"sort"
"strings"

"gopkg.in/yaml.v3"

"github.com/golangci/golangci-lint/internal/renameio"
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/lint/linter"
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
)
Expand Down Expand Up @@ -251,7 +253,11 @@ func getName(lc *linter.Config) string {
name := lc.Name()

if lc.OriginalURL != "" {
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
name = fmt.Sprintf("[%s](%s)", name, lc.OriginalURL)
}

if hasSettings(lc.Name()) {
name = fmt.Sprintf("%s [%s](#%s)", name, span("Configuration", "⚙️"), lc.Name())
}

if !lc.IsDeprecated() {
Expand Down Expand Up @@ -285,6 +291,18 @@ func check(b bool, title string) string {
return ""
}

func hasSettings(name string) bool {
tp := reflect.TypeOf(config.LintersSettings{})

for i := 0; i < tp.NumField(); i++ {
if strings.EqualFold(name, tp.Field(i).Name) {
return true
}
}

return false
}

func span(title, icon string) string {
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
}
Expand Down