This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-04
Channels
- # announcements (3)
- # babashka (14)
- # beginners (151)
- # calva (14)
- # cider (9)
- # clj-kondo (24)
- # cljdoc (12)
- # cljs-dev (195)
- # cljsjs (3)
- # cljsrn (13)
- # clojars (12)
- # clojure (234)
- # clojure-dev (3)
- # clojure-europe (9)
- # clojure-greece (1)
- # clojure-italy (2)
- # clojure-japan (4)
- # clojure-nl (4)
- # clojure-spec (89)
- # clojure-taiwan (1)
- # clojure-uk (16)
- # clojuredesign-podcast (2)
- # clojurescript (17)
- # conjure (11)
- # core-async (4)
- # core-typed (31)
- # cursive (9)
- # datomic (8)
- # emacs (17)
- # figwheel (1)
- # fulcro (5)
- # ghostwheel (42)
- # graphql (3)
- # hugsql (5)
- # jackdaw (3)
- # jobs-discuss (93)
- # joker (4)
- # meander (6)
- # mount (1)
- # off-topic (23)
- # pathom (10)
- # re-frame (23)
- # reitit (7)
- # remote-jobs (18)
- # shadow-cljs (153)
- # spacemacs (24)
- # sql (30)
- # tools-deps (14)
- # vim (12)
- # xtdb (1)
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
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:
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
just moved from 2020.01.13 -> 2020.05.09
$ 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
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