Fork me on GitHub
#clj-kondo
<
2022-11-11
>
Benjamin09:11:14

Does it make sense that clj-kondo throws "unresolved namespace" for user ? The use case is I setup dev vars in user, then reference them in rich comments in source files. Guess 1 solution is to have the rich comments in the user file instead.

borkdude09:11:46

@benjamin.schwerdtner Just write (require 'user) to solve this. All namespaces must be required prior to use is the rule

borkdude09:11:40

For user this might seem a bit silly, but don't know if it's common enough to make an exception for that

clojure-spin 1
mkvlr10:11:30

does clj-kondo support colored output on the CLI to differentiate warnings from errors?

borkdude10:11:04

not currently

borkdude10:11:39

you can build your own reporter by just using the EDN output though

馃憤 1
ericdallo12:11:28

Does it make sense to have a linter about files without newlines?

ericdallo12:11:59

I know it's not related to clojure, but it's pretty common to expect linters to check that

ericdallo12:11:02

Example from a github PR I'm reviewing

imre12:11:08

> files without EOF an endless file? 馃槢

borkdude12:11:45

Do you mean newline?

imre12:11:47

I do support the idea

ericdallo12:11:05

yep, my bad :p

ericdallo12:11:01

Seems pretty upvoted, so I think there are people thinking the same 馃檹

borkdude12:11:27

yes, would be good for the next iteration

馃憤 1
delaguardo12:11:27

I just stumble upon an exception that could be easily detected by clj-kondo but it doesn鈥檛 馃檪 After merging I鈥檝e got duplicate symbols in defrecord definition. On the first look It seems easy to add an extra linter to kondo if it sounds interesting 馃檹

borkdude12:11:03

Can you give an example?

delaguardo12:11:14

(defrecord X [y y])

borkdude12:11:50

hmyeah ok, seems like a good lint. this crashes the compiler?

borkdude12:11:06

yes it does

delaguardo12:11:07

yes, it throws

borkdude12:11:35

same for deftype, perhaps :duplicate-field {:level :error}

borkdude12:11:48

issue welcome, optionally followed by PR

delaguardo13:11:22

thanks for the confirmation 馃檪 I鈥檒l file one

delaguardo13:11:14

https://github.com/clj-kondo/clj-kondo/issues/1875 done, will make a PR later today (probably 馃檪)

Noah Bogart15:11:51

is it possible to get the pre and post map from a function definition in a hook? or do I have to do

(let [children (:children (drop 2 node))
      children (if (api/vector? (first children)) (rest children) children)]
  (if (api/list-node? (first children))
    (->> children
         (filter api/list-node?)
         (map :children)
         (map #(if (api/vector-node? (first %)) (rest %) %))
         (keep #(when (and (api/map-node? (first %)) (next %))
                  (->> (:children (first %))
                       (partition 2)
                       (filter (fn [[k _v]] (and (api/keyword-node? k) (#{:pre :post} (:k k)))))
                       (seq)))))
    (when (and (api/map-node? (first children)) (next children))
      (->> (:children (first children))
           (partition 2)
           (filter (fn [[k _v]] (and (api/keyword-node? k) (#{:pre :post} (:k k)))))
           (seq)))

borkdude09:11:42

There's nothing built-in for this

馃憤 1