Does clj-kondo merge home config with a project specific one? ๐งต
Related to this โ๏ธ I created this issue: https://github.com/clj-kondo/clj-kondo/issues/1281
I will get to it, currently afk
yes
I noticed if I have a home config with a custom :lint-as
and add a project config that has also a :lint-as
but both lint-as are different, clj-kondo doesn't merge it
it uses the project one only
is that right?
I think it should merge it
the project is merged in later, so the project config wins from the global config
example: home
:lint-as {a b}
project
:lint-as {c d}
I would expect a final config of
:lint-as {a b
c d}
yes, that should be the case
you can verify this if you call run!
and then inspect the :config
key in the result
hum, I will try to make a minimal repro, but it seems to me the final result is:
:lint-as {c d}
repro welcome
is there any easy way to test it via cli?
no
alright
LMK if I'm doing anything wrong: https://github.com/clj-kondo/clj-kondo/issues/1279
oh btw, there is also a clj-kondo.core/merge-configs
function, you could test this
user=> (clj-kondo/merge-configs '{:lint-as {a b}} '{:lint-as {c d}})
{:lint-as {a b, c d}}
Oh, nice, so why is not working for my case?
If you remove the project config, does it still use the home one - is your home config used at all?
you should put your config in ~/.config/clj-kondo
or XDG_CONFIG_HOME/clj-kondo
yeah, for some reason, clj-kondo is not detecting the home config, only if I move it to xdg-config one
let me confirm if now it gets merged correctly
the config should be in ~/.config/clj-kondo
, not in ~/.clj-kondo
but XDG_CONFIG_HOME
overrides this
like it should
for some reason the home one always worked :thinking_face:
does that support was dropped recently?
no, it has always worked like this
it was implemented in issue 992, you can still find the commits
the merge works fine now ๐
That's crazy, in nubank we always used the config on ~/.clj-kondo/config.edn
and it always worked
anyway, I'll update the config location
thanks for the help ๐
This is the first commit where the home config was read: https://github.com/clj-kondo/clj-kondo/commit/edd4ff14c286c644921cd84f874ff007699f01f4#diff-abd35172092e4f3c0969a9f59bd79ed193be63b1107549915d49758fae78bee7
(defn home-config []
(let [home-dir (if-let [xdg-config-home (System/getenv "XDG_CONFIG_HOME")]
(io/file xdg-config-home "clj-kondo")
(io/file (System/getProperty "user.home") ".config" "clj-kondo"))]
(when (.exists home-dir)
(read-config-from-dir home-dir))))
that function is still the same today
yeah, it makes sense, I still don't understand how that was/is working for a lot of people
maybe clj-kondo is checking recursively until /
for a config?
yes
it does
oh, so that makes sense now
it was indeed using the home one when there is no project one
everything makes sense now hahah
because it was not considering as a home config bug a project config
the home config must be on XDG or .config
@borkdude I think I found a bug with a copy-configs, sorry for bother you again ๐
โข I have a .config/clj-kondo config with :config-paths ["nubank/state-flow"]
โข if the project doesn't contains a .clj-kondo
dir, everything works, since clj-kondo copy the lib config to the global clj-kondo location and the config-paths works.
โข if the project has a .clj-kondo
dir, clj-kondo will copy the lib config to the project clj-kondo, but the :config-paths
from the global one will not work and the project will not have the lib config configured correctly
does that makes sense for you?
maybe copying the config for both places (global and project) would work?
I confirmed that adding :config-paths ["nubank/state-flow"]
to the project clj-kondo config works, so I think that's the issue, clj-kondo should check for config-paths on both configs and if finds, it should check for the folders on both config dirs as well
I was afk for dinner, let's see
yes, this makes sense. you should add :config-paths to the clj-kondo directory that is relative to the copied configs
I think you should just re-import your configs once again, if you decide that your project is going to have a .clj-kondo config
I don't expect this occurs very often in the lifecycle of a project (just one time)
Yes, my point is that clj-kondo is copying the config to the project one but the config with the config-paths is on the global one
So it doesn't find the confif
yes, this is because you introduced the local config later
I think this is the same issue @leoiacovini was having
which should not happen that frequently in the lifecycle of a project
where is this issue filed in the issue tracker? I have not heard about it before
but in my opinion this is just how it works, I don't think clj-kondo has to look in multiple places. it tells you that you should add a config dir to your local config if you copy the configs
if you don't agree with how that works, you can move your config to the global config as well, manually
perhaps I am missing something, but I'm kind of tired today and perhaps explaining it crystal clear in an issue helps
and I can look it at some other day with fresh eyes
the issue was in some other thread ๐ My point is just that we'd like to avoid manual moves or something like that to work well will everyone that use the project, I'll try to simulate a local repro to make sure we are talking about the same thing