diff options
Diffstat (limited to 'resources/clj-kondo/hooks/dompa.clj')
| -rw-r--r-- | resources/clj-kondo/hooks/dompa.clj | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/resources/clj-kondo/hooks/dompa.clj b/resources/clj-kondo/hooks/dompa.clj index 5e36df6..a5c802f 100644 --- a/resources/clj-kondo/hooks/dompa.clj +++ b/resources/clj-kondo/hooks/dompa.clj @@ -57,3 +57,30 @@ :message (str "Invalid argument type. Argument must be a $ macro " "or a sequence of $ macros.") :type :dompa.templates/$-arg-validation))))) + +(defn defhtml [{:keys [node]}] + (let [[_ first-arg second-arg & rest-args] (:children node)] + (cond + ; first argument has to be a symbol + (not (api/token-node? first-arg)) + (api/reg-finding! + (assoc (meta first-arg) + :message "Invalid argument type. Binding name must be a symbol." + :type :dompa.templates/defhtml-arg-validation)) + + ; second argument should be a vector + (not (api/vector-node? second-arg)) + (api/reg-finding! + (assoc (meta second-arg) + :message "Invalid argument type. Must be a vector of arguments." + :type :dompa.templates/defhtml-arg-validation)) + + ; rest of the arguments should be a list + (not (every? #(api/list-node? %) rest-args)) + (doall + (for [arg rest-args] + (api/reg-finding! + (assoc (meta arg) + :message (str "Invalid argument type. Argument must be a $ macro " + "or a sequence of $ macros.")))))))) + |
