Configurable unsorted-required-namespaces #1583
Replies: 5 comments
-
|
Beta Was this translation helpful? Give feedback.
-
It's worth adding to the discussion that writing a hook for our custom use was very easy. |
Beta Was this translation helpful? Give feedback.
-
If I may ask, what kind of different sorting do you seek? It may help add the problem you want to solve at your company, so we can think how clj-kondo can be improved to solve the issue, WDYT? |
Beta Was this translation helpful? Give feedback.
-
@ericdallo an example would be to require internal libraries last. I never used anything other than the liters' defaults in any company I worked (except my current one). So I don't think its a common use case. But I do think supplying a key-function/comparator and basically configuring only the relation between required namespaces (and not writing the entire linter) is very flexible. And since it can be opt-in (default should be the current way) - I think it improves the linter overall. |
Beta Was this translation helpful? Give feedback.
-
What I'm missing so far is the alternatives considered: E.g. one could introduce a grouping construct so each group should be sorted (using the default linter). E.g.: (ns foo
(:require [external.lib1]
[external.lib2]
;; internal libs
[internal.lib1]
[internal.lib2]
)) What is also a concern: the linter can warn on custom sorting, but tooling should be able to fix it too then probably: clojure-lsp, clj-refactor, etc. |
Beta Was this translation helpful? Give feedback.
-
What are your thoughts about allowing configuration (probably a key-function just like
clojure.core/sort-by
has) that controls the sort order in unsorted-required-namespaces linter?I think it raises several questions:
.clj-kondo/hooks/...
How much of an effort is it to support it? I took a (brief) look on unsorted-required-imports and it seems to use
compare
recursively so maybe a different method will be less of an effort?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions