Add versions, improve deprecation system, improve linters page (#1854)

This commit is contained in:
Ludovic Fernandez 2021-03-17 16:17:33 +01:00 committed by GitHub
parent b6a6faa982
commit 8db518cee0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 156 additions and 39 deletions

View file

@ -20,6 +20,12 @@ const (
PresetUnused = "unused" // Related to the detection of unused code.
)
type Deprecation struct {
Since string
Message string
Replacement string
}
type Config struct {
Linter Linter
EnabledByDefault bool
@ -29,11 +35,13 @@ type Config struct {
InPresets []string
AlternativeNames []string
OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
CanAutoFix bool
IsSlow bool
DoesChangeTypes bool
DeprecatedMessage string
OriginalURL string // URL of original (not forked) repo, needed for autogenerated README
CanAutoFix bool
IsSlow bool
DoesChangeTypes bool
Since string
Deprecation *Deprecation
}
func (lc *Config) ConsiderSlow() *Config {
@ -82,13 +90,22 @@ func (lc *Config) WithChangeTypes() *Config {
return lc
}
func (lc *Config) Deprecated(message string) *Config {
lc.DeprecatedMessage = message
func (lc *Config) WithSince(version string) *Config {
lc.Since = version
return lc
}
func (lc *Config) Deprecated(message, version, replacement string) *Config {
lc.Deprecation = &Deprecation{
Since: version,
Message: message,
Replacement: replacement,
}
return lc
}
func (lc *Config) IsDeprecated() bool {
return lc.DeprecatedMessage != ""
return lc.Deprecation != nil
}
func (lc *Config) AllNames() []string {