Fork me on GitHub
#clj-kondo
<
2021-02-24
>
borkdude11:02:13

This project uses clj-kondo analysis :)

CarnunMP12:02:51

Hi. Quick question about unused cljs requires! :)) The following seems to elicit a false positive:

[react-autosuggest :as AutoSuggest] > warning: namespace react-autosuggest is required but never used
There's also an erroneous 'Unresolved symbol' in one of the two places AutoSuggest is passed as a component to https://github.com/lilactown/helix/blob/master/docs/creating-elements.md#-macro $ (???):
($ AutoSuggest > error: Unresolved symbol: AutoSuggest
   {:suggestions ...

...

($ AutoSuggest {:getSuggestionValue get-suggestion-value ...
Now, https://www.npmjs.com/package/react-autosuggest (see pic below) kinda suggests that I should be doing [react-autosuggest :refer [Autosuggest]] or something, not :as. But making this change (and accounting for AutoSuggest -> Autosuggest) breaks things. (Separate issue, but probably because of helix...) So it could be that react-autosuggest is just strange (and I should add an inline reader comment or do some other config, say). Or maybe kondo doesn't realise react-autosuggest is a js module, not a ns? Or something else?

CarnunMP12:02:50

Also, my bad if this is more appropriate for #clojurescript! 🙂

CarnunMP12:02:25

Or #helix, for that matter...

borkdude13:02:23

@U018D6NKRA4 Let's start with the first issue

borkdude13:02:59

Can you make a full .cljs minimal repro for me?

CarnunMP13:02:01

For sure. On it! 🙂

CarnunMP14:02:11

In fact, both the 'required but never used' warning and the 'Unresolved symbol' error show up:

borkdude14:02:08

@U018D6NKRA4 Yeah, this is a known issue. You should use a string namespace when using npm deps.

(ns hello
  (:require ["react-autosuggest" :as AutoSuggest]))

(defn x
  []
  (AutoSuggest))

borkdude14:02:26

This way clj-kondo can distuingish between normal cljs deps and npm deps

CarnunMP14:02:36

Good to know! Thanks. :)))