Calva鈥檚 clj-kondo helps me detect when a require is not alphabetically sorted, but I鈥檇 love if Calva formats this automatically when I save the file, can it be done?
There's some work done already here: https://github.com/immoh/nsorg/
A good thing to have, but, please make it configurable via settings. I mean Format on save part.
Autoformat might make things harder if you want to keep your PR cleaner.
I think the first step here would be to make it on demand. So when you see kondo complain about this, you can issue the command to clean it up.
I guess a nice goal could be that it plays nicely with the linter. This past couple of years I've worked in several JavaScript projects and ESLint and Prettier would respect/help each other so there are no conflicts between their configurations.
Yes please!
For reference, Emacs clojure-mode has this as clojure-sort-ns:
It seems this might be the best path: https://github.com/clojure-emacs/refactor-nrepl#clean-ns
I believe we can soon do this via clojure-lsp :tada:
This has been released. See the clean-ns refactoring: https://calva.io/refactoring/#commands
@bpringe With all respect, clean ns is not the same as just ns sorting. I don't want a tool to remove requires automatically for me, to be honest.
Oh, my apologies. Reopening this.
Remove requires automatically can be super useful, but it's true that if it's happening on save, it can get in the middle of your workflow.
To be clear, clean-ns is only run manually via a command, currently.
Coming from emacs, I like that you have just clojure-sort-ns which isn't that intrusive as something which rewrites your ns form. So it would be nice if we could also have that option, while clean-ns does this and more.