diff --git a/.clj-kondo/config.edn b/.clj-kondo/config.edn index 4585c52..548c6e6 100644 --- a/.clj-kondo/config.edn +++ b/.clj-kondo/config.edn @@ -1,3 +1,5 @@ {:lint-as {lambdaisland.ornament/defprop clojure.core/def lambdaisland.ornament/defrules clojure.core/def} - :hooks {:analyze-call {lambdaisland.ornament/defstyled hooks.ornament/defstyled}}} + :hooks {:analyze-call {lambdaisland.ornament/defstyled hooks.ornament/defstyled}} + :linters {:lambdaisland.ornament/invalid-syntax + {:level :warning}}} diff --git a/.clj-kondo/hooks/ornament.clj b/.clj-kondo/hooks/ornament.clj index a8a9c7e..5cf30b0 100644 --- a/.clj-kondo/hooks/ornament.clj +++ b/.clj-kondo/hooks/ornament.clj @@ -13,34 +13,40 @@ _ (when-not (api/keyword-node? html-tag) (api/reg-finding! {:row (:row (meta html-tag)) :col (:col (meta html-tag)) - :message "Html-tag must be a keyword" + :message "Tag must be a keyword or an ornament-styled-component" :type :lambdaisland.ornament/invalid-syntax})) ; _ (prn :html-tag html-tag) ; _ (prn :more more) fn-tag (first (drop-while (fn [x] - (or (api/keyword-node? x) + (or (api/string-node? x) + (api/keyword-node? x) (api/map-node? x) (api/vector-node? x))) more)) - _ (prn :fn-tag fn-tag) - _ (when (or (api/list-node? fn-tag) - (nil? fn-tag)) + ; _ (prn :fn-tag fn-tag) + _ (when (and fn-tag + (not (api/list-node? fn-tag))) (api/reg-finding! {:row (:row (meta fn-tag)) :col (:col (meta fn-tag)) - :message "fn-tag must be at least a list or nil" - :type :lambdaisland.ornament/invalid-syntax})) - def-class-form (api/list-node - (list (api/token-node 'def) - class-name - (api/token-node 'nil)))] + :message "Function part (if present) must be a list" + :type :lambdaisland.ornament/invalid-syntax}))] (if (api/list-node? fn-tag) (let [[binding-vec & body] (:children fn-tag) - new-node (api/list-node - (list* - (api/token-node 'fn) - binding-vec - body))] - (prn :new-node (api/sexpr new-node)) - {:node new-node}) + fn-node (api/list-node + (list* + (api/token-node 'fn) + binding-vec + body)) + new-def-node (api/list-node + (list (api/token-node 'def) + class-name + fn-node))] + (prn :new-def-node (api/sexpr new-def-node)) + {:node new-def-node}) ;; nil node - {:node def-class-form}))) + (let [def-class-form (api/list-node + (list (api/token-node 'def) + class-name + (api/token-node 'nil)))] + (prn :def-class-form (api/sexpr def-class-form)) + {:node def-class-form}))))