Last active
February 12, 2021 08:02
-
-
Save helins/52d03847157b0dc95c6987844a74dd68 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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