Skip to content

Commit d7e110e

Browse files
authored
docs: add link to configuration in the linters list (#2587)
1 parent 949b059 commit d7e110e

File tree

1 file changed

+19
-1
lines changed
  • scripts/expand_website_templates

1 file changed

+19
-1
lines changed

Diff for: scripts/expand_website_templates/main.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import (
1313
"os"
1414
"os/exec"
1515
"path/filepath"
16+
"reflect"
1617
"sort"
1718
"strings"
1819

1920
"gopkg.in/yaml.v3"
2021

2122
"github.com/golangci/golangci-lint/internal/renameio"
23+
"github.com/golangci/golangci-lint/pkg/config"
2224
"github.com/golangci/golangci-lint/pkg/lint/linter"
2325
"github.com/golangci/golangci-lint/pkg/lint/lintersdb"
2426
)
@@ -251,7 +253,11 @@ func getName(lc *linter.Config) string {
251253
name := lc.Name()
252254

253255
if lc.OriginalURL != "" {
254-
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
256+
name = fmt.Sprintf("[%s](%s)", name, lc.OriginalURL)
257+
}
258+
259+
if hasSettings(lc.Name()) {
260+
name = fmt.Sprintf("%s [%s](#%s)", name, span("Configuration", "⚙️"), lc.Name())
255261
}
256262

257263
if !lc.IsDeprecated() {
@@ -285,6 +291,18 @@ func check(b bool, title string) string {
285291
return ""
286292
}
287293

294+
func hasSettings(name string) bool {
295+
tp := reflect.TypeOf(config.LintersSettings{})
296+
297+
for i := 0; i < tp.NumField(); i++ {
298+
if strings.EqualFold(name, tp.Field(i).Name) {
299+
return true
300+
}
301+
}
302+
303+
return false
304+
}
305+
288306
func span(title, icon string) string {
289307
return fmt.Sprintf(`<span title=%q>%s</span>`, title, icon)
290308
}

0 commit comments

Comments
 (0)