Linting is just having tools look for common mistakes and reporting if they find any.
Whereas we automatically format our code to avoid fights, we lint our code to make sure that needed fights are had.
:dev
and :nREPL
aliases into one.There would be many similarities between :dev
, :nREPL
,
and a hypothetical :test
alias. Because we aren't relying on :main-opts
there isn't much downside to just using one :dev
alias.
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.12.0"}
ring/ring {:mvn/version "1.13.0"}
metosin/reitit-ring {:mvn/version "0.7.2"}
org.clojure/tools.logging {:mvn/version "1.3.0"}
org.slf4j/slf4j-simple {:mvn/version "2.0.16"}
hiccup/hiccup {:mvn/version "2.0.0-RC3"}}
:aliases {:dev {:extra-paths ["dev"]
:extra-deps {nrepl/nrepl {:mvn/version "1.3.0"}}}
:format {:deps {dev.weavejester/cljfmt {:mvn/version "0.13.0"}}}
:lint {:deps {clj-kondo/clj-kondo {:mvn/version "2024.09.27"}}}}}
This does mean you will need to update how just nrepl
functions slightly.
help:
just --list
run:
clojure -M -m example.main
nrepl:
clojure -M:dev -m nrepl.cmdline
...
kaocha
and a new test
folder to your :dev
aliasKaocha is a test runner. It runs your tests. The test
folder is to have a place to write those tests.
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.12.0"}
ring/ring {:mvn/version "1.13.0"}
metosin/reitit-ring {:mvn/version "0.7.2"}
org.clojure/tools.logging {:mvn/version "1.3.0"}
org.slf4j/slf4j-simple {:mvn/version "2.0.16"}
hiccup/hiccup {:mvn/version "2.0.0-RC3"}}
:aliases {:dev {:extra-paths ["dev" "test"]
:extra-deps {nrepl/nrepl {:mvn/version "1.3.0"}
lambdaisland/kaocha {:mvn/version "1.91.1392"}}}
:format {:deps {dev.weavejester/cljfmt {:mvn/version "0.13.0"}}}
:lint {:deps {clj-kondo/clj-kondo {:mvn/version "2024.09.27"}}}}}
test/example/math_test.clj
(ns example.math-test
(:require [clojure.test :as t]))
(t/deftest one-plus-one
(t/is (= (+ 1 1) 3) "One plus one equals 3!"))
test
recipe to your Justfile
help:
just --list
run:
clojure -M -m example.main
nrepl:
clojure -M:dev -m nrepl.cmdline
format_check:
clojure -M:format -m cljfmt.main check src dev
format:
clojure -M:format -m cljfmt.main fix src dev
lint:
clojure -M:lint -m clj-kondo.main --lint .
test:
clojure -M:dev -m kaocha.runner
just test
Because 1 + 1 does not equal 3, you should see a test failure reported.
just test
again(ns example.math-test
(:require [clojure.test :as t]))
(t/deftest one-plus-one
(t/is (= (+ 1 1) 2) "One plus one equals 2!"))
test
to the list of directories to automatically format.help:
just --list
run:
clojure -M -m example.main
nrepl:
clojure -M:dev -m nrepl.cmdline
format_check:
clojure -M:format -m cljfmt.main check src dev test
format:
clojure -M:format -m cljfmt.main fix src dev test
lint:
clojure -M:lint -m clj-kondo.main --lint .
test:
clojure -M:dev -m kaocha.runner