This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-09
Channels
- # announcements (14)
- # babashka (2)
- # beginners (33)
- # calva (25)
- # cider (4)
- # clj-kondo (14)
- # clojure (11)
- # cursive (4)
- # datomic (3)
- # fulcro (53)
- # gratitude (3)
- # integrant (2)
- # leiningen (7)
- # lsp (10)
- # malli (34)
- # missionary (3)
- # off-topic (71)
- # other-languages (18)
- # pathom (1)
- # practicalli (2)
- # releases (1)
- # ring (4)
- # spacemacs (1)
- # vim (14)
the plumatic syntax is merged in master, also better dev-tooling for CLJS (thanks to @danvingo!). Looking forward to test reports, will release soon/after.
That’s so exciting!
I’m interested in using malli with clj-kondo for static type checking. We already have clj-kondo in our project, and I saw in the malli readme on how to generate configs. Wondering if there are any decent examples that would demonstrate how to organize this for a large production code base?
Static type checking in Clojure is a bit limited without type inference, which malli and kondo don't do. You'll have to specify everything you want checked. A sane middle ground is having a "schema" namespace where you specify the schema of data coming in or out of your code base, then validate at the edges of the system.
(some type-inference? clj-kondo) ;; => true How much type inference does it do, exactly?
$ clj-kondo --lint - <<< '(let [x :foo] (inc x))'
<stdin>:1:20: error: Expected: number, received: keyword.
$ clj-kondo --lint - <<< '(let [x (inc 2)] (assoc x :foo :bar))'
<stdin>:1:25: error: Expected: associative collection or nil, received: number.
there is one open issue by @U055NJ5CC about this, that I haven't gotten around to yet
we already use plumatic.schema for data validation at the edges. I’m primarily talking about this:
https://github.com/metosin/malli#clj-kondo
I can see how to define the function spec right after with m/=>
.
What I’m wondering is if there’s a best practice for emitting all of the configs for a project after defining the specs in each ns?
And further than that, would this buy me anything when it comes to associative collections?
@U774Z4VJA you get things for free and it might improve over time if you complain enough in the #clj-kondo channel :)
associative collections: if you specify a required key as input to a function and you pass a map literal, then clj-kondo will be able to see it
ha, ya. Maybe if work stay calm enough, I may even be able to contribute here and there 😉
tl;dr of above thread. One unanswered question: Any tips on emitting clj-kondo config for a whole project?
There is no guide for that and as there are 3+ ways to declare the schemas for functions, no best practices yet I think. I put the schemas next to the functions (my favourite is the plumatic-syntax, so inlined) and have the
in the user / dev namespace, so you can do that easily. It instruments all the functions from all loaded namespaces, so should work ok.
if not, please report 🙂 planning to mallify a large codebase, can comment after that how it works / doesn’t.
Many thanks for the response!
Will
also emit the clj-kondo config @U055NJ5CC?