Liking cljdoc? Tell your friends :D

Naming

naming/conventional-aliases

Enabled by defaultVersion AddedVersion Updated
true1.3.01.3.0

Through community and core practices over the years, various core libraries have gained standard or expected aliases. To better align with the community, it's best to use those aliases in favor of alternatives.

Examples

; bad
(:require [clojure.string :as string])

; good
(:require [clojure.string :as str])

Reference


naming/conversion-functions

Enabled by defaultVersion AddedVersion Updated
true0.1.940.1.94

Use -> instead of to in the names of conversion functions.

Will only warn when there is no - before the -to-.

Examples

; bad
(defn f-to-c ...)

; good
(defn f->c ...)
(defn expect-f-to-c ...)

Reference


naming/lisp-case

Enabled by defaultVersion AddedVersion Updated
true1.3.01.3.0

Use lisp-case for function and variable names. (Replacement is generated with camel-snake-kebab.)

Examples

; bad
(def someVar ...)
(def some_fun ...)

; good
(def some-var ...)
(defn some-fun ...)

Reference


naming/predicate

Enabled by defaultVersion AddedVersion Updated
true0.1.690.1.94

Functions that return a boolean should end in a question mark.

Doesn't verify the kind of function, just checks for anti-patterns in the names. Also doesn't actually check the classic Common Lisp convention as we have no way to know when a function name uses a word that naturally ends in a 'p' (such as map).

Examples

; bad
(defn palindrome-p ...)
(defn is-palindrome ...)

; good
(defn palindrome? ...)

Reference


naming/record-name

Enabled by defaultVersion AddedVersion Updated
true0.1.691.0

Records should use PascalCase.

Examples

; bad
(defrecord foo [a b c])

; good
(defrecord Foo [a b c])

Reference


naming/single-segment-namespace

Enabled by defaultVersion AddedVersion Updated
true1.3.01.3.0

Namespaces exist to disambiguate names. Using a single segment namespace puts you in direct conflict with everyone else using single segment namespaces, thus making it more likely you will conflict with another code base.

Examples

; bad
(ns simple)

; good
(ns noahtheduke.simple)

Reference

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close