This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-11
Channels
- # announcements (5)
- # babashka (43)
- # beginners (78)
- # calva (1)
- # cider (35)
- # clj-kondo (15)
- # clj-otel (3)
- # cljs-dev (2)
- # clojure (24)
- # clojure-denmark (1)
- # clojure-dev (9)
- # clojure-europe (43)
- # clojure-israel (1)
- # clojure-italy (1)
- # clojure-losangeles (3)
- # clojure-nl (1)
- # clojure-norway (54)
- # clojure-romania (1)
- # clojure-uk (2)
- # clojurescript (1)
- # core-async (25)
- # cursive (7)
- # datascript (6)
- # datomic (7)
- # docker (2)
- # emacs (2)
- # events (8)
- # exercism (2)
- # fulcro (2)
- # hyperfiddle (16)
- # lsp (46)
- # malli (10)
- # membrane (2)
- # music (6)
- # nbb (30)
- # off-topic (49)
- # polylith (4)
- # reagent (3)
- # releases (4)
- # shadow-cljs (5)
- # slack-help (1)
- # sql (2)
- # testing (2)
- # timbre (6)
- # tools-deps (29)
- # xtdb (36)
I have a ClojureScript library that defines a macro in src/portfolio/react.clj
, and some cljs functions in src/portfolio/react.cljs
. People typically use it like so: (require [portfolio.react :refer-macros [defscene]])
(code is here btw: https://github.com/cjohansen/portfolio/blob/main/src/portfolio/react.clj / https://github.com/cjohansen/portfolio/blob/main/src/portfolio/react.cljs). The macro has optional parts, but can look like this:
(d/defcomponent SideEffecty
:key value
,,,
[data]
[:h1])
Is there any way I can provide some config, metadata or other in the library that will help clj-kondo understand this macro in projects that depend on the library? Ideally it'd understand both that SideEffecty
is being defined, and that data
is a binding.Yep. On phone right now but take a look at lint-as + catch-all in the config.md docs
Cool, thanks. Can I ship these with the library somehow? If it's covered in the docs I'll find it 😅
Here's a long list of examples: https://github.com/clj-kondo/clj-kondo/discussions/1528
Very cool 🙏 Thanks again, and sorry for not responding - I overstretched a little 😅
You can also remove the refer-macros requirement -
On the cljs side add a form like this to the namespace declaration https://github.com/mentat-collective/emmy/blob/e16b5692b04972f0bc9ea6d07f7ead41edccc066/src/emmy/util/def.cljc#L6
And then your users can use :refer or just the alias from require without treating the macro in a special way
Wow, interesting. Am I understanding this right, that the cljs-part of the cljc-file will effectively be merged with the same-named cljs file?
@U9MKYDN4Q sorry my example here is slightly confusing — in this case I am using a single cljc file instead of separate clj and cljs files
so for your example you would have to add that form to your cljs file only