electric icon indicating copy to clipboard operation
electric copied to clipboard

Add clj-kondo config for e/for-by

Open simon-katz opened this issue 1 year ago • 2 comments
trafficstars

simon-katz avatar Mar 19 '24 16:03 simon-katz

CA received, thank you @simon-katz Per our DMs, the approach taken is that Kondo uses a mock/fake macroexpansion before linting. The capability has been available in Kondo for a couple years.

dustingetz avatar Mar 19 '24 16:03 dustingetz

A few more details…

The clj-kondo feature is documented at https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md.

I've used the simple approach of a :macroexpand hook. This works pretty well, but one linting message is less than ideal: when e/for-by is called with the wrong number of arguments, the message is (for example) clojure.core/for is called with 1 arg but expects 2 [invalid-arity] — the mention of clojure.core/for is not ideal.

Something more sophisticated is probably possible using an :analyze-call hook.

simon-katz avatar Mar 20 '24 10:03 simon-katz