reagent icon indicating copy to clipboard operation
reagent copied to clipboard

Find a way to make Hiccup forms easier to analyze

Open Deraen opened this issue 5 years ago • 1 comments

https://github.com/borkdude/clj-kondo/issues/25

  • Optional way to create normal Reagent components from functions using some keyword, like :n> :$. Would work the same way as [comp], but the keyword would make it possible to find the calls.
    • Namespaced keyword would be even better, but would be quite verbose.
  • Provide function based API to optionally replace Hiccup syntax (like om.dom, helix.dom).

Deraen avatar Dec 22 '20 13:12 Deraen

Alternatives (not necessarily better than what's already mentioned):

  • macro which expands into a vector call:
(defmacro f [& args] `[~@args])
(r/f component  1 2 3)

This solution doesn't need any changes to other code in Reagent, but allows static analysis to detect reagent calls accurately.

  • clj-kondo could have a mode in which it always treats [foo 1 2 3] as a function call in .cljs files. False positives should be handled by users.

borkdude avatar Dec 23 '20 15:12 borkdude