Fork me on GitHub

Rather wild idea, what if it would be possible to provide clj-kondo config fragments within JAR, eg. through symbol metadata? I also happen to have if-let* in my project(s) and for all intents and purposes it could be linted as let macro as is.


That idea has come up more often and there were some problems associated with it. Can't remember the details, but feel free to look through the issues


Hmm, couldn’t find any on cursory look…


So far the lowest friction solution is to just provide some docs around how to use your macro with clj-kondo. Possibly in the docstring, or in the README.


Hmm, not sure if I see that as a problem. I was thinking that if I were to eg. (defmacro ^{:kondo/lint-as #'clojure.core/binding} if-let* …) that would be a pretty clean way to provide library author intended linting rule for the macro which is pulled in when the macro is used and this metadata would be taken into consideration only if project/user specific rules do not match. Not quite a huge side step IMHO but I don’t know much about how kondo works internally so maybe the issue really is there…?


It's technically all possible, but too fragile imo. I mentioned already some reasons in the linked issue, I'm not going to repeat them all. clj-kondo focuses on performance. it doesn't do multi-pass linting. if someone uses a macro in code before the config metadata has been read, they will still get an error. also config would be hard to debug if library authors put invalid configs on their metadata, etc.


also there are several alternatives to consider how to go about this


it's not clear cut


there could be a user provided tool which scans vars for :clj-kondo/lint-as metadata at runtime and spits out that config to .clj-kondo/config.edn


then clj-kondo wouldn't have to support anything other than it does right now


Feel free to post another issue about this, and enumerate all possibilities


The original issue is not easy to find and it a bit cluttered.


@suomi.esko The problem is very similar to: why does Clojure choose to define data reader config in data_readers.clj instead of metadata.


Well, I’ll take your word for it 🙂 I don’t think I know enough to have a fully educated suggestion for this.