clj-kondo

micha 2025-03-29T19:00:15.273499Z

Hi! Is there a way to access sci.core/parse-next+string from within a hook?

borkdude 2025-03-30T08:13:54.217419Z

currently not, these are the only ones currently: https://github.com/clj-kondo/clj-kondo/blob/b48c405351da8baa9f57259194129e0dd46b77b1/src/clj_kondo/impl/hooks.clj#L72 what's your goal?

micha 2025-03-30T12:46:38.050069Z

my OCD wants me to write a hook for the << macro, which does string interpolation:

micha 2025-03-30T12:47:38.646689Z

i need some way to incrementally read forms from the string, keeping track of read position in the string

borkdude 2025-03-30T18:53:26.172669Z

I think it would make sense to expose edamame which is the clojure parser library used in SCI. which would let you write it almost in the same way https://github.com/borkdude/edamame is this the clojure contrib << interpolation macro?

borkdude 2025-03-30T19:04:19.315609Z

user=> (require '[edamame.core :as e])
user=> (e/parse-next+string (e/source-reader ", (+ 1 2 3)"))
[(+ 1 2 3) ", (+ 1 2 3)"]

borkdude 2025-03-30T19:05:18.927939Z

feel free to open an issue about it

awb99 2025-04-07T21:32:09.928469Z

Is it possible to get a lint error if a var that is required is not defined in the source code of a namespace? Example (ns lib) (def foo 1) (ns app (:require [lib :refer [foo bar]])) -> ns lib does not contain bar, so I would like to get a lint error.

borkdude 2025-04-07T21:33:54.679099Z

@hoertlehner this already works.

$ clj-kondo --lint - <<< '(ns lib) (def foo 1) (ns app (:require [lib :refer [foo bar]]))'
<stdin>:1:41: warning: namespace lib is required but never used [:unused-namespace]
<stdin>:1:53: warning: #'lib/foo is referred but never used [:unused-referred-var]
<stdin>:1:57: warning: #'lib/bar is referred but never used [:unused-referred-var]
<stdin>:1:57: warning: Unresolved var: bar [:unresolved-var]

borkdude 2025-04-07T21:34:04.948249Z

the last warning is about that

borkdude 2025-04-07T21:34:20.152319Z

let's take this to a different thread though, as it's not related at all to the OP

awb99 2025-04-07T21:38:34.085829Z

Wow ! Thanks so much @borkdude! I dont know about OP - I posted on clj-kondo thread; isnt that the right thread?

awb99 2025-04-07T21:39:59.484709Z

borkdude 2025-04-07T21:40:00.961769Z

On slack a channel (#clj-kondo) is the main thing where you post messages. if you want to react to a specific message, you can start a thread. you're now in a thread started by @micha about a specific question

awb99 2025-04-07T21:40:43.851579Z

I see that now. Im the ui on my Phone I had no way of seeing that. Sorry!!

borkdude 2025-04-07T21:41:03.838899Z

no problem