Fork me on GitHub
#clj-kondo
<
2021-04-08
>
Proctor01:04:03

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))

Proctor01:04:18

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

Proctor01:04:08

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

Proctor01:04:32

since the standard threading operators don’t give those warning

Proctor02:04:50

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

borkdude07:04:56

Love your podcast btw!

Proctor12:04:36

Thanks, and thanks!!!

Proctor14:04:01

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?

Proctor14:04:35

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

Proctor20:04:51

@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

borkdude20:04:08

ah great :)