-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dont remove ns requires without an alias #359
Comments
Note that there are two conditions: no alias or no referred vars. |
Agreed. I remember this being discussed here before, but I don't remember why it wasn't changed. Maybe @expez has a clue? |
Found an issue here: #292 |
Nobody's added the setting. That's the only reason 🙂 Personally I prefer the workaround in #292 (and I don't write much cljs, where it's not available!) because I think it's helpful to indicate that the required ns is special and I also always add a comment about why we need those side-effects. |
From clj-kondo/clj-kondo#241 which dates back to 2019 a few things can be observed:
I'm particularly concerned about intentionally introducing false negatives in other tools. And also trying to follow any 'conventions' that aren't described in https://clojure.org/ seems a pretty bad precedent - it would be similar to making other tools honor I'd be happy if we could revisit the topic in a particularly productive fashion - maybe opening a poll on the internet isn't exactly bound to give optimal results. Surely it should be a matter of "who's going to adhere by this convention", which is ultimately a tooling maker's concern. As a quick note I like .cljfmt.edn files (which appear to be a clojure-lsp thing), couldn't a simiar edn file be a good cross-tooling standard? Similar to EditorConfig. |
@dpsutton: this is incorrect, there's the |
Closing in face of the post above, using There's a slight room for a PR (inferring the whitelist if the convention is followed), however that would intentionally introduce false negatives, so I don't think it would be a great addition (at least not without pinging again a variety of tool makers). Cheers - V |
...One interesting thing refactor-nrepl could start doing is reading It's essentially the same as our own Will hammock and likely impl. |
Today's refactor-nrepl + clj-refactor releases honor Kondo |
Clj-kondo and refactor-nrepl disagree about how to clean
ns
forms and it would be nice if we could unify their notions. The problem is around how to tell the linter to not remove a namespace require which has no visible usages in the buffer, but is required for side effects. Refactor nrepl will remove them unconditionally and there seems to be an agreed upon workaround to include a formClj-kondo takes the approach that any require that does not have an alias is presumably there for side effects.
In this form both
foo.bar
andfoo.bar.baz
will remain because they do not have aliases.This analysis also powers how
clojure-lsp
will clean the ns form.It would be nice if refactor-nrepl would align to this style. Clj-kondo is by far the most popular linter and will complain about the unresolved symbols in the
bar/keep-me
form. Clojure-lsp is powered by clj-kondo's analysis and will count those alias use sites as usages and keep the requires they intend to keep, but will also keep them if the alias is dropped since it uses clj-kondo's analysis. Adopting this style in refactor-nrepl would mean less work for users of refactor-nrepl and no tension with the other tooling.The text was updated successfully, but these errors were encountered: