diff options
| author | Asko Nõmm <asko@nmm.ee> | 2025-10-13 02:57:33 +0300 |
|---|---|---|
| committer | Asko Nõmm <asko@nmm.ee> | 2025-10-13 02:57:33 +0300 |
| commit | 25bee7bb06c92bff4779bb959f8cdf76934f6a21 (patch) | |
| tree | cfaa5d51bf50776dc8f236be5215fc783873763f /resources | |
| parent | 19a81b030ba84b365c14aa22893c2eb9abcd72ff (diff) | |
Remove manual hooks in favor of a simple lint-as rule
Diffstat (limited to 'resources')
| -rw-r--r-- | resources/clj-kondo/config.edn | 5 | ||||
| -rw-r--r-- | resources/clj-kondo/hooks/dompa.clj | 83 |
2 files changed, 0 insertions, 88 deletions
diff --git a/resources/clj-kondo/config.edn b/resources/clj-kondo/config.edn deleted file mode 100644 index e6b8708..0000000 --- a/resources/clj-kondo/config.edn +++ /dev/null @@ -1,5 +0,0 @@ -{:hooks {:analyze-call {dompa.nodes/$ hooks.dompa/$ - dompa.nodes/defhtml hooks.dompa/defhtml}} - :linters {:dompa.nodes/$-arg-validation {:level :warning} - :dompa.nodes/defhtml-arg-validation {:level :warning}} - :lint-as {dompa.nodes/defhtml clojure.core/defn}} diff --git a/resources/clj-kondo/hooks/dompa.clj b/resources/clj-kondo/hooks/dompa.clj deleted file mode 100644 index 1712a02..0000000 --- a/resources/clj-kondo/hooks/dompa.clj +++ /dev/null @@ -1,83 +0,0 @@ -(ns hooks.dompa - (:require [clj-kondo.hooks-api :as api])) - -(defn str-able? [x] - (or (api/string-node? x) - (api/token-node? x))) - -(defn $ [{:keys [node]}] - (let [[_ first-arg & rest-args] (:children node)] - (cond - ; if the first arg is string-like, then no sequences - ; are allowed, because you are only allowed to concat - ; strings, i.e. whatever (str) can do. - (or (api/string-node? first-arg) - (api/token-node? first-arg)) - (let [invalid-args (filter #(not (str-able? %)) rest-args)] - (doseq [invalid-arg invalid-args] - (api/reg-finding! - (assoc (meta invalid-arg) - :message (str "Invalid argument type. When creating a text node, " - "only literal values (strings, numbers and symbols) " - "are allowed.") - :type :dompa.nodes/$-arg-validation)))) - - ; if the first arg is a keyword, then the second argument can only be - ; a sequence or a map. - (and (api/keyword-node? first-arg) - (seq rest-args) - (not (or (api/map-node? (first rest-args)) - (api/list-node? (first rest-args))))) - (api/reg-finding! - (assoc (meta (first rest-args)) - :message "Invalid argument type. Argument must be a sequence or a map." - :type :dompa.nodes/$-arg-validation)) - - ; if the first arg is a keyword, the second arg is a list, then - ; every arg has to be a list node. - (and (api/keyword-node? first-arg) - (api/list-node? (first rest-args)) - (not (every? #(api/list-node? %) (rest rest-args)))) - (doseq [arg (filter #(not (api/list-node? %)) rest-args)] - (api/reg-finding! - (assoc (meta arg) - :message (str "Invalid argument type. Argument must be a $ node " - "or a sequence of $ nodes.") - :type :dompa.nodes/$-arg-validation))) - - ; if the first arg is a keyword, the second arg is a map, then from - ; the second forwards everything has to be a list node - (and (api/keyword-node? first-arg) - (api/map-node? (first rest-args)) - (not (every? #(api/list-node? %) (rest rest-args)))) - (api/reg-finding! - (assoc (meta (second rest-args)) - :message (str "Invalid argument type. Argument must be a $ node. " - "or a sequence of $ nodes.") - :type :dompa.nodes/$-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.nodes/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.nodes/defhtml-arg-validation)) - - ; rest of the arguments should be a list - (not (every? #(api/list-node? %) rest-args)) - (doseq [arg rest-args] - (api/reg-finding! - (assoc (meta arg) - :message (str "Invalid argument type. Argument must be a $ node " - "or a sequence of $ nodes"))))))) - |
