Skip to content

Instantly share code, notes, and snippets.

@helins
Last active February 12, 2021 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helins/52d03847157b0dc95c6987844a74dd68 to your computer and use it in GitHub Desktop.
Save helins/52d03847157b0dc95c6987844a74dd68 to your computer and use it in GitHub Desktop.
(ns hooks.fulcro
""
{:author "Adam Helins"}
(:require [clj-kondo.hooks-api :as hook]))
(defn defmutation
[{:keys [node]}]
(let [[_call
sym
& arg+] (:children node)
docstring (first arg+)
[[param+
& fn-like+]
docstring-2] (if (hook/string-node? docstring)
[(rest arg+)
docstring]
[arg+
nil])]
{:node (hook/list-node (concat [(hook/token-node 'defn)
sym]
(when docstring-2
[docstring-2])
[param+
(hook/vector-node (map #(let [[_sym
arg+
& body] (:children %)]
(hook/list-node (list* (hook/token-node 'fn)
arg+
body)))
fn-like+))]))}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment