clj-kondo

https://github.com/clj-kondo/clj-kondo
eskos 2020-05-18T09:33:01.217500Z

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.

borkdude 2020-05-18T09:37:02.218700Z

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

eskos 2020-05-18T12:03:13.219Z

Hmm, couldn’t find any on cursory look…

borkdude 2020-05-18T12:08:48.220400Z

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.

eskos 2020-05-18T12:16:35.223500Z

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

borkdude 2020-05-18T12:22:15.226300Z

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.

borkdude 2020-05-18T12:25:37.226800Z

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

borkdude 2020-05-18T12:25:41.227Z

it's not clear cut

borkdude 2020-05-18T12:26:20.227800Z

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

borkdude 2020-05-18T12:26:32.228200Z

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

borkdude 2020-05-18T12:31:32.229400Z

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

borkdude 2020-05-18T12:31:43.229700Z

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

borkdude 2020-05-18T13:41:25.230200Z

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

eskos 2020-05-18T13:44:57.230700Z

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