clj-kondo

teodorlu 2025-10-01T16:54:50.161119Z

Is it disallowed to have a macro and an :analyze-call hook for that macro in the same namespace? Conclusion: not really, but hooks must be in the .clj-kondo-directory, and you probably don't want your own application code in that folder.

✅ 1
teodorlu 2025-10-01T16:55:51.030279Z

I'm asking because I have just that, and I'm unable to tell Kondo how to find my hook:

$ head -n 9 kondo_hooks_for_application_programmers.clj
^{:nextjournal.clerk/visibility {:code :fold :result :hide}}
(ns kondo-hooks-for-application-programmers
  {:nextjournal.clerk/toc true
   :clj-kondo/config
   '{:hooks
     {:analyze-call
      {kondo-hooks-for-application-programmers/defgrinning
       kondo-hooks-for-application-programmers/defgrinning-hook}}}}
  (:require [clojure.string :as str]))
$ ls
deps.edn                                    kondo_hooks_for_application_programmers.clj
index.edn                                   kondo-does-not-understand-it.png
index.html                                  play.edn
$ cat deps.edn
{:paths ["."],
 :deps {clj-kondo/clj-kondo {:mvn/version "2025.09.22"}
        io.github.teodorlu/play.teod.eu {:local/root ".."}}}
$ clj-kondo --lint kondo_hooks_for_application_programmers.clj
WARNING: file kondo_hooks_for_application_programmers not found while loading hook
WARNING: error while trying to read hook for kondo-hooks-for-application-programmers/defgrinning: Could not find namespace: kondo-hooks-for-application-programmers.
[...]
linting took 18ms, errors: 2, warnings: 2

teodorlu 2025-10-01T17:03:04.311249Z

I missed this part from https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md: > This code will be placed in a file hooks/with_bound.clj in your .clj-kondo directory.

teodorlu 2025-10-01T17:03:18.425189Z

Back to work! 😄

teodorlu 2025-10-01T17:08:17.182649Z

got it working! 😁

$ clj-kondo --lint kondo_hooks_for_application_programmers.clj | grep "Radioactivity disallowed"
kondo_hooks_for_application_programmers.clj:151:1: error: Radioactivity disallowed, it does not cause grinning!

teodorlu 2025-10-01T17:08:33.631819Z

reading the docs helps, spelling my question out helps.