Fork me on GitHub
#clj-kondo
<
2020-12-22
>
borkdude13:12:09

@juhoteperi Congrats on the Reagent release 1.0.0! I notice for React functions you use :f> to call them. From a static analysis perspective, it would be nice to support an optional keyword in the first position of a normal component call as well, so e.g. clj-kondo could give you arity or type warnings. E.g.: [:r> my-component 1 2 3]

borkdude13:12:46

(not sure about :r>, maybe something nicer like [:fn my-component 1 2 3] could also work)

juhoteperi13:12:23

:r> is already used, it is for "raw" React components 🙂

borkdude13:12:41

[::r/f component 1 2 3] aliasing reagent.core?

borkdude13:12:26

maybe too verbose. but something to think about. if this can be detected uniquely by clj-kondo, it would solve an open issue I've been thinking about for a long time

juhoteperi13:12:04

I guess it would be OK to have keyword for the normal Reagent component also. Not sure how safe it would be to detect these keywords. Someone else could also be using them inside Hiccup vectors.

juhoteperi13:12:38

Best would be if Reagent just had DOM functions like Helix (or Om...)

borkdude13:12:58

you mean a function notation instead of vector?

borkdude13:12:43

then it would work automatically with clj-kondo.

juhoteperi13:12:17

Helix uses macro to generate fns so that probably doesn't work without additional config: https://github.com/lilactown/helix/blob/master/src/helix/dom.cljc

juhoteperi13:12:46

Though Helix components are used thorugh helix.core/$ macro so at they are easy to find... Anyway, I'll open issue on Reagent to keep track of ideas on making the forms easier to analyse.

borkdude13:12:15

maybe a simple solution would be to use a macro in reagent.core:

(defmacro f [& args] `[~@args])
so you can write:
(r/f component  1 2 3)
and this would uniquely signal a reagent component being called.