hey how does the missing map keys feature work in clj-kondo? What's an example that would make clj-kondo flag this?
@sfyire do you mean this?
$ clj-kondo --lint - <<< '{:a}'
<stdin>:1:2: error: missing value for key :a
ah I see, I misunderstood yeah I think so
@sfyire How did you understand it initially?
I thought it was some kind of key checking, not sure how that would have worked
@sfyire clj-kondo also has something like that, although you should configure it yourself:
{:op :keys, :req {:a :string} :opt {:b :int}}
https://github.com/borkdude/clj-kondo/blob/master/doc/types.mdI use it in one place in clj-kondo where I must make a map with 5 keys, of which I always forget at least one. clj-kondo reminds me what additional keys I should provide
that's quite cool I didn't realise that was possible
https://github.com/borkdude/clj-kondo/blob/master/src/clj_kondo/impl/findings.types.edn
I'm going to try and see if I can get that working on an example function
What have I done wrong here?
My test code looks like this:
:args
should be a vector
yeah I've put that back in, was just reading some more docs but no dice so far
ah what I should try is updating in case my version is old
always a good plan
just moved from 2020.01.13 -> 2020.05.09
The type stuff is already from Autumn 2019
$ clj-kondo --lint /tmp/foo.clj --config '{:linters
{:type-mismatch
{:level :warning
:namespaces
{foo
{full-name {:arities {1 {:args [{:op :keys
:req {:first-name :string
:last-name :string}}]}}}}}}}}'
/tmp/foo.clj:5:12: warning: Missing required key: :first-name
/tmp/foo.clj:5:12: warning: Missing required key: :last-name
linting took 43ms, errors: 0, warnings: 2
(ns foo)
(defn full-name [_])
(full-name {})
works here
I'm afk now
ah cool I'll try that out locally thank you for your help
ah it helps if I update the jar file the lsp plugin in cursive is pointed to