Fork me on GitHub
#clj-kondo
<
2021-04-13
>
cjsauer13:04:27

This isn’t any fault of kondo’s, but I’m wondering how others handle this situation: I have a .cljc file that looks like this

(ns my.cljc.file
  (:require #?(:clj [datomic.client.api :as d])
            [my.model.thing :as thing]
            [my.model.account :as account]))

#?(:clj
   (defn some-function
     []
     {::thing/x 42
      ::account/id 123}))
Because of the way kondo lints cljc files (one pass with clj, one pass with cljs) both the my.model.* requires are marked as unused. This is because technically they aren’t used by the cljs side. But, if I were to move my.model.* requires up into the #?(:clj …) conditional, suddenly the ns can no longer be read, and tools.reader will complain about “unresolved keyword alias ::thing/x”. So tools.reader ignores the reader conditionals, and even in cljs, will attempt to read what’s inside of the #?(:clj ..) conditional forms. Has anyone figured out a clever way to solve this dilemma? At the moment I’m just living with a few “unused namespace” warnings, but they start to become very noisy…

cjsauer15:04:07

One solution I’ve found is just to fully type out qualified keywords, like :my.model.thing/id. It seems that all the headaches are the fault of the :: keyword sugar. Clojure keeps pushing me into just not using it at all…

yenda20:04:41

Isn't it a tools.reader bug then?

cjsauer00:04:10

I think it is, I remember seeing a ticket for it at some point.