Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -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}}}
44 changes: 25 additions & 19 deletions .clj-kondo/hooks/ornament.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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}))))
Loading