Gabriel Horner 3 年之前
父节点
当前提交
821ebcb888
共有 2 个文件被更改,包括 26 次插入1 次删除
  1. 3 1
      .carve/config.edn
  2. 23 0
      docs/dev-practices.md

+ 3 - 1
.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

+ 23 - 0
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.