Skip to content

Commit 92adaa4

Browse files
authored
docs: improve linters page (#1842)
1 parent e1a734e commit 92adaa4

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

pkg/golinters/errorlint.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func NewErrorLint(cfg *config.ErrorLintSettings) *goanalysis.Linter {
1919
return goanalysis.NewLinter(
2020
"errorlint",
2121
"go-errorlint is a source code linter for Go software "+
22-
"that can be used to find code that will cause problems"+
22+
"that can be used to find code that will cause problems "+
2323
"with the error wrapping scheme introduced in Go 1.13.",
2424
[]*analysis.Analyzer{a},
2525
cfgMap,

pkg/lint/lintersdb/manager.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
237237
WithLoadForGoAnalysis().
238238
WithURL("https://github.com/denis-tingajkin/go-header"),
239239
linter.NewConfig(golinters.NewGci()).
240+
WithPresets(linter.PresetFormatting).
240241
WithLoadForGoAnalysis().
241242
WithAutoFix().
242243
WithURL("https://github.com/daixiang0/gci"),
@@ -254,8 +255,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
254255
WithAutoFix().
255256
WithURL("https://github.com/client9/misspell"),
256257
linter.NewConfig(golinters.NewLLL()).
257-
WithPresets(linter.PresetStyle).
258-
WithURL("https://github.com/walle/lll"),
258+
WithPresets(linter.PresetStyle),
259259
linter.NewConfig(golinters.NewUnparam()).
260260
WithPresets(linter.PresetUnused).
261261
WithLoadForGoAnalysis().

scripts/expand_website_templates/main.go

+43-8
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,56 @@ func getLintersListMarkdown(enabled bool) string {
225225
sort.Slice(neededLcs, func(i, j int) bool {
226226
return neededLcs[i].Name() < neededLcs[j].Name()
227227
})
228-
var lines []string
228+
229+
lines := []string{
230+
"|Name|Description|Presets|AutoFix|Deprecated|",
231+
"|---|---|---|---|---|",
232+
}
233+
229234
for _, lc := range neededLcs {
230-
var link string
231-
if lc.OriginalURL != "" {
232-
link = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
233-
} else {
234-
link = lc.Name()
235-
}
236-
line := fmt.Sprintf("- %s - %s", link, lc.Linter.Desc())
235+
line := fmt.Sprintf("|%s|%s|%s|%v|%s|",
236+
getName(lc),
237+
getDesc(lc),
238+
strings.Join(lc.InPresets, ", "),
239+
check(lc.CanAutoFix, "Auto fix supported"),
240+
check(lc.DeprecatedMessage != "", "Deprecated"),
241+
)
237242
lines = append(lines, line)
238243
}
239244

240245
return strings.Join(lines, "\n")
241246
}
242247

248+
func getName(lc *linter.Config) string {
249+
name := lc.Name()
250+
251+
if lc.OriginalURL != "" {
252+
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
253+
}
254+
255+
if lc.DeprecatedMessage != "" {
256+
name += ` <span title="deprecated">⚠</span>`
257+
}
258+
259+
return name
260+
}
261+
262+
func getDesc(lc *linter.Config) string {
263+
desc := lc.Linter.Desc()
264+
if lc.DeprecatedMessage != "" {
265+
desc = lc.DeprecatedMessage
266+
}
267+
268+
return strings.ReplaceAll(desc, "\n", "<br/>")
269+
}
270+
271+
func check(b bool, title string) string {
272+
if b {
273+
return `<span title="` + title + `">✔</span>`
274+
}
275+
return ""
276+
}
277+
243278
func getThanksList() string {
244279
var lines []string
245280
addedAuthors := map[string]bool{}

0 commit comments

Comments
 (0)