diff --git a/.carve/config.edn b/.carve/config.edn index 381abe04f..2678d77eb 100644 --- a/.carve/config.edn +++ b/.carve/config.edn @@ -1,4 +1,6 @@ -{:paths ["src/main" "src/electron" "src/test"] +{;; Only lint production namespaces as most dev + ;; namespaces are unused + :paths ["src/main" "src/electron" "src/test"] :api-namespaces [ ;; Ignore b/c too many false positives frontend.db diff --git a/docs/dev-practices.md b/docs/dev-practices.md index 0319300b8..a1324fe0e 100644 --- a/docs/dev-practices.md +++ b/docs/dev-practices.md @@ -4,6 +4,8 @@ This page describes development practices for this codebase. ## Linting +### Clojure code + To lint: ``` clojure -M:clj-kondo --lint src @@ -16,6 +18,27 @@ There are outstanding linting items that are currently ignored to allow linting * Comments starting with `TODO:lint` * Code marked with `#_:clj-kondo/ignore` require a good understanding of the context to address as they usually involve something with a side effect or require changing multiple fns up the call stack. +### Unused vars + +We use https://github.com/borkdude/carve to detect unused vars in our codebase. +Before running it, please install https://github.com/babashka/babashka. + +To run this linter: +``` +scripts/carve.clj +``` + +By default, the script runs in CI mode which prints unused vars if they are +found. The script can be run in an interactive mode which prompts for keeping +(ignoring) an unused var or removing it. Run this mode with: + +``` +scripts/carve.clj '{:interactive true}' +``` + +When a var is ignored, it is added to `.carve/ignore`. Please add a comment for +why a var is ignored to help others understand why it's unused. + ## Testing We have unit and end to end tests as described in https://github.com/logseq/logseq#5-run-tests.