Fork me on GitHub
#clj-kondo
<
2020-05-18
>
eskos09:05:01

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.

borkdude09:05:02

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

eskos12:05:13

Hmm, couldn’t find any on cursory look…

borkdude12:05:48

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.

eskos12:05:35

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…?

borkdude12:05:15

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.

borkdude12:05:37

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

borkdude12:05:41

it's not clear cut

borkdude12:05:20

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

borkdude12:05:32

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

borkdude12:05:32

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

borkdude12:05:43

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

borkdude13:05:25

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

eskos13:05:57

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