clj-kondo

https://github.com/clj-kondo/clj-kondo
cjsauer 2021-04-13T13:40:27.253900Z

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…

cjsauer 2021-04-13T15:49:07.254Z

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…

yenda 2021-04-13T20:51:41.254200Z

Isn't it a tools.reader bug then?