mirror of
https://github.com/penpot/penpot.git
synced 2025-04-13 07:21:40 -05:00
🎉 Add linter for check duplicte potok types.
This commit is contained in:
parent
926fa483b9
commit
7e0c097f23
19 changed files with 54 additions and 35 deletions
|
@ -23,6 +23,9 @@
|
|||
{:unsorted-required-namespaces
|
||||
{:level :warning}
|
||||
|
||||
:potok/reify-type
|
||||
{:level :error}
|
||||
|
||||
:unresolved-namespace
|
||||
{:level :warning
|
||||
:exclude [data_readers]}
|
||||
|
|
|
@ -10,15 +10,34 @@
|
|||
sname])]
|
||||
{:node result}))
|
||||
|
||||
(def registry (atom {}))
|
||||
|
||||
(defn potok-reify
|
||||
[{:keys [:node]}]
|
||||
[{:keys [:node :filename] :as params}]
|
||||
(let [[rnode rtype & other] (:children node)
|
||||
result (api/list-node
|
||||
(into [(api/token-node (symbol "deftype"))
|
||||
(api/token-node (gensym (name (:k rtype))))
|
||||
(api/vector-node [])]
|
||||
other))]
|
||||
{:node result}))
|
||||
rsym (symbol (str "event-type-" (name (:k rtype))))
|
||||
reg (get @registry filename #{})]
|
||||
(when-not (:namespaced? rtype)
|
||||
(let [{:keys [:row :col]} (meta rtype)]
|
||||
(api/reg-finding! {:message "ptk/reify type should be namespaced"
|
||||
:type :potok/reify-type
|
||||
:row row
|
||||
:col col})))
|
||||
|
||||
(if (contains? reg rsym)
|
||||
(let [{:keys [:row :col]} (meta rtype)]
|
||||
(api/reg-finding! {:message (str "duplicate type: " (name (:k rtype)))
|
||||
:type :potok/reify-type
|
||||
:row row
|
||||
:col col}))
|
||||
(swap! registry update filename (fnil conj #{}) rsym))
|
||||
|
||||
(let [result (api/list-node
|
||||
(into [(api/token-node (symbol "deftype"))
|
||||
(api/token-node rsym)
|
||||
(api/vector-node [])]
|
||||
other))]
|
||||
{:node result})))
|
||||
|
||||
(defn clojure-specify
|
||||
[{:keys [:node]}]
|
||||
|
|
|
@ -710,14 +710,14 @@
|
|||
|
||||
(defn go-to-files
|
||||
([project-id]
|
||||
(ptk/reify ::go-to-files
|
||||
(ptk/reify ::go-to-files-1
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [team-id (:current-team-id state)]
|
||||
(rx/of (rt/nav :dashboard-files {:team-id team-id
|
||||
:project-id project-id}))))))
|
||||
([team-id project-id]
|
||||
(ptk/reify ::go-to-files
|
||||
(ptk/reify ::go-to-files-2
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of (rt/nav :dashboard-files {:team-id team-id
|
||||
|
@ -739,13 +739,13 @@
|
|||
|
||||
(defn go-to-projects
|
||||
([]
|
||||
(ptk/reify ::go-to-projects
|
||||
(ptk/reify ::go-to-projects-0
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [team-id (:current-team-id state)]
|
||||
(rx/of (rt/nav :dashboard-projects {:team-id team-id}))))))
|
||||
([team-id]
|
||||
(ptk/reify ::go-to-projects
|
||||
(ptk/reify ::go-to-projects-1
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(du/set-current-team! team-id)
|
||||
|
|
|
@ -232,7 +232,7 @@
|
|||
(rt/nav :viewer pparams (assoc qparams :index (dec index)))))))))
|
||||
|
||||
(def select-next-frame
|
||||
(ptk/reify ::select-prev-frame
|
||||
(ptk/reify ::select-next-frame
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(prn "select-next-frame")
|
||||
|
@ -290,7 +290,7 @@
|
|||
|
||||
(defn go-to-frame-by-index
|
||||
[index]
|
||||
(ptk/reify ::go-to-frame
|
||||
(ptk/reify ::go-to-frame-by-index
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [route (:route state)
|
||||
|
|
|
@ -365,7 +365,6 @@
|
|||
(when (= id (:current-page-id state))
|
||||
go-to-file))))))
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; WORKSPACE File Actions
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -376,7 +375,7 @@
|
|||
(ptk/reify ::rename-file
|
||||
IDeref
|
||||
(-deref [_]
|
||||
{:ev/origin "workspace" :id id :name name})
|
||||
{::ev/origin "workspace" :id id :name name})
|
||||
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
|
@ -1134,7 +1133,7 @@
|
|||
(defn align-objects
|
||||
[axis]
|
||||
(us/verify ::gal/align-axis axis)
|
||||
(ptk/reify :align-objects
|
||||
(ptk/reify ::align-objects
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
|
@ -1165,7 +1164,7 @@
|
|||
(defn distribute-objects
|
||||
[axis]
|
||||
(us/verify ::gal/dist-axis axis)
|
||||
(ptk/reify :align-objects
|
||||
(ptk/reify ::distribute-objects
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [page-id (:current-page-id state)
|
||||
|
@ -1240,7 +1239,7 @@
|
|||
(rx/of (rt/nav' :workspace pparams qparams))))))
|
||||
([page-id]
|
||||
(us/verify ::us/uuid page-id)
|
||||
(ptk/reify ::go-to-page
|
||||
(ptk/reify ::go-to-page-2
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [project-id (:current-project-id state)
|
||||
|
@ -1303,7 +1302,7 @@
|
|||
|
||||
(defn go-to-dashboard-fonts
|
||||
[]
|
||||
(ptk/reify ::go-to-dashboard
|
||||
(ptk/reify ::go-to-dashboard-fonts
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [team-id (:current-team-id state)]
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
(defn show-palette
|
||||
"Show the palette tool and change the library it uses"
|
||||
[selected]
|
||||
(ptk/reify ::change-palette-selected
|
||||
(ptk/reify ::show-palette
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(-> state
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
[app.common.math :as mth]
|
||||
[app.common.spec :as us]
|
||||
[app.main.data.comments :as dcm]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.common :as dwc]
|
||||
[app.main.streams :as ms]
|
||||
|
@ -72,7 +71,7 @@
|
|||
(defn center-to-comment-thread
|
||||
[{:keys [position] :as thread}]
|
||||
(us/assert ::dcm/comment-thread thread)
|
||||
(ptk/reify :center-to-comment-thread
|
||||
(ptk/reify ::center-to-comment-thread
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update state :workspace-local
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
(defn remove-frame-grid
|
||||
[frame-id index]
|
||||
(ptk/reify ::set-frame-grid
|
||||
(ptk/reify ::remove-frame-grid
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(rx/of (dch/update-shapes [frame-id] (fn [o] (update o :grids (fnil #(d/remove-at-index % index) []))))))))
|
||||
|
|
|
@ -295,7 +295,7 @@
|
|||
[]
|
||||
(ptk/reify ::add-component
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(watch [_ state _]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
selected (->> (wsh/lookup-selected state)
|
||||
(cp/clean-loops objects))]
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
|
||||
(defn- handle-pointer-send
|
||||
[file-id point]
|
||||
(ptk/reify ::handle-pointer-update
|
||||
(ptk/reify ::handle-pointer-send
|
||||
ptk/EffectEvent
|
||||
(effect [_ state _]
|
||||
(let [ws (get-in state [:ws file-id])
|
||||
|
|
|
@ -179,7 +179,7 @@
|
|||
:right (gpt/point 1 0)))
|
||||
|
||||
(defn finish-move-selected []
|
||||
(ptk/reify ::move-selected
|
||||
(ptk/reify ::finish-move-selected
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [id (get-in state [:workspace-local :edition])]
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
;; Shortcuts format https://github.com/ccampbell/mousetrap
|
||||
|
||||
(defn esc-pressed []
|
||||
(ptk/reify :esc-pressed
|
||||
(ptk/reify ::esc-pressed
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
;; Not interrupt when we're editing a path
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
"Joins the head with the previous undo in one. This is done so when the user changes a
|
||||
node handlers after adding it the undo merges both in one operation only"
|
||||
[]
|
||||
(ptk/reify ::add-undo-entry
|
||||
(ptk/reify ::merge-head
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [id (st/get-path-id state)
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
(defn deselect-shape
|
||||
[id]
|
||||
(us/verify ::us/uuid id)
|
||||
(ptk/reify ::select-shape
|
||||
(ptk/reify ::deselect-shape
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-local :selected] disj id))))
|
||||
|
|
|
@ -511,7 +511,7 @@
|
|||
|
||||
(defn- start-move-duplicate
|
||||
[from-position]
|
||||
(ptk/reify ::start-move-selected
|
||||
(ptk/reify ::start-move-duplicate
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ stream]
|
||||
(->> stream
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.router :as rt]
|
||||
[beicon.core :as rx]
|
||||
[potok.core :as ptk]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(defn get-project-name
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
[app.common.spec :as us]
|
||||
[app.config :as cfg]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.refs :as refs]
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
(:require
|
||||
[app.common.spec :as us]
|
||||
[app.config :as cfg]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.users :as du]
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
(ns app.main.ui.viewer.handoff.code
|
||||
(:require
|
||||
["js-beautify" :as beautify]
|
||||
[app.main.data.events :as ev]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.code-block :refer [code-block]]
|
||||
[app.main.ui.components.copy-button :refer [copy-button]]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.main.store :as st]
|
||||
[potok.core :as ptk]
|
||||
[app.util.code-gen :as cg]
|
||||
[app.util.dom :as dom]
|
||||
[cuerdas.core :as str]
|
||||
[potok.core :as ptk]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(defn generate-markup-code [_type shapes]
|
||||
|
|
Loading…
Add table
Reference in a new issue