docs: improve linters page (#1842)
This commit is contained in:
parent
e1a734e559
commit
92adaa4497
@ -237,6 +237,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithURL("https://github.com/denis-tingajkin/go-header"),
|
WithURL("https://github.com/denis-tingajkin/go-header"),
|
||||||
linter.NewConfig(golinters.NewGci()).
|
linter.NewConfig(golinters.NewGci()).
|
||||||
|
WithPresets(linter.PresetFormatting).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://github.com/daixiang0/gci"),
|
WithURL("https://github.com/daixiang0/gci"),
|
||||||
@ -254,8 +255,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
|
|||||||
WithAutoFix().
|
WithAutoFix().
|
||||||
WithURL("https://github.com/client9/misspell"),
|
WithURL("https://github.com/client9/misspell"),
|
||||||
linter.NewConfig(golinters.NewLLL()).
|
linter.NewConfig(golinters.NewLLL()).
|
||||||
WithPresets(linter.PresetStyle).
|
WithPresets(linter.PresetStyle),
|
||||||
WithURL("https://github.com/walle/lll"),
|
|
||||||
linter.NewConfig(golinters.NewUnparam()).
|
linter.NewConfig(golinters.NewUnparam()).
|
||||||
WithPresets(linter.PresetUnused).
|
WithPresets(linter.PresetUnused).
|
||||||
WithLoadForGoAnalysis().
|
WithLoadForGoAnalysis().
|
||||||
|
@ -225,21 +225,56 @@ func getLintersListMarkdown(enabled bool) string {
|
|||||||
sort.Slice(neededLcs, func(i, j int) bool {
|
sort.Slice(neededLcs, func(i, j int) bool {
|
||||||
return neededLcs[i].Name() < neededLcs[j].Name()
|
return neededLcs[i].Name() < neededLcs[j].Name()
|
||||||
})
|
})
|
||||||
var lines []string
|
|
||||||
for _, lc := range neededLcs {
|
lines := []string{
|
||||||
var link string
|
"|Name|Description|Presets|AutoFix|Deprecated|",
|
||||||
if lc.OriginalURL != "" {
|
"|---|---|---|---|---|",
|
||||||
link = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
|
|
||||||
} else {
|
|
||||||
link = lc.Name()
|
|
||||||
}
|
}
|
||||||
line := fmt.Sprintf("- %s - %s", link, lc.Linter.Desc())
|
|
||||||
|
for _, lc := range neededLcs {
|
||||||
|
line := fmt.Sprintf("|%s|%s|%s|%v|%s|",
|
||||||
|
getName(lc),
|
||||||
|
getDesc(lc),
|
||||||
|
strings.Join(lc.InPresets, ", "),
|
||||||
|
check(lc.CanAutoFix, "Auto fix supported"),
|
||||||
|
check(lc.DeprecatedMessage != "", "Deprecated"),
|
||||||
|
)
|
||||||
lines = append(lines, line)
|
lines = append(lines, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join(lines, "\n")
|
return strings.Join(lines, "\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getName(lc *linter.Config) string {
|
||||||
|
name := lc.Name()
|
||||||
|
|
||||||
|
if lc.OriginalURL != "" {
|
||||||
|
name = fmt.Sprintf("[%s](%s)", lc.Name(), lc.OriginalURL)
|
||||||
|
}
|
||||||
|
|
||||||
|
if lc.DeprecatedMessage != "" {
|
||||||
|
name += ` <span title="deprecated">⚠</span>`
|
||||||
|
}
|
||||||
|
|
||||||
|
return name
|
||||||
|
}
|
||||||
|
|
||||||
|
func getDesc(lc *linter.Config) string {
|
||||||
|
desc := lc.Linter.Desc()
|
||||||
|
if lc.DeprecatedMessage != "" {
|
||||||
|
desc = lc.DeprecatedMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.ReplaceAll(desc, "\n", "<br/>")
|
||||||
|
}
|
||||||
|
|
||||||
|
func check(b bool, title string) string {
|
||||||
|
if b {
|
||||||
|
return `<span title="` + title + `">✔</span>`
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func getThanksList() string {
|
func getThanksList() string {
|
||||||
var lines []string
|
var lines []string
|
||||||
addedAuthors := map[string]bool{}
|
addedAuthors := map[string]bool{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user