Update defstate clj-kondo hook to return a var

This commit is contained in:
Noah Bogart 2024-07-11 11:41:52 -04:00
parent 632977ff41
commit 4065f5df36
5 changed files with 13 additions and 8 deletions

1
.clj-kondo/config.edn Normal file
View file

@ -0,0 +1 @@
{:config-paths ["../resources/clj-kondo.exports/mount/mount/"]}

1
.gitignore vendored
View file

@ -21,3 +21,4 @@ doo-index.html
/.nrepl-history /.nrepl-history
.cljs_rhino_repl/ .cljs_rhino_repl/
out/ out/
.clj-kondo/.cache

View file

@ -1,3 +1,3 @@
{:lint-as {mount.core/defstate clojure.core/def-catch-all} {:linters {:mount/defstate {:level :warning}}
:linters {:mount/defstate {:level :warning}} :hooks {:analyze-call {mount.core/defstate hooks.defstate/defstate
:hooks {:analyze-call {mount.core/defstate hooks.defstate/defstate}}} mount.core/defstate! hooks.defstate/defstate}}}

View file

@ -32,8 +32,10 @@
:col (:col (meta n))}) :col (:col (meta n))})
:else :else
{:node (api/list-node {:node (api/list-node
(list* (list
(api/token-node 'fn*) (api/token-node 'def)
(api/vector-node [n])
n n
args))}))) (api/list-node
(list*
(api/token-node 'do)
args))))})))

View file

@ -6,8 +6,9 @@
(defn entity [conn id] (defn entity [conn id]
(d/entity (d/db conn) id)) (d/entity (d/db conn) id))
(defn touch [conn results] (defn touch
"takes 'entity ids' results from a query "takes 'entity ids' results from a query
e.g. '#{[272678883689461] [272678883689462] [272678883689459] [272678883689457]}'" e.g. '#{[272678883689461] [272678883689462] [272678883689459] [272678883689457]}'"
[conn results]
(let [e (partial entity conn)] (let [e (partial entity conn)]
(map #(-> % first e d/touch) results))) (map #(-> % first e d/touch) results)))