-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to make actionlint usable when using it as a library #327
Conversation
…te to public, otherwise It's not possible to create new rules
…t as a golang library
What is the reason to make these APIs public? Especially, |
Yes I would like to make my own rules |
Sounds nice. However, current API doesn't assume adding new rules. You need to reimplement Do you want some API to define additional rules? For example: opts := &LinterOptions {
AdditionalRules: func() []Rule {
return []Rule {
NewYourOwnRule(),
}
}
}
linter = NewLinter(os.Stdout, opts)
linter.LintFiles("/path/to/dir", nil) |
Co-authored-by: Linda_pp <[email protected]>
I was actually reimplementing my own Linter to run my custom rules, because I don't want all the rules, so I just need to access the RuleBase and the methods error and errorf to create new rules |
OK. But please note that you can filter out errors from specific rules by |
@hugo-syn I added You can add/remove rules without reimplementing o := &LinterOptions{
OnRulesCreated: func(rules []Rule) []Rule {
// Remove 'runner-label' rule
for i, r := range rules {
if r.Name() == "runner-label" {
rules = append(rules[:i], rules[i+1:]...)
break
}
}
// Add your own rule
rules = append(rules, NewYourOwnRule())
return rules
},
} So you no longer need to reimplement I'd like to keep the API private since it is an implementation detail and can be updated on patch releases. |
Sounds nice, I think that I don't need to re-implement my linter now, thanks :) |
Great. Thank you for confirming that. I'll revert |
I've added a constructor for RuleBase and changed error and errorf from private to public, otherwise It's not possible to create new rules. I hope that this is the best option, if not, how should we create new rules when using actionlint as a library ?
I also changed wait from private to public in process.go.