Fork me on GitHub
#clj-kondo
<
2022-05-06
>
borkdude10:05:03

Hello y'all! I made a small documentation tool based on clj-kondo output. Example: https://github.com/babashka/sci/blob/master/API.md Repo: https://github.com/borkdude/quickdoc

šŸŽ‰ 4
orestis11:05:04

Hi! I'm using transit-cljs for the first time in this codebase, and I'm getting this unexpected error from clj-kondo: ā€¢ cognitect.transit/reader is called with 1 arg but expects 2 or 3 ā€¢ cognitect.transit/read is called with 2 args but expects 1

orestis11:05:04

With the linted function being:

(defn get-transit-var [x]
  (let [json (gobj/get js/window x)
        reader (transit/reader :json)]
    (transit/read reader (js/JSON.stringify json))))
And the require being [cognitect.transit :as transit]

borkdude11:05:24

@orestis Are you using this in a .cljc file?

borkdude18:05:06

@orestis The issue might be that clj-kondo has an older version of transit in its built-in cache

borkdude18:05:26

if you lint your dependencies, that should take care of the problem

orestis19:05:13

I'm starting with linting dependencies and clearing the cache, but perhaps I need to look into the classpath generated for that.

borkdude19:05:10

either way, issue welcome on github with repro

orestis06:05:47

No worries, I was preparing the classpath without the cljs alias. There was a mismatch between what VSCode/Calva was linting and what I was linting from the command line.

orestis11:05:56

But in the classpath there is also the CLJ version of transit.

orestis11:05:06

I'm using the latest version for everything (transit, kondo)

cldwalker17:05:23

Hi y'all. I'm looking to disable clojure linting in a .cljc file since I'm only wanting to lint it for cljs and nbb. I tried #?(:clj {:clj-kondo/config ^:replace {:linters {}}}) per https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#disable-all-linters-but-one but that doesn't seem to work. Any advice?

borkdude17:05:02

@cldwalker try on the project level:

{:cljc {:features [:cljs]}}

cldwalker17:05:16

That works great for all files but unfortunately I have other cljc files that do need clj linting enabled. I tried it at the namespace level but no dice. Would namespace groups support it?

borkdude17:05:44

The reader conditional processing happens before clj-kondo sees the ns form, so no

borkdude17:05:44

Maybe you're able to get away with a .cljs extension?

cldwalker17:05:15

Ok. Should ^:replace work for namespace level configs or is that more for commandline usage per the example? I was hoping to disable all linters at once. For now I have a workaround that I disable new clj linter keys as they come up

borkdude17:05:06

You can disable it with :output {:exclude-files "regex"}}

šŸ‘€ 2
cldwalker17:05:59

> Maybe you're able to get away with a .cljs extension? Unfortunately I can't because because nbb and cljs have different require semantics for this example e.g.:

#?(:org.babashka/nbb ["mldoc$default" :refer [Mldoc]]
   :default ["mldoc" :refer [Mldoc]])

borkdude17:05:37

@cldwalker Is one target the browser and the other Node.js, or both Node.js?

cldwalker17:05:19

@borkdude one targets node and the other browser and node

borkdude18:05:42

@cldwalker in nbb you can cheat by doing: (def mldoc (js/require "mldoc")) probably but this probably doesn't work for the browser

borkdude18:05:21

@cldwalker I solved this problem in a different project by moving these differences to one spot and then use the required libraries from there.

(ns deps (:require #?(:org.babashka/nbb ["mldoc$default" :refer [Mldoc]]
   :default ["mldoc" :refer [Mldoc]])))

(def Mldoc Mldoc)

borkdude18:05:53

(ns whatever (:require [deps :refer [Mldoc]]))
(.fooBar Mldoc)

borkdude18:05:35

You could also consider target :esm for both Node.js and browser and have everything the same as nbb

borkdude18:05:44

Anyway :exclude-files should solve it

cldwalker18:05:36

Thanks for the suggestions. Will try em out and see what works

Joshua Suskalo18:05:13

Thanks a lot for the quickdoc tool @borkdude! I've wanted a reasonable doc tool for a while that produces something readable for my projects that can't be read by cljdoc or that I don't want to publish. I'd been using codox before, but even that's a pain to set up for some projects. I think this'll be a great tool to add to my toolbox. šŸ™‚