Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Reagent component function calls for arity linting #25

Closed
borkdude opened this issue Mar 28, 2019 · 6 comments
Closed

Detect Reagent component function calls for arity linting #25

borkdude opened this issue Mar 28, 2019 · 6 comments

Comments

@borkdude
Copy link
Owner

@borkdude borkdude commented Mar 28, 2019

(defn my-component []
  [:div "Hello"])

[:div [my-component 1 2 3]] ;; <- arity error
@borkdude

This comment has been minimized.

Copy link
Owner Author

@borkdude borkdude commented Apr 15, 2019

How do we detect if a function is intended as a Reagent component and hence a "vector call" should be interpreted as a function call?

A combination of one or more of these:

  1. we're in .cljs or a CLJS reader conditional part in .cljc
  2. We could look at the namespace requires. If reagent.core occurs there, it's extremely likely
  3. Check if a function uses r/create-class

Still, it's not 100% accurate to tell if [foo bar baz] is a Reagent component call or just a random vector with some symbols, so this will probably introduce a lot of false positives.

@borkdude borkdude added this to Needs triage in clj-kondo Oct 15, 2019
@agoldhammer

This comment has been minimized.

Copy link

@agoldhammer agoldhammer commented Oct 29, 2019

In addition, using the idiomatic reagent [component.classname ...] or [component#id ...] produces "unresolved symbol" errors. Can this be fixed?

@borkdude

This comment has been minimized.

Copy link
Owner Author

@borkdude borkdude commented Oct 29, 2019

@agoldhammer That's a separate issue. Can you please make an issue with a self-consistent example (.cljs file) that I can lint?

@borkdude borkdude changed the title Detect Reagent component function calls Detect Reagent component function calls for arity linting Oct 29, 2019
@borkdude

This comment has been minimized.

Copy link
Owner Author

@borkdude borkdude commented Oct 29, 2019

@agoldhammer According to a Reagent maintainer on Clojurians slack (@Deraen) this is not supported.

@agoldhammer

This comment has been minimized.

Copy link

@agoldhammer agoldhammer commented Oct 29, 2019

Sorry, my mistake. Supported in Hiccup, not Reagent. Please ignore.

@borkdude borkdude added the wontfix label Nov 23, 2019
@borkdude

This comment has been minimized.

Copy link
Owner Author

@borkdude borkdude commented Nov 23, 2019

Thought about this long enough and I don't see a feasible way to do this without producing false positives.

@borkdude borkdude closed this Nov 23, 2019
clj-kondo automation moved this from Needs hammock time to Done Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
clj-kondo
  
Done
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.