forked from yoheimuta/protolint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
34 lines (27 loc) · 883 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"flag"
"github.com/yoheimuta/protolint/_example/plugin/customrules"
"github.com/yoheimuta/protolint/internal/addon/rules"
"github.com/yoheimuta/protolint/linter/rule"
"github.com/yoheimuta/protolint/plugin"
)
var (
goStyle = flag.Bool("go_style", true, "the comments should follow a golang style")
)
func main() {
flag.Parse()
plugin.RegisterCustomRules(
// The purpose of this line just illustrates that you can implement the same as internal linter rules.
rules.NewEnumsHaveCommentRule(rule.SeverityWarning, *goStyle),
// A common custom rule example. It's simple.
customrules.NewEnumNamesLowerSnakeCaseRule(),
// Wrapping with RuleGen allows referring to command-line flags.
plugin.RuleGen(func(
verbose bool,
fixMode bool,
) rule.Rule {
return customrules.NewSimpleRule(verbose, fixMode, rule.SeverityError)
}),
)
}