Proposal: Custom Linter#190
Conversation
5178ee3 to
246f818
Compare
|
Sounds cool, ima take a look. If it's not too hard to implement maintain would be a good addition |
|
Let me summarize the changes I made today: I moved the linter logic into internal and made it take a struct lintRule. What is lint rule? In the same directory there is a file: linterRules.go that contains a struct lintrule. This struct defines where the linter goes, what files it should skip, and bad imports. Thats all for now, but it can be easily expanded upon later if we want to check for functions and such. After the struct is defined, there is a function below that creates a list of rules to lint through. Once main receives this list, it goes through and lints all the rules. |
|
|
||
| func Lint(rule lintRule) { | ||
|
|
||
| os.Chdir(rule.path) |
There was a problem hiding this comment.
This line might cause issues. I am thinking what if it goes to internal/api/etc and then tries to change to internal/cli/etc from there? Haven't confirmed if this is the case yet.
Hello, I was messing around with go/ast and had an idea we could make a custom linter for our project.
Why?
A custom linter can be useful for our projects to enforce architectural rules, for example here in this proposal I am enforcing the rule of no dbmodel imports in the api handlers. I think this will help future contributors follow architectural rules that they may not be aware off by getting caught in the ci first and reading about it possibly. The ci will fail if merged, which means it is currently working as intended.
It's pretty messy right now in the proposal state, but I want to put the idea out there for you all. Feel free to leave thoughts/comments/questions about it, Ill answer them.