fixes #187 by adding exported clj-kondo config

This commit is contained in:
Sean Corfield 2021-11-07 12:47:26 -08:00
parent 5d68f59608
commit 99f814bb25
6 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1 @@
{:hooks {:analyze-call {next.jdbc/with-transaction hooks.next-jdbc/with-transaction}}}

View file

@ -0,0 +1,15 @@
(ns hooks.next-jdbc
(:require [clj-kondo.hooks-api :as api]))
(defn with-transaction [{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))

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

@ -0,0 +1 @@
{:config-paths ["com.github.seancorfield/next.jdbc"]}

View file

@ -3,6 +3,7 @@
Only accretive/fixative changes will be made from now on.
* 1.2.next in progress
* Address #187 by adding `clj-kondo.exports` for future expansion (`with-transaction` is already built into `clj-kondo`).
* Documentation updates; `pom.xml` template cleanup.
* 1.2.737 -- 2021-10-17

View file

@ -0,0 +1 @@
{:hooks {:analyze-call {next.jdbc/with-transaction hooks.next-jdbc/with-transaction}}}

View file

@ -0,0 +1,18 @@
(ns hooks.next-jdbc
(:require [clj-kondo.hooks-api :as api]))
(defn with-transaction
"Expands (with-transaction [tx expr opts] body)
to (let [tx expr] opts body) pre clj-kondo examples."
[{:keys [:node]}]
(let [[binding-vec & body] (rest (:children node))
[sym val opts] (:children binding-vec)]
(when-not (and sym val)
(throw (ex-info "No sym and val provided" {})))
(let [new-node (api/list-node
(list*
(api/token-node 'let)
(api/vector-node [sym val])
opts
body))]
{:node new-node})))