Try to keep lines ≤ 80 columns long
; OKAY
(defn foo [x] (inc x))
; OKAY
(defn bar
[{:keys [a b c]}]
(println a b c))
; Pls don't
(defn quux [things]
(for [thing things]
(println thing)))
¹: Where "trivial" is deliberately left subjective
Based on How I NS
In summary, things should look like this:
(ns com.example.my-application.server
"Example application HTTP server and routing."
(:refer-clojure :exclude [send])
(:require
[clojure.core.async :as async :refer [<! <!! >! >!!]]
[com.example.my-application.base]
[com.example.my-application.server.sse :as server.sse]
[io.pedestal.http :as http]
[io.pedestal.http.sse :as http.sse]
[ring.util.response :as response])
(:import
(java.nio.file Files LinkOption)
(org.apache.commons.io FileUtils)))
Forms in the ns
macro should be:
:refer-clojure
if any:require
if any:import
if any
The :require
and :import
keywords should be followed by a newline, with all the following namespaces sorted alphabetically
; OKAY
(ns foo.stuff
(:require
[clojure.string :as string]
[foo.things]))
; Pls don't
(ns foo.bloop
(:require
[clojure.string :as string]
foo.things))
; OKAY
(ns foo.blaap
(:import
(java.nio.file Files)))
; Pls don't
(ns foo.quupx
(:import
java.nio.file.Files)))