This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-11
Channels
- # announcements (15)
- # aws (11)
- # babashka (13)
- # babashka-sci-dev (2)
- # beginners (63)
- # calva (20)
- # cider (9)
- # clj-kondo (27)
- # clojars (3)
- # clojure (34)
- # clojure-art (4)
- # clojure-europe (21)
- # clojure-filipino (1)
- # clojure-indonesia (1)
- # clojure-my (1)
- # clojure-nl (11)
- # clojure-norway (10)
- # clojure-sg (1)
- # clojure-spec (4)
- # clojure-uk (4)
- # clojurescript (5)
- # cursive (8)
- # deps-new (2)
- # events (1)
- # exercism (2)
- # fulcro (44)
- # graphql (6)
- # gratitude (1)
- # introduce-yourself (1)
- # jobs (3)
- # leiningen (5)
- # lsp (26)
- # membrane (18)
- # missionary (9)
- # off-topic (1)
- # pedestal (5)
- # portal (1)
- # quil (24)
- # re-frame (17)
- # reagent (5)
- # remote-jobs (2)
- # reveal (3)
- # spacemacs (4)
- # tools-build (1)
- # tools-deps (12)
According to docs ^:replace
is supposed to also apply to inner parts when merging configs, but it does not seem to work for me. Should both examples result in {:linters {:b 2}}
or something else?
(clj-kondo.impl.config/merge-config! {:linters {:a 1}} ^:replace {:linters {:b 2}})
;; => {:linters {:b 2}}
(clj-kondo.impl.config/merge-config! {:linters {:a 1}} {:linters ^:replace {:b 2}})
;; => {:linters {:a 1, :b 2}}
@kloud Looking at the code, it seems ^:replace
was ever only support to replace top level configs
There are hints in the https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md that it should work for nested options:
> The ^:replace
metadata hint can be used to replace parts or all of the configuration instead of merging with previous ones. The home dir config is implicitly part of :config-paths
. To opt out of merging with home dir config use :config-paths ^:replace []
in your project config.
I guess it should not hurt performance too much if we check for meta on the deep-merge function, but it might be good to double check this on large merges
Would it make sense to have separate functions? add a new one for config merging and keep the old one for the analyzer for perf reasons?
I think checking meta should be fast and then getting the replace key if there is meta should also be fast, so the overhead should not be gigantic
Another option could be also a shallow merge of top-level keys. In my case I just need to override :linters
but keep the inferred paths to keep hooks working.