This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-13
Channels
- # babashka (7)
- # babashka-sci-dev (3)
- # beginners (29)
- # biff (16)
- # calva (2)
- # clojars (1)
- # clojure (50)
- # clojure-austin (5)
- # clojure-europe (29)
- # clojure-france (8)
- # clojure-nl (3)
- # clojure-uk (3)
- # clojured (10)
- # clojurescript (19)
- # code-reviews (3)
- # core-async (22)
- # cursive (5)
- # data-science (11)
- # datalevin (1)
- # datomic (10)
- # eastwood (4)
- # helix (4)
- # introduce-yourself (2)
- # jobs (1)
- # jobs-discuss (1)
- # joyride (6)
- # leiningen (4)
- # london-clojurians (2)
- # lsp (82)
- # malli (7)
- # meander (12)
- # minecraft (3)
- # nbb (14)
- # off-topic (52)
- # podcasts-discuss (3)
- # portal (3)
- # re-frame (32)
- # reagent (9)
- # releases (2)
- # shadow-cljs (95)
- # tools-deps (14)
@ericdallo There is a conflict between how clj-kondo reports unsorted namespaces and how lsp-organize-import sorts them.
(ns example
(:require
["prism-react-renderer$default.default" :as Highlight]
["prism-react-renderer$default.Prism" :as Prism]
[reagent.core :as r]
[reagent.dom.server :as srv]))
Here the capitalized suffix should go before, because capitals are before small letters sorting-wise. Clj-kondo reports this but when you fix it manually and then run lsp-organize-imports, clojure-lsp reverts it.Seems like a bug in clj-kondo? I would expect case-insensitive sorting.
It's not a bug, always been like this, there is no such thing as case insensitive sorting in clj-kondo.
To be honest I was not aware of that clj-kondo linter, I'll enable for clojure-lsp repo to help with those kind of issues
it'd be nice to have it enabled as default, but It would probably cause lots of headaches for most users
@U04V15CAJ I found we already have a setting for that:
:clean {:sort {:require :lexicographically}}
it is the default of tooling prior to clojure-lsp, like clojure-sort-ns
which is why clj-kondo warns about it like this. having multiple options just creates more confusion imo
I agree, if this setting changes only this behavior, I'm ok changing it, but if causes any other behavior that should not be default we need to think more about it
we have https://github.com/clojure-lsp/clojure-lsp/blob/master/lib/src/clojure_lsp/feature/clean_ns.clj#L71-L85, which sorts differently, we need to check if we need to change anything with lexicographic or it will behave ok
@U0BUV7XSA we were already trying to make sorting lexicographically as default, but not right 😅 , I'll fix it to be lexicographically not needing the lexicographically
setting anymore
What is the proper way to sort this?
(ns foo.bar
(:require
["foo.bar" :default Foo]
[ball import1]
[zebra]
apple
ball))
we are sorting like that with the existing lexicographically
setting, but kondo says it should be:
(ns foo.bar
(:require
["foo.bar" :default Foo]
apple
ball
[ball import1]
[zebra]))
if you agree kondo is right, I can change that behavior @U0BUV7XSA it's just that it has a test testing that way
@ericdallo strings go first lexicographically, for the dumb reason that "
is before a
but surrounding vectors are ignored
again, clj-kondo respects how other tools always did it and it didn't want to cause any friction with those: clj-kondo only warns, other tools fix (clojure-sort-ns)
is it ok for you to change to follow other tools standard @U0BUV7XSA?
cursive just had sort lines for the longest time (still?) if you sort lines you end up with the top
clojure-lsp issue i raised about this: https://github.com/clojure-lsp/clojure-lsp/issues/561
Well remembered @U11BV7MTK, so I think we have 2 differents sorts indeed, but kondo (our main linter) has a preference
so we should at least change the default to match kondo I guess? or change kondo to match current clojure-lsp one
I actually don't care that much which we choose, but if people fix it up with some other tool which then causes lint warnings, that is mostly what I want to prevent
and clojure-sort-ns was the tool I was using myself for this (and many other people)
yes, cursive users may not use on editor, but all nubank projects have clojure-lsp as cli tool on CI for example
maybe we should have something on https://github.com/bbatsov/clojure-style-guide 😅
I think we can prevent the []
discussion by saying: always wrap your ns name in a vector, as the default style
then there's the case insensitivity: I'm open to making this the default in clj-kondo or at least make clj-kondo not complain about either way
this one is not on by default but I use it in my home config, so I have it on by default in any project
so should we change anything on clojure-lsp side? We had https://github.com/clojure-lsp/clojure-lsp/issues/561 to on purpose ignore case in sorting
I'll just make clj-kondo more lenient with case sensitivity then I guess and if people complain, we can make an option to make it more strict again
Now I see why this linter is not enabled by default 😂 lots of different opinions. I still think it should have something mentioning that on ClojureStyleGuide or something
I've made the linter lenient before, it should probably only warn on things that are unarguably not sorted by a very broad collection of opinions 🤷
https://github.com/clojure-emacs/clojure-mode/issues/409#issuecomment-247744974 interesting comment here.
I've had requests to support custom sorting "opinions" in clj-kondo, but I refused since I think we have enough discussion on indentation in the community already ;)
Btw, one more thing. Often scripts or clerk notebooks have this:
(require '[nextjournal.clerk :as clerk]
'[babashka.fs :as fs])
and clj-kondo also warns about those, but clojure-lsp does not "organize" thisNo hurry. I want to get in some more stuff on Wednesday and might release a new clj-kondo then
Actually the only thing left for me to do is make an macos aarch64 binary and then I'm good to go
Right, I think I'll wait for you, we have lots of change so clojure-lsp, that's why I wanted to do a release
Lost track of that classpath issue from recently, but I'm having a case of that again. Navigating to a var in the same project and I end up in gitlibs. This is with clerk (open source project)
You mean that there is the same ns both in the project and in the classpath as a git lib dep?
I don't know why it would be on the classpath - it doesn't appear when I do clojure -Spath