Fork me on GitHub
#clj-kondo
<
2022-08-29
>
Martynas Maciulevičius14:08:09

Hey. I used function format in cljc file and it complains that it's unresolved. It would be a little more helpful if it would say that it doesn't exist in all implementations :thinking_face:

borkdude14:08:24

@invertisment_clojuria There is an open issue for this, to say for which branch the error applies

1
nate16:08:28

I recently ran into this as well, when making a namespace compatible with clojure and bb. I ended up with this so that the spit inside my-fn is properly resolved:

(ns test
  (:refer-clojure :exclude [spit format]))

(def spit #?(:clj clojure.core/spit))
(def format #?(:clj clojure.core/format))

(defn my-fn
  []
  (spit "output.txt" (format "yay %s" "format")))

(my-fn)
Is there a better way to accomplish this?

borkdude16:08:28

@nate Try: {:cljc {:features [:clj]} in config.edn : this will only activate linting for the :clj branches

nate16:08:09

that works!

nate16:08:45

hm, should it be possible to put that in the namespace config?

(ns test
  {:clj-kondo/config '{:cljc {:features [:clj]}}})

(defn my-fn
  []
  (spit "output.txt" (format "yay %s" "format")))

(my-fn)
clj-kondo --lint test.cljc 
test.cljc:6:4: error: Unresolved symbol: spit
test.cljc:6:23: error: Unresolved symbol: format
linting took 40ms, errors: 2, warnings: 0

borkdude17:08:25

no, it's a project-wide config

nate17:08:45

ah makes sense, thank you

borkdude17:08:24

the issue there is that this config has to be known before the file is being being processed