bbatsov / clojure-style-guide

A community coding style guide for the Clojure programming language
https://guide.clojure.style
3.99k stars 279 forks source link

How to sort requires in .cljc? #205

Open borkdude opened 4 years ago

borkdude commented 4 years ago

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

Heliosmaster commented 4 years ago

@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?