This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-21
Channels
- # announcements (4)
- # aws (29)
- # aws-lambda (1)
- # babashka (21)
- # beginners (143)
- # calva (47)
- # cider (31)
- # clj-kondo (24)
- # cljsrn (4)
- # clojure (70)
- # clojure-australia (3)
- # clojure-czech (1)
- # clojure-europe (97)
- # clojure-greece (4)
- # clojure-nl (3)
- # clojure-uk (45)
- # clojurescript (70)
- # code-reviews (1)
- # conjure (7)
- # cursive (10)
- # datomic (13)
- # duct (5)
- # emacs (1)
- # fulcro (38)
- # graalvm (1)
- # graphql (9)
- # honeysql (13)
- # integrant (33)
- # jobs (14)
- # jobs-rus (1)
- # malli (7)
- # off-topic (72)
- # pathom (1)
- # re-frame (11)
- # reitit (9)
- # remote-jobs (2)
- # sci (11)
- # shadow-cljs (9)
- # sql (5)
- # tools-deps (5)
- # xtdb (6)
What do people think of a clj-kondo linter that warns on aliased keyword usage? e.g.
(ns blah.blah (:require [foo.bar :as bar]))
::bar/baz ;; <- WARNING: aliased keyword
:foo.bar/baz ;; <-- ok
i.e. to encourage find/replaceable keywordsBut if it did, you could use that to still make it easy to find/replace, and still let people use aliases
Basically, it forces the alias to be consistent across the board. So you know that you just need to find/replace that one alias.
@rickmoynihan @snoe and @ericdallo and currently working on adding keyword analysis output (for LSP) but this would also allow you to get all aliased keywords (and write a tool that spits out warnings). But it can also included in clj-kondo pretty easily and by default turned off.
cool… so clj-kondo currently doesn’t preserve that sort of data or have keyword analysis, that would make this linter easy?
Similarly I was thinking of another for integrant keys, that ensures the keys are compatible with ig/load-namespaces
e.g.
(ns foo.bar (:require [integrant.core :as ig]))
(defmethod ig/init-key :wibble/wobble ;; <-- WARNING: integrant key does not match the namespace defining ig/init-key not discoverable by ig/load-namespaces
[_ opts] ,,,)
(defmethod ig/init-key :foo.bar/baz ;; ok
[_ opts] ,,,)
(defmethod ig/init-key :foo/bar ;; ok
[_ opts] ,,,)
the defmethod would need to be put in a namespace wibble.wobble
or wibble
(single segment namespaces aside)
essentially ig/load-namespaces
uses the key names specified in the integrant config to load the set of configured keys / namespaces. So it infers the namespace from the keywords name
I wonder if you could do this with a hook. I think you could but the namespace is currently not passed to the hook function. Can be added though.
no its ok because there are two rules for matching… I forget exactly but something like:
1. if you have the key :foo/bar
try first to load the namespace foo.bar
2. if that fails try the namespace foo
(and expect to find the ig/init-key :foo/bar
in it)
i.e. sometimes a namespaced keyword might fully identify a namespace (and a single component). Other times a namespace might contain many components; either is fine.
my example is perhaps a bit confusing because I combined all the examples in a single ns. See here for the official docs: https://github.com/weavejester/integrant#loading-namespaces
Thanks, will do :thumbsup: just wanted to check they seemed feasible