Fork me on GitHub
#clj-kondo
<
2022-09-13
>
Noah Bogart14:09:46

Lint idea: there's :unresolved-namespace (https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md#unresolved-namespace), but it doesn't raise any flags when a fully qualified symbol's namespace is required and aliased or the symbol is referred. I'd love a linter that says "if an alias exists, warn on not using the alias. if the symbol is referred, warn on using the full namespace". Something like :qualified-symbols? To allow for fully configuring it with different styles: :fully-qualified would mean you have to write clojure.string/join , :prefer-alias would mean you have to write str/join if [clojure.string :as str :refer [join]] , :prefer-refer would mean you have to write join if [clojure.string :as str :refer [join]], :any would mean either str/join or join is fine if [clojure.string :as str :refer [join]] .

👍 1
Noah Bogart14:09:28

hmm idk about the styles lol, probably just have an order of preference: referred -> alias -> fully qualified.

borkdude14:09:20

There is a recent issue posted about this

Noah Bogart14:09:50

oops! thank you

borkdude14:09:09

no problem :)

escherize21:09:05

There is a clojure convention to use s, n, coll, m, and others to refer to the type of a function argument. Has there ever been any thought to transforming those kind of arguments into :type-mismatch linting rules? I am asking if it exists before I start building such a thing to see if it’s worthwhile.

escherize21:09:40

That’s 1 example of ‘baked in’ type data. There’s also e.g. prismatic schema s/defn that gives typing info. Also I know that malli is able to write type-mismatch rules from its function schemas, which is pretty neat