-
|
ktlint has just been inflicted onto me, and I'm trying to integrate it into my workflow. I've been using jj as a layer on top of git to make it easier to manage patch series. It lets me take a PR with 10 commits, edit the 3rd, and have the changes automatically ripple through the remaining 6 commits, without needing to enter a special git rebase flow. Of course, any rebase operation could turn code that ktlint was happy with into code that ktlint is unhappy with. jj doesn't support commit hooks (long story), but it does accommodate for code reformatters — so long as they read source code from stdin, and write formatted source code to stdout, preferrably without throwing hands (ktlint being unable to wrap long lines around on its own is very disappointing). Can ktlint be coerced to work in this fashion, so I can plug it into jj and keep using my workflow despite having to comply with ktlint's idea of what code is supposed to look like? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Okay, it seems like (once I can figure out which version of ktlint is being used by ktlint-gradle... but that's a separate conversation), all I need to run is something not entirely unlike $ jj config edit --repo
[fix.tools.ktlint]
# --loglevel=none because of https://github.com/pinterest/ktlint/issues/2246
command = ["/path/to/ktlint", "-F", "--stdin", "--stdin-path=$path", "--editorconfig", "/path/to/.editorconfig", "--loglevel=none"]
patterns = ["glob:'**/*.kt'", "glob:'**/*.kts'"]It's not a perfect solution because the editorconfig file might change mid-branch, and |
Beta Was this translation helpful? Give feedback.
Okay, it seems like (once I can figure out which version of ktlint is being used by ktlint-gradle... but that's a separate conversation), all I need to run is something not entirely unlike
It's not a perfect solution because the editorconfig file might change mid-branch, and
jj fixwill apply the same editorconfig to all editable commits... but that's a shortcoming of jj's design.