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

Lint extensions/ and wrap up hanging frontend dirs

fs/, format/ and logseq/ also added to linting by adding todos for later
inspection
Gabriel Horner 3 жил өмнө
parent
commit
b7b3375f62

+ 6 - 2
.clj-kondo/config.edn

@@ -1,8 +1,12 @@
 {:linters
  {:unresolved-symbol {:exclude [goog.DEBUG
                                 goog.string.unescapeEntities
-                                ;; TODO: Fix when fixing all type hints
-                                object]}}
+                                ;; 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}}

+ 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,db,context,components}
+        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: |

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

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

@@ -654,7 +654,7 @@
 
           :disabled
           (or downloading?
-              (and (not (empty? unchecked))
+              (and (seq unchecked)
                    (= (count unchecked) (count updates)))))])]))
 
 (defn open-select-theme!

+ 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)]])])))

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

+ 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))

+ 5 - 2
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,7 +58,7 @@
        s])))
 
 (defn html-export
-  [s block? display?]
+  [s block? _display?]
   (let [element (if block?
                   :div.latex
                   :span.latex-inline)]
@@ -66,9 +66,12 @@
                block?
                (util/format "$$%s$$" s)
 
+               ;; TODO: We never get to :else b/c this branch always evaluates as true
+               #_:clj-kondo/ignore
                :display?
                (util/format "$$%s$$" s)
 
+               #_:clj-kondo/ignore
                :else
                ;; 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)]
 

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