clj-kondo

https://github.com/clj-kondo/clj-kondo
borkdude 2020-12-22T13:06:09.199100Z

@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]

borkdude 2020-12-22T13:08:46.200700Z

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

juhoteperi 2020-12-22T13:09:23.201400Z

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

borkdude 2020-12-22T13:09:41.201800Z

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

borkdude 2020-12-22T13:10:26.202700Z

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

borkdude 2020-12-22T13:11:03.203600Z

The issue is here: https://github.com/borkdude/clj-kondo/issues/25

juhoteperi 2020-12-22T13:11:04.203800Z

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.

borkdude 2020-12-22T13:11:17.204200Z

yeah

juhoteperi 2020-12-22T13:11:38.204900Z

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

borkdude 2020-12-22T13:12:58.205Z

you mean a function notation instead of vector?

juhoteperi 2020-12-22T13:13:21.205200Z

Yeah

borkdude 2020-12-22T13:13:43.205400Z

then it would work automatically with clj-kondo.

juhoteperi 2020-12-22T13:14:17.205600Z

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

juhoteperi 2020-12-22T13:16:46.205900Z

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.

borkdude 2020-12-22T13:19:15.206100Z

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.