Fork me on GitHub
#clj-kondo
<
2024-01-06
>
Adam Helins12:01:17

Hey, Is there a way to restrict the linting language at the level of a single namespace? E.g. I have a CLJC namespace for Clojure JVM + Babashka which I don't want to be linted as CLJS

borkdude12:01:05

currently not supported, but you can maybe rename the file to .clj and use the if-bb macro:

(defmacro if-bb [then else]
  (if (System/getProperty "babashka.version")
    then else))
(defn foobar [x]
  (if-bb (inc x) (dec x)))

👌 1
Ivana17:01:16

Hello! May I add something to config for excluding files & folders in project from linting? I tried :exclude-files and :paths-ignore-regex in a lot of ways but without success. Also can't find any example of it in all the internet 🙂

borkdude17:01:04

What is :paths-ignore-regex? It might be a clojure-lsp thing but it's not a clj-kondo thing

borkdude17:01:18

:exclude-files should work

Ivana17:01:59

Your last link doesn't show which level of config should I put it - and above you show :output level

borkdude17:01:27

yeah both are valid but without output the file isn't linted at all, and with output only the output is suppressed

Ivana17:01:21

I have .sandbox folder in project, and want to exclude all these files from linting. All the tried doesn't work

{:lint-as {reagent.core/with-let clojure.core/let}
 :linters {:unresolved-symbol {:exclude [devdb devconn devsystem match?]}}
 ;;  :exclude-files ".sandbox/handler.clj"
 ;;  :exclude-files ".sandbox/handler.clj$"
 ;;  :exclude-files ".sandbox/*.clj$"
 :output {:exclude-files ".sandbox"}}

Ivana17:01:17

v2023.12.15

Ivana17:01:55

I feel myself stupid, but what actual config should I have for my goal?

borkdude17:01:10

if you do lint the file which path is reported?

borkdude17:01:37

the paths are matched using re-find

Ivana17:01:29

[{ "resource": "/home/ivana/work/yoobeedoobics/yoobeedoobics-web/.sandbox/handler.clj", "owner": "generateddiagnostic_collection_name_#0", "severity": 8, "message": "Namespace name does not match file name: yoobeedoobics-web.handler", "source": "clj-kondo", "startLineNumber": 1, "startColumn": 5, "endLineNumber": 1, "endColumn": 30 },{ "resource": "/home/ivana/work/yoobeedoobics/yoobeedoobics-web/.sandbox/handler.clj", "owner": "generateddiagnostic_collection_name_#0", "severity": 8, "message": "Unresolved symbol: zz", "source": "clj-kondo", "startLineNumber": 12, "startColumn": 1, "endLineNumber": 12, "endColumn": 3 },{ "resource": "/home/ivana/work/yoobeedoobics/yoobeedoobics-web/.sandbox/handler.clj", "owner": "generateddiagnostic_collection_name_#0", "severity": 4, "message": "#'compojure.core/DELETE is referred but never used", "source": "clj-kondo", "startLineNumber": 2, "startColumn": 46, "endLineNumber": 2, "endColumn": 52 },{ "resource": "/home/ivana/work/yoobeedoobics/yoobeedoobics-web/.sandbox/handler.clj", "owner": "generateddiagnostic_collection_name_#0", "severity": 4, "message": "#'compojure.core/OPTIONS is referred but never used", "source": "clj-kondo", "startLineNumber": 2, "startColumn": 53, "endLineNumber": 2, "endColumn": 60 },{ "resource": "/home/ivana/work/yoobeedoobics/yoobeedoobics-web/.sandbox/handler.clj", "owner": "generateddiagnostic_collection_name_#0", "severity": 4, "message": "#'compojure.core/ANY is referred but never used", "source": "clj-kondo", "startLineNumber": 2, "startColumn": 61, "endLineNumber": 2, "endColumn": 64 },{ "resource": "/home/ivana/work/yoobeedoobics/yoobeedoobics-web/.sandbox/handler.clj", "owner": "generateddiagnostic_collection_name_#0", "severity": 4, "message": "unused binding e", "source": "clj-kondo", "startLineNumber": 171, "startColumn": 56, "endLineNumber": 171, "endColumn": 57 }]

Ivana17:01:10

I tried a lot of ways - with regexes etc

borkdude17:01:31

brb, dinner

Ivana17:01:47

so may you show actual config line for excluding this folder from linting?

Ivana18:01:30

Finally found a hack - it is much simplier to set included files, than the excluded ones, this works

:output {:include-files ["src" "test" "project.clj"]}

borkdude18:01:06

why not just lint src test and project.clj then?

borkdude18:01:16

--lint src test project.clj