1
0
Эх сурвалжийг харах

Merge pull request #3871 from logseq/test/add-clj-kondo-part-two

Test/add clj kondo part two
Tienson Qin 3 жил өмнө
parent
commit
7c85920d92
83 өөрчлөгдсөн 795 нэмэгдсэн , 943 устгасан
  1. 13 4
      .clj-kondo/config.edn
  2. 8 0
      .github/workflows/build.yml
  3. 1 1
      .gitignore
  4. 1 1
      README.md
  5. 12 0
      docs/dev-practices.md
  6. 16 24
      src/main/frontend/components/block.cljs
  7. 4 5
      src/main/frontend/components/command_palette.cljs
  8. 3 1
      src/main/frontend/components/commit.cljs
  9. 4 4
      src/main/frontend/components/content.cljs
  10. 14 16
      src/main/frontend/components/datetime.cljs
  11. 2 2
      src/main/frontend/components/diff.cljs
  12. 14 18
      src/main/frontend/components/editor.cljs
  13. 3 4
      src/main/frontend/components/encryption.cljs
  14. 1 0
      src/main/frontend/components/export.cljs
  15. 1 2
      src/main/frontend/components/file.cljs
  16. 5 12
      src/main/frontend/components/header.cljs
  17. 1 1
      src/main/frontend/components/journal.cljs
  18. 2 0
      src/main/frontend/components/lazy_editor.cljs
  19. 1 2
      src/main/frontend/components/onboarding.cljs
  20. 16 42
      src/main/frontend/components/page.cljs
  21. 2 6
      src/main/frontend/components/page_menu.cljs
  22. 17 18
      src/main/frontend/components/plugins.cljs
  23. 2 6
      src/main/frontend/components/query_table.cljs
  24. 3 4
      src/main/frontend/components/reference.cljs
  25. 3 3
      src/main/frontend/components/repo.cljs
  26. 8 8
      src/main/frontend/components/right_sidebar.cljs
  27. 41 51
      src/main/frontend/components/search.cljs
  28. 3 4
      src/main/frontend/components/settings.cljs
  29. 1 1
      src/main/frontend/components/shortcut.cljs
  30. 11 17
      src/main/frontend/components/sidebar.cljs
  31. 1 1
      src/main/frontend/components/svg.cljs
  32. 3 4
      src/main/frontend/components/theme.cljs
  33. 4 7
      src/main/frontend/components/widgets.cljs
  34. 1 1
      src/main/frontend/db/conn.cljs
  35. 1 2
      src/main/frontend/db/debug.cljs
  36. 12 18
      src/main/frontend/db/model.cljs
  37. 1 1
      src/main/frontend/db/outliner.cljs
  38. 0 1
      src/main/frontend/db/persist.cljs
  39. 2 3
      src/main/frontend/db/query_custom.cljs
  40. 28 29
      src/main/frontend/db/query_dsl.cljs
  41. 23 23
      src/main/frontend/db/query_react.cljs
  42. 6 8
      src/main/frontend/db/react.cljs
  43. 1 1
      src/main/frontend/extensions/calc.cljc
  44. 2 3
      src/main/frontend/extensions/code.cljs
  45. 1 10
      src/main/frontend/extensions/excalidraw.cljs
  46. 3 3
      src/main/frontend/extensions/graph.cljs
  47. 31 30
      src/main/frontend/extensions/graph/pixi.cljs
  48. 111 113
      src/main/frontend/extensions/html_parser.cljs
  49. 2 3
      src/main/frontend/extensions/latex.cljs
  50. 3 2
      src/main/frontend/extensions/pdf/assets.cljs
  51. 16 25
      src/main/frontend/extensions/pdf/highlights.cljs
  52. 2 2
      src/main/frontend/extensions/pdf/utils.cljs
  53. 0 1
      src/main/frontend/extensions/sci.cljs
  54. 61 97
      src/main/frontend/extensions/srs.cljs
  55. 2 2
      src/main/frontend/extensions/video/youtube.cljs
  56. 16 17
      src/main/frontend/extensions/zotero.cljs
  57. 1 2
      src/main/frontend/extensions/zotero/handler.cljs
  58. 48 42
      src/main/frontend/external/roam.cljc
  59. 7 11
      src/main/frontend/format/adoc.cljs
  60. 44 43
      src/main/frontend/format/block.cljs
  61. 13 12
      src/main/frontend/format/mldoc.cljs
  62. 11 11
      src/main/frontend/fs/bfs.cljs
  63. 21 24
      src/main/frontend/fs/capacitor_fs.cljs
  64. 12 15
      src/main/frontend/fs/nfs.cljs
  65. 13 15
      src/main/frontend/fs/node.cljs
  66. 1 1
      src/main/frontend/handler/editor.cljs
  67. 5 6
      src/main/frontend/handler/repo.cljs
  68. 1 5
      src/main/frontend/mobile/core.cljs
  69. 1 1
      src/main/frontend/modules/datascript_report/core.cljs
  70. 2 3
      src/main/frontend/modules/editor/undo_redo.cljs
  71. 12 14
      src/main/frontend/modules/file/core.cljs
  72. 1 1
      src/main/frontend/modules/instrumentation/sentry.cljs
  73. 2 2
      src/main/frontend/modules/layout/core.cljs
  74. 23 33
      src/main/frontend/modules/outliner/core.cljs
  75. 1 2
      src/main/frontend/modules/outliner/datascript.cljc
  76. 1 3
      src/main/frontend/modules/outliner/file.cljs
  77. 3 6
      src/main/frontend/modules/outliner/pipeline.cljs
  78. 3 4
      src/main/frontend/modules/outliner/tree.cljs
  79. 4 4
      src/main/frontend/modules/shortcut/data_helper.cljs
  80. 7 8
      src/main/frontend/search/browser.cljs
  81. 2 0
      src/main/frontend/search/db.cljs
  82. 6 6
      src/main/frontend/search/node.cljs
  83. 4 5
      src/main/frontend/tools/html_export.cljs

+ 13 - 4
.clj-kondo/config.edn

@@ -1,9 +1,18 @@
-{:linters {:unresolved-symbol {:exclude [goog.DEBUG 
-                                         goog.string.unescapeEntities]}}
+{:linters
+ {:unresolved-symbol {:exclude [goog.DEBUG
+                                goog.string.unescapeEntities
+                                ;; TODO:lint: Fix when fixing all type hints
+                                object]}
+  ;; TODO:lint: Remove node-path excludes once we have a cleaner api
+  :unresolved-var {:exclude [frontend.util/node-path.basename
+                             frontend.util/node-path.dirname
+                             frontend.util/node-path.join]}}
+
  :hooks {:analyze-call {rum.core/defc hooks.rum/defc
-                        rum.core/defcs hooks.rum/defcs}}
+                         rum.core/defcs hooks.rum/defcs}}
  :lint-as {promesa.core/let clojure.core/let
            promesa.core/loop clojure.core/loop
+           promesa.core/recur clojure.core/recur
            garden.def/defstyles clojure.core/def
            garden.def/defkeyframes clojure.core/def
            rum.core/defcc rum.core/defc
@@ -17,4 +26,4 @@
            frontend.namespaces/import-vars potemkin/import-vars
            ;; src/test
            frontend.react/defc clojure.core/defn}
- :skip-comments true}
+ :skip-comments true}

+ 8 - 0
.github/workflows/build.yml

@@ -55,6 +55,11 @@ jobs:
         with:
           cli: ${{ env.CLOJURE_VERSION }}
 
+      - uses: actions/checkout@v2
+      - uses: DeLaGuardo/setup-clj-kondo@master
+        with:
+          version: '2021.12.19'
+
       - name: Fetch Clojure deps
         if: steps.clojure-deps.outputs.cache-hit != 'true'
         run: clojure -A:cljs -P
@@ -73,6 +78,9 @@ jobs:
       - name: Fetch yarn deps
         run: yarn cache clean && yarn install
 
+      - name: Run clj-kondo lint
+        run: clj-kondo --lint src/workspaces src/electron src/test src/dev-cljs src/main/{electron,grammar,logseq} src/main/frontend/{worker,util,ui,tools,search,publishing,modules,mobile,fs,format,external,extensions,db,context,components}
+
       - name: Run ClojureScript test
         run: |
           yarn cljs:test

+ 1 - 1
.gitignore

@@ -30,7 +30,7 @@ strings.csv
 
 .calva
 resources/electron.js
-.clj-kondo/
+.clj-kondo/.cache
 .lsp/
 /libs/dist/
 charlie/

+ 1 - 1
README.md

@@ -76,7 +76,7 @@ Logseq is also made possible by the following projects:
 
 The following is for developers and designers who want to build and run Logseq locally and contribute to this project.
 
-We also have [a dedicated page](https://github.com/logseq/logseq/blob/master/CODEBASE_OVERVIEW.md) for LogSeq's codebase overview.
+We have [a dedicated overview page](https://github.com/logseq/logseq/blob/master/CODEBASE_OVERVIEW.md) for LogSeq's codebase overview and [a development practices page](docs/dev-practices.md).
 
 ## Set up development environment
 

+ 12 - 0
docs/dev-practices.md

@@ -0,0 +1,12 @@
+## Description
+
+This page describes development practices for this codebase.
+
+## Linting
+
+We lint our Clojure(Script) code with https://github.com/clj-kondo/clj-kondo/. If you need to configure specific linters, see [this documentation](https://github.com/clj-kondo/clj-kondo/blob/master/doc/linters.md). Where possible, a global linting configuration is used and namespace specific configuration is avoided.
+
+Linting is a work in progress as this is a large Clojure codebase with some areas to refactor. There are outstanding linting items that are currently ignored in order to allow full linting of the codebase to run in CI. These outstanding linting items should be addressed at some point:
+
+* 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.

+ 16 - 24
src/main/frontend/components/block.cljs

@@ -8,7 +8,6 @@
             [clojure.walk :as walk]
             [datascript.core :as dc]
             [dommy.core :as d]
-            [frontend.mobile.util :as mobile]
             [frontend.commands :as commands]
             [frontend.components.datetime :as datetime-comp]
             [frontend.components.lazy-editor :as lazy-editor]
@@ -48,7 +47,7 @@
             [frontend.template :as template]
             [frontend.text :as text]
             [frontend.ui :as ui]
-            [frontend.util :as util :refer [profile]]
+            [frontend.util :as util]
             [frontend.util.clock :as clock]
             [frontend.util.property :as property]
             [frontend.util.drawer :as drawer]
@@ -258,7 +257,7 @@
   (let [src (::src state)
         granted? (state/sub [:nfs/user-granted? (state/get-current-repo)])
         href (config/get-local-asset-absolute-path href)]
-    (when (or granted? (util/electron?) (mobile/is-native-platform?))
+    (when (or granted? (util/electron?) (mobile-util/is-native-platform?))
       (p/then (editor-handler/make-asset-url href) #(reset! src %)))
 
     (when @src
@@ -280,9 +279,7 @@
      (if (and (config/local-asset? href)
               (config/local-db? (state/get-current-repo)))
        (asset-link config title href metadata full_text)
-       (let [protocol (and (= "Complex" (first url))
-                           (:protocol (second url)))
-             href (cond
+       (let [href (cond
                     (util/starts-with? href "http")
                     href
 
@@ -1353,10 +1350,6 @@
   [uuid]
   (= (:block/uuid @*dragging-block) uuid))
 
-(defn- get-data-transfer-attr
-  [event attr]
-  (.getData (gobj/get event "dataTransfer") attr))
-
 (defn- bullet-drag-start
   [event block uuid block-id]
   (editor-handler/highlight-block! uuid)
@@ -1383,7 +1376,7 @@
     (route-handler/redirect-to-page! uuid)))
 
 (defn- toggle-block-children
-  [e children]
+  [_e children]
   (let [block-ids (map :block/uuid children)]
     (dorun
      (if (some editor-handler/collapsable? block-ids)
@@ -1522,7 +1515,7 @@
                     :checked checked?
                     :on-mouse-down (fn [e]
                                      (util/stop-propagation e))
-                    :on-change (fn [e]
+                    :on-change (fn [_e]
                                  (if checked?
                                    (editor-handler/uncheck block)
                                    (editor-handler/check block)))}))))
@@ -1777,7 +1770,7 @@
           (datetime-comp/date-picker nil nil ts)]))]))
 
 (defn- block-content-on-mouse-down
-  [e block block-id content edit-input-id]
+  [e block block-id _content edit-input-id]
   (.stopPropagation e)
   (let [target (gobj/get e "target")
         button (gobj/get e "buttons")]
@@ -1966,7 +1959,7 @@
      [:pre.m-0.text-sm content]]))
 
 (rum/defc block-content-or-editor < rum/reactive
-  [config {:block/keys [uuid body format] :as block} edit-input-id block-id heading-level edit?]
+  [config {:block/keys [uuid format] :as block} edit-input-id block-id heading-level edit?]
   (let [editor-box (get config :editor-box)
         editor-id (str "editor-" edit-input-id)
         slide? (:slide? config)]
@@ -2115,7 +2108,7 @@
   (editor-handler/unhighlight-blocks!))
 
 (defn- block-drag-end
-  [event *move-to]
+  [_event *move-to]
   (reset! *dragging? false)
   (reset! *dragging-block nil)
   (reset! *drag-to-block nil)
@@ -2198,8 +2191,7 @@
                        (not= (select-keys (first (:rum/args old-state)) config-compare-keys)
                              (select-keys (first (:rum/args new-state)) config-compare-keys)))))}
   [state config {:block/keys [uuid repo children pre-block? top? properties refs heading-level level type format content] :as block}]
-  (let [init-collapsed? (::init-collapsed? state)
-        block (merge block (block/parse-title-and-body uuid format pre-block? content))
+  (let [block (merge block (block/parse-title-and-body uuid format pre-block? content))
         body (:block/body block)
         blocks-container-id (:blocks-container-id config)
         config (update config :block merge block)
@@ -2412,7 +2404,8 @@
   (let [clocks (filter #(string/starts-with? % "CLOCK:") log)
         clocks (reverse (sort-by str clocks))
         ;; TODO: diplay states change log
-        states (filter #(not (string/starts-with? % "CLOCK:")) log)]
+        ; states (filter #(not (string/starts-with? % "CLOCK:")) log)
+        ]
     (when (seq clocks)
       (let [tr (fn [elm cols] (->elem :tr
                                       (mapv (fn [col] (->elem elm col)) cols)))
@@ -2903,7 +2896,7 @@
        (map #(dissoc % :block/children))))
 
 (defn- get-segment
-  [config flat-blocks idx blocks->vec-tree]
+  [_config flat-blocks idx blocks->vec-tree]
   (let [new-idx (if-not (zero? idx)
                   (+ idx step-loading-blocks)
                   initial-blocks-length)
@@ -2914,12 +2907,11 @@
      idx]))
 
 (rum/defcs lazy-blocks <
-  {:did-remount (fn [old-state new-state]
+  {:did-remount (fn [_old-state new-state]
                   ;; Loading more when pressing Enter or paste
-                  (let [args (:rum/args new-state)]
-                    ;; FIXME: what if users paste too many blocks?
-                    ;; or, a template with a lot of blocks?
-                    (swap! (::last-idx new-state) + 100))
+                  ;; FIXME: what if users paste too many blocks?
+                  ;; or, a template with a lot of blocks?
+                  (swap! (::last-idx new-state) + 100)
                   new-state)}
   (rum/local 0 ::last-idx)
   [state config flat-blocks blocks->vec-tree]

+ 4 - 5
src/main/frontend/components/command_palette.cljs

@@ -1,6 +1,5 @@
 (ns frontend.components.command-palette
-  (:require [clojure.string :as str]
-            [frontend.handler.command-palette :as cp]
+  (:require [frontend.handler.command-palette :as cp]
             [frontend.modules.shortcut.core :as shortcut]
             [frontend.modules.shortcut.data-helper :as shortcut-helper]
             [frontend.context.i18n :as i18n]
@@ -14,7 +13,7 @@
 (defn translate [t {:keys [id desc]}]
   (when id
     (let [desc-i18n (t (shortcut-helper/decorate-namespace id))]
-      (if (str/starts-with? desc-i18n "{Missing key")
+      (if (string/starts-with? desc-i18n "{Missing key")
         desc
         desc-i18n))))
 
@@ -23,7 +22,7 @@
 
 (rum/defc render-command
   [{:keys [id shortcut] :as cmd} chosen?]
-  (let [first-shortcut (first (str/split shortcut #" \| "))]
+  (let [first-shortcut (first (string/split shortcut #" \| "))]
     (rum/with-context [[t] i18n/*tongue-context*]
                       (let [desc (translate t cmd)]
                         [:div.inline-grid.grid-cols-4.gap-x-4.w-full
@@ -56,7 +55,7 @@
 
        [:div.command-results-wrap
         (ui/auto-complete
-         (if (str/blank? @input)
+         (if (string/blank? @input)
            (cp/top-commands limit)
            (get-matched-commands commands @input limit t))
          {:item-render render-command

+ 3 - 1
src/main/frontend/components/commit.cljs

@@ -35,8 +35,9 @@
                       :node (gdom/getElement "commit-message")
                       :on-enter (fn []
                                   (commit-and-push!)))))
-  [state close-fn]
+  [state _close-fn]
   (let [electron? (util/electron?)]
+    #_:clj-kondo/ignore
     (when-let [repo (state/sub :git/current-repo)]
       [:div.w-full.mx-auto.sm:max-w-lg.sm:w-96 {:style {:padding "48px 0"}}
        [:div.sm:flex.sm:items-start
@@ -63,6 +64,7 @@
          (not (gobj/get e "ctrlKey"))
          (not (gobj/get e "altKey"))
          (not (gobj/get e "metaKey")))
+    #_:clj-kondo/ignore
     (when-let [repo-url (state/get-current-repo)]
       (when-not (state/get-edit-input-id)
         (util/stop e)

+ 4 - 4
src/main/frontend/components/content.cljs

@@ -37,7 +37,7 @@
       (when-not (protocol/loaded? record)
         (set-format-js-loading! format true)
         (protocol/lazyLoad record
-                           (fn [result]
+                           (fn [_result]
                              (set-format-js-loading! format false)))))))
 
 (defn lazy-load-js
@@ -147,7 +147,7 @@
        "Make template"))))
 
 (rum/defc block-context-menu-content
-  [target block-id]
+  [_target block-id]
 
   (let [*el-ref (rum/use-ref nil)]
 
@@ -323,7 +323,7 @@
   (mixins/event-mixin
    (fn [state]
      (mixins/listen state js/window "mouseup"
-                    (fn [e]
+                    (fn [_e]
                       (when-not (state/in-selection-mode?)
                         (when-let [blocks (seq (util/get-selected-nodes "ls-block"))]
                           (let [blocks (remove nil? blocks)
@@ -371,7 +371,7 @@
 
                           :else
                           nil))))))
-  [id {:keys [hiccup] :as option}]
+  [id {:keys [hiccup]}]
   [:div {:id id}
    (if hiccup
      hiccup

+ 14 - 16
src/main/frontend/components/datetime.cljs

@@ -10,9 +10,7 @@
             [frontend.ui :as ui]
             [frontend.util :as util]
             [frontend.mixins :as mixins]
-            [rum.core :as rum]
-            [goog.dom :as gdom]
-            [frontend.commands :as commands]))
+            [rum.core :as rum]))
 
 (defonce default-timestamp-value {:time ""
                                   :repeater {}})
@@ -89,22 +87,22 @@
 (defn- on-submit
   [e]
   (when e (util/stop e))
-  (let [{:keys [time repeater] :as timestamp} @*timestamp
+  (let [{:keys [repeater] :as timestamp} @*timestamp
         date (:date-picker/date @state/state)
         timestamp (assoc timestamp :date (or date (t/today)))
         kind (if (= "w" (:duration repeater)) "++" ".+")
         timestamp (assoc-in timestamp [:repeater :kind] kind)
         text (repeated/timestamp-map->text timestamp)
-        block-data (state/get-timestamp-block)]
-    (let [{:keys [block typ show?]} block-data
-          block-id (or (:block/uuid (state/get-edit-block))
-                       (:block/uuid block))
-          typ (or @commands/*current-command typ)]
-      (editor-handler/set-block-timestamp! block-id
-                                           typ
-                                           text)
-      (when show?
-        (reset! show? false))))
+        block-data (state/get-timestamp-block)
+        {:keys [block typ show?]} block-data
+        block-id (or (:block/uuid (state/get-edit-block))
+                     (:block/uuid block))]
+    typ (or @commands/*current-command typ)
+    (editor-handler/set-block-timestamp! block-id
+                                         typ
+                                         text)
+    (when show?
+      (reset! show? false)))
   (clear-timestamp!)
   (state/set-editor-show-date-picker! false)
   (commands/restore-state false))
@@ -117,7 +115,7 @@
                                         :node input
                                         :on-enter on-submit) 100))))
   []
-  (let [{:keys [time repeater] :as timestamp} (rum/react *timestamp)]
+  (let [{:keys [time repeater]} (rum/react *timestamp)]
     [:div#time-repeater.py-1.px-4 {:style {:min-width 300}}
      [:p.text-sm.opacity-50.font-medium.mt-4 "Time:"]
      (time-input time)
@@ -142,7 +140,7 @@
    :will-unmount (fn [state]
                    (clear-timestamp!)
                    state)}
-  [id format ts]
+  [id format _ts]
   (let [current-command @commands/*current-command
         deadline-or-schedule? (and current-command
                                    (contains? #{"deadline" "scheduled"}

+ 2 - 2
src/main/frontend/components/diff.cljs

@@ -167,7 +167,7 @@
               repo
               path
               remote-latest-commit
-              (fn [{:keys [repo-url path ref content]}]
+              (fn [{:keys [repo-url path content]}]
                 (p/let [content (encrypt/decrypt content)]
                   (swap! state/state
                          assoc-in [:github/contents repo-url remote-latest-commit path] content)))
@@ -278,7 +278,7 @@
         :on-click
         (fn []
           (when-let [value @disk-value]
-            (file/alter-file repo path @disk-value
+            (file/alter-file repo path value
                             {:re-render-root? true
                              :skip-compare? true}))
           (state/close-modal!)))]

+ 14 - 18
src/main/frontend/components/editor.cljs

@@ -1,6 +1,5 @@
 (ns frontend.components.editor
   (:require [clojure.string :as string]
-            [dommy.core :as d]
             [frontend.commands :as commands
              :refer [*angle-bracket-caret-pos *first-command-group *matched-block-commands *matched-commands *show-block-commands *show-commands *slash-caret-pos]]
             [frontend.components.block :as block]
@@ -10,7 +9,6 @@
             [frontend.mobile.camera :as mobile-camera]
             [frontend.mobile.util :as mobile-util]
             [frontend.config :as config]
-            [frontend.handler.notification :as notification]
             [frontend.db :as db]
             [frontend.extensions.zotero :as zotero]
             [frontend.handler.editor :as editor-handler :refer [get-state]]
@@ -20,7 +18,6 @@
             [frontend.modules.shortcut.core :as shortcut]
             [frontend.state :as state]
             [frontend.ui :as ui]
-            [frontend.handler.ui :as ui-handler]
             [frontend.util :as util]
             [frontend.util.cursor :as cursor]
             [frontend.util.keycode :as keycode]
@@ -157,7 +154,7 @@
                                             (editor-handler/get-matched-blocks q (:block/uuid edit-block)))]
                      (reset! result matched-blocks)))
                  state)}
-  [state edit-block input id q format]
+  [state _edit-block input id q format]
   (let [result (rum/react (get state ::result))
         chosen-handler (editor-handler/block-on-chosen-handler input id q format)
         non-exist-block-handler (editor-handler/block-non-exist-handler input)]
@@ -167,7 +164,7 @@
        {:on-chosen   chosen-handler
         :on-enter    non-exist-block-handler
         :empty-div   [:div.text-gray-500.pl-4.pr-4 "Search for a block"]
-        :item-render (fn [{:block/keys [content page uuid] :as item}]
+        :item-render (fn [{:block/keys [content page uuid]}]
                        (let [page (or (:block/original-name page)
                                       (:block/name page))
                              repo (state/sub :git/current-repo)
@@ -181,7 +178,7 @@
                    (reset! editor-handler/*selected-text nil)
                    (state/clear-search-result!)
                    state)}
-  [state id format]
+  [state id _format]
   (when (state/sub :editor/show-block-search?)
     (let [pos (:editor/last-saved-cursor @state/state)
           input (gdom/getElement id)
@@ -198,7 +195,7 @@
 
 (rum/defc template-search < rum/reactive
   {:will-unmount (fn [state] (reset! editor-handler/*selected-text nil) state)}
-  [id format]
+  [id _format]
   (when (state/sub :editor/show-template-search?)
     (let [pos (:editor/last-saved-cursor @state/state)
           input (gdom/getElement id)]
@@ -222,7 +219,7 @@
             :class       "black"}))))))
 
 (rum/defc mobile-bar < rum/reactive
-  [parent-state parent-id]
+  [_parent-state parent-id]
   (let [vw-state (state/sub :ui/visual-viewport-state)
         vw-pending? (state/sub :ui/visual-viewport-pending?)
         ;; TODO: should we add this focus step to `simple-insert!`?
@@ -230,7 +227,7 @@
                              (util/make-el-into-center-viewport input)
                              (.focus input)))]
     [:div#mobile-editor-toolbar.bg-base-2
-     {:style {:bottom (if (and vw-state)
+     {:style {:bottom (if vw-state
                         (- (.-clientHeight js/document.documentElement)
                            (:height vw-state)
                            (:offset-top vw-state))
@@ -423,7 +420,7 @@
                       command (:command (first input-option))]
                   (on-submit command @input-value pos))
                 (reset! input-value nil))))})))
-  [state id on-submit]
+  [state _id on-submit]
   (when-let [input-option (state/sub :editor/show-input)]
     (let [{:keys [pos]} (util/react *slash-caret-pos)
           input-value (get state ::input-value)]
@@ -522,6 +519,7 @@
                   (let [files (.-files (.-target e))]
                     (editor-handler/upload-asset id files format editor-handler/*asset-uploading? false)))
      :hidden    true}]
+   #_:clj-kondo/ignore
    (when-let [uploading? (util/react editor-handler/*asset-uploading?)]
      (let [processing (util/react editor-handler/*asset-uploading-process)]
        (transition-cp
@@ -532,7 +530,7 @@
         *slash-caret-pos)))])
 
 (defn- set-up-key-down!
-  [repo state format]
+  [state format]
   (mixins/on-key-down
    state
    {}
@@ -549,11 +547,10 @@
 
 (defn- setup-key-listener!
   [state]
-  (let [{:keys [id format block]} (get-state)
+  (let [{:keys [id format]} (get-state)
         input-id id
-        input (gdom/getElement input-id)
-        repo (:block/repo block)]
-    (set-up-key-down! repo state format)
+        input (gdom/getElement input-id)]
+    (set-up-key-down! state format)
     (set-up-key-up! state input input-id search-timeout)))
 
 (def starts-with? clojure.string/starts-with?)
@@ -674,7 +671,7 @@
 
      (state/sub :editor/show-input)
      (animated-modal "input" (input id
-                                    (fn [command m pos]
+                                    (fn [command m _pos]
                                       (editor-handler/handle-command-input command id format m)))
                      true (util/react *slash-caret-pos))
 
@@ -693,8 +690,7 @@
   (mixins/event-mixin setup-key-listener!)
   (shortcut/mixin :shortcut.handler/block-editing-only)
   lifecycle/lifecycle
-  [state {:keys [on-hide node format block block-parent-id heading-level]
-          :as   option} id config]
+  [state {:keys [format block]} id _config]
   (let [content (state/sub-edit-content)
         heading-class (get-editor-style-class content format)]
     [:div.editor-inner {:class (if block "block-editor" "non-block-editor")}

+ 3 - 4
src/main/frontend/components/encryption.cljs

@@ -14,7 +14,6 @@
   (rum/local false ::reveal-secret-phrase?)
   [state repo-url close-fn]
   (let [reveal-secret-phrase? (get state ::reveal-secret-phrase?)
-        secret-phrase (e/get-key-pair repo-url)
         public-key (e/get-public-key repo-url)
         private-key (e/get-secret-key repo-url)]
     (rum/with-context [[t] i18n/*tongue-context*]
@@ -54,7 +53,7 @@
   (rum/local "" ::password)
   (rum/local "" ::password-confirm)
   [state repo-url close-fn]
-  (rum/with-context [[t] i18n/*tongue-context*]
+  (rum/with-context [[_t] i18n/*tongue-context*]
     (let [password (get state ::password)
           password-confirm (get state ::password-confirm)]
       [:div
@@ -137,8 +136,8 @@
 (rum/defcs encryption-input-secret-inner <
   (rum/local "" ::secret)
   (rum/local false ::loading)
-  [state repo-url db-encrypted-secret close-fn]
-  (rum/with-context [[t] i18n/*tongue-context*]
+  [state _repo-url db-encrypted-secret close-fn]
+  (rum/with-context [[_t] i18n/*tongue-context*]
     (let [secret (::secret state)
           loading (::loading state)]
       [:div

+ 1 - 0
src/main/frontend/components/export.cljs

@@ -45,6 +45,7 @@
 
 (rum/defc export-page
   []
+  #_:clj-kondo/ignore
   (when-let [current-repo (state/get-current-repo)]
     (when-let [page (state/get-current-page)]
       (rum/with-context [[t] i18n/*tongue-context*]

+ 1 - 2
src/main/frontend/components/file.cljs

@@ -3,7 +3,6 @@
             [cljs-time.core :as t]
             [clojure.string :as string]
             [datascript.core :as dc]
-            [frontend.components.content :as content]
             [frontend.components.lazy-editor :as lazy-editor]
             [frontend.components.svg :as svg]
             [frontend.config :as config]
@@ -59,7 +58,7 @@
 
                 (when-not mobile?
                   [:td [:a.text-sm
-                       {:on-click (fn [e]
+                       {:on-click (fn [_e]
                                     (export-handler/download-file! file))}
                        [:span (tongue :download)]]])]))]]))]))
 

+ 5 - 12
src/main/frontend/components/header.cljs

@@ -2,11 +2,8 @@
   (:require [frontend.components.export :as export]
             [frontend.components.plugins :as plugins]
             [frontend.components.repo :as repo]
-            [frontend.components.page :as page]
-            [clojure.string :as str]
             [frontend.components.page-menu :as page-menu]
             [frontend.components.right-sidebar :as sidebar]
-            [frontend.components.search :as search]
             [frontend.components.svg :as svg]
             [frontend.config :as config]
             [frontend.context.i18n :as i18n]
@@ -23,9 +20,7 @@
             [cljs-bean.core :as bean]
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]
-            [frontend.mobile.util :as mobile-util]
-            [frontend.components.widgets :as widgets]
-            [frontend.handler.web.nfs :as nfs-handler]))
+            [frontend.mobile.util :as mobile-util]))
 
 (rum/defc home-button []
   (ui/with-shortcut :go/home "left"
@@ -66,10 +61,8 @@
      (ui/icon "menu-2" {:style {:fontSize ui/icon-size}})]))
 
 (rum/defc dropdown-menu < rum/reactive
-  [{:keys [me current-repo t default-home]}]
-  (let [projects (state/sub [:me :projects])
-        developer-mode? (state/sub [:ui/developer-mode?])
-        logged? (state/logged?)
+  [{:keys [current-repo t]}]
+  (let [logged? (state/logged?)
         page-menu (page-menu/page-menu nil)
         page-menu-and-hr (when (seq page-menu)
                            (concat page-menu [{:hr true}]))]
@@ -177,7 +170,7 @@
         :on-double-click (fn [^js e]
                            (when-let [target (.-target e)]
                              (when (and (util/electron?)
-                                        (or (.. target -classList (contains "cp__header"))))
+                                        (.. target -classList (contains "cp__header")))
                                (js/window.apis.toggleMaxOrMinActiveWindow))))
         :style           {:fontSize  50
                           :transform (str "translateY(" (or (:offset-top vw-state) 0) "px)")}}
@@ -225,7 +218,7 @@
                   "Yes"
                   :on-click (fn []
                               (state/close-modal!)
-                              (nfs-handler/refresh! (state/get-current-repo) repo/refresh-cb)))]]))}
+                              (nfs/refresh! (state/get-current-repo) repo/refresh-cb)))]]))}
            (if refreshing?
              [:div {:class "animate-spin-reverse"}
               svg/refresh]

+ 1 - 1
src/main/frontend/components/journal.cljs

@@ -23,7 +23,7 @@
 
 (rum/defc blocks-cp < rum/reactive db-mixins/query
   {}
-  [repo page format]
+  [repo page _format]
   (when-let [page-e (db/pull [:block/name (util/page-name-sanity-lc page)])]
     (page/page-blocks-cp repo page-e {})))
 

+ 2 - 0
src/main/frontend/components/lazy_editor.cljs

@@ -5,6 +5,8 @@
             [frontend.ui :as ui]
             [frontend.state :as state]))
 
+;; TODO: Why does shadow fail when code is required
+#_:clj-kondo/ignore
 (def lazy-editor (lazy/loadable frontend.extensions.code/editor))
 
 (defonce loaded? (atom false))

+ 1 - 2
src/main/frontend/components/onboarding.cljs

@@ -1,6 +1,5 @@
 (ns frontend.components.onboarding
-  (:require [frontend.components.shortcut :as shortcut]
-            [frontend.components.svg :as svg]
+  (:require [frontend.components.svg :as svg]
             [frontend.context.i18n :as i18n]
             [frontend.handler.route :as route-handler]
             [frontend.util :as util]

+ 16 - 42
src/main/frontend/components/page.cljs

@@ -1,11 +1,8 @@
 (ns frontend.components.page
-  (:require [cljs.pprint :as pprint]
-            [clojure.string :as string]
-            [frontend.commands :as commands]
+  (:require [clojure.string :as string]
             [frontend.components.block :as block]
             [frontend.components.content :as content]
             [frontend.components.editor :as editor]
-            [frontend.components.export :as export]
             [frontend.components.hierarchy :as hierarchy]
             [frontend.components.plugins :as plugins]
             [frontend.components.reference :as reference]
@@ -18,7 +15,6 @@
             [frontend.db.model :as model]
             [frontend.extensions.graph :as graph]
             [frontend.extensions.pdf.assets :as pdf-assets]
-            [frontend.format.mldoc :as mldoc]
             [frontend.format.block :as format-block]
             [frontend.handler.common :as common-handler]
             [frontend.handler.config :as config-handler]
@@ -28,9 +24,7 @@
             [frontend.handler.page :as page-handler]
             [frontend.handler.plugin :as plugin-handler]
             [frontend.handler.route :as route-handler]
-            [frontend.handler.shell :as shell]
             [frontend.mixins :as mixins]
-            [frontend.modules.shortcut.core :as shortcut]
             [frontend.state :as state]
             [frontend.text :as text]
             [frontend.search :as search]
@@ -70,7 +64,7 @@
 (rum/defc page-blocks-inner <
   {:did-mount  open-first-block!
    :did-update open-first-block!}
-  [page-name page-blocks hiccup sidebar? preview? block-uuid]
+  [page-name _page-blocks hiccup sidebar? _preview? _block-uuid]
   [:div.page-blocks-inner {:style {:margin-left (if sidebar? 0 -20)}}
    (rum/with-key
      (content/content page-name
@@ -121,15 +115,8 @@
   (when page-e
     (let [page-name (or (:block/name page-e)
                         (str (:block/uuid page-e)))
-          page-original-name (or (:block/original-name page-e) page-name)
-          format (get-page-format page-name)
-          journal? (db/journal-page? page-name)
           block? (util/uuid-string? page-name)
           block-id (and block? (uuid page-name))
-          page-empty? (and (not block?) (db/page-empty? repo (:db/id page-e)))
-          page-e (if (and page-e (:db/id page-e))
-                   {:db/id (:db/id page-e)}
-                   page-e)
           page-blocks (get-blocks repo page-name block-id)]
       (if (empty? page-blocks)
         (dummy-block page-name)
@@ -162,7 +149,7 @@
     (let [queries (state/sub [:config repo :default-queries :journals])]
       (when (seq queries)
         [:div#today-queries.mt-10
-         (for [{:keys [title] :as query} queries]
+         (for [query queries]
            (rum/with-key
              (block/custom-query {:attr {:class "mt-10"}
                                   :editor-box editor/box
@@ -188,29 +175,18 @@
   (rum/local false ::edit?)
   {:init (fn [state]
            (assoc state ::title-value (atom (nth (:rum/args state) 2))))}
-  [state page-name icon title format fmt-journal?]
+  [state page-name icon title _format fmt-journal?]
   (when title
     (let [*title-value (get state ::title-value)
           *edit? (get state ::edit?)
           repo (state/get-current-repo)
-          title-element (if (and (string/includes? title "[[")
-                                 (string/includes? title "]]"))
-                          (let [title (case format
-                                        :markdown
-                                        (string/replace title #"^#+\s+" "")
-                                        :org
-                                        (string/replace title #"^\*+\s+" "")
-                                        title)
-                                ast (mldoc/->edn title (mldoc/default-config format))]
-                            (block/markup-element-cp {} (ffirst ast)))
-                          title)
           hls-file? (pdf-assets/hls-file? title)
           title (if hls-file?
                   (pdf-assets/human-hls-filename-display title)
                   (if fmt-journal? (date/journal-title->custom-format title) title))
           old-name (or title page-name)
           confirm-fn (fn []
-                       (let [merge? (and (not= (util/page-name-sanity-lc page-name) 
+                       (let [merge? (and (not= (util/page-name-sanity-lc page-name)
                                                (util/page-name-sanity-lc @*title-value))
                                          (page-handler/page-exists? page-name)
                                          (page-handler/page-exists? @*title-value))]
@@ -270,7 +246,7 @@
 
 ;; A page is just a logical block
 (rum/defcs page < rum/reactive
-  [state {:keys [repo page-name preview?] :as option}]
+  [state {:keys [repo page-name] :as option}]
   (when-let [path-page-name (or page-name
                                 (get-page-name state)
                                 (state/get-current-page))]
@@ -286,7 +262,7 @@
           journal? (db/journal-page? page-name)
           fmt-journal? (boolean (date/journal-title->int page-name))
           sidebar? (:sidebar? option)]
-      (rum/with-context [[t] i18n/*tongue-context*]
+      (rum/with-context [[_t] i18n/*tongue-context*]
         (let [route-page-name path-page-name
               page (if block?
                      (->> (:db/id (:block/page (db/entity repo [:block/uuid block-id])))
@@ -296,7 +272,7 @@
                          (let [m (format-block/page-name->map path-page-name true)]
                            (db/transact! repo [m])))
                        (db/pull [:block/name page-name])))
-              {:keys [icon] :as properties} (:block/properties page)
+              {:keys [icon]} (:block/properties page)
               page-name (:block/name page)
               page-original-name (:block/original-name page)
               title (or page-original-name page-name)
@@ -392,9 +368,8 @@
 
 (rum/defc graph-filters < rum/reactive
   [graph settings n-hops]
-  (let [{:keys [layout journal? orphan-pages? builtin-pages?]
-         :or {layout "gForce"
-              orphan-pages? true}} settings
+  (let [{:keys [journal? orphan-pages? builtin-pages?]
+         :or {orphan-pages? true}} settings
         journal?' (rum/react *journal?)
         orphan-pages?' (rum/react *orphan-pages?)
         builtin-pages?' (rum/react *builtin-pages?)
@@ -535,7 +510,7 @@
                                                  (and (not (nodes (:source link)))
                                                       (not (nodes (:target link)))))
                                                links))))]
-    (rum/with-context [[t] i18n/*tongue-context*]
+    (rum/with-context [[_t] i18n/*tongue-context*]
       [:div.relative#global-graph
        (graph/graph-2d {:nodes (:nodes graph)
                         :links (:links graph)
@@ -559,7 +534,7 @@
   (mixins/event-mixin
    (fn [state]
      (mixins/listen state js/window "resize"
-                    (fn [e]
+                    (fn [_e]
                       (reset! layout [js/window.innerWidth js/window.innerHeight])))))
   {:will-mount (fn [state]
                  (state/set-search-mode! :graph)
@@ -574,12 +549,11 @@
         theme (state/sub :ui/theme)
         graph (graph-handler/build-global-graph theme settings)
         search-graph-filters (state/sub :search/graph-filters)
-        graph (update graph :nodes #(filter-graph-nodes % search-graph-filters))
-        reset? (rum/react *graph-reset?)]
+        graph (update graph :nodes #(filter-graph-nodes % search-graph-filters))]
     (global-graph-inner graph settings theme)))
 
 (rum/defc page-graph-inner < rum/static
-  [page graph dark?]
+  [_page graph dark?]
   [:div.sidebar-item.flex-col
    (graph/graph-2d {:nodes (:nodes graph)
                     :links (:links graph)
@@ -669,7 +643,7 @@
           (when-not orphaned-pages? [:th [:span (t :page/updated-at)]])]]
 
         [:tbody
-         (for [[n {:block/keys [idx name created-at updated-at backlinks] :as page}] (medley/indexed pages)]
+         (for [[n {:block/keys [name created-at updated-at backlinks] :as page}] (medley/indexed pages)]
            [:tr {:key name}
             [:td.n.w-10 [:span.opacity-70 (str (inc n) ". ")]]
             [:td.name [:a {:href     (rfe/href :page {:name (:block/name page)})}
@@ -761,7 +735,7 @@
        (when current-repo
 
          ;; all pages
-         (if (nil? @*pages)
+         (when (nil? @*pages)
            (let [pages (->> (page-handler/get-all-pages current-repo)
                             (map-indexed (fn [idx page] (assoc page
                                                                :block/backlinks (count (:block/_refs (db/entity (:db/id page))))

+ 2 - 6
src/main/frontend/components/page_menu.cljs

@@ -1,8 +1,6 @@
 (ns frontend.components.page-menu
   (:require [cljs.pprint :as pprint]
-            [clojure.string :as string]
             [frontend.commands :as commands]
-            [frontend.components.editor :as editor]
             [frontend.components.export :as export]
             [frontend.context.i18n :as i18n]
             [frontend.db :as db]
@@ -63,11 +61,9 @@
           repo (state/sub :git/current-repo)
           page (db/entity repo [:block/name page-name])
           page-original-name (:block/original-name page)
-          journal? (db/journal-page? page-name)
           block? (and page (util/uuid-string? page-name))
           contents? (= page-name "contents")
-          {:keys [title] :as properties} (:block/properties page)
-          title (or title page-original-name page-name)
+          properties (:block/properties page)
           public? (true? (:public properties))
           favorites (:favorites (state/sub-graph-config))
           favorited? (contains? (set (map util/page-name-sanity-lc favorites))
@@ -129,7 +125,7 @@
                          (shell/get-file-latest-git-log page 100))}})
 
           (when plugin-handler/lsp-enabled?
-            (for [[_ {:keys [key label] :as cmd} action pid] (state/get-plugins-commands-with-type :page-menu-item)]
+            (for [[_ {:keys [label] :as cmd} action pid] (state/get-plugins-commands-with-type :page-menu-item)]
               {:title label
                :options {:on-click #(commands/exec-plugin-simple-command!
                                      pid (assoc cmd :page (state/get-current-page)) action)}}))

+ 17 - 18
src/main/frontend/components/plugins.cljs

@@ -8,7 +8,6 @@
             [frontend.search :as search]
             [frontend.util :as util]
             [frontend.mixins :as mixins]
-            [electron.ipc :as ipc]
             [promesa.core :as p]
             [frontend.components.svg :as svg]
             [frontend.handler.notification :as notification]
@@ -28,12 +27,12 @@
           (.focus target)
           (mixins/on-key-down
             state {38                                       ;; up
-                   (fn [^js e]
+                   (fn [^js _e]
                      (reset! *cursor
                              (if (zero? @*cursor)
                                (dec @*total) (dec @*cursor))))
                    40                                       ;; down
-                   (fn [^js e]
+                   (fn [^js _e]
                      (reset! *cursor
                              (if (= @*cursor (dec @*total))
                                0 (inc @*cursor))))
@@ -63,7 +62,7 @@
                  plg (get (:plugin/installed-plugins @state/state) (keyword (:pid opt)))]
              [:div.it.flex.px-3.py-1.5.rounded-sm.justify-between
               {:key      (str idx (:url opt))
-               :title    (if current-selected "Cancel selected theme")
+               :title    (when current-selected "Cancel selected theme")
                :class    (util/classnames
                            [{:is-selected current-selected
                              :is-active   (= idx @*cursor)}])
@@ -74,7 +73,7 @@
                 [:small.opacity-60 (str (or (:name plg) "Logseq") " • ")]
                 (:name opt)]]
               [:small.flex-shrink-0.flex.items-center.opacity-10
-               (if current-selected (ui/icon "check"))]]))
+               (when current-selected (ui/icon "check"))]]))
          themes)])))
 
 (rum/defc unpacked-plugin-loader
@@ -141,7 +140,7 @@
        :dangerouslySetInnerHTML {:__html content}}]]))
 
 (rum/defc remote-readme-display
-  [repo content]
+  [repo _content]
 
   (let [src (str "lsp://logseq.com/marketplace.html?repo=" repo)]
     [:iframe.lsp-frame-readme {:src src}]))
@@ -189,7 +188,7 @@
         [:h3.head.text-xl.font-bold.pt-1.5
 
          [:span name]
-         (if (not market?) [:sup.inline-block.px-1.text-xs.opacity-50 version])]
+         (when (not market?) [:sup.inline-block.px-1.text-xs.opacity-50 version])]
 
         [:div.desc.text-xs.opacity-70
          [:p description]
@@ -209,7 +208,7 @@
 
         ;; Github repo
         [:div.flag.is-top.opacity-50
-         (if repo
+         (when repo
            [:a.flex {:target "_blank"
                      :href   (plugin-handler/gh-repo-url repo)}
             (svg/github {:width 16 :height 16})])]
@@ -224,7 +223,7 @@
 
             ;; downloads
             (when-let [downloads (and stat (:total_downloads stat))]
-              (if (and downloads (> downloads 0))
+              (when (and downloads (> downloads 0))
                 [:li.flex.text-sm.items-center.pr-3
                  (svg/cloud-down 16) [:span.pl-1 downloads]]))]
 
@@ -247,7 +246,7 @@
             [:div.de
              [:strong (ui/icon "settings")]
              [:ul.menu-list
-              [:li {:on-click #(if usf (js/apis.openPath usf))} (t :plugin/open-settings)]
+              [:li {:on-click #(when usf (js/apis.openPath usf))} (t :plugin/open-settings)]
               [:li {:on-click #(js/apis.openPath url)} (t :plugin/open-package)]
               [:li {:on-click
                     #(let [confirm-fn
@@ -269,7 +268,7 @@
             ]
 
            [:div.r.flex.items-center
-            (if (and unpacked? (not disabled))
+            (when (and unpacked? (not disabled))
               [:a.btn
                {:on-click #(js-invoke js/LSPluginCore "reload" id)}
                (t :plugin/reload)])
@@ -277,8 +276,8 @@
             (when (not unpacked?)
               [:div.updates-actions
                [:a.btn
-                {:class    (util/classnames [{:disabled (or installing-or-updating?)}])
-                 :on-click #(if-not has-other-pending?
+                {:class    (util/classnames [{:disabled installing-or-updating?}])
+                 :on-click #(when-not has-other-pending?
                               (plugin-handler/check-or-update-marketplace-plugin
                                 (assoc item :only-check (not new-version))
                                 (fn [e] (notification/show! e :error))))}
@@ -342,7 +341,7 @@
         {:placeholder "Search plugins"
          :ref         *search-ref
          :on-key-down (fn [^js e]
-                        (if (= 27 (.-keyCode e))
+                        (when (= 27 (.-keyCode e))
                           (when-not (string/blank? search-key)
                             (util/stop e)
                             (reset! *search-key nil))))
@@ -655,7 +654,7 @@
 
           :disabled
           (or downloading?
-              (and (not (empty? unchecked))
+              (and (seq unchecked)
                    (= (count unchecked) (count updates)))))])]))
 
 (defn open-select-theme!
@@ -706,7 +705,7 @@
       (when (seq items)
         [:div {:class     (str "ui-items-container")
                :data-type (name type)}
-         (for [[_ {:keys [key template] :as opts} pid] items]
+         (for [[_ {:keys [key] :as opts} pid] items]
            (rum/with-key (ui-item-renderer pid type opts) key))]))))
 
 (rum/defc plugins-page
@@ -747,7 +746,7 @@
           (installed-plugins))]])))
 
 (rum/defc custom-js-installer
-  [{:keys [t current-repo db-restoring? nfs-granted?] :as props}]
+  [{:keys [t current-repo db-restoring? nfs-granted?]}]
   (rum/use-effect!
     (fn []
       (when (and (not db-restoring?)
@@ -767,4 +766,4 @@
   (state/set-sub-modal!
     (fn [_close!]
       (waiting-coming-updates))
-    {:center? true}))
+    {:center? true}))

+ 2 - 6
src/main/frontend/components/query_table.cljs

@@ -1,6 +1,5 @@
 (ns frontend.components.query-table
-  (:require [clojure.string :as string]
-            [frontend.components.svg :as svg]
+  (:require [frontend.components.svg :as svg]
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.handler.common :as common-handler]
@@ -74,7 +73,6 @@
                   p-desc?
                   :else
                   true)
-          editor-box (get config :editor-box)
           ;; remove templates
           result (remove (fn [b] (some? (get-in b [:block/properties :template]))) result)
           result (if page? result (attach-clock-property result))
@@ -119,9 +117,7 @@
               (sortable-title key-name key *sort-by-item *desc? (:block/uuid current-block))))]]
         [:tbody
          (for [item result]
-           (let [format (:block/format item)
-                 edit-input-id (str "edit-block-" (:id config) "-" (:block/uuid item))
-                 heading-level (:block/heading-level item)]
+           (let [format (:block/format item)]
              [:tr.cursor
               (for [key keys]
                 (let [value (case key

+ 3 - 4
src/main/frontend/components/reference.cljs

@@ -3,7 +3,6 @@
             [frontend.components.block :as block]
             [frontend.components.content :as content]
             [frontend.components.editor :as editor]
-            [frontend.components.svg :as svg]
             [frontend.date :as date]
             [frontend.db :as db]
             [frontend.db.model :as model-db]
@@ -17,7 +16,7 @@
             [rum.core :as rum]))
 
 (rum/defc filter-dialog-inner < rum/reactive
-  [filters-atom close-fn references page-name]
+  [filters-atom _close-fn references page-name]
   [:div.filters
    [:div.sm:flex.sm:items-start
     [:div.mx-auto.flex-shrink-0.flex.items-center.justify-center.h-12.w-12.rounded-full.bg-gray-200.text-gray-500.sm:mx-0.sm:h-10.sm:w-10
@@ -74,7 +73,7 @@
                  filters (when page-name
                            (atom (page-handler/get-filters (string/lower-case page-name))))]
              (assoc state ::filters filters)))}
-  [state page-name marker?]
+  [state page-name _marker?]
   (when page-name
     (let [page-name (string/lower-case page-name)
           repo (state/get-current-repo)
@@ -179,7 +178,7 @@
                         (first (:rum/args state)))]
                    (count rfs))))
        (render-fn state)))}
-  [state page-name n-ref]
+  [state page-name _n-ref]
   (let [ref-blocks (db/get-page-unlinked-references page-name)]
     [:div.references-blocks
      (let [ref-hiccup (block/->hiccup ref-blocks

+ 3 - 3
src/main/frontend/components/repo.cljs

@@ -145,7 +145,7 @@
             :style {:border-radius "50%"
                     :margin-top 2}
             :on-mouse-over
-            (fn [e]
+            (fn [_e]
               (toggle-fn)
               (js/setTimeout common-handler/check-changed-files-status 0))}])
         (fn [{:keys [toggle-fn]}]
@@ -166,7 +166,7 @@
                        [:a {:href (rfe/href :file {:path file})}
                         file]
                        [:a.ml-4.text-sm.mt-1
-                        {:on-click (fn [e]
+                        {:on-click (fn [_e]
                                      (export-handler/download-file! file))}
                         [:span (t :download)]]]])]]
                  :else
@@ -220,7 +220,7 @@
                                      (= current-repo (:url repo)))
                                    repos)
               repo-links (mapv
-                          (fn [{:keys [id url]}]
+                          (fn [{:keys [url]}]
                             (let [repo-path (get-repo-name url)
                                   short-repo-name (text/get-graph-name-from-path repo-path)]
                               {:title short-repo-name

+ 8 - 8
src/main/frontend/components/right_sidebar.cljs

@@ -62,6 +62,7 @@
      (page/page-graph)]
 
     :block-ref
+    #_:clj-kondo/ignore
     (when-let [block (db/entity repo [:block/uuid (:block/uuid (:block block-data))])]
       [(t :right-side-bar/block-ref)
        (let [block (:block block-data)
@@ -74,6 +75,7 @@
            (block-cp repo idx block)]])])
 
     :block
+    #_:clj-kondo/ignore
     (when-let [block (db/entity repo [:block/uuid (:block/uuid block-data)])]
       (let [block-id (:block/uuid block-data)
             format (:block/format block-data)]
@@ -89,9 +91,9 @@
                       (:block/name (db/entity db-id))
                       page-name)]
       [[:a.page-title {:href     (rfe/href :page {:name page-name})
-            :on-click (fn [e]
-                        (when (gobj/get e "shiftKey")
-                          (.preventDefault e)))}
+                       :on-click (fn [e]
+                                   (when (gobj/get e "shiftKey")
+                                     (.preventDefault e)))}
         (db-model/get-page-original-name page-name)]
        [:div.ml-2
         (page-cp repo page-name)]])
@@ -167,8 +169,7 @@
 
 (defn get-current-page
   []
-  (let [match (:route-match @state/state)
-        theme (:ui/theme @state/state)]
+  (let [match (:route-match @state/state)]
     (get-page match)))
 
 (rum/defc sidebar-resizer
@@ -215,7 +216,7 @@
       [:div.cp__right-sidebar-topbar.flex.flex-row.justify-between.items-center.pl-4.pr-2.h-12
        [:div.cp__right-sidebar-settings.hide-scrollbar {:key "right-sidebar-settings"}
         [:div.ml-4.text-sm
-         [:a.cp__right-sidebar-settings-btn {:on-click (fn [e]
+         [:a.cp__right-sidebar-settings-btn {:on-click (fn [_e]
                                                          (state/sidebar-add-block! repo "contents" :contents nil))}
           (t :right-side-bar/contents)]]
 
@@ -254,8 +255,7 @@
                  [[(state/get-current-repo) "contents" :contents nil]]
                  blocks)
         sidebar-open? (state/sub :ui/sidebar-open?)
-        repo (state/sub :git/current-repo)
-        t (i18n/use-tongue)]
+        repo (state/sub :git/current-repo)]
     (rum/with-context [[t] i18n/*tongue-context*]
       [:div#right-sidebar.cp__right-sidebar.h-screen
        {:class (if sidebar-open? "open" "closed")}

+ 41 - 51
src/main/frontend/components/search.cljs

@@ -13,22 +13,13 @@
             [frontend.state :as state]
             [frontend.mixins :as mixins]
             [frontend.config :as config]
-            [frontend.search :as search]
             [clojure.string :as string]
-            [goog.object :as gobj]
-            [medley.core :as medley]
             [frontend.context.i18n :as i18n]
             [frontend.date :as date]
             [reitit.frontend.easy :as rfe]
             [frontend.modules.shortcut.core :as shortcut]
             [frontend.mobile.util :as mobile-util]))
 
-(defn- partition-between
-  "Split `coll` at positions where `pred?` is true."
-  [pred? coll]
-  (let [switch (reductions not= true (map pred? coll (rest coll)))]
-    (map (partial map first) (partition-by second (map list coll switch)))))
-
 (defn highlight-exact-query
   [content q]
   (if (or (string/blank? content) (string/blank? q))
@@ -75,7 +66,7 @@
    content])
 
 (rum/defc block-search-result-item
-  [repo uuid format content q search-mode]
+  [repo uuid _format content q search-mode]
   [:div [(when (not= search-mode :page)
            [:div {:class "mb-1" :key "parents"} (block/block-parents {:id "block-search-block-parent"
                                                                       :block? true
@@ -320,48 +311,47 @@
                   300)
         in-page-search? (= search-mode :page)]
     (rum/with-context [[t] i18n/*tongue-context*]
-      (let [input (::input state)]
-        [:div.cp__palette.cp__palette-main
-         (when (mobile-util/is-native-platform?)
-          {:style {:min-height "50vh"}})
+      [:div.cp__palette.cp__palette-main
+       (when (mobile-util/is-native-platform?)
+         {:style {:min-height "50vh"}})
 
-         [:div.input-wrap
-          [:input.cp__palette-input.w-full
-           {:type          "text"
-            :auto-focus    true
-            :placeholder   (case search-mode
-                             :graph
-                             (t :graph-search)
-                             :page
-                             (t :page-search)
-                             (t :search))
-            :auto-complete (if (util/chrome?) "chrome-off" "off") ; off not working here
-            :value         search-q
-            :on-change     (fn [e]
-                             (when @search-timeout
-                               (js/clearTimeout @search-timeout))
-                             (let [value (util/evalue e)
-                                   is-composing? (util/onchange-event-is-composing? e)] ;; #3199
-                               (if (and (string/blank? value) (not is-composing?))
-                                 (search-handler/clear-search! false)
-                                 (let [search-mode (state/get-search-mode)
-                                       opts (if (= :page search-mode)
-                                              (when-let [current-page (or (state/get-current-page)
-                                                                          (date/today))]
-                                                {:page-db-id (:db/id (db/entity [:block/name (util/page-name-sanity-lc current-page)]))})
-                                              {})]
-                                   (state/set-q! value)
-                                   (reset! search-timeout
-                                           (js/setTimeout
-                                            (fn []
-                                              (if (= :page search-mode)
-                                                (search-handler/search (state/get-current-repo) value opts)
-                                                (search-handler/search (state/get-current-repo) value)))
-                                            timeout))))))}]]
-         [:div.search-results-wrap
-          (if (seq search-result)
-            (search-auto-complete search-result search-q false)
-            (recent-search-and-pages in-page-search?))]]))))
+       [:div.input-wrap
+        [:input.cp__palette-input.w-full
+         {:type          "text"
+          :auto-focus    true
+          :placeholder   (case search-mode
+                           :graph
+                           (t :graph-search)
+                           :page
+                           (t :page-search)
+                           (t :search))
+          :auto-complete (if (util/chrome?) "chrome-off" "off") ; off not working here
+          :value         search-q
+          :on-change     (fn [e]
+                           (when @search-timeout
+                             (js/clearTimeout @search-timeout))
+                           (let [value (util/evalue e)
+                                 is-composing? (util/onchange-event-is-composing? e)] ;; #3199
+                             (if (and (string/blank? value) (not is-composing?))
+                               (search-handler/clear-search! false)
+                               (let [search-mode (state/get-search-mode)
+                                     opts (if (= :page search-mode)
+                                            (when-let [current-page (or (state/get-current-page)
+                                                                        (date/today))]
+                                              {:page-db-id (:db/id (db/entity [:block/name (util/page-name-sanity-lc current-page)]))})
+                                            {})]
+                                 (state/set-q! value)
+                                 (reset! search-timeout
+                                         (js/setTimeout
+                                          (fn []
+                                            (if (= :page search-mode)
+                                              (search-handler/search (state/get-current-repo) value opts)
+                                              (search-handler/search (state/get-current-repo) value)))
+                                          timeout))))))}]]
+       [:div.search-results-wrap
+        (if (seq search-result)
+          (search-auto-complete search-result search-q false)
+          (recent-search-and-pages in-page-search?))]])))
 
 (rum/defc more < rum/reactive
   [route]

+ 3 - 4
src/main/frontend/components/settings.cljs

@@ -466,7 +466,7 @@
                      (route-handler/redirect! {:to :shortcut-setting}))
     :-for         "customize_shortcuts"}))
 
-(defn zotero-settings-row [t]
+(defn zotero-settings-row [_t]
   [:div.it.sm:grid.sm:grid-cols-3.sm:gap-4.sm:items-start
    [:label.block.text-sm.font-medium.leading-5.opacity-70
     {:for "zotero_settings"}
@@ -482,7 +482,7 @@
         (state/close-settings!)
         (route-handler/redirect! {:to :zotero-setting})))]]])
 
-(defn auto-push-row [t current-repo enable-git-auto-push?]
+(defn auto-push-row [_t current-repo enable-git-auto-push?]
   (when (and current-repo (string/starts-with? current-repo "https://"))
     (toggle "enable_git_auto_push"
             "Enable Git auto push"
@@ -569,7 +569,6 @@
         enable-git-auto-push? (state/enable-git-auto-push? current-repo)
         ;; enable-block-timestamps? (state/enable-block-timestamps?)
         show-brackets? (state/show-brackets?)
-        github-token (state/sub [:me :access-token])
         cors-proxy (state/sub [:me :cors_proxy])
         logged? (state/logged?)
         developer-mode? (state/sub [:ui/developer-mode?])
@@ -663,7 +662,7 @@
            [:div.panel-wrap.is-advanced
             (when (and util/mac? (util/electron?)) (app-auto-update-row t))
             (usage-diagnostics-row t instrument-disabled?)
-            (if-not (mobile-util/is-native-platform?) (developer-mode-row t developer-mode?))
+            (when-not (mobile-util/is-native-platform?) (developer-mode-row t developer-mode?))
             (when (util/electron?) (plugin-system-switcher-row t))
             (clear-cache-row t)
 

+ 1 - 1
src/main/frontend/components/shortcut.cljs

@@ -58,7 +58,7 @@
                  "Shortcut conflict!"
                  (if disabled? "Cannot override system default" "Click to modify"))
         :background (if conflict? "pink" (when disabled? "gray"))
-        :on-click (if-not disabled?
+        :on-click (when-not disabled?
                     #(state/set-modal! (customize-shortcut-dialog k action-name displayed-binding))))])))
 
 (rum/defc shortcut-table < rum/reactive

+ 11 - 17
src/main/frontend/components/sidebar.cljs

@@ -14,7 +14,6 @@
             [frontend.context.i18n :as i18n]
             [frontend.db :as db]
             [frontend.db.model :as db-model]
-            [frontend.db.react :as db-react]
             [frontend.components.svg :as svg]
             [frontend.db-mixins :as db-mixins]
             [frontend.handler.editor :as editor-handler]
@@ -31,12 +30,11 @@
             [rum.core :as rum]
             [frontend.extensions.srs :as srs]
             [frontend.extensions.pdf.assets :as pdf-assets]
-            [frontend.components.widgets :as widgets]
             [frontend.mobile.util :as mobile-util]
             [frontend.handler.mobile.swipe :as swipe]))
 
 (defn nav-item
-  [title href svg-d active? close-modal-fn]
+  [title href svg-d _active? close-modal-fn]
   [:a.mb-1.group.flex.items-center.pl-4.py-2.text-base.leading-6.font-medium.hover:text-gray-200.transition.ease-in-out.duration-150.nav-item
    {:href href
     :on-click close-modal-fn}
@@ -50,7 +48,7 @@
    title])
 
 (rum/defc nav-content-item
-  [name {:keys [edit-fn class] :as opts} child]
+  [name {:keys [class]} child]
 
   [:div.nav-content-item.is-expand
    {:class class}
@@ -102,7 +100,7 @@
 (rum/defcs favorite-item <
   (rum/local nil ::up?)
   (rum/local nil ::dragging-over)
-  [state t name icon]
+  [state _t name icon]
   (let [up? (get state ::up?)
         dragging-over (get state ::dragging-over)
         target (state/sub :favorites/dragging)]
@@ -112,14 +110,14 @@
                "dragging-target"
                "")
       :draggable true
-      :on-drag-start (fn [event]
+      :on-drag-start (fn [_event]
                        (state/set-state! :favorites/dragging name))
       :on-drag-over (fn [e]
                       (util/stop e)
                       (reset! dragging-over name)
                       (when-not (= name (get @state/state :favorites/dragging))
                         (reset! up? (move-up? e))))
-      :on-drag-leave (fn [e]
+      :on-drag-leave (fn [_e]
                        (reset! dragging-over nil))
       :on-drop (fn [e]
                  (page-handler/reorder-favorites! {:to name
@@ -220,12 +218,9 @@
     [:span.flex-1 title]]])
 
 (rum/defc sidebar-nav
-  [route-match close-modal-fn]
+  [_route-match close-modal-fn]
   (rum/with-context [[t] i18n/*tongue-context*]
-    (let [active? (fn [route] (= route (get-in route-match [:data :name])))
-          page-active? (fn [page]
-                         (= page (get-in route-match [:parameters :path :name])))
-          default-home (get-default-home-if-valid)]
+    (let [default-home (get-default-home-if-valid)]
 
       [:div.left-sidebar-inner.flex-1.flex.flex-col.min-h-0
        {:on-click #(when-let [^js target (and (util/sm-breakpoint?) (.-target %))]
@@ -296,12 +291,12 @@
                   (dnd/subscribe!
                    element
                    :upload-files
-                   {:drop (fn [e files]
+                   {:drop (fn [_e files]
                             (when-let [id (state/get-edit-input-id)]
                               (let [format (:block/format (state/get-edit-block))]
                                 (editor-handler/upload-asset id files format editor-handler/*asset-uploading? true))))}))
                 state)}
-  [{:keys [route-match global-graph-pages? logged? home? route-name indexeddb-support? white? db-restoring? main-content]}]
+  [{:keys [route-match global-graph-pages? route-name indexeddb-support? db-restoring? main-content]}]
 
   (let [left-sidebar-open? (state/sub :ui/left-sidebar-open?)]
     (rum/with-context [[t] i18n/*tongue-context*]
@@ -363,8 +358,7 @@
                  (reset! sidebar-inited? true))))
            state)}
   []
-  (let [today (state/sub :today)
-        cloning? (state/sub :repo/cloning?)
+  (let [cloning? (state/sub :repo/cloning?)
         default-home (get-default-home-if-valid)
         importing-to-db? (state/sub :repo/importing-to-db?)
         current-repo (state/sub :git/current-repo)
@@ -481,7 +475,7 @@
                 (swipe/setup-listeners!)
                 state)}
   [state route-match main-content]
-  (let [{:keys [open? close-fn open-fn]} state
+  (let [{:keys [open-fn]} state
         me (state/sub :me)
         current-repo (state/sub :git/current-repo)
         granted? (state/sub [:nfs/user-granted? (state/get-current-repo)])

+ 1 - 1
src/main/frontend/components/svg.cljs

@@ -397,7 +397,7 @@
       "M1050 2180 c0 -5 -6 -10 -13 -10 -6 0 -23 -28 -36 -62 -40 -104 -440 -895 -441 -870 0 13 -6 22 -16 22 -14 0 -16 -8 -10 -47 6 -45 2 -55 -140 -331 -80 -157 -166 -321 -191 -365 -26 -46 -46 -96 -48 -117 -3 -36 1 -41 88 -116 50 -44 114 -99 142 -124 126 -115 185 -161 201 -158 24 4 395 393 396 415 0 10 -18 162 -40 338 -38 300 -74 651 -70 685 3 21 -12 127 -23 173 -9 36 -5 51 67 215 42 97 97 216 121 264 23 48 43 90 43 93 0 3 -7 5 -15 5 -8 0 -15 -4 -15 -10z m-230 -747 c11 -70 33 -238 49 -373 31 -248 67 -523 77 -593 6 -35 2 -42 -63 -114 -113 -127 -233 -252 -274 -284 l-38 -30 -195 182 c-180 166 -195 183 -184 203 6 11 57 104 113 206 56 102 130 238 164 302 35 65 67 121 73 124 7 4 9 -97 7 -312 -4 -321 -3 -322 29 -315 4 0 7 162 7 359 l0 358 105 210 c58 116 106 209 108 208 2 -1 12 -60 22 -131z"}]]])
 
 (rum/defc logo
-  [dark?]
+  [_dark?]
   [:svg
    {:fill "currentColor", :view-box "0 0 21 21", :height "21", :width "21"}
    [:ellipse

+ 3 - 4
src/main/frontend/components/theme.cljs

@@ -8,12 +8,11 @@
             [frontend.state :as state]
             [frontend.components.settings :as settings]
             [frontend.rum :refer [use-mounted]]
-            [rum.core :as rum]
-            [frontend.mobile.util :as mobile-util]))
+            [rum.core :as rum]))
 
 (rum/defc container
   [{:keys [t route theme on-click current-repo nfs-granted? db-restoring?
-           settings-open? sidebar-open? system-theme? sidebar-blocks-len edit?] :as props} child]
+           settings-open? sidebar-open? system-theme? sidebar-blocks-len]} child]
   (let [mounted-fn (use-mounted)
         [restored-sidebar? set-restored-sidebar?] (rum/use-state false)]
 
@@ -35,7 +34,7 @@
      [sidebar-open? restored-sidebar? sidebar-blocks-len])
 
     (rum/use-effect!
-     #(if lsp-enabled?
+     #(when lsp-enabled?
         (plugin-handler/setup-install-listener! t))
      [t])
 

+ 4 - 7
src/main/frontend/components/widgets.cljs

@@ -1,7 +1,5 @@
 (ns frontend.components.widgets
   (:require [clojure.string :as string]
-            [promesa.core :as p]
-            [frontend.mobile.util :as mobile]
             [frontend.context.i18n :as i18n]
             [frontend.handler.notification :as notification]
             [frontend.handler.page :as page-handler]
@@ -88,7 +86,7 @@
   (rum/with-context [[t] i18n/*tongue-context*]
     [:div.flex.flex-col
      [:h1.title (t :on-boarding/add-graph)]
-     (let [nfs-supported? (or (nfs/supported?) (mobile/is-native-platform?))]
+     (let [nfs-supported? (or (nfs/supported?) (mobile-util/is-native-platform?))]
        (if (mobile-util/is-native-platform?)
          [:div.text-sm
           (ui/button "Open a local directory"
@@ -142,7 +140,7 @@
 (rum/defc android-permission-alert
   []
   (when (mobile-util/native-android?)
-    (rum/with-context [[t] i18n/*tongue-context*]
+    (rum/with-context [[_t] i18n/*tongue-context*]
       [:div.flex.flex-col
        [:h1.title "Storage access permission"]
        [:div.text-sm
@@ -163,8 +161,7 @@
 
 (rum/defcs add-graph <
   [state & {:keys [graph-types]
-            :or {graph-types [:local :github]}
-            :as opts}]
+            :or {graph-types [:local :github]}}]
   (let [github-authed? (state/github-authed?)
         generate-f (fn [x]
                      (case x
@@ -184,7 +181,7 @@
                              (keep generate-f)
                              (vec)
                              (interpose [:b.mt-10.mb-5.opacity-50 "OR"]))]
-    (rum/with-context [[t] i18n/*tongue-context*]
+    (rum/with-context [[_t] i18n/*tongue-context*]
       [:div.p-8.flex.flex-col available-graph])))
 
 (rum/defc demo-graph-alert

+ 1 - 1
src/main/frontend/db/conn.cljs

@@ -46,7 +46,7 @@
   (swap! conns dissoc (datascript-db repo)))
 
 (defn me-tx
-  [db {:keys [name email avatar]}]
+  [_db {:keys [name email avatar]}]
   (util/remove-nils {:me/name name
                      :me/email email
                      :me/avatar avatar}))

+ 1 - 2
src/main/frontend/db/debug.cljs

@@ -23,8 +23,7 @@
                                 :block/parent (:db/id (:block/parent e))}))))
                     (remove nil?))
         count-1 (count blocks)
-        count-2 (count (distinct blocks))
-        result (filter #(> (second %) 1) (frequencies blocks))]
+        count-2 (count (distinct blocks))]
     (assert (= count-1 count-2) (util/format "Blocks count: %d, repeated blocks count: %d"
                                              count-1
                                              (- count-1 count-2)))))

+ 12 - 18
src/main/frontend/db/model.cljs

@@ -1,5 +1,7 @@
 (ns frontend.db.model
   "Core db functions."
+  ;; TODO: Remove this config once how repos are passed to this ns are standardized
+  {:clj-kondo/config {:linters {:unused-binding {:level :off}}}}
   (:require [clojure.set :as set]
             [clojure.string :as string]
             [clojure.walk :as walk]
@@ -438,8 +440,7 @@
 (defn flatten-blocks-sort-by-left
   [blocks parent]
   (let [ids->blocks (zipmap (map (fn [b] [(:db/id (:block/parent b))
-                                         (:db/id (:block/left b))]) blocks) blocks)
-        top-block (get ids->blocks [(:db/id parent) (:db/id parent)])]
+                                         (:db/id (:block/left b))]) blocks) blocks)]
     (loop [node parent
            next-siblings '()
            result []]
@@ -461,7 +462,7 @@
     (when block-id
       (some->
       (react/q repo-url [:block/refs-count block-id]
-        {:query-fn (fn [db]
+        {:query-fn (fn [_db]
                      (count (:block/_refs (db-utils/entity repo-url [:block/uuid block-id]))))}
         nil)
       react))))
@@ -479,8 +480,7 @@
      (let [page (util/page-name-sanity-lc (string/trim page))
            page-entity (or (db-utils/entity repo-url [:block/name page])
                            (db-utils/entity repo-url [:block/original-name page]))
-           page-id (:db/id page-entity)
-           db (conn/get-conn repo-url)]
+           page-id (:db/id page-entity)]
        (when page-id
          (some->
           (react/q repo-url [:page/blocks page-id]
@@ -603,7 +603,7 @@
                               ids))))))
 
 (defn block-and-children-transform
-  [result repo-url block-uuid]
+  [result repo-url _block-uuid]
   (some->> result
            db-utils/seq-flatten
            (db-utils/with-repo repo-url)))
@@ -742,12 +742,6 @@
     (db-utils/entity [:block/uuid (uuid page-name)])
     (db-utils/entity [:block/name (util/page-name-sanity-lc page-name)])))
 
-(defn- heading-block?
-  [block]
-  (and
-   (vector? block)
-   (= "Heading" (first block))))
-
 (defn get-redirect-page-name
   "Accepts both sanitized or unsanitized"
   ([page-name] (get-redirect-page-name page-name false))
@@ -897,7 +891,7 @@
                                db-utils/seq-flatten)]
       (mapv (fn [page] [page (get-page-alias repo page)]) mentioned-pages))))
 
-(defn- remove-children!
+(defn remove-children!
   [blocks]
   (let [parents (->> (mapcat :block/parent blocks)
                      (map :db/id)
@@ -1135,7 +1129,7 @@
 (defn get-matched-blocks
   [match-fn limit]
   (when-let [repo (state/get-current-repo)]
-    (let [pred (fn [db content]
+    (let [pred (fn [_db content]
                  (match-fn content))]
       (->> (d/q
             '[:find ?block
@@ -1231,7 +1225,7 @@
 
 (defn get-all-templates
   []
-  (let [pred (fn [db properties]
+  (let [pred (fn [_db properties]
                (some? (:template properties)))]
     (->> (d/q
           '[:find ?b ?p
@@ -1315,7 +1309,7 @@
         non-public-datoms (get-public-false-block-ids db)
         non-public-datom-ids (set (concat non-public-pages non-public-datoms))
         filtered-db (d/filter db
-                              (fn [db datom]
+                              (fn [_db datom]
                                 (let [ns (namespace (:a datom))]
                                   (and (not (remove? ns))
                                        (not (contains? #{:block/file} (:a datom)))
@@ -1347,7 +1341,7 @@
         [@(d/conn-from-datoms datoms db-schema/schema) assets]))))
 
 (defn delete-blocks
-  [repo-url files delete-page?]
+  [repo-url files _delete-page?]
   (when (seq files)
     (let [blocks (get-files-blocks repo-url files)]
       (mapv (fn [eid] [:db.fn/retractEntity eid]) blocks))))
@@ -1535,7 +1529,7 @@
   ([repo] (remove-orphaned-pages! repo (get-orphaned-pages {})))
   ([repo orphaned-pages]
    (let [transaction (mapv (fn [page] [:db/retractEntity (:db/id page)]) orphaned-pages)]
-     (db-utils/transact! transaction))))
+     (db-utils/transact! repo transaction))))
 
 (defn get-block-last-direct-child
   [db-id]

+ 1 - 1
src/main/frontend/db/outliner.cljs

@@ -8,7 +8,7 @@
   [conn id]
   (try
     (d/pull @conn '[*] id)
-    (catch js/Error e nil)))
+    (catch js/Error _e nil)))
 
 (defn get-by-parent-&-left
   [conn parent-id left-id]

+ 0 - 1
src/main/frontend/db/persist.cljs

@@ -1,6 +1,5 @@
 (ns frontend.db.persist
   (:require [frontend.util :as util]
-            [frontend.mobile.util :as mobile]
             [frontend.idb :as idb]
             [frontend.config :as config]
             [electron.ipc :as ipc]

+ 2 - 3
src/main/frontend/db/query_custom.cljs

@@ -4,7 +4,6 @@
             [clojure.string :as string]
             [cljs.reader :as reader]
             [frontend.db.query-react :as react]
-            [frontend.template :as template]
             [frontend.db.query-dsl :as dsl]
             [frontend.db.model :as model]
             [clojure.walk :as walk]))
@@ -26,11 +25,11 @@
   ([query]
    (custom-query query {}))
   ([query query-opts]
+   #_:clj-kondo/ignore
    (when-let [query' (cond
                        (and (string? query)
                             (not (string/blank? query)))
-                       (let [query-string (template/resolve-dynamic-template! query)]
-                         (reader/read-string query))
+                       (reader/read-string query)
 
                        (map? query)
                        query

+ 28 - 29
src/main/frontend/db/query_dsl.cljs

@@ -311,23 +311,23 @@
                      (keyword (string/lower-case (name order)))
                      :desc)
              k (-> (string/lower-case (name k))
-                   (string/replace "_" "-"))]
-         (let [get-value (cond
-                           (= k "created-at")
-                           :block/created-at
-
-                           (= k "updated-at")
-                           :block/updated-at
-
-                           :else
-                           #(get-in % [:block/properties k]))
-               comp (if (= order :desc) >= <=)]
-           (reset! sort-by
-                   (fn [result]
-                     (->> result
-                          flatten
-                          (clojure.core/sort-by get-value comp))))
-           nil))
+                   (string/replace "_" "-"))
+             get-value (cond
+                         (= k "created-at")
+                         :block/created-at
+
+                         (= k "updated-at")
+                         :block/updated-at
+
+                         :else
+                         #(get-in % [:block/properties k]))
+             comp (if (= order :desc) >= <=)]
+         (reset! sort-by
+                 (fn [result]
+                   (->> result
+                        flatten
+                        (clojure.core/sort-by get-value comp))))
+         nil)
 
        (= 'page fe)
        (let [page-name (text/page-ref-un-brackets! (str (first (rest e))))
@@ -362,18 +362,17 @@
             [true]]))
 
        (= 'page-tags fe)
-       (do
-         (let [tags (if (coll? (first (rest e)))
-                      (first (rest e))
-                      (rest e))
-               tags (map (comp string/lower-case name) tags)]
-           (when (seq tags)
-             (let [tags (set (map (comp text/page-ref-un-brackets! string/lower-case name) tags))]
-               (let [sym-1 (uniq-symbol counter "?t")
-                     sym-2 (uniq-symbol counter "?tag")]
-                 [['?p :block/tags sym-1]
-                  [sym-1 :block/name sym-2]
-                  [(list 'contains? tags sym-2)]])))))
+       (let [tags (if (coll? (first (rest e)))
+                    (first (rest e))
+                    (rest e))
+             tags (map (comp string/lower-case name) tags)]
+         (when (seq tags)
+           (let [tags (set (map (comp text/page-ref-un-brackets! string/lower-case name) tags))
+                 sym-1 (uniq-symbol counter "?t")
+                 sym-2 (uniq-symbol counter "?tag")]
+             [['?p :block/tags sym-1]
+              [sym-1 :block/name sym-2]
+              [(list 'contains? tags sym-2)]])))
 
        (= 'all-page-tags fe)
        [['?e :block/tags '?p]]

+ 23 - 23
src/main/frontend/db/query_react.cljs

@@ -61,29 +61,29 @@
   (try
     (let [repo (state/get-current-repo)
           result (db-utils/seq-flatten query-result)
-          block? (:block/uuid (first result))]
-      (let [result (if block?
-                     (let [result (if (seq remove-blocks)
-                                    (let [remove-blocks (set remove-blocks)]
-                                      (remove (fn [h]
-                                                (contains? remove-blocks (:block/uuid h)))
-                                              result))
-                                    result)]
-                       (some->> result
-                                remove-nested-children-blocks
-                                (model/sort-by-left-recursive)
-                                (db-utils/with-repo repo)
-                                (model/with-pages)))
-                     result)]
-        (if-let [result-transform (:result-transform q)]
-          (if-let [f (sci/eval-string (pr-str result-transform))]
-            (try
-              (sci/call-fn f result)
-              (catch js/Error e
-                (log/error :sci/call-error e)
-                result))
-            result)
-          result)))
+          block? (:block/uuid (first result))
+          result (if block?
+                   (let [result (if (seq remove-blocks)
+                                  (let [remove-blocks (set remove-blocks)]
+                                    (remove (fn [h]
+                                              (contains? remove-blocks (:block/uuid h)))
+                                            result))
+                                  result)]
+                     (some->> result
+                              remove-nested-children-blocks
+                              (model/sort-by-left-recursive)
+                              (db-utils/with-repo repo)
+                              (model/with-pages)))
+                   result)]
+      (if-let [result-transform (:result-transform q)]
+        (if-let [f (sci/eval-string (pr-str result-transform))]
+          (try
+            (sci/call-fn f result)
+            (catch js/Error e
+              (log/error :sci/call-error e)
+              result))
+          result)
+        result))
     (catch js/Error e
       (log/error :query/failed e))))
 

+ 6 - 8
src/main/frontend/db/react.cljs

@@ -11,7 +11,7 @@
             [frontend.db.conn :as conn]
             [frontend.db.utils :as db-utils]
             [frontend.state :as state]
-            [frontend.util :as util :refer [profile react]]
+            [frontend.util :as util :refer [react]]
             [frontend.util.marker :as marker]
             [frontend.db.rules :as rules]))
 
@@ -50,13 +50,13 @@
 (defn clear-query-state-without-refs-and-embeds!
   []
   (let [state @query-state
-        state (->> (filter (fn [[[_repo k] v]]
+        state (->> (filter (fn [[[_repo k] _v]]
                              (contains? #{:blocks :block/block :custom} k)) state)
                    (into {}))]
     (reset! query-state state)))
 
 (defn get-current-repo-refs-keys
-  [{:keys [key data]}]
+  [{:keys [data]}]
   (when-let [current-repo (state/get-current-repo)]
     (->>
      (map (fn [[repo k id]]
@@ -143,8 +143,7 @@
 (defn q
   [repo k {:keys [use-cache? transform-fn query-fn inputs-fn disable-reactive?]
            :or {use-cache? true
-                transform-fn identity}
-           :as opts} query & inputs]
+                transform-fn identity}} query & inputs]
   (let [kv? (and (vector? k) (= :kv (first k)))
         k (vec (cons repo k))]
     (when-let [conn (conn/get-conn repo)]
@@ -230,7 +229,6 @@
               current-priority (get-current-priority)
               current-marker (get-current-marker)
               current-page-id (:db/id (get-current-page))
-              {:block/keys [page]} (first blocks)
               related-keys (->>
                             (util/concat-without-nil
                              (mapcat
@@ -304,7 +302,7 @@
       [[key]])))
 
 (defn refresh!
-  [repo-url {:keys [key data] :as handler-opts}]
+  [repo-url handler-opts]
   (let [related-keys (get-related-keys handler-opts)
         db (conn/get-conn repo-url)]
     (doseq [related-key related-keys]
@@ -336,7 +334,7 @@
                 (set-new-result! related-key new-result)))))))))
 
 (defn transact-react!
-  [repo-url tx-data {:keys [key data] :as handler-opts}]
+  [repo-url tx-data handler-opts]
   (when-not config/publishing?
     (let [repo-url (or repo-url (state/get-current-repo))
           tx-data (->> (util/remove-nils tx-data)

+ 1 - 1
src/main/frontend/extensions/calc.cljc

@@ -100,5 +100,5 @@
           [:div.extensions__code-calc-output-line {:key i}
            [:span (cond
                     (nil? line)           ""
-                    (or  (failure? line)) "?"
+                    (failure? line) "?"
                     :else                 line)]])])))

+ 2 - 3
src/main/frontend/extensions/code.cljs

@@ -132,7 +132,6 @@
             [frontend.extensions.calc :as calc]
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.file :as file-handler]
-            [frontend.handler.notification :as notification]
             [frontend.state :as state]
             [frontend.utf8 :as utf8]
             [frontend.util :as util]
@@ -243,7 +242,7 @@
         (gobj/set textarea-ref codemirror-ref-name editor))
       (let [element (.getWrapperElement editor)]
         (when (= mode "calc")
-          (.on editor "change" (fn [_cm e]
+          (.on editor "change" (fn [_cm _e]
                                  (let [new-code (.getValue editor)]
                                    (reset! (:calc-atom state) (calc/eval-lines new-code))))))
         (.on editor "blur" (fn [_cm e]
@@ -289,7 +288,7 @@
    :did-update (fn [state]
                  (load-and-render! state)
                  state)}
-  [state config id attr code theme options]
+  [state _config id attr code _theme _options]
   [:div.extensions__code
    (when-let [mode (:data-lang attr)]
      (when-not (= mode "calc")

+ 1 - 10
src/main/frontend/extensions/excalidraw.cljs

@@ -28,13 +28,6 @@
          :error)))))
 
 (defonce *bounding-width (atom nil))
-(defn- get-bounding-width
-  [ref]
-  (when ref
-    (when-let [current (gobj/get ref "current")]
-      (-> current
-         (.getBoundingClientRect)
-         (gobj/get "width")))))
 
 (defn- update-draw-content-width
   [state]
@@ -52,9 +45,7 @@
   {:did-mount update-draw-content-width}
   {:did-update update-draw-content-width}
   [state data option]
-  (let [current-repo (state/sub :git/current-repo)
-        bounding-width (rum/react *bounding-width)
-        *draw-width (get state ::draw-width)
+  (let [*draw-width (get state ::draw-width)
         *zen-mode? (get state ::zen-mode?)
         *view-mode? (get state ::view-mode?)
         wide-mode? (state/sub :ui/wide-mode?)

+ 3 - 3
src/main/frontend/extensions/graph.cljs

@@ -7,7 +7,7 @@
             [rum.core :as rum]))
 
 (defn- highlight-neighbours!
-  [^js graph node focus-nodes dark?]
+  [^js graph node focus-nodes _dark?]
   (.forEachNeighbor
    (.-graph graph) node
    (fn [node attributes]
@@ -23,7 +23,7 @@
   [^js graph node dark?]
   (.forEachEdge
    (.-graph graph) node
-   (fn [edge attributes]
+   (fn [edge _attributes]
      (.resetEdgeStyle graph edge (bean/->js {:width 1
                                              :color (if dark? "#999" "#A5B4FC")})))))
 
@@ -59,7 +59,7 @@
    :will-unmount (fn [state]
                    (reset! pixi/*graph-instance nil)
                    state)}
-  [state opts]
+  [state _opts]
   [:div.graph {:ref (fn [value]
                       (let [ref (get state :ref)]
                         (when (and ref value)

+ 31 - 30
src/main/frontend/extensions/graph/pixi.cljs

@@ -46,7 +46,7 @@
           :color (if dark? "#094b5a" "#cccccc")}})
 
 (defn default-hover-style
-  [dark?]
+  [_dark?]
   {:node {:color  "#6366F1"
           :label  {:backgroundColor "rgba(238, 238, 238, 1)"
                    :color           "#333333"}}
@@ -105,7 +105,7 @@
                              :y (.-y obj)}))
 
 (defn- tick!
-  [pixi graph nodes-js links-js]
+  [pixi _graph nodes-js links-js]
   (fn []
     (let [nodes-objects (.getNodesObjects pixi)
           edges-objects (.getEdgesObjects pixi)]
@@ -126,7 +126,7 @@
     ;; drag start
     (let [*dragging? (atom false)
           nodes (.getNodesObjects pixi-graph)
-          on-drag-end (fn [node event]
+          on-drag-end (fn [_node event]
                         (.stopPropagation event)
                         (when-let [s @*simulation]
                           (when-not (.-active event)
@@ -134,6 +134,7 @@
                         (reset! *dragging? false))]
       (.on pixi-graph "nodeMousedown"
            (fn [event node-key]
+             #_:clj-kondo/ignore
              (when-let [node (.get nodes node-key)]
                (when-let [s @*simulation]
                  (when-not (.-active event)
@@ -173,33 +174,33 @@
           nodes                                                                     (remove nil? nodes)
           links                                                                     (remove (fn [{:keys [source target]}] (or (nil? source) (nil? target))) links)
           nodes-js                                                                  (bean/->js nodes)
-          links-js                                                                  (bean/->js links)]
-      (let [simulation (layout! nodes-js links-js)]
-        (doseq [node nodes-js]
-          (try (.addNode graph (.-id node) node)
-               (catch js/Error e
-                 (js/console.error e))))
-        (doseq [link links-js]
-          (let [source (.-id (.-source link))
-                target (.-id (.-target link))]
-            (try (.addEdge graph source target link)
-                 (catch js/Error e
-                   (js/console.error e)))))
-        (when-let [container-ref (:ref state)]
-          (let [pixi-graph (new (.-PixiGraph Pixi-Graph)
-                                (bean/->js
-                                 {:container  @container-ref
-                                  :graph      graph
-                                  :style      style
-                                  :hoverStyle hover-style
-                                  :height     height}))]
-            (reset! *graph-instance
-                    {:graph graph
-                     :pixi  pixi-graph})
-            (when register-handlers-fn
-              (register-handlers-fn pixi-graph))
-            (set-up-listeners! pixi-graph)
-            (.on simulation "tick" (tick! pixi-graph graph nodes-js links-js))))))
+          links-js                                                                  (bean/->js links)
+          simulation                                                                (layout! nodes-js links-js)]
+      (doseq [node nodes-js]
+        (try (.addNode graph (.-id node) node)
+          (catch js/Error e
+            (js/console.error e))))
+      (doseq [link links-js]
+        (let [source (.-id (.-source link))
+              target (.-id (.-target link))]
+          (try (.addEdge graph source target link)
+            (catch js/Error e
+              (js/console.error e)))))
+      (when-let [container-ref (:ref state)]
+        (let [pixi-graph (new (.-PixiGraph Pixi-Graph)
+                           (bean/->js
+                            {:container  @container-ref
+                             :graph      graph
+                             :style      style
+                             :hoverStyle hover-style
+                             :height     height}))]
+          (reset! *graph-instance
+                  {:graph graph
+                   :pixi  pixi-graph})
+          (when register-handlers-fn
+            (register-handlers-fn pixi-graph))
+          (set-up-listeners! pixi-graph)
+          (.on simulation "tick" (tick! pixi-graph graph nodes-js links-js)))))
     (catch js/Error e
       (js/console.error e)))
   state)

+ 111 - 113
src/main/frontend/extensions/html_parser.cljs

@@ -32,7 +32,7 @@
                                (->> (map transform-fn children)
                                     (string/join " "))
                                "\n"))
-        emphasis-transform (fn [tag attrs children]
+        emphasis-transform (fn [tag _attrs children]
                              (let [pattern (cond
                                              (contains? #{:b :strong} tag)
                                              (config/get-bold format)
@@ -61,120 +61,118 @@
                     content))
         single-hiccup-transform
         (fn [x]
-          (do
-            (cond
-              (vector? x)
-              (let [[tag attrs & children] x
-                    result (match tag
-                             :head nil
-                             :h1 (block-transform 1 children)
-                             :h2 (block-transform 2 children)
-                             :h3 (block-transform 3 children)
-                             :h4 (block-transform 4 children)
-                             :h5 (block-transform 5 children)
-                             :h6 (block-transform 6 children)
-                             :a (let [href (:href attrs)
-                                      title (:title attrs)
-                                      label (map-join children)
-                                      has-img-tag? (util/safe-re-find #"\[:img" (str x))]
-                                  (if has-img-tag?
-                                    (export-hiccup x)
+          (cond
+            (vector? x)
+            (let [[tag attrs & children] x
+                  result (match tag
+                                :head nil
+                                :h1 (block-transform 1 children)
+                                :h2 (block-transform 2 children)
+                                :h3 (block-transform 3 children)
+                                :h4 (block-transform 4 children)
+                                :h5 (block-transform 5 children)
+                                :h6 (block-transform 6 children)
+                                :a (let [href (:href attrs)
+                                         label (map-join children)
+                                         has-img-tag? (util/safe-re-find #"\[:img" (str x))]
+                                     (if has-img-tag?
+                                       (export-hiccup x)
+                                       (case format
+                                         :markdown (util/format "[%s](%s)" label href)
+                                         :org (util/format "[[%s][%s]]" href label)
+                                         nil)))
+                                :img (let [src (:src attrs)
+                                           alt (:alt attrs)]
+                                       (case format
+                                         :markdown (util/format "![%s](%s)" alt src)
+                                         :org (util/format "[[%s][%s]]" src alt)
+                                         nil))
+                                :p (util/format "%s"
+                                                (map-join children))
+
+                                :hr (config/get-hr format)
+
+                                (_ :guard #(contains? #{:b :strong
+                                                        :i :em
+                                                        :ins
+                                                        :del
+                                                        :mark} %))
+                                (emphasis-transform tag attrs children)
+
+                                :code (if @*inside-pre?
+                                        (map-join children)
+                                        (let [pattern (config/get-code format)]
+                                          (str " "
+                                               (str pattern (first children) pattern)
+                                               " ")))
+
+                                :pre
+                                (do
+                                  (reset! *inside-pre? true)
+                                  (let [content (string/trim (doall (map-join children)))]
+                                    (reset! *inside-pre? false)
                                     (case format
-                                      :markdown (util/format "[%s](%s)" label href)
-                                      :org (util/format "[[%s][%s]]" href label)
+                                      :markdown (if (util/starts-with? content "```")
+                                                  content
+                                                  (str "```\n" content "\n```"))
+                                      :org (if (util/starts-with? content "#+BEGIN_SRC")
+                                             content
+                                             (util/format "#+BEGIN_SRC\n%s\n#+END_SRC" content))
                                       nil)))
-                             :img (let [src (:src attrs)
-                                        alt (:alt attrs)]
-                                    (case format
-                                      :markdown (util/format "![%s](%s)" alt src)
-                                      :org (util/format "[[%s][%s]]" src alt)
-                                      nil))
-                             :p (util/format "%s"
-                                             (map-join children))
-
-                             :hr (config/get-hr format)
-
-                             (_ :guard #(contains? #{:b :strong
-                                                     :i :em
-                                                     :ins
-                                                     :del
-                                                     :mark} %))
-                             (emphasis-transform tag attrs children)
-
-                             :code (if @*inside-pre?
-                                     (map-join children)
-                                     (let [pattern (config/get-code format)]
-                                       (str " "
-                                            (str pattern (first children) pattern)
-                                            " ")))
-
-                             :pre
-                             (do
-                               (reset! *inside-pre? true)
-                               (let [content (string/trim (doall (map-join children)))]
-                                 (reset! *inside-pre? false)
-                                 (case format
-                                   :markdown (if (util/starts-with? content "```")
-                                               content
-                                               (str "```\n" content "\n```"))
-                                   :org (if (util/starts-with? content "#+BEGIN_SRC")
-                                          content
-                                          (util/format "#+BEGIN_SRC\n%s\n#+END_SRC" content))
-                                   nil)))
-
-                             :blockquote
-                             (case format
-                               :markdown (str "> " (map-join children))
-                               :org (util/format "#+BEGIN_QUOTE\n%s\n#+END_QUOTE" (map-join children))
-                               nil)
-
-                             :li
-                             (str "- " (map-join children))
-
-                             :dt
-                             (case format
-                               :org (str "- " (map-join children) " ")
-                               :markdown (str (map-join children) "\n")
-                               nil)
-
-                             :dd
-                             (case format
-                               :markdown (str ": " (map-join children) "\n")
-                               :org (str ":: " (map-join children) "\n")
-                               nil)
-
-                             :thead
-                             (case format
-                               :markdown (let [columns (count (last (first children)))]
-                                           (str
-                                            (map-join children)
-                                            (str "| " (string/join " | "
-                                                                   (repeat columns "----"))
-                                                 " |")))
-                               :org (let [columns (count (last (first children)))]
-                                      (str
-                                       (map-join children)
-                                       (str "|" (string/join "+"
-                                                             (repeat columns "----"))
-                                            "|")))
-                               nil)
-                             :tr
-                             (str "| "
-                                  (->> (map transform-fn children)
-                                       (string/join " | "))
-                                  " |")
-
-                             (_ :guard #(contains? #{:aside :center :figure :figcaption :fieldset :footer :header} %))
-                             (export-hiccup x)
-
-                             :else (map-join children))]
-                (wrapper tag result))
-
-              (string? x)
-              x
-
-              :else
-              (println "hiccup->doc error: " x))))
+
+                                :blockquote
+                                (case format
+                                  :markdown (str "> " (map-join children))
+                                  :org (util/format "#+BEGIN_QUOTE\n%s\n#+END_QUOTE" (map-join children))
+                                  nil)
+
+                                :li
+                                (str "- " (map-join children))
+
+                                :dt
+                                (case format
+                                  :org (str "- " (map-join children) " ")
+                                  :markdown (str (map-join children) "\n")
+                                  nil)
+
+                                :dd
+                                (case format
+                                  :markdown (str ": " (map-join children) "\n")
+                                  :org (str ":: " (map-join children) "\n")
+                                  nil)
+
+                                :thead
+                                (case format
+                                  :markdown (let [columns (count (last (first children)))]
+                                              (str
+                                               (map-join children)
+                                               (str "| " (string/join " | "
+                                                                      (repeat columns "----"))
+                                                    " |")))
+                                  :org (let [columns (count (last (first children)))]
+                                         (str
+                                          (map-join children)
+                                          (str "|" (string/join "+"
+                                                                (repeat columns "----"))
+                                               "|")))
+                                  nil)
+                                :tr
+                                (str "| "
+                                     (->> (map transform-fn children)
+                                          (string/join " | "))
+                                     " |")
+
+                                (_ :guard #(contains? #{:aside :center :figure :figcaption :fieldset :footer :header} %))
+                                (export-hiccup x)
+
+                                :else (map-join children))]
+              (wrapper tag result))
+
+            (string? x)
+            x
+
+            :else
+            (println "hiccup->doc error: " x)))
         result (if (vector? (first hiccup))
                  (for [x hiccup]
                    (single-hiccup-transform x))

+ 2 - 3
src/main/frontend/extensions/latex.cljs

@@ -46,7 +46,7 @@
                 (js/setTimeout #(load-and-render! state) 0)
                 state)
    :did-update load-and-render!}
-  [id s block? display?]
+  [id s block? _display?]
   (let [loading? (rum/react *loading?)]
     (when loading?
       (ui/loading "Loading"))
@@ -58,12 +58,11 @@
        s])))
 
 (defn html-export
-  [s block? display?]
+  [s block? _display?]
   (let [element (if block?
                   :div.latex
                   :span.latex-inline)]
     [element (if (or block? display?)
                (util/format "$$%s$$" s)
-
                ;; inline
                (util/format "$%s$" s))]))

+ 3 - 2
src/main/frontend/extensions/pdf/assets.cljs

@@ -85,7 +85,7 @@
   (and hl (not (nil? (get-in hl [:content :image])))))
 
 (defn persist-hl-area-image$
-  [^js viewer current new-hl old-hl {:keys [top left width height] :as vw-bounding}]
+  [^js viewer current new-hl old-hl {:keys [top left width height]}]
   (when-let [^js canvas (and (:key current) (.-canvas (.getPageView viewer (dec (:page new-hl)))))]
     (let [^js doc (.-ownerDocument canvas)
           ^js canvas' (.createElement doc "canvas")
@@ -138,7 +138,7 @@
       (:block/uuid block) :hl-stamp (get-in highlight [:content :image]))))
 
 (defn unlink-hl-area-image$
-  [^js viewer current hl]
+  [^js _viewer current hl]
   (when-let [fkey (and (area-highlight? hl) (:key current))]
     (let [repo-cur (state/get-current-repo)
           repo-dir (config/get-repo-dir repo-cur)
@@ -201,6 +201,7 @@
 
 (defn del-ref-block!
   [{:keys [id]}]
+  #_:clj-kondo/ignore
   (when-let [repo (state/get-current-repo)]
     (when-let [block (db-model/get-block-by-uuid id)]
       (editor-handler/delete-block-aux! block true))))

+ 16 - 25
src/main/frontend/extensions/pdf/highlights.cljs

@@ -2,7 +2,6 @@
   (:require [cljs-bean.core :as bean]
             [clojure.string :as string]
             [frontend.components.svg :as svg]
-            [frontend.config :as config]
             [frontend.context.i18n :as i18n]
             [frontend.extensions.pdf.assets :as pdf-assets]
             [frontend.extensions.pdf.utils :as pdf-utils]
@@ -137,8 +136,7 @@
                           (pdf-utils/clear-all-selection))
 
                         "link"
-                        (do
-                          (pdf-assets/goto-block-ref! highlight))
+                        (pdf-assets/goto-block-ref! highlight)
 
                         "del"
                         (do
@@ -158,8 +156,7 @@
                               (pdf-assets/copy-hl-ref! highlight))
 
                             ;; update highlight
-                            (do
-                              (upd-hl! (assoc highlight :properties properties)))))))
+                            (upd-hl! (assoc highlight :properties properties))))))
 
                     (clear-ctx-tip!))}
 
@@ -181,8 +178,7 @@
   [^js viewer vw-hl hl
    {:keys [show-ctx-tip!]}]
 
-  (let [id (:id hl)
-        {:keys [rects]} (:position vw-hl)
+  (let [{:keys [rects]} (:position vw-hl)
         {:keys [color]} (:properties hl)
         open-tip! (fn [^js/MouseEvent e]
                     (.preventDefault e)
@@ -225,7 +221,7 @@
                          (.resizable
                            (bean/->js
                              {:edges     {:left true :right true :top true :bottom true}
-                              :listeners {:start (fn [^js/MouseEvent e]
+                              :listeners {:start (fn [^js/MouseEvent _e]
                                                    (rum/set-ref! *dirty true))
 
                                           :end   (fn [^js/MouseEvent e]
@@ -319,7 +315,7 @@
        ))])
 
 (rum/defc pdf-highlight-area-selection
-  [^js viewer {:keys [clear-ctx-tip! show-ctx-tip!] :as ops}]
+  [^js viewer {:keys [show-ctx-tip!]}]
 
   (let [^js viewer-clt (.. viewer -viewer -classList)
         *el (rum/use-ref nil)
@@ -633,7 +629,7 @@
         })]))
 
 (rum/defc pdf-settings
-  [^js viewer theme {:keys [hide-settings! select-theme! t]}]
+  [^js _viewer theme {:keys [hide-settings! select-theme! t]}]
 
   (let [*el-popup (rum/use-ref nil)
         [area-dashed? set-area-dashed?] (use-atom *area-dashed?)]
@@ -678,7 +674,7 @@
 
 (rum/defc pdf-outline-item
   [^js viewer
-   {:keys [title items href parent dest expanded] :as node}
+   {:keys [title items parent dest expanded]}
    {:keys [upt-outline-node!] :as ops}]
   (let [has-child? (seq items)
         expanded? (boolean expanded)]
@@ -727,12 +723,13 @@
       (rum/use-effect!
         (fn []
           (p/catch
-            (p/let [^js data (.getOutline pdf-doc)]
-              (when-let [data (and data (.map data (fn [^js it]
-                                                     (set! (.-href it) (.. viewer -linkService (getDestinationHash (.-dest it))))
-                                                     (set! (.-expanded it) false)
-                                                     it)))])
-              (set-outline-data! (bean/->clj data)))
+           (p/let [^js data (.getOutline pdf-doc)]
+                  #_:clj-kondo/ignore
+                  (when-let [data (and data (.map data (fn [^js it]
+                                                         (set! (.-href it) (.. viewer -linkService (getDestinationHash (.-dest it))))
+                                                         (set! (.-expanded it) false)
+                                                         it)))])
+                  (set-outline-data! (bean/->clj data)))
 
             (fn [e]
               (js/console.error "[Load outline Error]" e))))
@@ -784,7 +781,7 @@
                :on-click
                (fn []
                  (let [text (.-innerText (js/document.querySelector "#pdf-docinfo > .inner-text"))
-                       text (string/replace-all text #"[\n\t]+" "\n")]
+                       text (string/replace text #"[\n\t]+" "\n")]
                    (front-utils/copy-to-clipboard! text)
                    (notification/show! "Copied!" :success)
                    (close-fn!))))]])
@@ -921,7 +918,6 @@
   ;;(dd "==== render pdf-viewer ====")
 
   (let [*el-ref (rum/create-ref)
-        [area-dashed?, set-area-dashed?] (use-atom *area-dashed?)
         [state, set-state!] (rum/use-state {:viewer nil :bus nil :link nil :el nil})
         [ano-state, set-ano-state!] (rum/use-state {:loaded-pages []})
         [page-ready?, set-page-ready!] (rum/use-state false)]
@@ -959,9 +955,7 @@
     (rum/use-effect!
       (fn []
         (when-let [^js viewer (:viewer state)]
-          (let [^js el (rum/deref *el-ref)
-
-                fn-textlayer-ready
+          (let [fn-textlayer-ready
                 (fn [^js p]
                   (set-ano-state! {:loaded-pages (conj (:loaded-pages ano-state) (int (.-pageNumber p)))}))
 
@@ -1005,8 +999,6 @@
   (let [*doc-ref (rum/use-ref nil)
         [state, set-state!] (rum/use-state {:error nil :pdf-document nil :status nil})
         [hls-state, set-hls-state!] (rum/use-state {:initial-hls nil :latest-hls nil})
-        repo-cur (state/get-current-repo)
-        repo-dir (config/get-repo-dir repo-cur)
         set-dirty-hls! (fn [latest-hls]                     ;; TODO: incremental
                          (set-hls-state! {:initial-hls [] :latest-hls latest-hls}))]
 
@@ -1044,7 +1036,6 @@
     (rum/use-effect!
       (fn []
         (let [get-doc$ (fn [^js opts] (.-promise (js/pdfjsLib.getDocument opts)))
-              own-doc (rum/deref *doc-ref)
               opts {:url           url
                     :ownerDocument js/document
                     :cMapUrl       "./js/pdfjs/cmaps/"

+ 2 - 2
src/main/frontend/extensions/pdf/utils.cljs

@@ -165,10 +165,10 @@
   []
   (try
     (js-invoke js/window.lsPdfViewer "nextPage")
-    (catch js/Error e nil)))
+    (catch js/Error _e nil)))
 
 (defn prev-page
   []
   (try
     (js-invoke js/window.lsPdfViewer "previousPage")
-    (catch js/Error e nil)))
+    (catch js/Error _e nil)))

+ 0 - 1
src/main/frontend/extensions/sci.cljs

@@ -5,7 +5,6 @@
 (def sum (partial apply +))
 
 (defn average [coll]
-  (def coll coll)
   (/ (reduce + coll) (count coll)))
 
 (defn eval-string

+ 61 - 97
src/main/frontend/extensions/srs.cljs

@@ -11,7 +11,6 @@
             [frontend.handler.editor :as editor-handler]
             [frontend.components.block :as component-block]
             [frontend.components.macro :as component-macro]
-            [frontend.components.svg :as svg]
             [frontend.ui :as ui]
             [frontend.date :as date]
             [frontend.commands :as commands]
@@ -123,11 +122,6 @@
     (contains? refs card-entity)))
 
 (declare get-root-block)
-(defn- card-group-by-repeat [cards]
-  (let [groups (group-by
-                #(get (get-block-card-properties (get-root-block %)) card-repeats-property)
-                cards)]
-    groups))
 
 ;;; ================================================================
 ;;; sr algorithm (sm-5)
@@ -169,10 +163,9 @@
 
 (defn next-interval
   "return [next-interval repeats next-ef of-matrix]"
-  [last-interval repeats ef quality of-matrix]
+  [_last-interval repeats ef quality of-matrix]
   (assert (and (<= quality 5) (>= quality 0)))
   (let [ef (or ef 2.5)
-        last-interval (if (or (nil? last-interval) (<= last-interval 0)) 1 last-interval)
         next-ef (next-ef ef quality)
         next-of-matrix (next-of-matrix of-matrix repeats quality (learning-fraction) ef)
         next-interval (interval repeats next-ef next-of-matrix)]
@@ -215,9 +208,9 @@
 
 (deftype Sided-Cloze-Card [block]
   ICard
-  (get-root-block [this] (db/pull [:block/uuid (:block/uuid block)]))
+  (get-root-block [_this] (db/pull [:block/uuid (:block/uuid block)]))
   ICardShow
-  (show-cycle [this phase]
+  (show-cycle [_this phase]
     (let [blocks (-> (db/get-block-and-children (state/get-current-repo) (:block/uuid block))
                      clear-collapsed-property)
           cloze? (has-cloze? blocks)]
@@ -230,7 +223,7 @@
         3
         {:value blocks :next-phase 1})))
 
-  (show-cycle-config [this phase]
+  (show-cycle-config [_this phase]
     (case phase
       1
       {}
@@ -254,28 +247,28 @@
   ([repo query-string {:keys [disable-reactive? use-cache?]
                        :or {use-cache? true}}]
    (when (string? query-string)
-     (let [query-string (template/resolve-dynamic-template! query-string)]
-       (let [{:keys [query sort-by] :as result} (query-dsl/parse repo query-string)]
-         (let [query* (concat [['?b :block/refs [:block/name card-hash-tag]]]
-                              (if (coll? (first query))
-                                query
-                                [query]))]
-           (when-let [query (query-dsl/query-wrapper query* true)]
-             (let [result (react/react-query repo
-                                             {:query query}
-                                             (merge
-                                              {:use-cache? use-cache?}
-                                              (cond->
-                                                (when sort-by
-                                                  {:transform-fn sort-by})
-                                                disable-reactive?
-                                                (assoc :disable-reactive? true))))]
-               (when result
-                 (flatten (util/react result)))))))))))
+     (let [query-string (template/resolve-dynamic-template! query-string)
+           {:keys [query sort-by]} (query-dsl/parse repo query-string)
+           query* (concat [['?b :block/refs [:block/name card-hash-tag]]]
+                          (if (coll? (first query))
+                            query
+                            [query]))]
+       (when-let [query (query-dsl/query-wrapper query* true)]
+         (let [result (react/react-query repo
+                                         {:query query}
+                                         (merge
+                                          {:use-cache? use-cache?}
+                                          (cond->
+                                           (when sort-by
+                                             {:transform-fn sort-by})
+                                           disable-reactive?
+                                           (assoc :disable-reactive? true))))]
+           (when result
+             (flatten (util/react result)))))))))
 
 (defn- query-scheduled
   "Return blocks scheduled to 'time' or before"
-  [repo blocks time]
+  [_repo blocks time]
   (let [filtered-result (filterv (fn [b]
                                    (let [props (:block/properties b)
                                          next-sched (get props card-next-schedule-property)
@@ -303,19 +296,19 @@
         props (get-block-card-properties block)
         last-interval (or (util/safe-parse-float (get props card-last-interval-property)) 0)
         repeats (or (util/safe-parse-int (get props card-repeats-property)) 0)
-        last-ef (or (util/safe-parse-float (get props card-last-easiness-factor-property)) 2.5)]
-    (let [[next-interval next-repeats next-ef of-matrix*]
-          (next-interval last-interval repeats last-ef score @of-matrix)
-          next-interval* (if (< next-interval 0) 0 next-interval)
-          next-schedule (tc/to-string (t/plus (tl/local-now) (t/hours (* 24 next-interval*))))
-          now (tc/to-string (tl/local-now))]
-      {:next-of-matrix of-matrix*
-       card-last-interval-property next-interval
-       card-repeats-property next-repeats
-       card-last-easiness-factor-property next-ef
-       card-next-schedule-property next-schedule
-       card-last-reviewed-property now
-       card-last-score-property score})))
+        last-ef (or (util/safe-parse-float (get props card-last-easiness-factor-property)) 2.5)
+        [next-interval next-repeats next-ef of-matrix*]
+        (next-interval last-interval repeats last-ef score @of-matrix)
+        next-interval* (if (< next-interval 0) 0 next-interval)
+        next-schedule (tc/to-string (t/plus (tl/local-now) (t/hours (* 24 next-interval*))))
+        now (tc/to-string (tl/local-now))]
+    {:next-of-matrix of-matrix*
+     card-last-interval-property next-interval
+     card-repeats-property next-repeats
+     card-last-easiness-factor-property next-ef
+     card-next-schedule-property next-schedule
+     card-last-reviewed-property now
+     card-last-score-property score}))
 
 (defn- operation-score!
   [card score]
@@ -346,12 +339,7 @@
     (let [review-count (count (flatten (vals review-records)))
           review-cards-count (count review-cards)
           score-5-count (count (get review-records 5))
-          score-4-count (count (get review-records 4))
-          score-3-count (count (get review-records 3))
-          score-2-count (count (get review-records 2))
-          score-1-count (count (get review-records 1))
-          score-0-count (count (get review-records 0))
-          skip-count (count (get review-records "skip"))]
+          score-1-count (count (get review-records 1))]
       (editor-handler/paste-block-tree-after-target
        (:db/id card-query-block) false
        [{:content (util/format "Summary: %d items, %d review counts [[%s]]"
@@ -365,25 +353,6 @@
 ;;; ================================================================
 ;;; UI
 
-(defn- score-help-info [days-3 days-4 days-5]
-  (ui/tippy {:html [:div
-                    [:p.text-sm "0-2: you have forgotten this card."]
-                    [:p.text-sm "3-5: you remember this card."]
-                    [:p.text-sm "0: completely forgot."]
-                    [:p.text-sm "1: it still takes a while to recall even after seeing the answer."]
-                    [:p.text-sm "2: immediately recall after seeing the answer."]
-                    [:p.text-sm
-                     (util/format "3: it takes a while to recall. (will reappear after %d days)" days-3)]
-                    [:p.text-sm
-                     (util/format "4: you recall this after a little thought. (will reappear after %d days)"
-                                  days-4)]
-                    [:p.text-sm
-                     (util/format "5: you remember it easily. (will reappear after %d days)" days-5)]]
-             :class "tippy-hover"
-             :interactive true
-             :disabled false}
-            (svg/info)))
-
 (defn- dec-cards-due-count!
   []
   (state/update-state! :srs/cards-due-count
@@ -397,9 +366,8 @@
   (swap! *review-records #(update % score (fn [ov] (conj ov card))))
   (if (>= (inc @*card-index) (count cards))
     (when cb
-      (do
-        (swap! *card-index inc)
-        (cb @*review-records)))
+      (swap! *card-index inc)
+      (cb @*review-records))
     (do
       (swap! *card-index inc)
       (reset! *phase 1)))
@@ -438,7 +406,6 @@
                    state)}
   [state blocks {preview? :preview?
                  modal? :modal?
-                 global? :global?
                  cb :callback}
    card-index]
   (let [cards (map ->card blocks)
@@ -482,29 +449,26 @@
                  :on-click #(skip-card card card-index cards phase review-records cb)))
 
              (when (and (not preview?) (= 1 next-phase))
-               (let [interval-days-score-3 (get (get-next-interval card 3) card-last-interval-property)
-                     interval-days-score-4 (get (get-next-interval card 5) card-last-interval-property)
-                     interval-days-score-5 (get (get-next-interval card 5) card-last-interval-property)]
-                 [:div.flex.flex-row.justify-between
-                  (btn-with-shortcut {:btn-text   "Forgotten"
-                                      :shortcut   "f"
-                                      :id         "card-forgotten"
-                                      :background "red"
-                                      :on-click   (fn []
-                                                    (score-and-next-card 1 card card-index cards phase review-records cb)
-                                                    (let [tomorrow (tc/to-string (t/plus (t/today) (t/days 1)))]
-                                                      (editor-handler/set-block-property! root-block-id card-next-schedule-property tomorrow)))})
-
-                  (btn-with-shortcut {:btn-text (if (util/mobile?) "Hard" "Took a while to recall")
-                                      :shortcut "t"
-                                      :id       "card-recall"
-                                      :on-click #(score-and-next-card 3 card card-index cards phase review-records cb)})
-
-                  (btn-with-shortcut {:btn-text   "Remembered"
-                                      :shortcut   "r"
-                                      :id         "card-remembered"
-                                      :background "green"
-                                      :on-click   #(score-and-next-card 5 card card-index cards phase review-records cb)})]))]
+               [:div.flex.flex-row.justify-between
+                (btn-with-shortcut {:btn-text   "Forgotten"
+                                    :shortcut   "f"
+                                    :id         "card-forgotten"
+                                    :background "red"
+                                    :on-click   (fn []
+                                                  (score-and-next-card 1 card card-index cards phase review-records cb)
+                                                  (let [tomorrow (tc/to-string (t/plus (t/today) (t/days 1)))]
+                                                    (editor-handler/set-block-property! root-block-id card-next-schedule-property tomorrow)))})
+
+                (btn-with-shortcut {:btn-text (if (util/mobile?) "Hard" "Took a while to recall")
+                                    :shortcut "t"
+                                    :id       "card-recall"
+                                    :on-click #(score-and-next-card 3 card card-index cards phase review-records cb)})
+
+                (btn-with-shortcut {:btn-text   "Remembered"
+                                    :shortcut   "r"
+                                    :id         "card-remembered"
+                                    :background "green"
+                                    :on-click   #(score-and-next-card 5 card card-index cards phase review-records cb)})])]
 
             (when preview?
               (ui/tippy {:html [:div.text-sm
@@ -569,7 +533,7 @@
 (rum/defcs cards
   < rum/reactive
   {:will-mount (fn [state]
-                 (let [[config options] (:rum/args state)
+                 (let [[_config options] (:rum/args state)
                        repo (state/get-current-repo)
                        query-string (string/join ", " (:arguments options))
                        blocks (query repo query-string)]
@@ -577,7 +541,7 @@
                           :query-string query-string
                           :query-result blocks)))}
   (rum/local 0 ::card-index)
-  [state config options]
+  [state config _options]
   (let [repo (state/get-current-repo)
         query-string (:query-string state)
         card-index (::card-index state)

+ 2 - 2
src/main/frontend/extensions/video/youtube.cljs

@@ -1,6 +1,6 @@
 (ns frontend.extensions.video.youtube
   (:require [rum.core :as rum]
-            [cljs.core.async :refer [<! >! chan go go-loop] :as a]
+            [cljs.core.async :refer [<! chan go] :as a]
             [frontend.components.svg :as svg]
             [frontend.state :as state]
             [frontend.util :as util]
@@ -32,7 +32,7 @@
                 (rum/dom-node state)
                 (clj->js
                  {:events
-                  {"onReady" (fn [e] (js/console.log id " ready"))}}))]
+                  {"onReady" (fn [_e] (js/console.log id " ready"))}}))]
     (state/update-state! [:youtube/players]
                          (fn [players]
                            (assoc players id player)))))

+ 16 - 17
src/main/frontend/extensions/zotero.cljs

@@ -20,22 +20,21 @@
 (def debounce-chan-mult (a/mult (api/debounce term-chan 500)))
 
 (rum/defc zotero-search-item [{:keys [data] :as item} id]
-  (let [[is-creating-page set-is-creating-page!] (rum/use-state false)]
-    (let [title (:title data)
-          type (:item-type data)
-          abstract (str (subs (:abstract-note data) 0 200) "...")]
-
-      [:div.zotero-search-item.px-2.py-4.border-b.cursor-pointer.border-solid.last:border-none.relative
-       {:on-click (fn [] (go
-                           (set-is-creating-page! true)
-                           (<!
-                            (zotero-handler/create-zotero-page item {:block-dom-id id}))
-                           (set-is-creating-page! false)))}
-       [[:div [[:span.font-bold.mb-1.mr-1 title]
-               [:span.zotero-search-item-type.text-xs.p-1.rounded type]]]
-        [:div.text-sm abstract]]
-
-       (when is-creating-page [:div.zotero-search-item-loading-indicator [:span.animate-spin-reverse  svg/refresh]])])))
+  (let [[is-creating-page set-is-creating-page!] (rum/use-state false)
+        title (:title data)
+        type (:item-type data)
+        abstract (str (subs (:abstract-note data) 0 200) "...")]
+    [:div.zotero-search-item.px-2.py-4.border-b.cursor-pointer.border-solid.last:border-none.relative
+     {:on-click (fn [] (go
+                        (set-is-creating-page! true)
+                        (<!
+                         (zotero-handler/create-zotero-page item {:block-dom-id id}))
+                        (set-is-creating-page! false)))}
+     [[:div [[:span.font-bold.mb-1.mr-1 title]
+             [:span.zotero-search-item-type.text-xs.p-1.rounded type]]]
+      [:div.text-sm abstract]]
+
+     (when is-creating-page [:div.zotero-search-item-loading-indicator [:span.animate-spin-reverse  svg/refresh]])]))
 
 (rum/defc zotero-search
   [id]
@@ -446,7 +445,7 @@
   (rum/local (setting/profile) ::profile)
   rum/reactive
   {:should-update
-   (fn [old-state new-state]
+   (fn [old-state _new-state]
      (let [all-profiles (setting/all-profiles)]
        (not= all-profiles @(::all-profiles old-state))))}
   [state]

+ 1 - 2
src/main/frontend/extensions/zotero/handler.cljs

@@ -64,8 +64,7 @@
   ([item]
    (create-zotero-page item {}))
   ([item {:keys [block-dom-id insert-command? notification?]
-          :or {insert-command? true notification? true}
-          :as opt}]
+          :or {insert-command? true notification? true}}]
    (go
      (let [{:keys [page-name properties abstract-note]} (extractor/extract item)]
 

+ 48 - 42
src/main/frontend/external/roam.cljc

@@ -1,19 +1,21 @@
 (ns frontend.external.roam
   (:require #?(:cljs [cljs-bean.core :as bean]
                :clj [cheshire.core :as json])
-            #?(:cljs ["/frontend/utils" :as utils])
+            ;; TODO: clj-kondo incorrectly thinks these requires are unused
+            #_:clj-kondo/ignore
             [frontend.external.protocol :as protocol]
+            #_:clj-kondo/ignore
+            [frontend.date :as date]
             [medley.core :as medley]
             [clojure.walk :as walk]
             [clojure.string :as string]
             [frontend.util :as util]
-            [frontend.text :as text]
-            [frontend.date :as date]))
+            [frontend.text :as text]))
 
 (defonce all-refed-uids (atom #{}))
 (defonce uid->uuid (atom {}))
 
-(defn- reset-state!
+(defn reset-state!
   []
   (reset! all-refed-uids #{})
   (reset! uid->uuid {}))
@@ -39,6 +41,8 @@
   (string/replace text macro-pattern (fn [[original text]]
                                        (let [[name arg] (util/split-first ":" text)]
                                          (if name
+                                           ;; TODO: Why unresolved var
+                                           #_:clj-kondo/ignore
                                            (let [name (text/page-ref-un-brackets! name)]
                                              (util/format "{{%s %s}}" name arg))
                                            original)))))
@@ -75,7 +79,7 @@
 
 (declare children->text)
 (defn child->text
-  [{:keys [uid string children] :as child} level]
+  [{:keys [uid string children]} level]
   (when-not (and (get @uid->uuid uid) uid)
     (swap! uid->uuid assoc uid (medley/random-uuid)))
   (let [children-text (children->text children (inc level))
@@ -98,48 +102,50 @@
        (interpose "\n")
        (apply str)))
 
-(defn ->file
-  [page-data]
-  (let [{:keys [create-time title children edit-time]} page-data
-        initial-level 1
-        text (when (seq children)
-               (when-let [text (children->text children (dec initial-level))]
-                 (let [journal? (date/valid-journal-title? title)
-                       front-matter (if journal?
-                                      ""
-                                      (util/format "---\ntitle: %s\n---\n\n" title))]
-                   (str front-matter (transform text)))))]
-    (when (and (not (string/blank? title))
-               text)
-      {:title title
-       :created-at create-time
-       :last-modified-at edit-time
-       :text text})))
-
-(defn ->files
-  [edn-data]
-  (load-all-refed-uids! edn-data)
-  (let [files (map ->file edn-data)
-        files (remove #(nil? (:title %)) files)
-        files (group-by (fn [f] (string/lower-case (:title f)))
-                        files)]
-    (map
-     (fn [[_ [fst & others]]]
-       (assoc fst :text
-              (->> (map :text (cons fst others))
-                   (interpose "\n")
-                   (apply str))))
-     files)))
-
 (defn json->edn
   [raw-string]
   #?(:cljs (-> raw-string js/JSON.parse bean/->clj)
      :clj (-> raw-string json/parse-string clojure.walk/keywordize-keys)))
 
-(defrecord Roam []
-  protocol/External
-  (toMarkdownFiles [this content _config]
-    (-> content json->edn ->files)))
+#?(:cljs
+   (do
+     (defn ->file
+      [page-data]
+      (let [{:keys [create-time title children edit-time]} page-data
+            initial-level 1
+            text (when (seq children)
+                   (when-let [text (children->text children (dec initial-level))]
+                     (let [journal? (date/valid-journal-title? title)
+                           front-matter (if journal?
+                                          ""
+                                          (util/format "---\ntitle: %s\n---\n\n" title))]
+                       (str front-matter (transform text)))))]
+        (when (and (not (string/blank? title))
+                   text)
+          {:title title
+           :created-at create-time
+           :last-modified-at edit-time
+           :text text})))
+
+     (defn ->files
+       [edn-data]
+       (load-all-refed-uids! edn-data)
+       (let [files (map ->file edn-data)
+             files (remove #(nil? (:title %)) files)
+             files (group-by (fn [f] (string/lower-case (:title f)))
+                             files)]
+         (map
+          (fn [[_ [fst & others]]]
+            (assoc fst :text
+                   (->> (map :text (cons fst others))
+                        (interpose "\n")
+                        (apply str))))
+          files)))
+
+     (defrecord Roam []
+       protocol/External
+       (toMarkdownFiles [_this content _config]
+                        (-> content json->edn ->files)))))
 
 (comment
   (defonce test-roam-json (frontend.db/get-file "same.json"))

+ 7 - 11
src/main/frontend/format/adoc.cljs

@@ -5,15 +5,11 @@
 (defn loaded? []
   js/window.Asciidoctor)
 
-(defn ->edn
-  [content config]
-  nil)
-
 (defrecord AdocMode []
   protocol/Format
-  (toEdn [this content config]
-    (->edn content config))
-  (toHtml [this content config references]
+  (toEdn [_this _content _config]
+    nil)
+  (toHtml [_this content _config _references]
     (when (loaded?)
       (let [config {:attributes {:showTitle false
                                  :hardbreaks true
@@ -21,13 +17,13 @@
                                  ;; :source-highlighter "pygments"
                                  }}]
         (.convert (js/window.Asciidoctor) content (clj->js config)))))
-  (loaded? [this]
+  (loaded? [_this]
     (some? (loaded?)))
-  (lazyLoad [this ok-handler]
+  (lazyLoad [_this ok-handler]
     (loader/load
      "https://cdnjs.cloudflare.com/ajax/libs/asciidoctor.js/1.5.9/asciidoctor.min.js"
      ok-handler))
-  (exportMarkdown [this content config references]
+  (exportMarkdown [_this _content _config _references]
     (throw "not support"))
-  (exportOPML [this content config title references]
+  (exportOPML [_this _content _config _title _references]
     (throw "not support")))

+ 44 - 43
src/main/frontend/format/block.cljs

@@ -176,7 +176,6 @@
   [properties]
   (when (seq properties)
     (let [properties (seq properties)
-          properties-order (keys properties)
           page-refs (->>
                      properties
                      (remove (fn [[k _]]
@@ -274,7 +273,7 @@
              {:block/name page-name
               :block/original-name original-page-name}
              (when with-id?
-               (if-let [block (db/entity [:block/name page-name])]
+               (if (db/entity [:block/name page-name])
                  {}
                  {:block/uuid (db/new-block-id)}))
              (when namespace?
@@ -437,16 +436,15 @@
                                       end-pos)
                       (utf8/substring utf8-content
                                       (:start-pos meta))))
-        content-orig content]
-    (let [content (when content
-                    (let [content (text/remove-level-spaces content format)]
-                      (if (or (:pre-block? block)
-                              (= (:format block) :org))
-                        content
-                        (text/remove-indentation-spaces content (inc (:level block)) false))))]
-      (if (= format :org)
-        content
-        (property/->new-properties content)))))
+        content (when content
+                  (let [content (text/remove-level-spaces content format)]
+                    (if (or (:pre-block? block)
+                            (= (:format block) :org))
+                      content
+                      (text/remove-indentation-spaces content (inc (:level block)) false))))]
+    (if (= format :org)
+      content
+      (property/->new-properties content))))
 
 (defn- remove-indentations
   [format level element]
@@ -500,6 +498,36 @@
           block-tags->pages
           (update :refs (fn [col] (remove nil? col)))))
 
+(defn extract-blocks*
+  [blocks pre-block-body pre-block-properties encoded-content]
+  (let [first-block (first blocks)
+        first-block-start-pos (get-in first-block [:block/meta :start-pos])
+        blocks (if (or (seq @pre-block-body)
+                       (seq @pre-block-properties))
+                 (cons
+                  (merge
+                   (let [content (utf8/substring encoded-content 0 first-block-start-pos)
+                         id (get-custom-id-or-new-id {:properties @pre-block-properties})
+                         block {:uuid id
+                                :content content
+                                :level 1
+                                :meta {:start-pos 0
+                                       :end-pos (or first-block-start-pos
+                                                    (utf8/length encoded-content))}
+                                :body @pre-block-body
+                                :properties @pre-block-properties
+                                :properties-order (keys @pre-block-properties)
+                                :refs (get-page-refs-from-properties @pre-block-properties)
+                                :pre-block? true
+                                :unordered true}
+                         block (with-page-block-refs block false)]
+                     (block-keywordize block))
+                   (select-keys first-block [:block/format :block/page]))
+                  blocks)
+                 blocks)
+        blocks (map (fn [block] (dissoc block :block/anchor)) blocks)]
+    (with-path-refs blocks)))
+
 (defn extract-blocks
   [blocks content with-id? format]
   (try
@@ -518,7 +546,7 @@
                  children []
                  block-all-content []]
             (if (seq blocks)
-              (let [[block {:keys [start_pos end_pos] :as block-content}] (first blocks)
+              (let [[block {:keys [start_pos _end_pos] :as block-content}] (first blocks)
                     block-content (when (string? block-content) block-content)
                     unordered? (:unordered (second block))
                     markdown-heading? (and (:size (second block)) (= :markdown format))]
@@ -609,33 +637,7 @@
                     (reset! pre-block-properties properties)))
                 (-> (reverse headings)
                     safe-blocks))))]
-      (let [first-block (first blocks)
-            first-block-start-pos (get-in first-block [:block/meta :start-pos])
-            blocks (if (or (seq @pre-block-body)
-                           (seq @pre-block-properties))
-                     (cons
-                      (merge
-                       (let [content (utf8/substring encoded-content 0 first-block-start-pos)
-                             id (get-custom-id-or-new-id {:properties @pre-block-properties})
-                             block {:uuid id
-                                    :content content
-                                    :level 1
-                                    :meta {:start-pos 0
-                                           :end-pos (or first-block-start-pos
-                                                        (utf8/length encoded-content))}
-                                    :body @pre-block-body
-                                    :properties @pre-block-properties
-                                    :properties-order (keys @pre-block-properties)
-                                    :refs (get-page-refs-from-properties @pre-block-properties)
-                                    :pre-block? true
-                                    :unordered true}
-                             block (with-page-block-refs block false)]
-                         (block-keywordize block))
-                       (select-keys first-block [:block/format :block/page]))
-                      blocks)
-                     blocks)
-            blocks (map (fn [block] (dissoc block :block/anchor)) blocks)]
-        (with-path-refs blocks)))
+      (extract-blocks* blocks pre-block-body pre-block-properties encoded-content))
     (catch js/Error e
       (js/console.error "extract-blocks-failed")
       (log/error :exception e))))
@@ -646,13 +648,13 @@
          parents [{:page/id page-id     ; db id or a map {:block/name "xxx"}
                    :block/level 0
                    :block/level-spaces 0}]
-         sibling nil
+         _sibling nil
          result []]
     (if (empty? blocks)
       (map #(dissoc % :block/level-spaces) result)
       (let [[block & others] blocks
             level-spaces (:block/level-spaces block)
-            {:block/keys [uuid level parent unordered] :as last-parent} (last parents)
+            {:block/keys [uuid level parent] :as last-parent} (last parents)
             parent-spaces (:block/level-spaces last-parent)
             [blocks parents sibling result]
             (cond
@@ -696,7 +698,6 @@
                 :else
                 (let [[f r] (split-with (fn [p] (<= (:block/level-spaces p) level-spaces)) parents)
                       left (first r)
-                      parents' (->> (concat f [left]) vec)
                       parent-id (if-let [block-id (:block/uuid (last f))]
                                   [:block/uuid block-id]
                                   page-id)

+ 13 - 12
src/main/frontend/format/mldoc.cljs

@@ -90,6 +90,8 @@
                      (or references default-references)))
 
 ;; Org-roam
+;; TODO: recur is in wrong place. Unclear what the intent is but likely a bug
+#_:clj-kondo/ignore
 (defn get-tags-from-definition
   [ast]
   (loop [ast ast]
@@ -162,11 +164,10 @@
                    (->>
                     (map
                      (fn [[_ v]]
-                       (do
-                         (let [[k v] (util/split-first " " v)]
-                          (mapv
-                           string/trim
-                           [k v]))))
+                       (let [[k v] (util/split-first " " v)]
+                         (mapv
+                          string/trim
+                          [k v])))
                      macro-properties)
                     (into {}))
                    {})
@@ -200,7 +201,7 @@
                          (update :roam_alias ->vec)
                          (update :roam_tags (constantly roam-tags))
                          (update :filetags (constantly filetags)))
-          properties (medley/filter-kv (fn [k v] (not (empty? v))) properties)
+          properties (medley/filter-kv (fn [_k v] (seq v)) properties)
           properties (medley/map-vals util/unquote-string-if-wrapped properties)]
       (if (seq properties)
         (cons [["Properties" properties] nil] other-ast)
@@ -292,17 +293,17 @@
 
 (defrecord MldocMode []
   protocol/Format
-  (toEdn [this content config]
+  (toEdn [_this content config]
     (->edn content config))
-  (toHtml [this content config references]
+  (toHtml [_this content config references]
     (export "html" content config references))
-  (loaded? [this]
+  (loaded? [_this]
     true)
-  (lazyLoad [this ok-handler]
+  (lazyLoad [_this _ok-handler]
     true)
-  (exportMarkdown [this content config references]
+  (exportMarkdown [_this content config references]
     (parse-export-markdown content config references))
-  (exportOPML [this content config title references]
+  (exportOPML [_this content config title references]
     (parse-export-opml content config title references)))
 
 (defn plain->text

+ 11 - 11
src/main/frontend/fs/bfs.cljs

@@ -5,34 +5,34 @@
 
 (defrecord Bfs []
   protocol/Fs
-  (mkdir! [this dir]
+  (mkdir! [_this dir]
     (when (and js/window.pfs (not (util/electron?)))
       (->
        (js/window.pfs.mkdir dir)
        (p/catch (fn [error] (println "Mkdir error: " error))))))
-  (readdir [this dir]
+  (readdir [_this dir]
     (when js/window.pfs
       (js/window.pfs.readdir dir)))
-  (unlink! [this repo path opts]
+  (unlink! [_this _repo path opts]
     (when js/window.pfs
       (p/let [stat (js/window.pfs.stat path)]
         (if (= (.-type stat) "file")
           (js/window.pfs.unlink path opts)
           (p/rejected "Unlinking a directory is not allowed")))))
-  (rmdir! [this dir]
+  (rmdir! [_this dir]
     (js/window.workerThread.rimraf dir))
-  (read-file [this dir path options]
+  (read-file [_this dir path options]
     (js/window.pfs.readFile (str dir "/" path) (clj->js options)))
-  (write-file! [this repo dir path content opts]
+  (write-file! [_this _repo dir path content _opts]
     (when-not (util/electron?)
       (js/window.pfs.writeFile (str dir "/" path) content)))
-  (rename! [this repo old-path new-path]
+  (rename! [_this _repo old-path new-path]
     (js/window.pfs.rename old-path new-path))
-  (stat [this dir path]
+  (stat [_this dir path]
     (js/window.pfs.stat (str dir path)))
-  (open-dir [this ok-handler]
+  (open-dir [_this _ok-handler]
     nil)
-  (get-files [this path-or-handle ok-handler]
+  (get-files [_this _path-or-handle _ok-handler]
     nil)
-  (watch-dir! [this dir]
+  (watch-dir! [_this _dir]
     nil))

+ 21 - 24
src/main/frontend/fs/capacitor_fs.cljs

@@ -1,21 +1,18 @@
 (ns frontend.fs.capacitor-fs
   (:require [frontend.fs.protocol :as protocol]
             [lambdaisland.glogi :as log]
-            [cljs.core.async :as a]
-            [cljs.core.async.interop :refer [<p!]]
             [frontend.util :as futil]
             [frontend.config :as config]
             [cljs-bean.core :as bean]
-            ["@capacitor/filesystem" :refer [Filesystem Directory Encoding]]
-            [frontend.mobile.util :as util]
+            ["@capacitor/filesystem" :refer [Filesystem Encoding]]
             [promesa.core :as p]
             [clojure.string :as string]
             [frontend.mobile.util :as mobile-util]))
 
-(when (util/native-ios?)
+(when (mobile-util/native-ios?)
   (defn iOS-ensure-documents!
     []
-    (.ensureDocuments util/ios-file-container)))
+    (.ensureDocuments mobile-util/ios-file-container)))
 
 (defn check-permission-android []
   (p/let [permission (.checkPermissions Filesystem)
@@ -98,7 +95,7 @@
 
 (defrecord Capacitorfs []
   protocol/Fs
-  (mkdir! [this dir]
+  (mkdir! [_this dir]
     (p/let [result (.mkdir Filesystem
                            (clj->js
                             {:path dir
@@ -106,7 +103,7 @@
                              }))]
       (js/console.log result)
       result))
-  (mkdir-recur! [this dir]
+  (mkdir-recur! [_this dir]
     (p/let [result (.mkdir Filesystem
                            (clj->js
                             {:path dir
@@ -114,14 +111,14 @@
                              :recursive true}))]
       (js/console.log result)
       result))
-  (readdir [this dir]                   ; recursive
+  (readdir [_this dir]                   ; recursive
     (readdir dir))
-  (unlink! [this repo path _opts]
+  (unlink! [_this _repo _path _opts]
     nil)
-  (rmdir! [this dir]
+  (rmdir! [_this _dir]
     ;; Too dangerious!!! We'll never implement this.
     nil)
-  (read-file [this dir path _options]
+  (read-file [_this dir path _options]
     (let [path (str dir path)
           path (if (or (string/starts-with? path "file:")
                        (string/starts-with? path "content:"))
@@ -136,9 +133,9 @@
          content)
        (p/catch (fn [error]
                   (js/alert error))))))
-  (delete-file! [this repo dir path {:keys [ok-handler error-handler] :as opts}]
+  (delete-file! [_this repo dir path {:keys [ok-handler error-handler]}]
     (let [path (cond
-                 (= (util/platform) "ios")
+                 (= (mobile-util/platform) "ios")
                  (js/encodeURI (js/decodeURI path))
 
                  (string/starts-with? path (config/get-repo-dir repo))
@@ -157,9 +154,9 @@
          (if error-handler
            (error-handler error)
            (log/error :delete-file-failed error))))))
-  (write-file! [this repo dir path content {:keys [ok-handler error-handler] :as opts}]
+  (write-file! [_this repo dir path content {:keys [ok-handler error-handler]}]
     (let [path (cond
-                 (= (util/platform) "ios")
+                 (= (mobile-util/platform) "ios")
                  (js/encodeURI (js/decodeURI path))
 
                  (string/starts-with? path (config/get-repo-dir repo))
@@ -181,28 +178,28 @@
             (if error-handler
               (error-handler error)
               (log/error :write-file-failed error))))))
-  (rename! [this repo old-path new-path]
+  (rename! [_this _repo _old-path _new-path]
     nil)
-  (stat [this dir path]
+  (stat [_this dir path]
     (let [path (str dir path)]
       (p/let [result (.stat Filesystem (clj->js
                                         {:path path
                                          ;; :directory (.-ExternalStorage Directory)
                                          }))]
         result)))
-  (open-dir [this ok-handler]
-    (p/let [_    (when (= (util/platform) "android") (check-permission-android))
+  (open-dir [_this _ok-handler]
+    (p/let [_    (when (= (mobile-util/platform) "android") (check-permission-android))
             path (p/chain
-                  (.pickFolder util/folder-picker)
+                  (.pickFolder mobile-util/folder-picker)
                   #(js->clj % :keywordize-keys true)
                   :path)
-            _ (when (util/native-ios?) (.downloadFilesFromiCloud util/download-icloud-files))
+            _ (when (mobile-util/native-ios?) (.downloadFilesFromiCloud mobile-util/download-icloud-files))
             files (readdir path)
             files (js->clj files :keywordize-keys true)]
       (into [] (concat [{:path path}] files))))
-  (get-files [this path-or-handle _ok-handler]
+  (get-files [_this path-or-handle _ok-handler]
     (readdir path-or-handle))
-  (watch-dir! [this dir]
+  (watch-dir! [_this _dir]
     nil))
 
 

+ 12 - 15
src/main/frontend/fs/nfs.cljs

@@ -65,7 +65,7 @@
 
 (defrecord Nfs []
   protocol/Fs
-  (mkdir! [this dir]
+  (mkdir! [_this dir]
     (let [parts (->> (string/split dir "/")
                      (remove string/blank?))
           root (->> (butlast parts)
@@ -87,7 +87,7 @@
                   (js/console.debug "mkdir error: " error ", dir: " dir)
                   (throw error))))))
 
-  (readdir [this dir]
+  (readdir [_this dir]
     (let [prefix (str "handle/" dir)
           cached-files (keys @nfs-file-handles-cache)]
       (p/resolved
@@ -95,7 +95,7 @@
             (map (fn [path]
                    (string/replace path prefix "")))))))
 
-  (unlink! [this repo path opts]
+  (unlink! [this repo path _opts]
     (let [[dir basename] (util/get-dir-and-basename path)
           handle-path (str "handle" path)]
       (->
@@ -121,19 +121,18 @@
                   (log/error :unlink/path {:path path
                                            :error error}))))))
 
-  (rmdir! [this dir]
+  (rmdir! [_this _dir]
     ;; TOO dangerious, we should never implement this
     nil)
 
-  (read-file [this dir path options]
+  (read-file [_this dir path _options]
     (let [handle-path (str "handle" dir "/" path)]
       (p/let [handle (idb/get-item handle-path)
               local-file (and handle (.getFile handle))]
         (and local-file (.text local-file)))))
 
-  (write-file! [this repo dir path content opts]
-    (let [last-modified-at (db/get-file-last-modified-at repo path)
-          parts (string/split path "/")
+  (write-file! [_this repo dir path content opts]
+    (let [parts (string/split path "/")
           basename (last parts)
           sub-dir (->> (butlast parts)
                        (remove string/blank?)
@@ -212,9 +211,7 @@
                         (js/console.error error)))))))))
 
   (rename! [this repo old-path new-path]
-    (p/let [[dir basename] (util/get-dir-and-basename old-path)
-            [_ new-basename] (util/get-dir-and-basename new-path)
-            parts (->> (string/split new-path "/")
+    (p/let [parts (->> (string/split new-path "/")
                        (remove string/blank?))
             dir (str "/" (first parts))
             new-path (->> (rest parts)
@@ -224,7 +221,7 @@
             content (.text file)
             _ (protocol/write-file! this repo dir new-path content nil)]
       (protocol/unlink! this repo old-path nil)))
-  (stat [this dir path]
+  (stat [_this dir path]
     (if-let [file (get-nfs-file-handle (str "handle/"
                                             (string/replace-first dir "/" "")
                                             path))]
@@ -234,12 +231,12 @@
            :file/size (get-attr "size")
            :file/type (get-attr "type")}))
       (p/rejected "File not exists")))
-  (open-dir [this ok-handler]
+  (open-dir [_this ok-handler]
     (utils/openDirectory #js {:recursive true}
                          ok-handler))
-  (get-files [this path-or-handle ok-handler]
+  (get-files [_this path-or-handle ok-handler]
     (utils/getFiles path-or-handle true ok-handler))
 
   ;; TODO:
-  (watch-dir! [this dir]
+  (watch-dir! [_this _dir]
     nil))

+ 13 - 15
src/main/frontend/fs/node.cljs

@@ -35,7 +35,7 @@
       (p/resolved (= (string/trim disk-content) (string/trim db-content))))))
 
 (defn- write-file-impl!
-  [this repo dir path content {:keys [ok-handler error-handler old-content skip-compare?] :as opts} stat]
+  [this repo dir path content {:keys [ok-handler error-handler old-content skip-compare?]} stat]
   (if skip-compare?
     (p/catch
         (p/let [result (ipc/ipc "writeFile" repo path content)]
@@ -53,8 +53,6 @@
                                           nil))))
             disk-content (or disk-content "")
             ext (string/lower-case (util/get-file-ext path))
-            file-page (db/get-file-page-id path)
-            page-empty? (and file-page (db/page-empty? repo file-page))
             db-content (or old-content (db/get-file repo path) "")
             contents-matched? (contents-matched? disk-content db-content)
             pending-writes (state/get-write-chan-length)]
@@ -101,23 +99,23 @@
 
 (defrecord Node []
   protocol/Fs
-  (mkdir! [this dir]
+  (mkdir! [_this dir]
     (ipc/ipc "mkdir" dir))
-  (mkdir-recur! [this dir]
+  (mkdir-recur! [_this dir]
     (ipc/ipc "mkdir-recur" dir))
-  (readdir [this dir]                   ; recursive
+  (readdir [_this dir]                   ; recursive
     (ipc/ipc "readdir" dir))
-  (unlink! [this repo path _opts]
+  (unlink! [_this repo path _opts]
     (ipc/ipc "unlink"
              (config/get-repo-dir repo)
              path))
-  (rmdir! [this dir]
+  (rmdir! [_this _dir]
     ;; Too dangerious!!! We'll never implement this.
     nil)
-  (read-file [this dir path _options]
+  (read-file [_this dir path _options]
     (let [path (concat-path dir path)]
       (ipc/ipc "readFile" path)))
-  (write-file! [this repo dir path content {:keys [ok-handler error-handler] :as opts}]
+  (write-file! [this repo dir path content opts]
     (let [path (concat-path dir path)]
       (p/let [stat (p/catch
                        (protocol/stat this dir path)
@@ -125,14 +123,14 @@
               sub-dir (first (util/get-dir-and-basename path))
               _ (protocol/mkdir-recur! this sub-dir)]
         (write-file-impl! this repo dir path content opts stat))))
-  (rename! [this repo old-path new-path]
+  (rename! [_this _repo old-path new-path]
     (ipc/ipc "rename" old-path new-path))
-  (stat [this dir path]
+  (stat [_this dir path]
     (let [path (concat-path dir path)]
       (ipc/ipc "stat" path)))
-  (open-dir [this ok-handler]
+  (open-dir [_this _ok-handler]
     (open-dir))
-  (get-files [this path-or-handle ok-handler]
+  (get-files [_this path-or-handle _ok-handler]
     (ipc/ipc "getFiles" path-or-handle))
-  (watch-dir! [this dir]
+  (watch-dir! [_this dir]
     (ipc/ipc "addDirWatcher" dir)))

+ 1 - 1
src/main/frontend/handler/editor.cljs

@@ -1550,7 +1550,7 @@
                                      true)]
       (commands/restore-state restore-slash-caret-pos?))))
 
-(defn- get-asset-file-link
+(defn get-asset-file-link
   [format url file-name image?]
   (let [pdf? (and url (string/ends-with? url ".pdf"))]
     (case (keyword format)

+ 5 - 6
src/main/frontend/handler/repo.cljs

@@ -261,8 +261,7 @@
         (parse-files-and-create-default-files! repo-url files delete-files delete-blocks file-paths first-clone? db-encrypted? re-render? re-render-opts metadata opts)))))
 
 (defn load-repo-to-db!
-  [repo-url {:keys [first-clone? diffs nfs-files refresh?]
-             :as opts}]
+  [repo-url {:keys [first-clone? diffs nfs-files refresh?]}]
   (spec/validate :repos/url repo-url)
   (when (= :repos (state/get-current-route))
     (route-handler/redirect-to-home!))
@@ -380,9 +379,9 @@
                          result (git/fetch repo-url token)]
                    (let [{:keys [fetchHead]} (bean/->clj result)]
                      (-> (git/merge repo-url)
-                         (p/then (fn [result]
+                         (p/then (fn [_result]
                                    (-> (git/checkout repo-url)
-                                       (p/then (fn [result]
+                                       (p/then (fn [_result]
                                                  (git-handler/set-git-status! repo-url nil)
                                                  (git-handler/set-git-last-pulled-at! repo-url)
                                                  (when (and local-latest-commit fetchHead
@@ -503,7 +502,7 @@
        (do
          (state/set-cloning! true)
          (git/clone repo-url token))
-       (fn [result]
+       (fn [_result]
          (state/set-current-repo! repo-url)
          (db/start-db-conn! (state/get-me) repo-url)
          (db/mark-repo-as-cloned! repo-url))
@@ -603,7 +602,7 @@
   (spec/validate :state/me me)
   (if (and js/window.git js/window.pfs)
     (do
-      (doseq [{:keys [id url]} (:repos me)]
+      (doseq [{:keys [url]} (:repos me)]
         (let [repo url]
           (if (db/cloned? repo)
             (p/do!

+ 1 - 5
src/main/frontend/mobile/core.cljs

@@ -3,12 +3,8 @@
             [frontend.state :as state]
             ["@capacitor/app" :refer [^js App]]
             ["@capacitor/keyboard" :refer [^js Keyboard]]
-            [reitit.frontend.easy :as rfe]
             [clojure.string :as string]
-            [frontend.handler.notification :as notification]
             [frontend.fs.capacitor-fs :as fs]
-            [frontend.handler.page :as page-handler]
-            [frontend.modules.shortcut.core :as shortcut]
             [frontend.components.repo :as repo]
             [frontend.handler.web.nfs :as nfs-handler]))
 
@@ -44,7 +40,7 @@
                   #(state/pub-event! [:mobile/keyboard-will-show]))
     (.addListener Keyboard "keyboardDidShow"
                   #(state/pub-event! [:mobile/keyboard-did-show]))
-    
+
     (.addListener App "appStateChange"
                   #(when-let [repo (state/get-current-repo)]
                      (nfs-handler/refresh! repo repo/refresh-cb)

+ 1 - 1
src/main/frontend/modules/datascript_report/core.cljs

@@ -21,7 +21,7 @@
       r)))
 
 (defn get-blocks-and-pages
-  [{:keys [db-before db-after tx-data tx-meta] :as tx-report}]
+  [{:keys [db-before db-after tx-data tx-meta]}]
   (let [updated-db-ids (-> (mapv first tx-data) (set))
         result (reduce
                 (fn [acc x]

+ 2 - 3
src/main/frontend/modules/editor/undo_redo.cljs

@@ -4,7 +4,6 @@
             [frontend.modules.datascript-report.core :as db-report]
             [frontend.db :as db]
             [frontend.state :as state]
-            [frontend.debug :as debug]
             [frontend.db.outliner :as db-outliner]
             [frontend.modules.outliner.pipeline :as pipelines]))
 
@@ -83,7 +82,7 @@
 (defn get-txs
   [redo? txs]
   (let [txs (if redo? txs (reverse txs))]
-    (mapv (fn [[id attr value tx add? :as datom]]
+    (mapv (fn [[id attr value tx add?]]
             (let [op (cond
                        (and redo? add?) :db/add
                        (and (not redo?) add?) :db/retract
@@ -103,7 +102,7 @@
   [txs]
   (let [conn (conn/get-conn false)
         db-report (d/transact! conn txs)]
-    (do (pipelines/invoke-hooks db-report))))
+    (pipelines/invoke-hooks db-report)))
 
 (defn- refresh!
   [opts]

+ 12 - 14
src/main/frontend/modules/file/core.cljs

@@ -6,7 +6,7 @@
             [frontend.db :as db]
             [frontend.db.utils :as db-utils]
             [frontend.state :as state]
-            [frontend.util :as util :refer [profile]]
+            [frontend.util :as util]
             [frontend.debug :as debug]
             [frontend.format.block :as block]))
 
@@ -26,7 +26,9 @@
          (ffirst body)))))
 
 (defn transform-content
-  [{:block/keys [uuid format properties pre-block? unordered content heading-level left page scheduled deadline parent] :as block} level {:keys [heading-to-list?]}]
+  [{:block/keys [uuid format properties pre-block? unordered content heading-level left page parent]}
+   level
+   {:keys [heading-to-list?]}]
   (let [{:block/keys [title body]} (block/parse-title-and-body uuid format pre-block? content)
         content (or content "")
         heading-with-title? (seq title)
@@ -85,8 +87,7 @@
     content))
 
 (defn tree->file-content
-  [tree {:keys [init-level heading-to-list?]
-         :or {heading-to-list? false}
+  [tree {:keys [init-level]
          :as opts}]
   (loop [block-contents []
          [f & r] tree
@@ -133,16 +134,13 @@
                   (-> (or (:block/original-name page) (:block/name page))
                       (util/page-name-sanity true))) "."
                 (if (= format "markdown") "md" format))
-          file-path (str "/" path)
-          dir (config/get-repo-dir repo)]
-      (let [file-path (config/get-file-path repo path)
-            page-blocks (db/get-page-blocks-no-cache (:block/name page))
-            file {:file/path file-path}
-            tx [{:file/path file-path}
-                {:block/name (:block/name page)
-                 :block/file file}]]
-        (db/transact! tx)
-        (when ok-handler (ok-handler))))))
+          file-path (config/get-file-path repo path)
+          file {:file/path file-path}
+          tx [{:file/path file-path}
+              {:block/name (:block/name page)
+               :block/file file}]]
+      (db/transact! tx)
+      (when ok-handler (ok-handler)))))
 
 (defn save-tree-aux!
   [page-block tree]

+ 1 - 1
src/main/frontend/modules/instrumentation/sentry.cljs

@@ -17,4 +17,4 @@
 (defn init []
   (let [config (clj->js config)
         init-fn (if (util/electron?) Sentry-electron/init Sentry/init)]
-    (Sentry/init config)))
+    (init-fn config)))

+ 2 - 2
src/main/frontend/modules/layout/core.cljs

@@ -5,7 +5,7 @@
 (defonce *movable-containers (atom {}))
 
 (defn- calc-layout-data
-  [^js cnt ^js evt]
+  [^js cnt ^js _evt]
   (.toJSON (.getBoundingClientRect cnt)))
 
 (defn ^:export move-container-to-top
@@ -111,4 +111,4 @@
     ;; manager
     (swap! *movable-containers assoc identity el)
 
-    #(swap! *movable-containers dissoc identity el)))
+    #(swap! *movable-containers dissoc identity el)))

+ 23 - 33
src/main/frontend/modules/outliner/core.cljs

@@ -320,7 +320,7 @@
 (defn- walk-&-insert-nodes
   [loc target-node sibling? transact]
   (let [update-node-fn
-        (fn [node new-node] new-node)]
+        (fn [_node new-node] new-node)]
     (if (zip/end? loc)
       loc
       (if (vector? (zip/node loc))
@@ -351,44 +351,34 @@
       (zip/left result-loc-or-vec)
       result-loc-or-vec)))
 
-(defn- get-node-tree-sub-topmost-last-loc
-  [loc]
-  (let [topmost-last-loc (get-node-tree-topmost-last-loc loc)
-        result-vec-or-nil (zip/right topmost-last-loc)]
-    (when (and (some? result-vec-or-nil)
-               (vector? (zip/node result-vec-or-nil)))
-      (get-node-tree-topmost-last-loc result-vec-or-nil))))
-
 (defn insert-nodes
   "Insert nodes as children(or siblings) of target-node.
   new-nodes-tree is an vector of blocks, e.g [1 [2 3] 4 [5 [6 7]]]"
   [new-nodes-tree target-node sibling?]
   (ds/auto-transact!
    [txs-state (ds/new-outliner-txs-state)] {:outliner-op :insert-nodes}
-   (let [loc (zip/vector-zip new-nodes-tree)]
-     ;; TODO: validate new-nodes-tree structure
-     (let [updated-nodes (walk-&-insert-nodes loc target-node sibling? txs-state)
-           loc (zip/vector-zip (zip/root updated-nodes))
-           ;; topmost-last-loc=4, new-nodes-tree=[1 [2 3] 4 [5 [6 7]]]
-           topmost-last-loc (get-node-tree-topmost-last-loc loc)
-           ;; sub-topmost-last-loc=5, new-nodes-tree=[1 [2 3] 4 [5 [6 7]]]
-           sub-topmost-last-loc (get-node-tree-sub-topmost-last-loc loc)
-           right-node (tree/-get-right target-node)
-           down-node (tree/-get-down target-node)]
-       ;; update node's left&parent after inserted nodes
-       (cond
-         (and (not sibling?) (some? right-node) (nil? down-node))
-         nil            ;ignore
-         (and sibling? (some? right-node) topmost-last-loc) ;; right-node.left=N
-         (let [topmost-last-node (zip/node topmost-last-loc)
-               updated-node (tree/-set-left-id right-node (tree/-get-id topmost-last-node))]
-           (tree/-save updated-node txs-state))
-         (and (not sibling?) (some? down-node) topmost-last-loc) ;; down-node.left=N
-         (let [topmost-last-node (zip/node topmost-last-loc)
-               updated-node (tree/-set-left-id down-node (tree/-get-id topmost-last-node))]
-           (tree/-save updated-node txs-state))
-         (and sibling? (some? down-node)) ;; unchanged
-         nil)))))
+   ;; TODO: validate new-nodes-tree structure
+   (let [loc (zip/vector-zip new-nodes-tree)
+         updated-nodes (walk-&-insert-nodes loc target-node sibling? txs-state)
+         loc (zip/vector-zip (zip/root updated-nodes))
+         ;; topmost-last-loc=4, new-nodes-tree=[1 [2 3] 4 [5 [6 7]]]
+         topmost-last-loc (get-node-tree-topmost-last-loc loc)
+         right-node (tree/-get-right target-node)
+         down-node (tree/-get-down target-node)]
+     ;; update node's left&parent after inserted nodes
+     (cond
+       (and (not sibling?) (some? right-node) (nil? down-node))
+       nil            ;ignore
+       (and sibling? (some? right-node) topmost-last-loc) ;; right-node.left=N
+       (let [topmost-last-node (zip/node topmost-last-loc)
+             updated-node (tree/-set-left-id right-node (tree/-get-id topmost-last-node))]
+         (tree/-save updated-node txs-state))
+       (and (not sibling?) (some? down-node) topmost-last-loc) ;; down-node.left=N
+       (let [topmost-last-node (zip/node topmost-last-loc)
+             updated-node (tree/-set-left-id down-node (tree/-get-id topmost-last-node))]
+         (tree/-save updated-node txs-state))
+       (and sibling? (some? down-node)) ;; unchanged
+       nil))))
 
 (defn move-nodes
   "Move nodes up/down."

+ 1 - 2
src/main/frontend/modules/outliner/datascript.cljc

@@ -7,8 +7,7 @@
                      [frontend.modules.editor.undo-redo :as undo-redo]
                      [frontend.state :as state]
                      [frontend.config :as config]
-                     [lambdaisland.glogi :as log]
-                     [frontend.util :as util])))
+                     [lambdaisland.glogi :as log])))
 
 #?(:cljs
    (defn new-outliner-txs-state [] (atom [])))

+ 1 - 3
src/main/frontend/modules/outliner/file.cljs

@@ -7,11 +7,9 @@
             [frontend.handler.notification :as notification]
             [frontend.modules.file.core :as file]
             [frontend.modules.outliner.tree :as tree]
-            [frontend.state :as state]
             [frontend.util :as util]
             [goog.object :as gobj]
-            [lambdaisland.glogi :as log]
-            [frontend.debug :as debug]))
+            [lambdaisland.glogi :as log]))
 
 (def write-chan (async/chan))
 

+ 3 - 6
src/main/frontend/modules/outliner/pipeline.cljs

@@ -2,13 +2,9 @@
   (:require [frontend.modules.datascript-report.core :as ds-report]
             [frontend.modules.outliner.file :as file]
             [frontend.db :as db]
-            [frontend.state :as state]
             [frontend.util :as util]
             [frontend.debug :as debug]))
 
-(defn updated-block-hook
-  [block])
-
 (defn updated-page-hook
   [page]
   (let [page (db/entity (:db/id page))
@@ -22,6 +18,7 @@
 
 (defn invoke-hooks
   [tx-report]
-  (let [{:keys [blocks pages]} (ds-report/get-blocks-and-pages tx-report)]
+  (let [{:keys [pages]} (ds-report/get-blocks-and-pages tx-report)]
     (doseq [p (seq pages)] (updated-page-hook p))
-    (doseq [b (seq blocks)] (updated-block-hook b))))
+    ;; TODO: Add blocks to hooks
+    #_(doseq [b (seq blocks)] )))

+ 3 - 4
src/main/frontend/modules/outliner/tree.cljs

@@ -23,9 +23,8 @@
   (satisfies? INode node))
 
 (defn- blocks->vec-tree-aux
-  [blocks root page?]
-  (let [*idx (atom (if page? 0 -1))
-        id-map (fn [m] {:db/id (:db/id m)})
+  [blocks root]
+  (let [id-map (fn [m] {:db/id (:db/id m)})
         root (id-map root)
         parent-blocks (group-by :block/parent blocks)
         sort-fn (fn [parent]
@@ -55,7 +54,7 @@
   (let [[page? root] (get-root-and-page (str root-id))]
     (if-not root ; custom query
       blocks
-      (let [result (blocks->vec-tree-aux blocks root page?)]
+      (let [result (blocks->vec-tree-aux blocks root)]
         (if page?
           result
           ;; include root block

+ 4 - 4
src/main/frontend/modules/shortcut/data_helper.cljs

@@ -149,10 +149,10 @@
             new-result (rewrite/update
                         result
                         :shortcuts
-                        #(dissoc (rewrite/sexpr %) k))]
-        (let [new-content (str new-result)]
-          (common-handler/reset-config! repo new-content)
-          (file/set-file-content! repo path new-content))))))
+                        #(dissoc (rewrite/sexpr %) k))
+            new-content (str new-result)]
+        (common-handler/reset-config! repo new-content)
+        (file/set-file-content! repo path new-content)))))
 
 (defn get-group
   "Given shortcut key, return handler group

+ 7 - 8
src/main/frontend/search/browser.cljs

@@ -9,8 +9,7 @@
 
 (defn search-blocks
   [repo q {:keys [limit page]
-            :or {limit 20}
-            :as option}]
+            :or {limit 20}}]
   (let [indice (or (get-in @indices [repo :blocks])
                    (search-db/make-blocks-indice! repo))
         result
@@ -22,7 +21,7 @@
         result (bean/->clj result)]
     (->>
      (map
-       (fn [{:keys [item matches] :as block}]
+       (fn [{:keys [item matches]}]
          (let [{:keys [content uuid page]} item]
            {:block/uuid uuid
             :block/content content
@@ -33,12 +32,12 @@
 
 (defrecord Browser [repo]
   protocol/Engine
-  (query [this q option]
+  (query [_this q option]
     (p/promise (search-blocks repo q option)))
-  (rebuild-blocks-indice! [this]
+  (rebuild-blocks-indice! [_this]
     (let [indice (search-db/make-blocks-indice! repo)]
       (p/promise indice)))
-  (transact-blocks! [this {:keys [blocks-to-remove-set
+  (transact-blocks! [_this {:keys [blocks-to-remove-set
                                   blocks-to-add]}]
     (swap! search-db/indices update-in [repo :blocks]
            (fn [indice]
@@ -51,7 +50,7 @@
                  (doseq [block blocks-to-add]
                    (.add indice (bean/->js block)))))
              indice)))
-  (truncate-blocks! [this]
+  (truncate-blocks! [_this]
     (swap! indices assoc-in [repo :blocks] nil))
-  (remove-db! [this]
+  (remove-db! [_this]
     nil))

+ 2 - 0
src/main/frontend/search/db.cljs

@@ -28,6 +28,8 @@
      :content result}))
 
 (defn build-blocks-indice
+  ;; TODO: Remove repo effects fns further up the call stack. db fns need standardization on taking connection
+  #_:clj-kondo/ignore
   [repo]
   (->> (db/get-all-block-contents)
        (map block->index)

+ 6 - 6
src/main/frontend/search/node.cljs

@@ -7,19 +7,19 @@
 
 (defrecord Node [repo]
   protocol/Engine
-  (query [this q opts]
+  (query [_this q opts]
     (p/let [result (ipc/ipc "search-blocks" repo q opts)
             result (bean/->clj result)]
-      (map (fn [{:keys [content id uuid page]}]
+      (map (fn [{:keys [content uuid page]}]
              {:block/uuid uuid
               :block/content content
               :block/page page}) result)))
-  (rebuild-blocks-indice! [this]
+  (rebuild-blocks-indice! [_this]
     (let [indice (search-db/build-blocks-indice repo)]
       (ipc/ipc "rebuild-blocks-indice" repo indice)))
-  (transact-blocks! [this data]
+  (transact-blocks! [_this data]
     (ipc/ipc "transact-blocks" repo (bean/->js data)))
-  (truncate-blocks! [this]
+  (truncate-blocks! [_this]
     (ipc/ipc "truncate-blocks" repo))
-  (remove-db! [this]
+  (remove-db! [_this]
     (ipc/ipc "remove-db" repo)))

+ 4 - 5
src/main/frontend/tools/html_export.cljs

@@ -6,7 +6,7 @@
             [frontend.db :as db]
             [frontend.extensions.slide :as slide]
             [medley.core :as medley]
-            [frontend.format.block :as block]))
+            [frontend.format.block :as format-block]))
 
 ;; Consider generate a db index so that search can still works
 
@@ -17,19 +17,18 @@
 
 (defn- build-block
   [config block]
-  (let [block (block/parse-title-and-body block)
+  (let [block (format-block/parse-title-and-body block)
         body (:block/body block)
         block (block/build-block-title config block)]
     [:div.block
      block
      (when (seq body)
        (for [child body]
-         (do
-           (block/markup-element-cp config child))))]))
+         (block/markup-element-cp config child)))]))
 
 (defn export-page
   [page-name blocks show-notification!]
-  (let [{:keys [slide] :as properties} (db/get-page-properties page-name)
+  (let [{:keys [slide]} (db/get-page-properties page-name)
         slide? slide
         blocks (if (:block/pre-block? (first blocks))
                  (rest blocks)