clj-kondo

igrishaev 2025-02-18T09:11:42.571829Z

When linting a project using a command-line version of clj-kondo, is it possible to skip non-existing directories? For example:

clj-kondo --list src --lint test --lint api
When there is no api folder, the tool fails with "no such file api". The thing is, I'm setting clj-kondo on CI such that it covers all Clojure projects, and some of them have the api directory, and some of them do not. Any ideas?

Kirill Chernyshov 2025-02-18T09:33:09.268449Z

I usually do clj-kondo --lint ./ Works great so far

igrishaev 2025-02-18T09:34:59.203979Z

linting root involves some dev stuff which is always broken in terms of linting... yes there is a way to exclude it, but it depends on a project

igrishaev 2025-02-18T09:35:46.521429Z

I'm thinking about clj-kondo --lint $(cat paths.txt) where the path.txt file has all the required paths to lint

imre 2025-02-18T09:36:14.075359Z

clj-kondo --lint (clojure -Srepro -Spath -A:test) is what I do most of the time

igrishaev 2025-02-18T09:37:42.521659Z

With the paths.txt file, I like the idea I can start with a small subset of a project and then extend it file after file, dir after dir

Kirill Chernyshov 2025-02-18T09:50:40.961329Z

but what enforces that paths.txt does not contain non existed dirs?

igrishaev 2025-02-18T09:52:34.228549Z

each project has its own paths.txt file, e.g some of them include the api dir, some of them don't

Kirill Chernyshov 2025-02-18T09:57:33.306339Z

I mean over time actual project paths that needs linting might change and there is nothing that synchronise the reality with paths.txt. Most likely not a big problem but you mentioned CI where all those nuances should be automated

Stig Brautaset 2025-02-18T10:39:18.697799Z

@igrishaev how about using this in CI:

mkdir -p api && clj-kondo --lint src:test:api

igrishaev 2025-02-18T11:53:12.406909Z

Hm, smart!

Ed 2025-02-18T12:41:26.667449Z

You could also use xargs to build a command line

ls -d src test api 2>/dev/null | xargs -i echo -n --lint "{}" | xargs clj-kondo