Open dpassen opened 10 months ago
Hi Derek,
Yes, for sure. That way many clj-kondo users benefit from better linting.
Got it working like that (based on mount-lite
hook):
(ns hooks.redelay
(:require [clojure.string :as str]))
(defn- qualified-exprs [qualifiers exprs]
(loop [qualifiers (set qualifiers)
exprs exprs
qualifier nil
qualified {}]
(if (seq exprs)
(let [expr (first exprs)]
(if-let [qualifier (qualifiers expr)]
(recur (disj qualifiers qualifier) (rest exprs) qualifier qualified)
(recur qualifiers (rest exprs) qualifier (update qualified qualifier (fnil conj []) expr))))
qualified)))
(defmacro defstate [name & args]
(let [{:keys [start stop] names :name metas :meta implicit-start nil}
(qualified-exprs [:name :start :stop :meta]
(concat [:name name] args))
start (or start implicit-start)
hmap {:name (first names)
:start-fn `(fn [] ~@start)
:stop-fn (if (str/includes? (str stop) "this")
`(fn [~'this] ~@stop)
`(fn [] ~@stop))
:meta (first metas)}]
`(def ~name (redelay.core/map->State ~hmap))))
@dpassen and @piranha could you have a look at #2? I hope it satisfies your needs with minimal code.
Is there any interest in clj-kondo configuration? I see
mount-lite
has some hooks defined.