Bläddra i källkod

Lint components and address comments in review

Start using :clj-kondo/ignore as lint violations that need to be
revisited. They may side effect and should be removed with better
understanding of their context
Gabriel Horner 3 år sedan
förälder
incheckning
f1d15b0e05
34 ändrade filer med 200 tillägg och 275 borttagningar
  1. 1 1
      .github/workflows/build.yml
  2. 16 24
      src/main/frontend/components/block.cljs
  3. 4 5
      src/main/frontend/components/command_palette.cljs
  4. 3 1
      src/main/frontend/components/commit.cljs
  5. 4 4
      src/main/frontend/components/content.cljs
  6. 14 16
      src/main/frontend/components/datetime.cljs
  7. 2 2
      src/main/frontend/components/diff.cljs
  8. 14 18
      src/main/frontend/components/editor.cljs
  9. 3 4
      src/main/frontend/components/encryption.cljs
  10. 1 0
      src/main/frontend/components/export.cljs
  11. 1 1
      src/main/frontend/components/file.cljs
  12. 5 12
      src/main/frontend/components/header.cljs
  13. 1 1
      src/main/frontend/components/journal.cljs
  14. 2 0
      src/main/frontend/components/lazy_editor.cljs
  15. 1 2
      src/main/frontend/components/onboarding.cljs
  16. 16 42
      src/main/frontend/components/page.cljs
  17. 2 6
      src/main/frontend/components/page_menu.cljs
  18. 17 18
      src/main/frontend/components/plugins.cljs
  19. 2 6
      src/main/frontend/components/query_table.cljs
  20. 3 4
      src/main/frontend/components/reference.cljs
  21. 3 3
      src/main/frontend/components/repo.cljs
  22. 8 8
      src/main/frontend/components/right_sidebar.cljs
  23. 41 51
      src/main/frontend/components/search.cljs
  24. 3 4
      src/main/frontend/components/settings.cljs
  25. 1 1
      src/main/frontend/components/shortcut.cljs
  26. 11 17
      src/main/frontend/components/sidebar.cljs
  27. 1 1
      src/main/frontend/components/svg.cljs
  28. 3 4
      src/main/frontend/components/theme.cljs
  29. 4 7
      src/main/frontend/components/widgets.cljs
  30. 2 0
      src/main/frontend/db/model.cljs
  31. 3 2
      src/main/frontend/db/query_custom.cljs
  32. 2 2
      src/main/frontend/extensions/code.cljs
  33. 3 6
      src/main/frontend/modules/outliner/pipeline.cljs
  34. 3 2
      src/main/frontend/search/db.cljs

+ 1 - 1
.github/workflows/build.yml

@@ -79,7 +79,7 @@ jobs:
         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} src/main/frontend/{worker,util,ui,tools,search,publishing,modules,mobile,external,context}
+        run: clj-kondo --lint src/workspaces src/electron src/test src/dev-cljs src/main/{electron,grammar} src/main/frontend/{worker,util,ui,tools,search,publishing,modules,mobile,external,db,context,components}
 
       - name: Run ClojureScript test
         run: |

+ 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 - 1
src/main/frontend/components/file.cljs

@@ -59,7 +59,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))))
@@ -612,7 +611,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
@@ -653,7 +652,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?)
@@ -665,5 +664,5 @@
 (defn open-plugins-modal!
   []
   (state/set-modal!
-    (fn [close!]
-      (plugins-page))))
+    (fn [_close!]
+      (plugins-page))))

+ 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

+ 2 - 0
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]

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

@@ -25,10 +25,11 @@
   ([query]
    (custom-query query {}))
   ([query query-opts]
-   (when-let [_query' (cond
+   #_:clj-kondo/ignore
+   (when-let [query' (cond
                        (and (string? query)
                             (not (string/blank? query)))
-                        (reader/read-string query)
+                       (reader/read-string query)
 
                        (map? query)
                        query

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

@@ -244,7 +244,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]
@@ -290,7 +290,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")

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

@@ -5,10 +5,6 @@
             [frontend.util :as util]
             [frontend.debug :as debug]))
 
-;; TODO: Do something or remove
-(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 - 2
src/main/frontend/search/db.cljs

@@ -27,9 +27,10 @@
      :page page
      :content result}))
 
-;; TODO: Do we want to pass repo here?
 (defn build-blocks-indice
-  [_repo]
+  ;; 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)
        (remove nil?)