Skip to content

Commit

Permalink
Lint extensions/ and wrap up hanging frontend dirs
Browse files Browse the repository at this point in the history
fs/, format/ and logseq/ also added to linting by adding todos for later
inspection
  • Loading branch information
logseq-cldwalker committed Jan 12, 2022
1 parent 89bef5b commit b7b3375
Show file tree
Hide file tree
Showing 20 changed files with 263 additions and 313 deletions.
8 changes: 6 additions & 2 deletions .clj-kondo/config.edn
Original file line number Diff line number Diff line change
@@ -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}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
1 change: 0 additions & 1 deletion src/main/frontend/components/file.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/components/plugins.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@

:disabled
(or downloading?
(and (not (empty? unchecked))
(and (seq unchecked)
(= (count unchecked) (count updates)))))])]))

(defn open-select-theme!
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/extensions/calc.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,5 @@
[:div.extensions__code-calc-output-line {:key i}
[:span (cond
(nil? line) ""
(or (failure? line)) "?"
(failure? line) "?"
:else line)]])])))
1 change: 0 additions & 1 deletion src/main/frontend/extensions/code.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 1 addition & 10 deletions src/main/frontend/extensions/excalidraw.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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?)
Expand Down
6 changes: 3 additions & 3 deletions src/main/frontend/extensions/graph.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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")})))))

Expand Down Expand Up @@ -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)
Expand Down
61 changes: 31 additions & 30 deletions src/main/frontend/extensions/graph/pixi.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}
Expand Down Expand Up @@ -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)]
Expand All @@ -126,14 +126,15 @@
;; 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)
(.alphaTarget s 0)))
(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)
Expand Down Expand Up @@ -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)
Loading

0 comments on commit b7b3375

Please sign in to comment.