Create proper clj-kondo hooks for various macros
Closed this issue · 4 comments
more-of, more->, maybe others.
The following works for more->:
(ns hooks.expectations.clojure.test.more-thread
(:require [clj-kondo.hooks-api :as api]))
(defn more-> [{:keys [node]}]
(let [tail (rest (:children node))
rewritten
(api/list-node
(list*
(api/token-node 'cond->)
(api/token-node 'nil)
tail))]
{:node rewritten}))The single test version of defexpect with an expected string can throw spurious errors, tho I think this is a clj-kondo issue and not an expectations issue.
(defexpect missing-body-in-when-test
"Missing body in when"
(:message (check-str "(when true)")))"Missing body in when" is labeled as a "missing docstring" currently, due to the :lint-as rule tying defexpect to deftest.
I'll add a hook for defexpect that does something like the transformation that shorthand form does in the actual macro -- that will fix this. And, yes, maybe clj-kondo also has a bug in its deftest handling but that's no excuse for Expectations to provide a lazy clj-kondo config :)
more-of has been added as a hook.
Closing his out (as a general issue) with the specific single test defexpect case moved to #37