This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-12
Channels
- # announcements (7)
- # babashka (13)
- # beginners (14)
- # business (7)
- # clerk (4)
- # clj-kondo (21)
- # clojure (42)
- # clojure-denmark (5)
- # clojure-dev (16)
- # clojure-europe (27)
- # clojure-finland (1)
- # clojure-nl (1)
- # clojure-norway (36)
- # clojure-sweden (2)
- # clojure-uk (34)
- # clojurescript (29)
- # datomic (15)
- # emacs (1)
- # hyperfiddle (13)
- # jobs (11)
- # joyride (8)
- # malli (15)
- # missionary (10)
- # off-topic (5)
- # portal (6)
- # releases (3)
- # shadow-cljs (9)
- # spacemacs (28)
- # specter (2)
- # squint (12)
New release: https://clojurians.slack.com/archives/C06MAR553/p1707744707619859
I have a macro which wraps a multimethod and is used like this
(defsearch :customer
[company id]
(let [customer (->> company
:company/customers
(remove :entity/deleted)
(find-first (fn [{:company/keys [reference] :as company}]
(= id (:company/id (or reference company))))))]
(or customer (err/not-found (str "Customer #" id " doesn't exist")))))
previously it was configured to lint as defn
but after last update it shows error
how can I define linter rule for it?I think the easiest would be write a hook for this which transforms it to (defn customer [...])
getting another error
error: Static fields should be referenced without parens unless they are intended as function calls
for
(def ^:private ^Locale locale
(Locale/US))
Locale/US
is a static field: https://docs.oracle.com/javase/8/docs/api/java/util/Locale.html#US
It should be referenced as (def locale Locale/US)
no problemo
yeah, this is part of the changes coming to Clojure in version 1.12. the alpha 6 announcement talks at length about it: https://clojure.org/news/2024/02/08/1-12-alpha6
> Note: Static fields are values and should be referenced without parens unless they are intended as function calls, e.g (System/out)
should be System/out
. Future Clojure releases will treat the field’s value as something invokable and invoke it.
it was a bug/quirk of the compiler previously that allowed this to work, but it wasn't intentional and now they're changing it to have a specific meaning going forward
Note: (SomeClass/staticField)
will still work in 1.12 but you shouldn't rely on it working in 1.13 or later.
I'm just going through some code cleanup at work and we had several of these that clj-kondo has helpfully called out for us to fix!