clojure-style-guide
clojure-style-guide copied to clipboard
How to sort requires in .cljc?
This commit adds a section about sorting namespaces. Clj-kondo want to check this, but currently there is no clarity around how "requirements" (which I find a bit of a weird word for libspecs in a require clause) in .cljc namespaces should be sorted.
Since there is no clarity around this, I'm thinking about just disabling the rule for clj-kondo in .cljc files for now.
See https://github.com/borkdude/clj-kondo/issues/741.
cc @Heliosmaster
@borkdude re about the wording "requirements". Feel free to improve it! Note that it also refer to the java classes in import statement though.. (requirements is still wrong, as they are imported classes)
About .cljc, I think the cleanest is to just sort the :clj, :cljr (🤷♂ ), :cljs and then the libspecs without a reader conditional. Within each block they should be sorted, independently (i.e. if in the same block we have both :clj and :cljs they should be sorted independently.
But is this consistent with the general usage of the reader conditional in ns declaration? Does it make sense?