github.com/yoheimuta/protolint@v0.49.8-0.20240515023657-4ecaebb7575d/_example/plugin/main.go (about)

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