This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-23
Channels
- # aws (3)
- # babashka (17)
- # beginners (44)
- # boot (1)
- # bristol-clojurians (1)
- # cider (19)
- # clj-kondo (7)
- # cljfx (5)
- # clojure (35)
- # clojure-australia (25)
- # clojure-europe (41)
- # clojure-nl (4)
- # clojure-spec (5)
- # clojure-uk (104)
- # clojuredesign-podcast (1)
- # clojurescript (41)
- # component (6)
- # conjure (5)
- # core-async (20)
- # core-logic (5)
- # cryogen (7)
- # cursive (4)
- # data-science (1)
- # datomic (14)
- # devcards (2)
- # events (1)
- # fulcro (6)
- # helix (6)
- # jobs (4)
- # kaocha (4)
- # lambdaisland (4)
- # leiningen (3)
- # luminus (1)
- # malli (2)
- # meander (2)
- # mount (6)
- # off-topic (2)
- # pedestal (25)
- # rdf (1)
- # re-frame (17)
- # reagent (5)
- # releases (1)
- # reveal (13)
- # rewrite-clj (45)
- # shadow-cljs (27)
- # sql (18)
- # tools-deps (93)
- # vim (13)
- # xtdb (11)
I'd like to start pooling together a clj-kondo config :) Here's what I have so far:
(ns hooks.frontend
(:require [clj-kondo.hooks-api :as api]))
(defn defnc
[{:keys [node]}]
(let [[type params & body] (rest (:children node))
[_docstring params body] (if (string? (api/sexpr params))
[params (first body) (rest body)]
[nil params body])]
{:node
(api/list-node
(list* (api/token-node 'defn) type
(api/vector-node [(api/token-node '&) (api/vector-node (vec (concat (:children params) [(api/token-node '_children)])))])
body))}))
(defn defcomponent
[{:keys [node]}]
(let [[name & methods] (rest (:children node))]
{:node
(api/list-node
(list* (api/token-node 'cljs.core/deftype)
name
(api/vector-node [])
(api/token-node 'js/not-a-protocol-you-know)
methods))}))
and
{:hooks {:analyze-call {helix.core/defnc hooks.frontend/defnc
helix.core/defcomponent hooks.frontend/defcomponent}}}
We could put it into Helix's code, then Kondo will pick it up automatically and we'll have more fun. I think it would be good to write a hook for $ that enforces that the second arg is a map literal.
wait, but the second arg can be either a map literal or the first child :thinking_face:
I wonder if clj-kondo would be better at discerning that than helix. helix already throws a warning if it infers you're passing a CLJS map in to the first arg
problem is that children are polymorphic too; they can be elements, or functions, or anything really depending on the component being used to create the element
@lilactown Oh yeah, I guess :) nevermind then!