https://pantsbuild.org/ logo
p

proud-dentist-22844

06/15/2022, 3:28 AM
It looks like 2.12 unifies fmt/lint under the hood: https://github.com/pantsbuild/pants/pull/14903 How will this tutorial change to account for that? https://www.pantsbuild.org/docs/plugins-fmt-goal#3-create-fmt-and-lint-rules Has anyone looked at that? ie, can I skip writing a lint rule, and just write a fmt rule?
w

wide-midnight-78598

06/15/2022, 5:29 AM
If you're writing a language formatter, you get the lint goal for free, and I think most/all of the formatter codes have been updated to that (example: https://github.com/pantsbuild/pants/blob/main/src/python/pants/backend/cc/lint/clangformat/rules.py) However, something I ran into yesterday is that if you have a tool that does best-effort lint fixes/formatting, but still has issues that are strictly lint, you need to write separate lint + fmt components, otherwise you suppress valid lint warnings. Seems obvious, but it was surprisingly surprising when I noticed it. So, in my case, I had to revert back to the classic way of doing this.
šŸ‘ 2
b

bitter-ability-32190

06/15/2022, 3:03 PM
if you have a tool that does best-effort lint fixes/formatting, but still has issues that are strictly lint, you need to write separate lint + fmt components
Oh this is interesting. Some notes: ā€¢ You probably want to have the lint rule do just lint things (if possible) so you don't duplicate the work or output ā€¢ You probably want it to use a different subsystem/option scope or else the output might duplicate the name
p

proud-dentist-22844

06/15/2022, 3:06 PM
ansible-lint
will do this. It's primarily a lint tool, but I'm adding the ability for it to reformat / update files. It will only be able to fix a subset of issues however.
However, for what I'm currently doing (codegen disguised as
fmt
), doing just one
fmt
implementation will work marvelously.
b

bitter-ability-32190

06/15/2022, 3:09 PM
Yeah it was really satisfying removing all the duplicitous code from our formatter šŸ˜ˆ
p

proud-dentist-22844

06/15/2022, 3:09 PM
Cleaning up legacy stuff is very satisfying. šŸ‘¼ (as it should be)
clean code is angelic in a devilishly pleasurable way...
āž• 2
w

wide-midnight-78598

06/15/2022, 4:49 PM
Hahah, @proud-dentist-22844 That was the exact tool I was referring to
šŸ˜† 1
Oh this is interesting. Some notes:
ā€¢ You probably want to have the lint rule do just lint things (if possible) so you don't duplicate the work or output
ā€¢ You probably want it to use a different subsystem/option scope or else the output might duplicate the name
Yeah, I'll need to look into this a bit - it was all a bit odd having to go back to the previous style - I'm still a bit discombobulated
šŸ˜µ 1