[INTT-54] Add code formatters for general projects#27
Conversation
b01aa11 to
8779985
Compare
7d3ce0d to
541b197
Compare
8779985 to
967200f
Compare
541b197 to
5d5a75e
Compare
e2c0d4d to
9d3cce6
Compare
d0c9fd7 to
98dc997
Compare
9d3cce6 to
b827153
Compare
98dc997 to
5e4322c
Compare
b827153 to
1fa2de8
Compare
5e4322c to
a73e464
Compare
1fa2de8 to
55899db
Compare
2b0046a to
03ae9e0
Compare
55899db to
ec56415
Compare
cf2069f to
290c8d4
Compare
ec56415 to
24692cb
Compare
| programs = { | ||
| prettier.enable = true; | ||
| sqlfluff.enable = true; | ||
| shfmt.enable = true; |
There was a problem hiding this comment.
We have programs.shfmt.indent_size = 0; to use tabs for indentation :))
There was a problem hiding this comment.
That's the default setting:
-i, --indent uint 0 for tabs (default), >0 for number of spaces
|
|
||
| programs = { | ||
| prettier.enable = true; | ||
| sqlfluff.enable = true; |
There was a problem hiding this comment.
We explicitly went without sqlfluff, because it couldn't handle our complicated postgres
| }; | ||
|
|
||
| programs = { | ||
| prettier.enable = true; |
There was a problem hiding this comment.
Might want to borrow our prettierrc:
{
"overrides": [
{
"files": [
"*.yml",
"*.yaml"
],
"options": {
"singleQuote": false,
"printWidth": 120,
"tabWidth": 2,
"proseWrap": "preserve"
}
}
]
}There was a problem hiding this comment.
arguing about formatting timeeeeee.
Maybe one formatter per PR would be the way to go :(
RasmusRendal
left a comment
There was a problem hiding this comment.
This is pretty great
emgrav
left a comment
There was a problem hiding this comment.
Looks good! I have two questions that are probably not really relevant to this PR, but if the blockers are not big it would be cool if we were able to close these tickets with this PR if we can clear the blockers.
| # TODO: We want to use this, but it conflicts with rustfmt in places | ||
| # In the future, we can simply make rustfmt run as a pre-commit hook | ||
| # after trailing-whitespace, and it won't be a problem. | ||
| # { id = "trailing-whitespace"; } |
There was a problem hiding this comment.
What exactly is needed to make rustfmt run as a pre-commit hook after trailing-whitespace? Adding this back in is tracked in https://famedly.atlassian.net/browse/INTT-55
If we already know what the blocker preventing us from re-enabling it is, it would be great if this information could be added to the ticket :)
There was a problem hiding this comment.
The only thing blocking trailing-whitespace running after the formatter on main is that on main, there's no formatter.
There was a problem hiding this comment.
Yeah, the reason it wasn't as of this PR is because we picked it up in nehws CI. It's a rustfmt bug to begin with, nehws just couldn't start using the pre-commit hooks if we left this one in.
We should probably just fix it as part of this PR.
| # TODO: We would like to use this, but we need to tweak it | ||
| # a little for helm charts. | ||
| # | ||
| # { id = "check-yaml"; } |
There was a problem hiding this comment.
Same thing here, we are tracking the missing check-yaml in INTT-56. In what way does it need to be tweaked for helm charts?
There was a problem hiding this comment.
It probably needs to be disabled entirely. Last time I checked, check-yaml breaks down completely in the face of go templating.
There was a problem hiding this comment.
Could we then maybe standardize around keeping helm charts always in a top-level directory called charts? Then we could reenable check-yaml and simply except crates/** from the check
There was a problem hiding this comment.
I think I like that better than permanently omitting this check. It's nice to be certain that any YAML files that make it into our repos evaluate correctly.
If Helm charts are simply not valid YAML we should find a way to exclude them.
24692cb to
56339b6
Compare
56339b6 to
977c7c1
Compare
This adds formatting with
treefmt, including a pre-commit hook for it. This seems to be reasonably performant, so I think it's fine to keep it in the pre-commit hooks.Documentation is added via devshell commands, which should hopefully be convenient enough for downstream users.