ソースを参照

Knock out a few lints in src/main/frontend

Gabriel Horner 3 年 前
コミット
40f327d77f

+ 4 - 6
src/main/frontend/ui/date_picker.cljs

@@ -1,5 +1,5 @@
 (ns frontend.ui.date-picker
-  (:require [cljs-time.core       :refer [after? before? day day-of-week days first-day-of-the-month minus month months plus weeks year]]
+  (:require [cljs-time.core       :refer [after? before? day day-of-week days first-day-of-the-month minus month months plus year]]
             [cljs-time.format     :refer [formatter formatters parse unparse]]
             [frontend.modules.shortcut.core :as shortcut]
             [frontend.state :as state]
@@ -32,8 +32,6 @@
 
 (defn- inc-date [date n] (plus date (days n)))
 
-(defn- inc-week [date n] (plus date (weeks n)))
-
 (defn previous
   "If date fails pred, subtract period until true, otherwise answer date"
   ;; date   - a date object that satisfies cljs-time.core/DateTimeProtocol.
@@ -181,9 +179,9 @@
            (reset! *internal-model (first (:rum/args state)))
            state)}
   (shortcut/mixin :shortcut.handler/date-picker)
-  [model {:keys [on-change on-switch disabled? start-of-week class style attr]
-          :or   {start-of-week (state/get-start-of-week)} ;; Default to Sunday
-          :as   args}]
+  [_model {:keys [on-change disabled? start-of-week class style attr]
+           :or   {start-of-week (state/get-start-of-week)} ;; Default to Sunday
+           :as   args}]
   (let [internal-model (util/react *internal-model)
         display-month (first-day-of-the-month (or internal-model (now->utc)))
         props-with-defaults (merge args {:start-of-week start-of-week})

+ 1 - 1
src/main/frontend/util/clock.cljs

@@ -77,7 +77,7 @@
               (str clock-in-log "\n")
               (str clock-out-log "\n"))))))
      content)
-    (catch js/Error e
+    (catch js/Error _e
       content)))
 
 (defn clock-summary

+ 1 - 4
src/main/frontend/util/list.cljs

@@ -1,9 +1,6 @@
 (ns frontend.util.list
   (:require [frontend.util.thingatpt :as thingatpt]
-            [frontend.util.cursor :as cursor]
-            [clojure.string :as string]
-            [frontend.state :as state]
-            [frontend.db :as db]))
+            [frontend.util.cursor :as cursor]))
 
 (defn get-prev-item [& [input]]
   (when-not (cursor/textarea-cursor-first-row? input)

+ 0 - 3
src/main/frontend/util/page_property.cljs

@@ -4,9 +4,7 @@
             [frontend.handler.ui :as ui-handler]
             [frontend.modules.outliner.core :as outliner-core]
             [frontend.modules.outliner.file :as outliner-file]
-            [frontend.format.mldoc :as mldoc]
             [frontend.state :as state]
-            [frontend.util.property :as property]
             [frontend.util :as util]))
 
 (defn insert-property
@@ -62,7 +60,6 @@
         (let [properties (:block/properties pre-block)
               new-properties (assoc properties key value)
               content (:block/content pre-block)
-              front-matter? (property/front-matter? content)
               new-content (insert-property format content key value)
               block {:db/id (:db/id pre-block)
                      :block/properties new-properties

+ 8 - 6
src/main/frontend/util/persist_var.cljs

@@ -3,6 +3,7 @@
             [frontend.state :as state]
             [frontend.fs :as fs]
             [frontend.util :as util]
+            [cljs.reader :as reader]
             [promesa.core :as p]))
 
 
@@ -19,7 +20,7 @@
   ILoad
   (-load [_]
     (state/add-watch-state (keyword (str "persist-var/" location))
-                           (fn [k r o n]
+                           (fn [_k _r _o n]
                              (let [repo (state/get-current-repo)]
                                (when (and
                                       (not (get-in @*value [repo :loaded?]))
@@ -28,7 +29,7 @@
                                                   (config/get-repo-dir (state/get-current-repo))
                                                   (load-path location))]
                                    (when-let [content (and (some? content)
-                                                           (try (cljs.reader/read-string content)
+                                                           (try (reader/read-string content)
                                                                 (catch js/Error e
                                                                   (println (util/format "load persist-var failed: %s"  (load-path location)))
                                                                   (js/console.dir e))))]
@@ -46,15 +47,16 @@
       (fs/write-file! repo dir path content nil)))
 
   IDeref
-  (-deref [this]
+  (-deref [_this]
     (get-in @*value [(state/get-current-repo) :value]))
 
   IReset
-  (-reset! [o new-value]
-    (swap! *value (fn [o] (assoc-in @*value [(state/get-current-repo) :value] new-value)))))
+  (-reset! [_o new-value]
+    (swap! *value (fn [_o] (assoc-in @*value [(state/get-current-repo) :value] new-value)))))
 
-(defn persist-var [init-value location]
+(defn persist-var
   "This var is stored at logseq/LOCATION.edn"
+  [init-value location]
   (let [var (->PersistVar (atom {(state/get-current-repo)
                                  {:value init-value
                                   :loaded? false}})

+ 2 - 2
src/main/frontend/util/property.cljs

@@ -124,12 +124,12 @@
     (contains? (set (util/remove-first #{key} (get-property-keys format content))) key)))
 
 (defn goto-properties-beginning
-  [format input]
+  [_format input]
   (cursor/move-cursor-to-thing input properties-start 0)
   (cursor/move-cursor-forward input (count properties-start)))
 
 (defn goto-properties-end
-  [format input]
+  [_format input]
   (cursor/move-cursor-to-thing input properties-start 0)
   (let [from (cursor/pos input)]
     (cursor/move-cursor-to-thing input properties-end from)))

+ 3 - 2
src/main/frontend/util/thingatpt.cljs

@@ -5,6 +5,7 @@
             [frontend.util.cursor :as cursor]
             [frontend.config :as config]
             [frontend.text :as text]
+            [cljs.reader :as reader]
             [goog.object :as gobj]))
 
 (defn thing-at-point
@@ -83,7 +84,7 @@
               (let [key (first (string/split line "::"))
                     line-beginning-pos (cursor/line-beginning-pos input)
                     pos-in-line (- (cursor/pos input) line-beginning-pos)]
-                (if (<= 0 pos-in-line (+ (count key) (count "::")))
+                (when (<= 0 pos-in-line (+ (count key) (count "::")))
                   {:full-content (str key "::")
                    :raw-content key
                    :start line-beginning-pos
@@ -99,7 +100,7 @@
   (when-let [line (line-at-point input)]
     (when-let [[_ indent bullet checkbox]
                (get-list-item-indent&bullet (:raw-content line))]
-      (let [bullet (cljs.reader/read-string bullet)]
+      (let [bullet (reader/read-string bullet)]
         (assoc line
                :type "list-item"
                :indent indent

+ 10 - 12
src/main/logseq/api.cljs

@@ -14,7 +14,6 @@
             [frontend.db.query-dsl :as query-dsl]
             [frontend.db.utils :as db-utils]
             [frontend.fs :as fs]
-            [frontend.handler :as handler]
             [frontend.handler.dnd :as editor-dnd-handler]
             [frontend.handler.editor :as editor-handler]
             [frontend.handler.export :as export-handler]
@@ -119,7 +118,9 @@
           _ (when-not exist? (fs/mkdir-recur! path))
           user-path (util/node-path.join path file)
           sub-dir? (string/starts-with? user-path path)
-          _ (when-not sub-dir? (do (log/info :debug user-path) (throw "write file denied")))
+          _ (when-not sub-dir?
+              (log/info :debug user-path)
+              (throw "write file denied"))
           user-path-root (util/node-path.dirname user-path)
           exist? (fs/file-exists? user-path-root "")
           _ (when-not exist? (fs/mkdir-recur! user-path-root))
@@ -128,8 +129,7 @@
 
 (defn ^:private read_dotdir_file
   [file sub-root]
-  (p/let [repo ""
-          path (plugin-handler/get-ls-dotdir-root)
+  (p/let [path (plugin-handler/get-ls-dotdir-root)
           path (util/node-path.join path sub-root)
           user-path (util/node-path.join path file)
           sub-dir? (string/starts-with? user-path path)
@@ -258,7 +258,7 @@
         ;; handle keybinding commands
         (when-let [shortcut-args (and palette-cmd keybinding
                                       (plugin-handler/simple-cmd-keybinding->shortcut-args pid key keybinding))]
-          (let [dispatch-cmd (fn [_ e] (palette-handler/invoke-command palette-cmd))
+          (let [dispatch-cmd (fn [_ _e] (palette-handler/invoke-command palette-cmd))
                 [handler-id id shortcut-map] (update shortcut-args 2 assoc :fn dispatch-cmd)]
             (js/console.debug :shortcut/register-shortcut [handler-id id shortcut-map])
             (st/register-shortcut! handler-id id shortcut-map)))))))
@@ -469,16 +469,15 @@
           nil)))))
 
 (def ^:export remove_block
-  (fn [block-uuid ^js opts]
+  (fn [block-uuid ^js _opts]
     (let [includeChildren true
           repo (state/get-current-repo)]
       (editor-handler/delete-block-aux!
         {:block/uuid (medley/uuid block-uuid) :repo repo} includeChildren))))
 
 (def ^:export update_block
-  (fn [block-uuid content ^js opts]
-    (let [opts (and opts (bean/->clj opts))
-          repo (state/get-current-repo)
+  (fn [block-uuid content ^js _opts]
+    (let [repo (state/get-current-repo)
           edit-input (state/get-edit-input-id)
           editing? (and edit-input (string/ends-with? edit-input block-uuid))]
       (if editing?
@@ -586,9 +585,8 @@
 (defn ^:export q
   [query-string]
   (when-let [repo (state/get-current-repo)]
-    (when-let [conn (db/get-conn repo)]
-      (when-let [result (query-dsl/query repo query-string)]
-        (bean/->js (normalize-keyword-for-json (flatten @result)))))))
+    (when-let [result (query-dsl/query repo query-string)]
+      (bean/->js (normalize-keyword-for-json (flatten @result))))))
 
 (defn ^:export datascript_query
   [query & inputs]

+ 1 - 1
src/workspaces/workspaces/cards.cljs

@@ -36,7 +36,7 @@
   (ct.react/react-card
    (graph)))
 
-(defn- random-graph
+(defn random-graph
   [n]
   (let [nodes (for [i (range 0 n)]
                 {:id (str i)