clj-kondo

https://github.com/clj-kondo/clj-kondo
2021-04-08T01:54:03.223100Z

I did a threading macro for Promises in ClojureScript to make a Promise (.then p fn) chain look like the normal threading operator macro. clj-kondo started giving arity warnings on the functions that are going to be “threaded”, and was wondering if there is a way to hint at the arity fix: e.g.

(=> promise/resolve({})
  (assoc :a 1))

2021-04-08T01:56:18.225500Z

and it would give the arity warning on assoc equivalent, when the macro rewrites it to be:

(promise/then (promise/resolve {}) (fn [x] (assoc x : a)))
so it does get the correct arity when the ClojureScript is compiled and run, as it gives the expected results when doing tests

2021-04-08T01:57:08.226300Z

was wondering if there are any hints for the pre-compiled macro form in ClojureScript, or annotations on the macro

2021-04-08T01:57:32.226900Z

since the standard threading operators don’t give those warning

2021-04-08T01:57:44.227200Z

thanks!

2021-04-08T02:00:50.228300Z

(where promise/then and promise/resolve are function wrappers for (.then p some-fn) to make it safer to call)

borkdude 2021-04-08T07:17:56.230100Z

Love your podcast btw!

2021-04-08T12:43:36.230500Z

Thanks, and thanks!!!

2021-04-08T14:54:01.233400Z

I have never configured clj-kondo before, so a question on general practice: the macro is in a promise library, it is possible to setup the clj-kondo config with that project so that all projects that use the macro get the config, or does that need to be configured in each project that uses it?

borkdude 2021-04-08T14:54:48.233800Z

@steven.proctor That is possible. That mechanism is explained here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration

2021-04-08T14:57:35.234900Z

is that for the config.edn, the hooks definition, or both?

borkdude 2021-04-08T14:57:43.235200Z

both

2021-04-08T20:51:51.236300Z

@borkdude thanks!!! I think the lint-as config works, since I was basing it off the -> operator, it looks like I can just lint it as that operator

borkdude 2021-04-08T20:52:08.236500Z

ah great :)