0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-09 14:21:42 -05:00

❇️ Fix linter warnings

This commit is contained in:
alonso.torres 2021-06-18 15:29:07 +02:00
parent fbf1c10077
commit 234a698538
10 changed files with 55 additions and 115 deletions

View file

@ -17,14 +17,7 @@
{:exclude-files
["data_readers.clj"
"app/util/perf.cljs"
"app/common/exceptions.cljc"
"app/util/import/.*"
"app/worker/export.cljs"
"app/worker/import.cljs"
"app/libs/.*"
"app/main/data/workspace/path/selection.cljs"
"app/main/data/workspace/transforms.cljs"
]}
"app/common/exceptions.cljc"]}
:linters
{:unsorted-required-namespaces

View file

@ -25,59 +25,59 @@
(deftype File [^:mutable file]
Object
(addPage [self name]
(addPage [_ name]
(set! file (fb/add-page file {:name name}))
(str (:current-page-id file)))
(addPage [self name options]
(addPage [_ name options]
(set! file (fb/add-page file {:name name :options options}))
(str (:current-page-id file)))
(closePage [self]
(closePage [_]
(set! file (fb/close-page file)))
(addArtboard [self data]
(addArtboard [_ data]
(set! file (fb/add-artboard file (parse-data data)))
(str (:last-id file)))
(closeArtboard [self data]
(closeArtboard [_]
(set! file (fb/close-artboard file)))
(addGroup [self data]
(addGroup [_ data]
(set! file (fb/add-group file (parse-data data)))
(str (:last-id file)))
(closeGroup [self]
(closeGroup [_]
(set! file (fb/close-group file)))
(createRect [self data]
(createRect [_ data]
(set! file (fb/create-rect file (parse-data data)))
(str (:last-id file)))
(createCircle [self data]
(createCircle [_ data]
(set! file (fb/create-circle file (parse-data data)))
(str (:last-id file)))
(createPath [self data]
(createPath [_ data]
(set! file (fb/create-path file (parse-data data)))
(str (:last-id file)))
(createText [self data]
(createText [_ data]
(set! file (fb/create-text file (parse-data data)))
(str (:last-id file)))
(createImage [self data]
(createImage [_ data]
(set! file (fb/create-image file (parse-data data)))
(str (:last-id file)))
(createSVG [self data]
(createSVG [_ data]
(set! file (fb/create-svg-raw file (parse-data data)))
(str (:last-id file)))
(closeSVG [self]
(closeSVG [_]
(set! file (fb/close-svg-raw file)))
(asMap [self]
(asMap [_]
(clj->js file)))
(defn create-file-export [^string name]

View file

@ -141,9 +141,9 @@
selected? (contains? selected-points position)]
(streams/drag-stream
(rx/of
(when-not selected? (selection/select-node position shift? "drag"))
(when-not selected? (selection/select-node position shift?))
(drag-selected-points @ms/mouse-position))
(rx/of (selection/select-node position shift? "click")))))))
(rx/of (selection/select-node position shift?)))))))
(defn drag-selected-points
[start-position]

View file

@ -60,7 +60,7 @@
(some? id)
(assoc-in [:workspace-local :edit-path id :selected-points] positions))))))
(defn select-node [position shift? kk]
(defn select-node [position shift?]
(ptk/reify ::select-node
ptk/UpdateEvent
(update [_ state]
@ -79,38 +79,6 @@
(some? id)
(assoc-in [:workspace-local :edit-path id :selected-points] selected-points))))))
(defn deselect-node [position shift?]
(ptk/reify ::deselect-node
ptk/UpdateEvent
(update [_ state]
(let [id (get-in state [:workspace-local :edition])]
(-> state
(update-in [:workspace-local :edit-path id :selected-points] (fnil disj #{}) position))))))
(defn add-to-selection-handler [index type]
(ptk/reify ::add-to-selection-handler
ptk/UpdateEvent
(update [_ state]
state)))
(defn add-to-selection-node [index]
(ptk/reify ::add-to-selection-node
ptk/UpdateEvent
(update [_ state]
state)))
(defn remove-from-selection-handler [index]
(ptk/reify ::remove-from-selection-handler
ptk/UpdateEvent
(update [_ state]
state)))
(defn remove-from-selection-node [index]
(ptk/reify ::remove-from-selection-handler
ptk/UpdateEvent
(update [_ state]
state)))
(defn deselect-all []
(ptk/reify ::deselect-all
ptk/UpdateEvent
@ -140,7 +108,7 @@
(ptk/reify ::handle-selection
ptk/WatchEvent
(watch [_ state stream]
(watch [_ _ stream]
(let [stop? (fn [event] (or (dwc/interrupt? event) (ms/mouse-up? event)))
stoper (->> stream (rx/filter stop?))
from-p @ms/mouse-position]

View file

@ -98,8 +98,8 @@
;; -- RESIZE
(defn start-resize
[handler initial ids shape]
(letfn [(resize [shape initial resizing-shapes layout [point lock? point-snap]]
[handler ids shape]
(letfn [(resize [shape initial layout [point lock? point-snap]]
(let [{:keys [width height]} (:selrect shape)
{:keys [rotation]} shape
rotation (or rotation 0)
@ -181,7 +181,7 @@
(rx/switch-map (fn [[point :as current]]
(->> (snap/closest-snap-point page-id resizing-shapes layout zoom point)
(rx/map #(conj current %)))))
(rx/mapcat (partial resize shape initial-position resizing-shapes layout))
(rx/mapcat (partial resize shape initial-position layout))
(rx/take-until stoper))
(rx/of (apply-modifiers ids)
(finish-transform))))))))
@ -196,7 +196,7 @@
(assoc-in [:workspace-local :transform] :rotate)))
ptk/WatchEvent
(watch [it state stream]
(watch [_ _ stream]
(let [stoper (rx/filter ms/mouse-up? stream)
group (gsh/selection-rect shapes)
group-center (gsh/center-selrect group)
@ -235,7 +235,7 @@
[]
(ptk/reify ::start-move-selected
ptk/WatchEvent
(watch [it state stream]
(watch [_ state stream]
(let [initial (deref ms/mouse-position)
selected (wsh/lookup-selected state {:omit-blocked? true})
stopper (rx/filter ms/mouse-up? stream)]
@ -259,7 +259,7 @@
(defn start-move-duplicate [from-position]
(ptk/reify ::start-move-selected
ptk/WatchEvent
(watch [it state stream]
(watch [_ _ stream]
(->> stream
(rx/filter (ptk/type? ::dws/duplicate-selected))
(rx/first)
@ -268,7 +268,7 @@
(defn calculate-frame-for-move [ids]
(ptk/reify ::calculate-frame-for-move
ptk/WatchEvent
(watch [it state stream]
(watch [it state _]
(let [position @ms/mouse-position
page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
@ -313,7 +313,7 @@
(assoc-in [:workspace-local :transform] :move)))
ptk/WatchEvent
(watch [it state stream]
(watch [_ state stream]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
selected (wsh/lookup-selected state {:omit-blocked? true})
@ -349,20 +349,6 @@
(calculate-frame-for-move ids)
(finish-transform)))))))))
(defn- get-displacement-with-grid
"Retrieve the correct displacement delta point for the
provided direction speed and distances thresholds."
[shape direction options]
(let [grid-x (:grid-x options 10)
grid-y (:grid-y options 10)
x-mod (mod (:x shape) grid-x)
y-mod (mod (:y shape) grid-y)]
(case direction
:up (gpt/point 0 (- (if (zero? y-mod) grid-y y-mod)))
:down (gpt/point 0 (- grid-y y-mod))
:left (gpt/point (- (if (zero? x-mod) grid-x x-mod)) 0)
:right (gpt/point (- grid-x x-mod) 0))))
(defn- get-displacement
"Retrieve the correct displacement delta point for the
provided direction speed and distances thresholds."
@ -394,7 +380,7 @@
state))
ptk/WatchEvent
(watch [it state stream]
(watch [_ state stream]
(if (= same-event (get-in state [:workspace-local :current-move-selected]))
(let [selected (wsh/lookup-selected state {:omit-blocked? true})
move-events (->> stream
@ -539,7 +525,7 @@
(defn increase-rotation [ids rotation]
(ptk/reify ::increase-rotation
ptk/WatchEvent
(watch [it state stream]
(watch [_ state _]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
@ -559,7 +545,7 @@
(us/verify (s/coll-of uuid?) ids)
(ptk/reify ::apply-modifiers
ptk/WatchEvent
(watch [it state stream]
(watch [_ state _]
(let [objects (wsh/lookup-page-objects state)
children-ids (->> ids (mapcat #(cp/get-children % objects)))
ids-with-children (d/concat [] children-ids ids)
@ -610,11 +596,6 @@
(update [_ state]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
update-children
(fn [objects ids modifiers]
(reduce #(assoc-in %1 [%2 :modifiers] modifiers) objects ids))
;; For each shape updates the modifiers given as arguments
update-shape
@ -629,7 +610,7 @@
#(reduce update-shape % ids))))
ptk/WatchEvent
(watch [it state stream]
(watch [_ state _]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
ids (d/concat [] ids (mapcat #(cp/get-children % objects) ids))]
@ -638,7 +619,7 @@
(defn flip-horizontal-selected []
(ptk/reify ::flip-horizontal-selected
ptk/WatchEvent
(watch [it state stream]
(watch [_ state _]
(let [objects (wsh/lookup-page-objects state)
selected (wsh/lookup-selected state {:omit-blocked? true})
shapes (map #(get objects %) selected)
@ -654,7 +635,7 @@
(defn flip-vertical-selected []
(ptk/reify ::flip-vertical-selected
ptk/WatchEvent
(watch [it state stream]
(watch [_ state _]
(let [objects (wsh/lookup-page-objects state)
selected (wsh/lookup-selected state {:omit-blocked? true})
shapes (map #(get objects %) selected)
@ -687,6 +668,6 @@
[]
(ptk/reify ::selected-to-path
ptk/WatchEvent
(watch [_ state stream]
(watch [_ state _]
(let [ids (wsh/lookup-selected state {:omit-blocked? true})]
(rx/of (dch/update-shapes ids ups/convert-to-path))))))

View file

@ -191,8 +191,7 @@
(mf/defc export-data
[{:keys [shape]}]
(let [props (-> (obj/new) (add-data shape))
frame? (= (:type shape) :frame)]
(let [props (-> (obj/new) (add-data shape))]
[:> "penpot:shape" props
[:& export-shadow-data shape]
[:& export-blur-data shape]

View file

@ -286,9 +286,9 @@
shape-center (geom/center-shape shape)
on-resize (fn [current-position initial-position event]
on-resize (fn [current-position _initial-position event]
(dom/stop-propagation event)
(st/emit! (dw/start-resize current-position initial-position selected shape)))
(st/emit! (dw/start-resize current-position selected shape)))
on-rotate #(do (dom/stop-propagation %)
(st/emit! (dw/start-rotate shapes)))]
@ -311,9 +311,9 @@
shape (geom/transform-shape shape {:round-coords? false})
shape' (if (debug? :simple-selection) (geom/setup {:type :rect} (geom/selection-rect [shape])) shape)
on-resize (fn [current-position initial-position event]
on-resize (fn [current-position _initial-position event]
(dom/stop-propagation event)
(st/emit! (dw/start-resize current-position initial-position #{shape-id} shape')))
(st/emit! (dw/start-resize current-position #{shape-id} shape')))
on-rotate
#(do (dom/stop-propagation %)

View file

@ -126,7 +126,7 @@
(defn without-penpot-prefix
[m]
(let [no-penpot-prefix?
(fn [[k v]]
(fn [[k _]]
(not (str/starts-with? (d/name k) "penpot:")))]
(into {} (filter no-penpot-prefix?) m)))
@ -191,11 +191,11 @@
[props svg-data]
(let [values (->> (select-keys svg-data [:cx :cy :rx :ry])
(d/mapm (fn [_ val] (d/parse-double val))))]
{:x (- (:cx values) (:rx values))
(-> props
(assoc :x (- (:cx values) (:rx values))
:y (- (:cy values) (:ry values))
:width (* (:rx values) 2)
:height (* (:ry values) 2)}))
:height (* (:ry values) 2)))))
(defn parse-path
[props center svg-data]
@ -459,7 +459,7 @@
[props node]
(let [shadows (extract-from-data node :penpot:shadow parse-shadow)]
(cond-> props
(not (empty? shadows))
(d/not-empty? shadows)
(assoc :shadow shadows))))
(defn add-blur
@ -473,7 +473,7 @@
[props node]
(let [exports (extract-from-data node :penpot:export parse-export)]
(cond-> props
(not (empty? exports))
(d/not-empty? exports)
(assoc :exports exports))))
(defn add-layer-options
@ -507,7 +507,7 @@
(reduce assoc-key {}))))
(defn get-svg-defs
[node svg-defs]
[node]
(let [svg-import (get-data node :penpot:svg-import)]
(->> svg-import
@ -545,7 +545,7 @@
(some? svg-defs)
(assoc :svg-defs (get-svg-defs node svg-defs))))
(assoc :svg-defs (get-svg-defs node))))
props)))
@ -571,7 +571,7 @@
(defn add-frame-data [props node]
(let [grids (parse-grids node)]
(cond-> props
(not (empty? grids))
(d/not-empty? grids)
(assoc :grids grids))))
(defn has-image?
@ -641,12 +641,12 @@
background (:background style)
grids (->> (parse-grids node)
(group-by :type)
(d/mapm (fn [k v] (-> v first :params))))]
(d/mapm (fn [_ v] (-> v first :params))))]
(cond-> {}
(some? background)
(assoc-in [:options :background] background)
(not (empty? grids))
(d/not-empty? grids)
(assoc-in [:options :saved-grids] grids))))
(defn parse-interactions

View file

@ -182,7 +182,7 @@
(rx/map #(vector (get files file-id) %)))))))))
(defmethod impl/handler :export-file
[{:keys [team-id project-id files] :as message}]
[{:keys [team-id files] :as message}]
(->> (rx/from files)
(rx/mapcat #(export-file team-id %))

View file

@ -17,7 +17,6 @@
[app.util.zip :as uz]
[app.worker.impl :as impl]
[beicon.core :as rx]
[cuerdas.core :as str]
[tubax.core :as tubax]))
;; Upload changes batches size
@ -111,7 +110,7 @@
(some? (:last-id file))
(assoc-in [:id-mapping old-id] (:last-id file))
(not (empty? interactions))
(d/not-empty? interactions)
(assoc-in [:interactions old-id] interactions))))))
(defn post-process-file