clj-kondo

https://github.com/clj-kondo/clj-kondo
wilkerlucio 2020-08-08T21:36:47.303600Z

hello, is there a way to make clj-kondo ignore a namespace in the project?

wilkerlucio 2020-08-08T21:37:58.304200Z

my issue is because I'm using the potemkin library to implement a custom map structure: https://github.com/ztellman/potemkin#def-map-type

wilkerlucio 2020-08-08T21:38:16.304500Z

unless there is a easy way to get that macro understood, I would rather just ignore that namespace

borkdude 2020-08-08T21:39:55.304800Z

You can try {:lint-as {potemkin/weird-macro clj-kondo.lint-as/def-catch-all}

borkdude 2020-08-08T21:40:50.305Z

or lint as clojure.core/deftype

wilkerlucio 2020-08-08T21:42:40.305200Z

def-catch-all worked nicely, thanks! 😄

borkdude 2020-08-08T21:42:57.305400Z

This also seems to work:

(ns foo
  {:clj-kondo/config '{:lint-as {foo.bar/def-map-type clojure.core/deftype}}}
  (:require [foo.bar :refer [def-map-type]]))

(def-map-type LazyMap [m mta]
  (get [_ k default-value]
       (if (contains? m k)
         (let [v (get m k)]
           (if (instance? clojure.lang.Delay v)
             @v
             v))
         default-value))
  (assoc [_ k v]
         (LazyMap. (assoc m k v) mta))
  (dissoc [_ k]
          (LazyMap. (dissoc m k) mta))
  (keys [_]
        (keys m))
  (meta [_]
        mta)
  (with-meta [_ mta]
    (LazyMap. m mta)))

borkdude 2020-08-08T21:43:46.305600Z

You will then even get help with:

(->LazyMap 1)
which will show an arity error

wilkerlucio 2020-08-08T21:44:04.305800Z

yeah, true, that's better

wilkerlucio 2020-08-08T21:44:29.306Z

I would expect that not to work, because the Type is missing before the methods :man-shrugging:

borkdude 2020-08-08T21:45:25.306300Z

I think clj-kondo doesn't complain about (FooBar.) since it cannot know if that class exist or not

borkdude 2020-08-08T21:46:54.306600Z

As for your first question, you can exclude complete files like so: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#include-and-exclude-files-from-the-output

👍 1