mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 10:58:04 +08:00
Clean up web code errors and make CI enforce them
This commit is contained in:
@@ -203,7 +203,7 @@
|
||||
|
||||
function setColorRGB(channel: keyof RGB, strength: number | undefined) {
|
||||
// Do nothing if the given value is undefined
|
||||
if (strength === undefined) undefined;
|
||||
if (strength === undefined) return undefined;
|
||||
// Set the specified channel to the given value
|
||||
else if (channel === "r") setColor(new Color(strength / 255, newColor.green, newColor.blue, newColor.alpha));
|
||||
else if (channel === "g") setColor(new Color(newColor.red, strength / 255, newColor.blue, newColor.alpha));
|
||||
@@ -212,7 +212,7 @@
|
||||
|
||||
function setColorHSV(channel: keyof HSV, strength: number | undefined) {
|
||||
// Do nothing if the given value is undefined
|
||||
if (strength === undefined) undefined;
|
||||
if (strength === undefined) return undefined;
|
||||
// Set the specified channel to the given value
|
||||
else if (channel === "h") hue = strength / 360;
|
||||
else if (channel === "s") saturation = strength / 100;
|
||||
|
||||
@@ -219,7 +219,7 @@
|
||||
|
||||
childReference.open = true;
|
||||
// The reason we bother taking `highlightdEntry` as an argument is because, when this function is called, it can ensure `highlightedEntry` is not undefined.
|
||||
// But here we still have to set `highlighted` to itself so Svelte knows to reactively update it after we set its `.ref.open` property.
|
||||
// But here we still have to set `highlighted` to itself so Svelte knows to reactively update it after we set its `childReference.open` property.
|
||||
highlighted = highlighted;
|
||||
|
||||
// Highlight first item
|
||||
@@ -452,11 +452,11 @@
|
||||
|
||||
{#if entry.children}
|
||||
<MenuList
|
||||
on:naturalWidth={() => {
|
||||
on:naturalWidth={({ detail }) => {
|
||||
// We do a manual dispatch here instead of just `on:naturalWidth` as a workaround for the <script> tag
|
||||
// at the top of this file displaying a "'render' implicitly has return type 'any' because..." error.
|
||||
// See explanation at <https://github.com/sveltejs/language-tools/issues/452#issuecomment-723148184>.
|
||||
dispatch("naturalWidth");
|
||||
dispatch("naturalWidth", detail);
|
||||
}}
|
||||
open={getChildReference(entry)?.open || false}
|
||||
direction="TopRight"
|
||||
|
||||
@@ -178,10 +178,10 @@
|
||||
const { nodeOutput, nodeInput } = resolveWire(wire);
|
||||
if (!nodeOutput || !nodeInput) return [];
|
||||
|
||||
const wireStartNode = $nodeGraph.nodes.get((wire.wireStart as Node).nodeId);
|
||||
const wireStartNode = wire.wireStart.nodeId !== undefined ? $nodeGraph.nodes.get(wire.wireStart.nodeId) : undefined;
|
||||
const wireStart = wireStartNode?.isLayer || false;
|
||||
|
||||
const wireEndNode = $nodeGraph.nodes.get((wire.wireEnd as Node).nodeId);
|
||||
const wireEndNode = wire.wireEnd.nodeId !== undefined ? $nodeGraph.nodes.get(wire.wireEnd.nodeId) : undefined;
|
||||
const wireEnd = (wireEndNode?.isLayer && Number(wire.wireEnd.index) === 0) || false;
|
||||
|
||||
return [createWirePath(nodeOutput, nodeInput, wireStart, wireEnd, wire.dashed)];
|
||||
|
||||
@@ -42,11 +42,8 @@
|
||||
(e.target as HTMLElement | undefined)?.focus();
|
||||
|
||||
// Open the menu list floating menu
|
||||
if (self) {
|
||||
self.open = true;
|
||||
} else {
|
||||
throw new Error("The menu bar floating menu has no associated ref");
|
||||
}
|
||||
if (self) self.open = true;
|
||||
else throw new Error("The menu bar floating menu has no reference to `self`");
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
activeEntrySkipWatcher = false;
|
||||
} else if (activeEntry !== DASH_ENTRY) {
|
||||
// We need to set to the initial value first to track a right history step, as if we hover in initial selection.
|
||||
dispatch("hoverInEntry", initialSelectedIndex);
|
||||
if (initialSelectedIndex !== undefined) dispatch("hoverInEntry", initialSelectedIndex);
|
||||
dispatch("selectedIndex", entries.flat().indexOf(activeEntry));
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@
|
||||
}
|
||||
|
||||
function dispatchHoverOutEntry() {
|
||||
dispatch("hoverOutEntry", initialSelectedIndex);
|
||||
if (initialSelectedIndex !== undefined) dispatch("hoverOutEntry", initialSelectedIndex);
|
||||
}
|
||||
|
||||
function makeActiveEntry(): MenuListEntry {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
const pointerPosition = (direction: ScrollbarDirection, e: PointerEvent): number => (direction === "Vertical" ? e.clientY : e.clientX);
|
||||
|
||||
const dispatch = createEventDispatcher<{ handlePosition: number; pressTrack: number; pointerup }>();
|
||||
const dispatch = createEventDispatcher<{ handlePosition: number; pressTrack: number; pointerup: undefined }>();
|
||||
|
||||
export let direction: ScrollbarDirection = "Vertical";
|
||||
export let handlePosition = 0.5;
|
||||
|
||||
@@ -59,10 +59,9 @@
|
||||
|
||||
// New fields in `MenuListEntry`
|
||||
shortcutRequiresLock: entry.shortcut ? shortcutRequiresLock(entry.shortcut.keys) : undefined,
|
||||
value: undefined,
|
||||
value: "",
|
||||
disabled: entry.disabled ?? undefined,
|
||||
font: undefined,
|
||||
ref: undefined,
|
||||
});
|
||||
|
||||
entries = updateMenuBarLayout.layout.map(menuBarEntryToMenuListEntry);
|
||||
|
||||
Reference in New Issue
Block a user