소스 검색

fix: stop shadowing vars in deps and turn on related lint

Follow up to last commit. Added some exceptions for cljs.core
to minimize change for now
Gabriel Horner 1 년 전
부모
커밋
f2b38b5963
29개의 변경된 파일126개의 추가작업 그리고 118개의 파일을 삭제
  1. 1 0
      deps/common/.clj-kondo/config.edn
  2. 10 10
      deps/common/src/logseq/common/util/date_time.cljs
  3. 5 5
      deps/common/src/logseq/common/util/macro.cljs
  4. 2 2
      deps/common/src/logseq/common/uuid.cljs
  5. 3 0
      deps/db/.clj-kondo/config.edn
  6. 19 19
      deps/db/src/logseq/db.cljs
  7. 2 2
      deps/db/src/logseq/db/frontend/inputs.cljs
  8. 2 2
      deps/db/src/logseq/db/frontend/property/build.cljs
  9. 3 3
      deps/db/src/logseq/db/frontend/rules.cljc
  10. 2 2
      deps/db/src/logseq/db/sqlite/common_db.cljs
  11. 3 3
      deps/db/src/logseq/db/sqlite/create_graph.cljs
  12. 2 2
      deps/db/src/logseq/db/sqlite/util.cljs
  13. 3 0
      deps/graph-parser/.clj-kondo/config.edn
  14. 2 2
      deps/graph-parser/src/logseq/graph_parser.cljs
  15. 10 10
      deps/graph-parser/src/logseq/graph_parser/block.cljs
  16. 5 5
      deps/graph-parser/src/logseq/graph_parser/db.cljs
  17. 4 4
      deps/graph-parser/src/logseq/graph_parser/exporter.cljs
  18. 1 0
      deps/outliner/.clj-kondo/config.edn
  19. 12 12
      deps/outliner/src/logseq/outliner/core.cljs
  20. 2 2
      deps/outliner/src/logseq/outliner/pipeline.cljs
  21. 2 2
      deps/outliner/src/logseq/outliner/property.cljs
  22. 1 0
      deps/publishing/.clj-kondo/config.edn
  23. 8 8
      deps/publishing/src/logseq/publishing/db.cljs
  24. 4 4
      deps/publishing/src/logseq/publishing/html.cljs
  25. 2 2
      deps/publishing/test/logseq/publishing/test/helper.clj
  26. 8 8
      src/electron/electron/core.cljs
  27. 1 2
      src/main/frontend/common/file/core.cljs
  28. 3 3
      src/main/frontend/common/missionary_util.cljs
  29. 4 4
      src/main/frontend/common/search_fuzzy.cljs

+ 1 - 0
deps/common/.clj-kondo/config.edn

@@ -2,6 +2,7 @@
  {:aliased-namespace-symbol {:level :warning}
  {:aliased-namespace-symbol {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :used-underscored-binding {:level :warning}
   :used-underscored-binding {:level :warning}
+  :shadowed-var {:level :warning}
 
 
   :consistent-alias
   :consistent-alias
   {:aliases {clojure.string string}}}
   {:aliases {clojure.string string}}}

+ 10 - 10
deps/common/src/logseq/common/util/date_time.cljs

@@ -14,16 +14,16 @@
 (defn journal-title->
 (defn journal-title->
   [journal-title then-fn formatters]
   [journal-title then-fn formatters]
   (when-not (string/blank? journal-title)
   (when-not (string/blank? journal-title)
-    (when-let [time (->> (map
-                          (fn [formatter]
-                            (try
-                              (tf/parse (tf/formatter formatter) (common-util/capitalize-all journal-title))
-                              (catch :default _e
-                                nil)))
-                          formatters)
-                         (filter some?)
-                         first)]
-      (then-fn time))))
+    (when-let [time' (->> (map
+                           (fn [formatter]
+                             (try
+                               (tf/parse (tf/formatter formatter) (common-util/capitalize-all journal-title))
+                               (catch :default _e
+                                 nil)))
+                           formatters)
+                          (filter some?)
+                          first)]
+      (then-fn time'))))
 
 
 (defn journal-title->int
 (defn journal-title->int
   [journal-title formatters]
   [journal-title formatters]

+ 5 - 5
deps/common/src/logseq/common/util/macro.cljs

@@ -25,13 +25,13 @@
 (defn- macro-expand-value
 (defn- macro-expand-value
   "Checks a string for a macro and expands it if there's a macro entry for it.
   "Checks a string for a macro and expands it if there's a macro entry for it.
    This is a slimmer version of macro-else-cp"
    This is a slimmer version of macro-else-cp"
-  [val macros]
-  (if-let [[_ macro args] (and (string? val)
-                               (seq (re-matches #"\{\{(\S+)\s+(.*)\}\}" val)))]
+  [value macros]
+  (if-let [[_ macro args] (and (string? value)
+                               (seq (re-matches #"\{\{(\S+)\s+(.*)\}\}" value)))]
     (if-let [content (get macros macro)]
     (if-let [content (get macros macro)]
       (macro-subs content (string/split args #"\s+"))
       (macro-subs content (string/split args #"\s+"))
-      val)
-    val))
+      value)
+    value))
 
 
 (defn expand-value-if-macro
 (defn expand-value-if-macro
   [s macros]
   [s macros]

+ 2 - 2
deps/common/src/logseq/common/uuid.cljs

@@ -35,7 +35,7 @@ the remaining chars for data of this type"
   - :journal-page-uuid
   - :journal-page-uuid
   - :db-ident-block-uuid"
   - :db-ident-block-uuid"
   ([] (d/squuid))
   ([] (d/squuid))
-  ([type v]
-   (case type
+  ([type' v]
+   (case type'
      :journal-page-uuid (gen-journal-page-uuid v)
      :journal-page-uuid (gen-journal-page-uuid v)
      :db-ident-block-uuid (gen-db-ident-block-uuid v))))
      :db-ident-block-uuid (gen-db-ident-block-uuid v))))

+ 3 - 0
deps/db/.clj-kondo/config.edn

@@ -2,6 +2,9 @@
  {:aliased-namespace-symbol {:level :warning}
  {:aliased-namespace-symbol {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :used-underscored-binding {:level :warning}
   :used-underscored-binding {:level :warning}
+  :shadowed-var {:level :warning
+                 ;; FIXME: Remove these as shadowing core fns isn't a good practice
+                 :exclude [val key]}
 
 
   :consistent-alias
   :consistent-alias
   {:aliases {clojure.string string
   {:aliases {clojure.string string

+ 19 - 19
deps/db/src/logseq/db.cljs

@@ -189,11 +189,11 @@
 
 
 (defn page-exists?
 (defn page-exists?
   "Whether a page exists with the `type`."
   "Whether a page exists with the `type`."
-  [db page-name type]
+  [db page-name type']
   (when page-name
   (when page-name
     (if (db-based-graph? db)
     (if (db-based-graph? db)
       ;; Classes and properties are case sensitive
       ;; Classes and properties are case sensitive
-      (if (#{"class" "property"} type)
+      (if (#{"class" "property"} type')
         (seq
         (seq
          (d/q
          (d/q
           '[:find [?p ...]
           '[:find [?p ...]
@@ -203,7 +203,7 @@
             [?p :block/type ?type]]
             [?p :block/type ?type]]
           db
           db
           page-name
           page-name
-          type))
+          type'))
         ;; TODO: Decouple db graphs from file specific :block/name
         ;; TODO: Decouple db graphs from file specific :block/name
         (seq
         (seq
          (d/q
          (d/q
@@ -214,7 +214,7 @@
             [?p :block/type ?type]]
             [?p :block/type ?type]]
           db
           db
           (common-util/page-name-sanity-lc page-name)
           (common-util/page-name-sanity-lc page-name)
-          type)))
+          type')))
       (d/entity db [:block/name (common-util/page-name-sanity-lc page-name)]))))
       (d/entity db [:block/name (common-util/page-name-sanity-lc page-name)]))))
 
 
 (defn get-page
 (defn get-page
@@ -260,7 +260,7 @@
                         (map
                         (map
                          (fn [page]
                          (fn [page]
                            (when-let [page (get-page db page)]
                            (when-let [page (get-page db page)]
-                             (let [name (:block/name page)]
+                             (let [name' (:block/name page)]
                                (and
                                (and
                                 (empty-ref-f page)
                                 (empty-ref-f page)
                                 (or
                                 (or
@@ -271,12 +271,12 @@
                                     first-child
                                     first-child
                                     (= 1 (count children))
                                     (= 1 (count children))
                                     (contains? #{"" "-" "*"} (string/trim (:block/title first-child))))))
                                     (contains? #{"" "-" "*"} (string/trim (:block/title first-child))))))
-                                (not (contains? built-in-pages name))
+                                (not (contains? built-in-pages name'))
                                 (not (whiteboard? page))
                                 (not (whiteboard? page))
                                 (not (:block/_namespace page))
                                 (not (:block/_namespace page))
                                 (not (property? page))
                                 (not (property? page))
                                  ;; a/b/c might be deleted but a/b/c/d still exists (for backward compatibility)
                                  ;; a/b/c might be deleted but a/b/c/d still exists (for backward compatibility)
-                                (not (and (string/includes? name "/")
+                                (not (and (string/includes? name' "/")
                                           (not (journal? page))))
                                           (not (journal? page))))
                                 (not (:block/properties page))
                                 (not (:block/properties page))
                                 page))))
                                 page))))
@@ -323,13 +323,13 @@
 (defn get-block-parents
 (defn get-block-parents
   [db block-id {:keys [depth] :or {depth 100}}]
   [db block-id {:keys [depth] :or {depth 100}}]
   (loop [block-id block-id
   (loop [block-id block-id
-         parents (list)
+         parents' (list)
          d 1]
          d 1]
     (if (> d depth)
     (if (> d depth)
-      parents
+      parents'
       (if-let [parent (:block/parent (d/entity db [:block/uuid block-id]))]
       (if-let [parent (:block/parent (d/entity db [:block/uuid block-id]))]
-        (recur (:block/uuid parent) (conj parents parent) (inc d))
-        parents))))
+        (recur (:block/uuid parent) (conj parents' parent) (inc d))
+        parents'))))
 
 
 (def get-block-children-ids sqlite-common-db/get-block-children-ids)
 (def get-block-children-ids sqlite-common-db/get-block-children-ids)
 (def get-block-children sqlite-common-db/get-block-children)
 (def get-block-children sqlite-common-db/get-block-children)
@@ -533,9 +533,9 @@
 ;; File based fns
 ;; File based fns
 (defn get-namespace-pages
 (defn get-namespace-pages
   "Accepts both sanitized and unsanitized namespaces"
   "Accepts both sanitized and unsanitized namespaces"
-  [db namespace {:keys [db-graph?]}]
-  (assert (string? namespace))
-  (let [namespace (common-util/page-name-sanity-lc namespace)
+  [db namespace' {:keys [db-graph?]}]
+  (assert (string? namespace'))
+  (let [namespace'' (common-util/page-name-sanity-lc namespace')
         pull-attrs  (cond-> [:db/id :block/name :block/title :block/namespace]
         pull-attrs  (cond-> [:db/id :block/name :block/title :block/namespace]
                       (not db-graph?)
                       (not db-graph?)
                       (conj {:block/file [:db/id :file/path]}))]
                       (conj {:block/file [:db/id :file/path]}))]
@@ -547,16 +547,16 @@
       (list 'namespace '?p '?c)]
       (list 'namespace '?p '?c)]
      db
      db
      (:namespace rules/rules)
      (:namespace rules/rules)
-     namespace)))
+     namespace'')))
 
 
 (defn get-pages-by-name-partition
 (defn get-pages-by-name-partition
-  [db partition]
-  (when-not (string/blank? partition)
-    (let [partition (common-util/page-name-sanity-lc (string/trim partition))
+  [db partition']
+  (when-not (string/blank? partition')
+    (let [partition'' (common-util/page-name-sanity-lc (string/trim partition'))
           ids (->> (d/datoms db :aevt :block/name)
           ids (->> (d/datoms db :aevt :block/name)
                    (filter (fn [datom]
                    (filter (fn [datom]
                              (let [page (:v datom)]
                              (let [page (:v datom)]
-                               (string/includes? page partition))))
+                               (string/includes? page partition''))))
                    (map :e))]
                    (map :e))]
       (when (seq ids)
       (when (seq ids)
         (d/pull-many db
         (d/pull-many db

+ 2 - 2
deps/db/src/logseq/db/frontend/inputs.cljs

@@ -17,10 +17,10 @@ it will return 1622433600000, which is equivalent to Mon May 31 2021 00 :00:00."
    (.setHours (js/Date. date) hours mins secs millisecs)))
    (.setHours (js/Date. date) hours mins secs millisecs)))
 
 
 (defn- old->new-relative-date-format [input]
 (defn- old->new-relative-date-format [input]
-  (let [count (re-find #"^\d+" (name input))
+  (let [count' (re-find #"^\d+" (name input))
         plus-minus (if (re-find #"after" (name input)) "+" "-")
         plus-minus (if (re-find #"after" (name input)) "+" "-")
         ms? (string/ends-with? (name input) "-ms")]
         ms? (string/ends-with? (name input) "-ms")]
-    (keyword :today (str plus-minus count "d" (if ms? "-ms" "")))))
+    (keyword :today (str plus-minus count' "d" (if ms? "-ms" "")))))
 
 
 (comment
 (comment
   (old->new-relative-date-format "1d")
   (old->new-relative-date-format "1d")

+ 2 - 2
deps/db/src/logseq/db/frontend/property/build.cljs

@@ -43,10 +43,10 @@
                                                                                      :ref-type? true})
                                                                                      :ref-type? true})
                            property-attributes)]
                            property-attributes)]
     (into [property-tx]
     (into [property-tx]
-          (map (fn [{:keys [db-ident value icon uuid]}]
+          (map (fn [{uuid' :uuid :keys [db-ident value icon]}]
                  (cond->
                  (cond->
                   (build-closed-value-block
                   (build-closed-value-block
-                   uuid
+                   uuid'
                    value
                    value
                    property
                    property
                    {:db-ident db-ident :icon icon})
                    {:db-ident db-ident :icon icon})

+ 3 - 3
deps/db/src/logseq/db/frontend/rules.cljc

@@ -234,10 +234,10 @@
    * :deps - A map of rule names to their dependencies. Only one-level of dependencies are resolved.
    * :deps - A map of rule names to their dependencies. Only one-level of dependencies are resolved.
    No dependencies are detected by default though we could add it later e.g. find-rules-in-where"
    No dependencies are detected by default though we could add it later e.g. find-rules-in-where"
   ([rules-m] (extract-rules rules-m (keys rules-m)))
   ([rules-m] (extract-rules rules-m (keys rules-m)))
-  ([rules-m rules & {:keys [deps]}]
-   (let [rules-with-deps (concat rules
+  ([rules-m rules' & {:keys [deps]}]
+   (let [rules-with-deps (concat rules'
                                  (when (map? deps)
                                  (when (map? deps)
-                                   (mapcat deps rules)))]
+                                   (mapcat deps rules')))]
      (vec
      (vec
       (mapcat #(let [val (rules-m %)]
       (mapcat #(let [val (rules-m %)]
                  ;; if vector?, rule has multiple clauses
                  ;; if vector?, rule has multiple clauses

+ 2 - 2
deps/db/src/logseq/db/sqlite/common_db.cljs

@@ -213,8 +213,8 @@
 
 
 (defn get-structured-datoms
 (defn get-structured-datoms
   [db]
   [db]
-  (mapcat (fn [type]
-            (->> (d/datoms db :avet :block/type type)
+  (mapcat (fn [type']
+            (->> (d/datoms db :avet :block/type type')
                  (mapcat (fn [d]
                  (mapcat (fn [d]
                            (d/datoms db :eavt (:e d))))))
                            (d/datoms db :eavt (:e d))))))
           [
           [

+ 3 - 3
deps/db/src/logseq/db/sqlite/create_graph.cljs

@@ -61,9 +61,9 @@
 (defn kv
 (defn kv
   "Creates a key-value pair tx with the key and value respectively stored under
   "Creates a key-value pair tx with the key and value respectively stored under
   :db/ident and :kv/value.  The key must be under the namespace :logseq.kv"
   :db/ident and :kv/value.  The key must be under the namespace :logseq.kv"
-  [key value]
-  {:pre [(= "logseq.kv" (namespace key))]}
-  {:db/ident key
+  [k value]
+  {:pre [(= "logseq.kv" (namespace k))]}
+  {:db/ident k
    :kv/value value})
    :kv/value value})
 
 
 (def built-in-pages-names
 (def built-in-pages-names

+ 2 - 2
deps/db/src/logseq/db/sqlite/util.cljs

@@ -24,8 +24,8 @@
   (transit/write transit-w data))
   (transit/write transit-w data))
 
 
 (defn transit-read
 (defn transit-read
-  [str]
-  (transit/read transit-r str))
+  [s]
+  (transit/read transit-r s))
 
 
 (def write-transit-str
 (def write-transit-str
   (let [write-handlers (->> (assoc dt/write-handlers
   (let [write-handlers (->> (assoc dt/write-handlers

+ 3 - 0
deps/graph-parser/.clj-kondo/config.edn

@@ -2,6 +2,9 @@
  {:aliased-namespace-symbol {:level :warning}
  {:aliased-namespace-symbol {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :used-underscored-binding {:level :warning}
   :used-underscored-binding {:level :warning}
+  :shadowed-var {:level :warning
+                 ;; FIXME: Remove these as shadowing core fns isn't a good practice
+                 :exclude [val format key name alias type parents exists?]}
 
 
   :consistent-alias
   :consistent-alias
   {:aliases {clojure.string string
   {:aliases {clojure.string string

+ 2 - 2
deps/graph-parser/src/logseq/graph_parser.cljs

@@ -12,8 +12,8 @@
 
 
 (defn- retract-blocks-tx
 (defn- retract-blocks-tx
   [blocks retain-uuids]
   [blocks retain-uuids]
-  (mapcat (fn [{uuid :block/uuid eid :db/id}]
-            (if (and uuid (contains? retain-uuids uuid))
+  (mapcat (fn [{uuid' :block/uuid eid :db/id}]
+            (if (and uuid' (contains? retain-uuids uuid'))
               (map (fn [attr] [:db.fn/retractAttribute eid attr]) db-schema/retract-attributes)
               (map (fn [attr] [:db.fn/retractAttribute eid attr]) db-schema/retract-attributes)
               (when eid [[:db.fn/retractEntity eid]])))
               (when eid [[:db.fn/retractEntity eid]])))
           blocks))
           blocks))

+ 10 - 10
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -341,9 +341,9 @@
                                                                new-uuid*))]
                                                                new-uuid*))]
                                                {:block/uuid new-uuid}))
                                                {:block/uuid new-uuid}))
                                            (when namespace?
                                            (when namespace?
-                                             (let [namespace (first (common-util/split-last "/" original-page-name))]
-                                               (when-not (string/blank? namespace)
-                                                 {:block/namespace {:block/name (common-util/page-name-sanity-lc namespace)}})))
+                                             (let [namespace' (first (common-util/split-last "/" original-page-name))]
+                                               (when-not (string/blank? namespace')
+                                                 {:block/namespace {:block/name (common-util/page-name-sanity-lc namespace')}})))
                                            (when (and with-timestamp? (or skip-existing-page-check? (not page-entity))) ;; Only assign timestamp on creating new entity
                                            (when (and with-timestamp? (or skip-existing-page-check? (not page-entity))) ;; Only assign timestamp on creating new entity
                                              (let [current-ms (common-util/time-ms)]
                                              (let [current-ms (common-util/time-ms)]
                                                {:block/created-at current-ms
                                                {:block/created-at current-ms
@@ -463,13 +463,13 @@
        blocks))
        blocks))
 
 
 (defn get-block-content
 (defn get-block-content
-  [utf8-content block format meta block-pattern]
-  (let [content (if-let [end-pos (:end_pos meta)]
+  [utf8-content block format meta' block-pattern]
+  (let [content (if-let [end-pos (:end_pos meta')]
                   (utf8/substring utf8-content
                   (utf8/substring utf8-content
-                                  (:start_pos meta)
+                                  (:start_pos meta')
                                   end-pos)
                                   end-pos)
                   (utf8/substring utf8-content
                   (utf8/substring utf8-content
-                                  (:start_pos meta)))
+                                  (:start_pos meta')))
         content (when content
         content (when content
                   (let [content (text/remove-level-spaces content format block-pattern)]
                   (let [content (text/remove-level-spaces content format block-pattern)]
                     (if (or (:pre-block? block)
                     (if (or (:pre-block? block)
@@ -599,7 +599,7 @@
                 (-> (assoc block :collapsed? true)
                 (-> (assoc block :collapsed? true)
                     (update :properties (fn [m] (dissoc m :collapsed)))
                     (update :properties (fn [m] (dissoc m :collapsed)))
                     (update :properties-text-values dissoc :collapsed)
                     (update :properties-text-values dissoc :collapsed)
-                    (update :properties-order (fn [keys] (vec (remove #{:collapsed} keys)))))
+                    (update :properties-order (fn [keys'] (vec (remove #{:collapsed} keys')))))
                 block)
                 block)
         title (cond->> (get-block-content encoded-content block format pos-meta block-pattern)
         title (cond->> (get-block-content encoded-content block format pos-meta block-pattern)
                 remove-properties?
                 remove-properties?
@@ -742,7 +742,7 @@
                    (map #(dissoc % :block/level-spaces) result)
                    (map #(dissoc % :block/level-spaces) result)
                    (let [[block & others] blocks
                    (let [[block & others] blocks
                          level-spaces (:block/level-spaces block)
                          level-spaces (:block/level-spaces block)
-                         {:block/keys [uuid level parent] :as last-parent} (last parents)
+                         {uuid' :block/uuid :block/keys [level parent] :as last-parent} (last parents)
                          parent-spaces (:block/level-spaces last-parent)
                          parent-spaces (:block/level-spaces last-parent)
                          [blocks parents result]
                          [blocks parents result]
                          (cond
                          (cond
@@ -755,7 +755,7 @@
                              [others parents' result'])
                              [others parents' result'])
 
 
                            (> level-spaces parent-spaces)         ; child
                            (> level-spaces parent-spaces)         ; child
-                           (let [parent (if uuid [:block/uuid uuid] (:page/id last-parent))
+                           (let [parent (if uuid' [:block/uuid uuid'] (:page/id last-parent))
                                  block (cond->
                                  block (cond->
                                         (assoc block
                                         (assoc block
                                                :block/parent parent)
                                                :block/parent parent)

+ 5 - 5
deps/graph-parser/src/logseq/graph_parser/db.cljs

@@ -31,12 +31,12 @@
 
 
 (defn- build-pages-tx
 (defn- build-pages-tx
   [pages]
   [pages]
-  (let [time (common-util/time-ms)]
+  (let [time' (common-util/time-ms)]
     (map
     (map
      (fn [m]
      (fn [m]
        (-> m
        (-> m
-           (assoc :block/created-at time)
-           (assoc :block/updated-at time)))
+           (assoc :block/created-at time')
+           (assoc :block/updated-at time')))
      pages)))
      pages)))
 
 
 (defn create-default-pages!
 (defn create-default-pages!
@@ -44,8 +44,8 @@
    fn is idempotent"
    fn is idempotent"
   [db-conn]
   [db-conn]
   (when-not (ldb/get-page @db-conn "card")
   (when-not (ldb/get-page @db-conn "card")
-    (let [built-in-pages (build-pages-tx built-in-pages)]
-      (ldb/transact! db-conn built-in-pages))))
+    (let [built-in-pages' (build-pages-tx built-in-pages)]
+      (ldb/transact! db-conn built-in-pages'))))
 
 
 (defn start-conn
 (defn start-conn
   "Create datascript conn with schema and default data"
   "Create datascript conn with schema and default data"

+ 4 - 4
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -210,7 +210,7 @@
 (defn- text-with-refs?
 (defn- text-with-refs?
   "Detects if a property value has text with refs e.g. `#Logseq is #awesome`
   "Detects if a property value has text with refs e.g. `#Logseq is #awesome`
   instead of `#Logseq #awesome`. If so the property type is :default instead of :page"
   instead of `#Logseq #awesome`. If so the property type is :default instead of :page"
-  [vals val-text]
+  [prop-vals val-text]
   (let [replace-regex (re-pattern
   (let [replace-regex (re-pattern
                        ;; Regex removes all characters of a tag or page-ref
                        ;; Regex removes all characters of a tag or page-ref
                        ;; so that only ref chars are left
                        ;; so that only ref chars are left
@@ -219,7 +219,7 @@
                             ;; Sorts ref names in descending order so that longer names
                             ;; Sorts ref names in descending order so that longer names
                             ;; come first. Order matters since (foo-bar|foo) correctly replaces
                             ;; come first. Order matters since (foo-bar|foo) correctly replaces
                             ;; "foo-bar" whereas (foo|foo-bar) does not
                             ;; "foo-bar" whereas (foo|foo-bar) does not
-                            (->> vals (sort >) (map common-util/escape-regex-chars) (string/join "|"))
+                            (->> prop-vals (sort >) (map common-util/escape-regex-chars) (string/join "|"))
                             ")"))
                             ")"))
         remaining-text (string/replace val-text replace-regex "$1")
         remaining-text (string/replace val-text replace-regex "$1")
         non-ref-char (some #(if (or (string/blank? %) (#{"[" "]" "," "#"} %))
         non-ref-char (some #(if (or (string/blank? %) (#{"[" "]" "," "#"} %))
@@ -839,11 +839,11 @@
         ;; _ (when (seq new-properties) (prn :new-properties new-properties))
         ;; _ (when (seq new-properties) (prn :new-properties new-properties))
         [properties-tx pages-tx'] ((juxt filter remove)
         [properties-tx pages-tx'] ((juxt filter remove)
                                    #(contains? new-properties (keyword (:block/name %))) pages-tx)
                                    #(contains? new-properties (keyword (:block/name %))) pages-tx)
-        property-pages-tx (map (fn [{:block/keys [title uuid]}]
+        property-pages-tx (map (fn [{block-uuid :block/uuid :block/keys [title]}]
                                  (let [db-ident (get @(:all-idents import-state) (keyword (string/lower-case title)))]
                                  (let [db-ident (get @(:all-idents import-state) (keyword (string/lower-case title)))]
                                    (sqlite-util/build-new-property db-ident
                                    (sqlite-util/build-new-property db-ident
                                                                    (get @(:property-schemas import-state) (keyword title))
                                                                    (get @(:property-schemas import-state) (keyword title))
-                                                                   {:title title :block-uuid uuid})))
+                                                                   {:title title :block-uuid block-uuid})))
                                properties-tx)
                                properties-tx)
         converted-property-pages-tx
         converted-property-pages-tx
         (map (fn [kw-name]
         (map (fn [kw-name]

+ 1 - 0
deps/outliner/.clj-kondo/config.edn

@@ -2,6 +2,7 @@
  {:aliased-namespace-symbol {:level :warning}
  {:aliased-namespace-symbol {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :used-underscored-binding {:level :warning}
   :used-underscored-binding {:level :warning}
+  :shadowed-var {:level :warning}
 
 
   :consistent-alias
   :consistent-alias
   {:aliases {clojure.string string
   {:aliases {clojure.string string

+ 12 - 12
deps/outliner/src/logseq/outliner/core.cljs

@@ -445,10 +445,10 @@
     (if-let [list-type (and target-block (list-type-fn target-block))]
     (if-let [list-type (and target-block (list-type-fn target-block))]
       (mapv
       (mapv
        (fn [{:block/keys [title format] :as block}]
        (fn [{:block/keys [title format] :as block}]
-         (let [list? (and (some? (:block/uuid block))
-                          (nil? (list-type-fn block)))]
+         (let [list?' (and (some? (:block/uuid block))
+                           (nil? (list-type-fn block)))]
            (cond-> block
            (cond-> block
-             list?
+             list?'
              ((fn [b]
              ((fn [b]
                 (if db-based?
                 (if db-based?
                   (assoc b :logseq.property/order-list-type list-type)
                   (assoc b :logseq.property/order-list-type list-type)
@@ -493,10 +493,10 @@
         get-new-id (fn [block lookup]
         get-new-id (fn [block lookup]
                      (cond
                      (cond
                        (or (map? lookup) (vector? lookup) (de/entity? lookup))
                        (or (map? lookup) (vector? lookup) (de/entity? lookup))
-                       (when-let [uuid (if (and (vector? lookup) (= (first lookup) :block/uuid))
+                       (when-let [uuid' (if (and (vector? lookup) (= (first lookup) :block/uuid))
                                          (get uuids (last lookup))
                                          (get uuids (last lookup))
                                          (get id->new-uuid (:db/id lookup)))]
                                          (get id->new-uuid (:db/id lookup)))]
-                         [:block/uuid uuid])
+                         [:block/uuid uuid'])
 
 
                        (integer? lookup)
                        (integer? lookup)
                        lookup
                        lookup
@@ -505,14 +505,14 @@
                        (throw (js/Error. (str "[insert-blocks] illegal lookup: " lookup ", block: " block)))))
                        (throw (js/Error. (str "[insert-blocks] illegal lookup: " lookup ", block: " block)))))
         orders (get-block-orders blocks target-block sibling? keep-block-order?)]
         orders (get-block-orders blocks target-block sibling? keep-block-order?)]
     (map-indexed (fn [idx {:block/keys [parent] :as block}]
     (map-indexed (fn [idx {:block/keys [parent] :as block}]
-                   (when-let [uuid (get uuids (:block/uuid block))]
+                   (when-let [uuid' (get uuids (:block/uuid block))]
                      (let [top-level? (= (:block/level block) 1)
                      (let [top-level? (= (:block/level block) 1)
                            parent (compute-block-parent block parent target-block top-level? sibling? get-new-id outliner-op replace-empty-target? idx)
                            parent (compute-block-parent block parent target-block top-level? sibling? get-new-id outliner-op replace-empty-target? idx)
 
 
                            order (nth orders idx)
                            order (nth orders idx)
                            _ (assert (and parent order) (str "Parent or order is nil: " {:parent parent :order order}))
                            _ (assert (and parent order) (str "Parent or order is nil: " {:parent parent :order order}))
                            m {:db/id (:db/id block)
                            m {:db/id (:db/id block)
-                              :block/uuid uuid
+                              :block/uuid uuid'
                               :block/page target-page
                               :block/page target-page
                               :block/parent parent
                               :block/parent parent
                               :block/order order}]
                               :block/order order}]
@@ -647,7 +647,7 @@
                        :target-block target-block}))
                        :target-block target-block}))
       (let [uuids-tx (->> (map :block/uuid tx')
       (let [uuids-tx (->> (map :block/uuid tx')
                           (remove nil?)
                           (remove nil?)
-                          (map (fn [uuid] {:block/uuid uuid})))
+                          (map (fn [uuid'] {:block/uuid uuid'})))
             tx (assign-temp-id tx' replace-empty-target? target-block)
             tx (assign-temp-id tx' replace-empty-target? target-block)
             from-property (:logseq.property/created-from-property target-block)
             from-property (:logseq.property/created-from-property target-block)
             property-values-tx (when (and sibling? from-property)
             property-values-tx (when (and sibling? from-property)
@@ -776,10 +776,10 @@
         original-position? (move-to-original-position? blocks target-block sibling? non-consecutive?)]
         original-position? (move-to-original-position? blocks target-block sibling? non-consecutive?)]
     (when (and (not (contains? (set (map :db/id blocks)) (:db/id target-block)))
     (when (and (not (contains? (set (map :db/id blocks)) (:db/id target-block)))
                (not original-position?))
                (not original-position?))
-      (let [parents (->> (ldb/get-block-parents db (:block/uuid target-block) {})
-                         (map :db/id)
-                         (set))
-            move-parents-to-child? (some parents (map :db/id blocks))]
+      (let [parents' (->> (ldb/get-block-parents db (:block/uuid target-block) {})
+                          (map :db/id)
+                          (set))
+            move-parents-to-child? (some parents' (map :db/id blocks))]
         (when-not move-parents-to-child?
         (when-not move-parents-to-child?
           (batch-tx/with-batch-tx-mode conn {:outliner-op :move-blocks}
           (batch-tx/with-batch-tx-mode conn {:outliner-op :move-blocks}
             (doseq [[idx block] (map vector (range (count blocks)) blocks)]
             (doseq [[idx block] (map vector (range (count blocks)) blocks)]

+ 2 - 2
deps/outliner/src/logseq/outliner/pipeline.cljs

@@ -74,10 +74,10 @@
                (when-not (@*computed-ids (:block/uuid block))
                (when-not (@*computed-ids (:block/uuid block))
                  (let [page? (ldb/page? block)
                  (let [page? (ldb/page? block)
                        from-property (:logseq.property/created-from-property block)
                        from-property (:logseq.property/created-from-property block)
-                       parents (when-not page?
+                       parents' (when-not page?
                                  (ldb/get-block-parents db-after (:block/uuid block) {}))
                                  (ldb/get-block-parents db-after (:block/uuid block) {}))
                        parents-refs (->> (cond->>
                        parents-refs (->> (cond->>
-                                          (mapcat :block/path-refs parents)
+                                          (mapcat :block/path-refs parents')
                                            from-property
                                            from-property
                                            (remove (fn [parent] (and (ldb/property? parent) (not= (:db/id parent) (:db/id from-property))))))
                                            (remove (fn [parent] (and (ldb/property? parent) (not= (:db/id parent) (:db/id from-property))))))
                                          (map :db/id))
                                          (map :db/id))

+ 2 - 2
deps/outliner/src/logseq/outliner/property.cljs

@@ -71,12 +71,12 @@
     v-str))
     v-str))
 
 
 (defn- update-datascript-schema
 (defn- update-datascript-schema
-  [property {:keys [type cardinality]}]
+  [property {type' :type :keys [cardinality]}]
   (let [ident (:db/ident property)
   (let [ident (:db/ident property)
         cardinality (if (= cardinality :many) :db.cardinality/many :db.cardinality/one)
         cardinality (if (= cardinality :many) :db.cardinality/many :db.cardinality/one)
         old-type (get-in property [:block/schema :type])
         old-type (get-in property [:block/schema :type])
         old-ref-type? (db-property-type/ref-property-types old-type)
         old-ref-type? (db-property-type/ref-property-types old-type)
-        ref-type? (db-property-type/ref-property-types type)]
+        ref-type? (db-property-type/ref-property-types type')]
     [(cond->
     [(cond->
       {:db/ident ident
       {:db/ident ident
        :db/cardinality cardinality}
        :db/cardinality cardinality}

+ 1 - 0
deps/publishing/.clj-kondo/config.edn

@@ -2,6 +2,7 @@
  {:aliased-namespace-symbol {:level :warning}
  {:aliased-namespace-symbol {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :namespace-name-mismatch {:level :warning}
   :used-underscored-binding {:level :warning}
   :used-underscored-binding {:level :warning}
+  :shadowed-var {:level :warning}
 
 
   :consistent-alias
   :consistent-alias
   {:aliases {clojure.string string}}}
   {:aliases {clojure.string string}}}

+ 8 - 8
deps/publishing/src/logseq/publishing/db.cljs

@@ -16,13 +16,13 @@
     (let [prop-lookup-fn (if (entity-util/db-based-graph? db)
     (let [prop-lookup-fn (if (entity-util/db-based-graph? db)
                            #(db-property/property-value-content (get %1 %2))
                            #(db-property/property-value-content (get %1 %2))
                            #(get %1 (keyword (name %2))))]
                            #(get %1 (keyword (name %2))))]
-      (when-some [uuid (:block/uuid block)]
+      (when-some [uuid' (:block/uuid block)]
         (when-some [stamp (prop-lookup-fn props :logseq.property.pdf/hl-stamp)]
         (when-some [stamp (prop-lookup-fn props :logseq.property.pdf/hl-stamp)]
           (let [group-key      (string/replace-first (:block/title page) #"^hls__" "")
           (let [group-key      (string/replace-first (:block/title page) #"^hls__" "")
                 hl-page        (prop-lookup-fn props :logseq.property.pdf/hl-page)
                 hl-page        (prop-lookup-fn props :logseq.property.pdf/hl-page)
                 encoded-chars? (boolean (re-find #"(?i)%[0-9a-f]{2}" group-key))
                 encoded-chars? (boolean (re-find #"(?i)%[0-9a-f]{2}" group-key))
                 group-key      (if encoded-chars? (js/encodeURI group-key) group-key)]
                 group-key      (if encoded-chars? (js/encodeURI group-key) group-key)]
-            (str "./assets/" group-key "/" (str hl-page "_" uuid "_" stamp ".png"))))))))
+            (str "./assets/" group-key "/" (str hl-page "_" uuid' "_" stamp ".png"))))))))
 
 
 (defn- clean-asset-path-prefix
 (defn- clean-asset-path-prefix
   [path]
   [path]
@@ -170,8 +170,8 @@
                                (set (concat (get-public-false-pages db) (get-public-false-block-ids db))))
                                (set (concat (get-public-false-pages db) (get-public-false-block-ids db))))
         filtered-db (d/filter db
         filtered-db (d/filter db
                               (fn [_db datom]
                               (fn [_db datom]
-                                (let [ns (namespace (:a datom))]
-                                  (and (not (remove? ns))
+                                (let [ns' (namespace (:a datom))]
+                                  (and (not (remove? ns'))
                                        (not (contains? #{:block/file} (:a datom)))
                                        (not (contains? #{:block/file} (:a datom)))
                                        (not (contains? non-public-datom-ids (:e datom)))))))
                                        (not (contains? non-public-datom-ids (:e datom)))))))
         datoms (d/datoms filtered-db :eavt)
         datoms (d/datoms filtered-db :eavt)
@@ -189,13 +189,13 @@
         exported-namespace? #(contains? #{"block" "recent"} %)
         exported-namespace? #(contains? #{"block" "recent"} %)
         filtered-db (d/filter db
         filtered-db (d/filter db
                               (fn [db datom]
                               (fn [db datom]
-                                (let [ns (namespace (:a datom))]
+                                (let [ns' (namespace (:a datom))]
                                   (and
                                   (and
                                    (not (contains? #{:block/file} (:a datom)))
                                    (not (contains? #{:block/file} (:a datom)))
-                                   (not= ns "file")
+                                   (not= ns' "file")
                                    (or
                                    (or
-                                    (not (exported-namespace? ns))
-                                    (and (= ns "block")
+                                    (not (exported-namespace? ns'))
+                                    (and (= ns' "block")
                                          (or
                                          (or
                                           (contains? public-pages (:e datom))
                                           (contains? public-pages (:e datom))
                                           (contains? public-pages (:db/id (:block/page (d/entity db (:e datom))))))))))))
                                           (contains? public-pages (:db/id (:block/page (d/entity db (:e datom))))))))))))

+ 4 - 4
deps/publishing/src/logseq/publishing/html.cljs

@@ -42,9 +42,9 @@ necessary db filtering"
 
 
 (defn- ^:large-vars/html publishing-html
 (defn- ^:large-vars/html publishing-html
   [transit-db app-state options]
   [transit-db app-state options]
-  (let [{:keys [icon name alias title description url]} options
+  (let [{name' :name :keys [icon alias title description url]} options
         icon (or icon "static/img/logo.png")
         icon (or icon "static/img/logo.png")
-        project (or alias name)]
+        project (or alias name')]
     (str "<!DOCTYPE html>\n"
     (str "<!DOCTYPE html>\n"
          (html
          (html
           (list
           (list
@@ -138,8 +138,8 @@ necessary db filtering"
   "Given the graph's db, filters the db using the given options and returns the
   "Given the graph's db, filters the db using the given options and returns the
 generated index.html string and assets used by the html"
 generated index.html string and assets used by the html"
   [db* {:keys [app-state repo-config html-options db-graph?]}]
   [db* {:keys [app-state repo-config html-options db-graph?]}]
-  (let [all-pages-public? (if-let [val (:publishing/all-pages-public? repo-config)]
-                            val
+  (let [all-pages-public? (if-let [value (:publishing/all-pages-public? repo-config)]
+                            value
                             (:all-pages-public? repo-config))
                             (:all-pages-public? repo-config))
         [db asset-filenames'] (if all-pages-public?
         [db asset-filenames'] (if all-pages-public?
                                 (db/clean-export! db* {:db-graph? db-graph?})
                                 (db/clean-export! db* {:db-graph? db-graph?})

+ 2 - 2
deps/publishing/test/logseq/publishing/test/helper.clj

@@ -5,12 +5,12 @@
   "A wrapper around deftest that handles async and done in all cases.
   "A wrapper around deftest that handles async and done in all cases.
   Importantly, it prevents unexpected failures in an async test from abruptly
   Importantly, it prevents unexpected failures in an async test from abruptly
   ending a test suite"
   ending a test suite"
-  [name opts & body]
+  [name' opts & body]
   (let [[opts body]
   (let [[opts body]
         (if (map? opts)
         (if (map? opts)
           [opts body]
           [opts body]
           [nil (cons opts body)])]
           [nil (cons opts body)])]
-    `(cljs.test/deftest ~name
+    `(cljs.test/deftest ~name'
        ~@(when-let [pre (:before opts)]
        ~@(when-let [pre (:before opts)]
            [pre])
            [pre])
        (cljs.test/async
        (cljs.test/async

+ 8 - 8
src/electron/electron/core.cljs

@@ -58,8 +58,8 @@
     (when (= (str LSP_SCHEME ":") (.-protocol parsed-url))
     (when (= (str LSP_SCHEME ":") (.-protocol parsed-url))
       (logseq-url-handler win parsed-url))))
       (logseq-url-handler win parsed-url))))
 
 
-(defn setup-interceptor! [^js app]
-  (.setAsDefaultProtocolClient app LSP_SCHEME)
+(defn setup-interceptor! [^js app']
+  (.setAsDefaultProtocolClient app' LSP_SCHEME)
 
 
   (.registerFileProtocol
   (.registerFileProtocol
    protocol FILE_ASSETS_SCHEME
    protocol FILE_ASSETS_SCHEME
@@ -242,13 +242,13 @@
                (open-url-handler win url))))))
                (open-url-handler win url))))))
 
 
 (defn- on-app-ready!
 (defn- on-app-ready!
-  [^js app]
-  (.on app "ready"
+  [^js app']
+  (.on app' "ready"
        (fn []
        (fn []
-         (let [t0 (setup-interceptor! app)
+         (let [t0 (setup-interceptor! app')
                ^js win (win/create-main-window!)
                ^js win (win/create-main-window!)
                _ (reset! *win win)]
                _ (reset! *win win)]
-           (logger/info (str "Logseq App(" (.getVersion app) ") Starting... "))
+           (logger/info (str "Logseq App(" (.getVersion app') ") Starting... "))
 
 
            (utils/<restore-proxy-settings)
            (utils/<restore-proxy-settings)
 
 
@@ -297,10 +297,10 @@
                                               (.hide win)))
                                               (.hide win)))
                                         :else
                                         :else
                                         nil)))))
                                         nil)))))
-           (.on app "before-quit" (fn [_e]
+           (.on app' "before-quit" (fn [_e]
                                     (reset! win/*quitting? true)))
                                     (reset! win/*quitting? true)))
 
 
-           (.on app "activate" #(when @*win (.show win)))))))
+           (.on app' "activate" #(when @*win (.show win)))))))
 
 
 (defn main []
 (defn main []
   (if-not (.requestSingleInstanceLock app)
   (if-not (.requestSingleInstanceLock app)

+ 1 - 2
src/main/frontend/common/file/core.cljs

@@ -128,8 +128,6 @@
   [repo db tree opts context]
   [repo db tree opts context]
   (->> (tree->file-content-aux repo db tree opts context) (string/join "\n")))
   (->> (tree->file-content-aux repo db tree opts context) (string/join "\n")))
 
 
-(def init-level 1)
-
 (defn- transact-file-tx-if-not-exists!
 (defn- transact-file-tx-if-not-exists!
   [conn page-block ok-handler context]
   [conn page-block ok-handler context]
   (when (:block/name page-block)
   (when (:block/name page-block)
@@ -163,6 +161,7 @@
 (defn- save-tree-aux!
 (defn- save-tree-aux!
   [repo db page-block tree blocks-just-deleted? context request-id]
   [repo db page-block tree blocks-just-deleted? context request-id]
   (let [page-block (d/pull db '[*] (:db/id page-block))
   (let [page-block (d/pull db '[*] (:db/id page-block))
+        init-level 1
         file-db-id (-> page-block :block/file :db/id)
         file-db-id (-> page-block :block/file :db/id)
         file-path (-> (d/entity db file-db-id) :file/path)
         file-path (-> (d/entity db file-db-id) :file/path)
         result (if (and (string? file-path) (not-empty file-path))
         result (if (and (string? file-path) (not-empty file-path))

+ 3 - 3
src/main/frontend/common/missionary_util.cljs

@@ -11,9 +11,9 @@
 (def ^:private retry-sentinel (js-obj))
 (def ^:private retry-sentinel (js-obj))
 (defn backoff
 (defn backoff
   "Retry task when it throw exception `(get ex-data :missionary/retry)`"
   "Retry task when it throw exception `(get ex-data :missionary/retry)`"
-  [delays task]
+  [delays-seq task]
   (m/sp
   (m/sp
-    (loop [[delay & delays] (seq delays)]
+    (loop [[delay & rest-delays] (seq delays-seq)]
       (let [r (try
       (let [r (try
                 (m/? task)
                 (m/? task)
                 (catch :default e
                 (catch :default e
@@ -24,7 +24,7 @@
                         retry-sentinel)
                         retry-sentinel)
                     (throw e))))]
                     (throw e))))]
         (if (identical? r retry-sentinel)
         (if (identical? r retry-sentinel)
-          (recur delays)
+          (recur rest-delays)
           r)))))
           r)))))
 
 
 (defn mix
 (defn mix

+ 4 - 4
src/main/frontend/common/search_fuzzy.cljs

@@ -36,11 +36,11 @@
            s (seq (char-array str))
            s (seq (char-array str))
            mult 1
            mult 1
            idx MAX-STRING-LENGTH
            idx MAX-STRING-LENGTH
-           score 0]
+           score' 0]
       (cond
       (cond
         ;; add str-len-distance to score, so strings with matches in same position get sorted by length
         ;; add str-len-distance to score, so strings with matches in same position get sorted by length
         ;; boost score if we have an exact match including punctuation
         ;; boost score if we have an exact match including punctuation
-        (empty? q) (+ score
+        (empty? q) (+ score'
                       (str-len-distance query str)
                       (str-len-distance query str)
                       (if (<= 0 (.indexOf ostr oquery)) MAX-STRING-LENGTH 0))
                       (if (<= 0 (.indexOf ostr oquery)) MAX-STRING-LENGTH 0))
         (empty? s) 0
         (empty? s) 0
@@ -49,12 +49,12 @@
                        (rest s)
                        (rest s)
                        (inc mult) ;; increase the multiplier as more query chars are matched
                        (inc mult) ;; increase the multiplier as more query chars are matched
                        (dec idx) ;; decrease idx so score gets lowered the further into the string we match
                        (dec idx) ;; decrease idx so score gets lowered the further into the string we match
-                       (+ mult score)) ;; score for this match is current multiplier * idx
+                       (+ mult score')) ;; score for this match is current multiplier * idx
                 (recur q
                 (recur q
                        (rest s)
                        (rest s)
                        1 ;; when there is no match, reset multiplier to one
                        1 ;; when there is no match, reset multiplier to one
                        (dec idx)
                        (dec idx)
-                       (- score 0.1)))))))
+                       (- score' 0.1)))))))
 
 
 (defn search-normalize
 (defn search-normalize
   "Normalize string for searching (loose)"
   "Normalize string for searching (loose)"