diff --git a/.clj-kondo/com.github.seancorfield/next.jdbc/config.edn b/.clj-kondo/com.github.seancorfield/next.jdbc/config.edn new file mode 100644 index 0000000..f49521a --- /dev/null +++ b/.clj-kondo/com.github.seancorfield/next.jdbc/config.edn @@ -0,0 +1 @@ +{:hooks {:analyze-call {next.jdbc/with-transaction hooks.next-jdbc/with-transaction}}} diff --git a/.clj-kondo/com.github.seancorfield/next.jdbc/hooks/next_jdbc.clj b/.clj-kondo/com.github.seancorfield/next.jdbc/hooks/next_jdbc.clj new file mode 100644 index 0000000..29f127e --- /dev/null +++ b/.clj-kondo/com.github.seancorfield/next.jdbc/hooks/next_jdbc.clj @@ -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}))) diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn new file mode 100644 index 0000000..022a4f9 --- /dev/null +++ b/.clj-kondo/config.edn @@ -0,0 +1 @@ +{:config-paths ["com.github.seancorfield/next.jdbc"]} diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b4cdb..9d79887 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/resources/clj-kondo.exports/com.github.seancorfield/next.jdbc/config.edn b/resources/clj-kondo.exports/com.github.seancorfield/next.jdbc/config.edn new file mode 100644 index 0000000..f49521a --- /dev/null +++ b/resources/clj-kondo.exports/com.github.seancorfield/next.jdbc/config.edn @@ -0,0 +1 @@ +{:hooks {:analyze-call {next.jdbc/with-transaction hooks.next-jdbc/with-transaction}}} diff --git a/resources/clj-kondo.exports/com.github.seancorfield/next.jdbc/hooks/next_jdbc.clj b/resources/clj-kondo.exports/com.github.seancorfield/next.jdbc/hooks/next_jdbc.clj new file mode 100644 index 0000000..e881dbf --- /dev/null +++ b/resources/clj-kondo.exports/com.github.seancorfield/next.jdbc/hooks/next_jdbc.clj @@ -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})))