Fork me on GitHub
#clj-kondo
<
2023-01-20
>
pmooser16:01:14

Is it possible to disable a certain type of warning (`unused-binding`) just inside of destructuring a map ?

pmooser16:01:55

When I destructure the incoming arguments of an fn, I often prefer to still give the argument a name using :as but clj-kondo doesn't like it if I don't use that name anywhere.

borkdude17:01:31

Have you checked linters.md? I believe this is a supported option

borkdude17:01:08

{:linters {:unused-binding {:exclude-destructured-as true}}}

pmooser17:01:42

@U04V15CAJ I'm sorry - I looked in config but evidently not closely enough. Thank you!

borkdude17:01:09

No worries :)

pavlosmelissinos19:01:19

@U07VBK5CJ I'm pretty sure you can prepend the name with a _ and the linter won't complain. No need to change any options if that works for you. E.g. :as foo -> :as _foo

pavlosmelissinos19:01:52

I omit :as if it's not going to be used in the code so I'd never disable the linter in projects I'm involved but within a team if other people like it _foo tells me two things: what the map represents and that it's not used :slightly_smiling_face:

serioga18:01:53

@U07VBK5CJ I suggest to use :arglists meta for documenting function arguments without performance penalty from unneeded destructuring.

borkdude19:01:32

but if you're destructuring anyway, then :as x isn't going to add any performance penalty

pmooser08:01:00

I appreciate the feedback too, and I often forget that arglist metadata even exists unless I'm writing macros.

Noah Bogart18:01:36

How interested would you be in a linter that yells about syntax quote on namespaced symbols where the namespace isn't an existing alias? I just dealt with a bug where I was trying to implement the Component library using metadata: (with-meta this {component/start #'start component/stop #'stop}) but I was missing [com.stuartsierra.component :as component] in my :require block, so the functions weren't getting called.

borkdude19:01:45

I think that would be useful

Noah Bogart19:01:18

cool, I'll write up an issue

borkdude20:01:02

:unresolved-namespace {:syntax-quote true} would maybe make sense

👍 2
borkdude20:01:08

@UKFSJSM38 Bump in lsp welcome

borkdude20:01:31

I see lsp crashes on the newest clj-kondo but this is because it relies on internals (.impl.config)

ericdallo20:01:37

yeah, would be nice to have those usages on public ns I think, I can take a look in the weekend