Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

add eslint rules + fixes

Andras Bacsai2c1752e4d7ae
diff --git a/apps/designer/app/canvas/canvas.tsx b/apps/designer/app/canvas/canvas.tsx
index 3e83d8c70a..f18a8e9d1a 100644
--- a/apps/designer/app/canvas/canvas.tsx
+++ b/apps/designer/app/canvas/canvas.tsx
@@ -65,7 +65,9 @@ const useElementsTree = () => {
const onChangeChildren: OnChangeChildren = useCallback(
(change) => {
store.createTransaction([rootInstanceContainer], (rootInstance) => {
- if (rootInstance === undefined) return;
+ if (rootInstance === undefined) {
+ return;
+ }
const { instanceId, updates } = change;
utils.tree.setInstanceChildrenMutable(
@@ -80,7 +82,9 @@ const useElementsTree = () => {
);
return useMemo(() => {
- if (rootInstance === undefined) return;
+ if (rootInstance === undefined) {
+ return;
+ }
return createElementsTree({
sandbox: true,
@@ -182,7 +186,9 @@ export const Canvas = ({ data }: CanvasProps): JSX.Element | null => {
const isPreviewMode = useSubscribePreviewMode();
const elements = useElementsTree();
- if (elements === undefined) return null;
+ if (elements === undefined) {
+ return null;
+ }
if (isPreviewMode || isDesignerReady === false) {
return (
diff --git a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx
index b391dbd4c2..088038544a 100644
--- a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx
+++ b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx
@@ -57,7 +57,9 @@ export const WrapperComponentDev = ({
const refCallback = useCallback(
(element) => {
// When entering text editing we unmount the instance element, so we need to update the reference, otherwise we have a detached element referenced and bounding box will be wrong.
- if (element !== null) setSelectedElement(element);
+ if (element !== null) {
+ setSelectedElement(element);
+ }
},
[setSelectedElement]
);
diff --git a/apps/designer/app/canvas/shared/breakpoints.ts b/apps/designer/app/canvas/shared/breakpoints.ts
index 54f5b92052..0dce73fd90 100644
--- a/apps/designer/app/canvas/shared/breakpoints.ts
+++ b/apps/designer/app/canvas/shared/breakpoints.ts
@@ -33,7 +33,9 @@ const usePublishBreakpoints = () => {
const useBreakpointChange = () => {
useSubscribe("breakpointChange", (breakpoint) => {
store.createTransaction([breakpointsContainer], (breakpoints) => {
- const foundBreakpoint = breakpoints.find(({ id }) => id == breakpoint.id);
+ const foundBreakpoint = breakpoints.find(
+ ({ id }) => id === breakpoint.id
+ );
if (foundBreakpoint) {
foundBreakpoint.label = breakpoint.label;
foundBreakpoint.minWidth = breakpoint.minWidth;
@@ -52,9 +54,11 @@ const useBreakpointDelete = () => {
store.createTransaction(
[breakpointsContainer, rootInstanceContainer],
(breakpoints, rootInstance) => {
- if (rootInstance === undefined) return;
+ if (rootInstance === undefined) {
+ return;
+ }
- const index = breakpoints.findIndex(({ id }) => id == breakpoint.id);
+ const index = breakpoints.findIndex(({ id }) => id === breakpoint.id);
if (index !== -1) {
breakpoints.splice(index, 1);
}
diff --git a/apps/designer/app/canvas/shared/instance.ts b/apps/designer/app/canvas/shared/instance.ts
index 450fcb2f77..f192f84637 100644
--- a/apps/designer/app/canvas/shared/instance.ts
+++ b/apps/designer/app/canvas/shared/instance.ts
@@ -97,7 +97,9 @@ export const useInsertInstance = ({ treeId }: { treeId: string }) => {
store.createTransaction(
[rootInstanceContainer, allUserPropsContainer],
(rootInstance, allUserProps) => {
- if (rootInstance === undefined) return;
+ if (rootInstance === undefined) {
+ return;
+ }
const populatedInstance = utils.tree.populateInstance(
instance,
breakpoints[0].id
@@ -127,7 +129,9 @@ export const useReparentInstance = () => {
useSubscribe("reparentInstance", ({ instanceId, dropTarget }) => {
store.createTransaction([rootInstanceContainer], (rootInstance) => {
- if (rootInstance === undefined) return;
+ if (rootInstance === undefined) {
+ return;
+ }
utils.tree.reparentInstanceMutable(
rootInstance,
instanceId,
@@ -254,7 +258,9 @@ export const usePublishSelectedInstanceDataRect = () => {
const rect = useMeasureInstance(element);
useEffect(() => {
- if (rect) publishRect(rect);
+ if (rect) {
+ publishRect(rect);
+ }
}, [rect]);
};
@@ -278,7 +284,9 @@ export const useSetHoveredInstance = () => {
);
useEffect(() => {
- if (hoveredElement === undefined) return;
+ if (hoveredElement === undefined) {
+ return;
+ }
publish({
type: "hoveredInstanceRect",
payload: hoveredElement.getBoundingClientRect(),
@@ -310,7 +318,9 @@ export const useUpdateSelectedInstance = () => {
instance = utils.tree.findInstanceById(rootInstance, selectedInstance.id);
}
// When it's a new inserted instance, it will be undefined, so we can't set it to undefined and remove it.
- if (instance !== undefined) setSelectedInstance(instance);
+ if (instance !== undefined) {
+ setSelectedInstance(instance);
+ }
}, [rootInstance, selectedInstance, setSelectedInstance]);
};
diff --git a/apps/designer/app/canvas/shared/styles.ts b/apps/designer/app/canvas/shared/styles.ts
index e89913f49b..dfa0f3b919 100644
--- a/apps/designer/app/canvas/shared/styles.ts
+++ b/apps/designer/app/canvas/shared/styles.ts
@@ -203,7 +203,9 @@ const useUpdateStyle = () => {
useSubscribe("updateStyle", ({ id, updates, breakpoint }) => {
// Only update styles if they match the selected instance
// It can potentially happen that we selected a difference instance right after we changed the style in style panel.
- if (id !== selectedInstance?.id) return;
+ if (id !== selectedInstance?.id) {
+ return;
+ }
for (const update of updates) {
setCssVar(id, update.property, undefined);
diff --git a/apps/designer/app/canvas/shared/sync/queue.ts b/apps/designer/app/canvas/shared/sync/queue.ts
index 684f371c15..18e0f4a3ec 100644
--- a/apps/designer/app/canvas/shared/sync/queue.ts
+++ b/apps/designer/app/canvas/shared/sync/queue.ts
@@ -19,7 +19,9 @@ const queue: Array<Job> = [];
export const enqueue = (job: Job) => {
queue.push(job);
- if (isInProgress === false) dequeue();
+ if (isInProgress === false) {
+ dequeue();
+ }
};
let isInProgress = false;
diff --git a/apps/designer/app/canvas/shared/sync/use-sync.ts b/apps/designer/app/canvas/shared/sync/use-sync.ts
index c25cd4bb04..e8f22b923c 100644
--- a/apps/designer/app/canvas/shared/sync/use-sync.ts
+++ b/apps/designer/app/canvas/shared/sync/use-sync.ts
@@ -14,7 +14,9 @@ export const useSync = ({
}) => {
useInterval(() => {
const entries = sync();
- if (entries.length === 0) return;
+ if (entries.length === 0) {
+ return;
+ }
// @todo this entire queueing logic needs to be gone, it's a workaround,
// because prisma can't do atomic updates yet with sandbox documents
diff --git a/apps/designer/app/canvas/shared/use-pointer-outline.ts b/apps/designer/app/canvas/shared/use-pointer-outline.ts
index 5845274fd5..ccdec7ade6 100644
--- a/apps/designer/app/canvas/shared/use-pointer-outline.ts
+++ b/apps/designer/app/canvas/shared/use-pointer-outline.ts
@@ -22,7 +22,9 @@ export const usePointerOutline = () => {
}, []);
return (offset: Point) => {
- if (ref.current === undefined) return;
+ if (ref.current === undefined) {
+ return;
+ }
ref.current.style.left = `${offset.x}px`;
ref.current.style.top = `${offset.y}px`;
};
diff --git a/apps/designer/app/canvas/shared/use-shortcuts.ts b/apps/designer/app/canvas/shared/use-shortcuts.ts
index 5255e8f549..5304d15a74 100644
--- a/apps/designer/app/canvas/shared/use-shortcuts.ts
+++ b/apps/designer/app/canvas/shared/use-shortcuts.ts
@@ -50,7 +50,9 @@ const publishZoom = (event: HandlerEvent) => {
"`publishZoom` doesn't account for being called without a `key`"
);
}
- if (event.preventDefault !== undefined) event.preventDefault();
+ if (event.preventDefault !== undefined) {
+ event.preventDefault();
+ }
publish({
type: "zoom",
payload: event.key === "-" ? "zoomOut" : "zoomIn",
@@ -100,7 +102,9 @@ export const useShortcuts = () => {
useHotkeys(
"esc",
() => {
- if (selectedInstance === undefined) return;
+ if (selectedInstance === undefined) {
+ return;
+ }
// Since we are in text editing mode, we want to first exit that mode without unselecting the instance.
if (editingInstanceId) {
setEditingInstanceId(undefined);
@@ -116,7 +120,9 @@ export const useShortcuts = () => {
useHotkeys(
"enter",
(event) => {
- if (selectedInstance === undefined) return;
+ if (selectedInstance === undefined) {
+ return;
+ }
const { type } = getComponentMeta(selectedInstance.component);
if (type === "rich-text") {
// Prevents inserting a newline when entering text-editing mode
diff --git a/apps/designer/app/canvas/shared/use-track-selected-element.ts b/apps/designer/app/canvas/shared/use-track-selected-element.ts
index e72070bb10..6c219d5ee7 100644
--- a/apps/designer/app/canvas/shared/use-track-selected-element.ts
+++ b/apps/designer/app/canvas/shared/use-track-selected-element.ts
@@ -36,7 +36,9 @@ export const useTrackSelectedElement = () => {
const [rootInstance] = useRootInstance();
const selectInstance = useCallback(
(id) => {
- if (rootInstance === undefined) return;
+ if (rootInstance === undefined) {
+ return;
+ }
const instance = utils.tree.findInstanceById(rootInstance, id);
setSelectedInstance(instance);
},
@@ -53,7 +55,9 @@ export const useTrackSelectedElement = () => {
selectedInstance?.id !== getInstanceIdFromElement(selectedElement))
) {
const element = getInstanceElementById(selectedInstance.id);
- if (element === null) return;
+ if (element === null) {
+ return;
+ }
setSelectedElement(element);
}
}, [selectedInstance, selectedElement, setSelectedElement]);
diff --git a/apps/designer/app/designer/designer.tsx b/apps/designer/app/designer/designer.tsx
index a4bff3cb18..d28bfdf3e7 100644
--- a/apps/designer/app/designer/designer.tsx
+++ b/apps/designer/app/designer/designer.tsx
@@ -144,7 +144,9 @@ const SidePanel = ({
gridArea,
css,
}: SidePanelProps) => {
- if (isPreviewMode === true) return null;
+ if (isPreviewMode === true) {
+ return null;
+ }
return (
<Box
as="aside"
diff --git a/apps/designer/app/designer/features/breakpoints/breakpoints.tsx b/apps/designer/app/designer/features/breakpoints/breakpoints.tsx
index c0be3c6029..26d9f72414 100644
--- a/apps/designer/app/designer/features/breakpoints/breakpoints.tsx
+++ b/apps/designer/app/designer/features/breakpoints/breakpoints.tsx
@@ -86,10 +86,14 @@ export const Breakpoints = ({ publish }: BreakpointsProps) => {
setView(undefined);
});
- if (selectedBreakpoint === undefined) return null;
+ if (selectedBreakpoint === undefined) {
+ return null;
+ }
const handleDelete = () => {
- if (breakpointToDelete === undefined) return;
+ if (breakpointToDelete === undefined) {
+ return;
+ }
const nextBreakpoints = [...breakpoints];
const index = breakpoints.indexOf(breakpointToDelete);
nextBreakpoints.splice(index, 1);
diff --git a/apps/designer/app/designer/features/breakpoints/trigger-button.tsx b/apps/designer/app/designer/features/breakpoints/trigger-button.tsx
index f735140051..511f4c76d2 100644
--- a/apps/designer/app/designer/features/breakpoints/trigger-button.tsx
+++ b/apps/designer/app/designer/features/breakpoints/trigger-button.tsx
@@ -37,7 +37,9 @@ export const TriggerButton = forwardRef<
const [zoom] = useZoom();
const [breakpoint] = useSelectedBreakpoint();
const [canvasWidth] = useCanvasWidth();
- if (breakpoint === undefined) return null;
+ if (breakpoint === undefined) {
+ return null;
+ }
const variant = willRender(breakpoint, canvasWidth) ? "contrast" : "hint";
return (
diff --git a/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts b/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts
index e989d856ef..4e1439bdf5 100644
--- a/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts
+++ b/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts
@@ -23,8 +23,9 @@ export const useSubscribeBreakpoints = () => {
const nextSelectedBreakpoint = breakpoints.find(
(breakpoint) => breakpoint.id === selectedBreakpoint.id
);
- if (nextSelectedBreakpoint !== undefined)
+ if (nextSelectedBreakpoint !== undefined) {
setSelectedBreakpoint(nextSelectedBreakpoint);
+ }
}
}, [breakpoints, selectedBreakpoint, setSelectedBreakpoint]);
};
diff --git a/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts b/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts
index 48e8a2799c..48f4ef9a87 100644
--- a/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts
+++ b/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts
@@ -11,7 +11,9 @@ export const useSubscribeSelectBreakpointFromShortcut = () => {
const [, setSelectedBreakpoint] = useSelectedBreakpoint();
useSubscribe("selectBreakpointFromShortcut", (index) => {
const breakpoint = utils.breakpoints.sort(breakpoints)[index - 1];
- if (breakpoint) setSelectedBreakpoint(breakpoint);
+ if (breakpoint) {
+ setSelectedBreakpoint(breakpoint);
+ }
});
};
diff --git a/apps/designer/app/designer/features/breakpoints/use-update-canvas-width.ts b/apps/designer/app/designer/features/breakpoints/use-update-canvas-width.ts
index 1dc7a29e7b..854923e752 100644
--- a/apps/designer/app/designer/features/breakpoints/use-update-canvas-width.ts
+++ b/apps/designer/app/designer/features/breakpoints/use-update-canvas-width.ts
@@ -14,7 +14,9 @@ export const useUpdateCanvasWidth = () => {
// Ensure the size is within currently selected breakpoint when returning to design mode out of preview mode,
// because preview mode enables resizing without constraining to the selected breakpoint.
useEffect(() => {
- if (isPreviewMode === true || selectedBreakpoint === undefined) return;
+ if (isPreviewMode === true || selectedBreakpoint === undefined) {
+ return;
+ }
setCanvasWidth(Math.max(selectedBreakpoint.minWidth, minWidth));
}, [isPreviewMode, selectedBreakpoint, setCanvasWidth]);
diff --git a/apps/designer/app/designer/features/breakpoints/width-setting.tsx b/apps/designer/app/designer/features/breakpoints/width-setting.tsx
index f4cc5ae2e6..92f815cd5b 100644
--- a/apps/designer/app/designer/features/breakpoints/width-setting.tsx
+++ b/apps/designer/app/designer/features/breakpoints/width-setting.tsx
@@ -24,11 +24,15 @@ const useNextBreakpoint = () => {
);
return useMemo(() => {
- if (selectedBreakpoint === undefined) return;
+ if (selectedBreakpoint === undefined) {
+ return;
+ }
const index = sortedBreakpoints.findIndex(
(breakpoint) => breakpoint.id === selectedBreakpoint.id
);
- if (index === -1) return undefined;
+ if (index === -1) {
+ return undefined;
+ }
return sortedBreakpoints[index + 1];
}, [sortedBreakpoints, selectedBreakpoint]);
};
@@ -39,7 +43,9 @@ export const WidthSetting = () => {
const nextBreakpoint = useNextBreakpoint();
const [isPreviewMode] = useIsPreviewMode();
- if (selectedBreakpoint === undefined) return null;
+ if (selectedBreakpoint === undefined) {
+ return null;
+ }
// We want to enable unconstrained resizing in a preview mode
const min = isPreviewMode
diff --git a/apps/designer/app/designer/features/props-panel/use-props-logic.ts b/apps/designer/app/designer/features/props-panel/use-props-logic.ts
index 653f118812..c3191eae43 100644
--- a/apps/designer/app/designer/features/props-panel/use-props-logic.ts
+++ b/apps/designer/app/designer/features/props-panel/use-props-logic.ts
@@ -202,7 +202,9 @@ export const usePropsLogic = ({
const prop = userProps.find((prop) => prop.id === id);
// Required prop should never be deleted
- if (prop === undefined || prop.required) return;
+ if (prop === undefined || prop.required) {
+ return;
+ }
const index = nextUserProps.indexOf(prop);
nextUserProps.splice(index, 1);
diff --git a/apps/designer/app/designer/features/sidebar-left/lib/navigator/navigator.tsx b/apps/designer/app/designer/features/sidebar-left/lib/navigator/navigator.tsx
index 9e7b0a2d61..1da8deea10 100644
--- a/apps/designer/app/designer/features/sidebar-left/lib/navigator/navigator.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/lib/navigator/navigator.tsx
@@ -78,7 +78,9 @@ export const Navigator = ({ publish, isClosable, onClose }: NavigatorProps) => {
[publish]
);
- if (rootInstance === undefined) return null;
+ if (rootInstance === undefined) {
+ return null;
+ }
return (
<Flex css={{ height: "100%", flexDirection: "column" }}>
<Header
diff --git a/apps/designer/app/designer/features/style-panel/controls/color/color-control.tsx b/apps/designer/app/designer/features/style-panel/controls/color/color-control.tsx
index 4cac018c00..be949031dc 100644
--- a/apps/designer/app/designer/features/style-panel/controls/color/color-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/color/color-control.tsx
@@ -14,7 +14,9 @@ export const ColorControl = ({
inheritedStyle,
property: styleConfig.property,
});
- if (value === undefined) return null;
+ if (value === undefined) {
+ return null;
+ }
const setValue = setProperty(styleConfig.property);
return (
diff --git a/apps/designer/app/designer/features/style-panel/controls/font-family/font-family-control.tsx b/apps/designer/app/designer/features/style-panel/controls/font-family/font-family-control.tsx
index 80ea48ade2..691223728a 100644
--- a/apps/designer/app/designer/features/style-panel/controls/font-family/font-family-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/font-family/font-family-control.tsx
@@ -19,7 +19,9 @@ export const FontFamilyControl = ({
});
const [isOpen, setIsOpen] = useState(false);
- if (value === undefined) return null;
+ if (value === undefined) {
+ return null;
+ }
const setValue = setProperty(styleConfig.property);
diff --git a/apps/designer/app/designer/features/style-panel/controls/font-weight/font-weight-control.tsx b/apps/designer/app/designer/features/style-panel/controls/font-weight/font-weight-control.tsx
index bfe647e781..40a82a3eb2 100644
--- a/apps/designer/app/designer/features/style-panel/controls/font-weight/font-weight-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/font-weight/font-weight-control.tsx
@@ -51,7 +51,7 @@ const useLabels = (
const selectedLabel = useMemo(() => {
const selectedOption = availableFontWeights.find(
- (option) => option.weight == currentWeight
+ (option) => option.weight === currentWeight
);
return selectedOption?.label;
}, [currentWeight, availableFontWeights]);
@@ -87,7 +87,9 @@ export const FontWeightControl = ({
toValue(fontWeight)
);
- if (fontWeight === undefined) return null;
+ if (fontWeight === undefined) {
+ return null;
+ }
const setValue = setProperty(styleConfig.property);
@@ -98,7 +100,7 @@ export const FontWeightControl = ({
value={selectedLabel}
onChange={(label) => {
const selected = availableFontWeights.find(
- (option) => option.label == label
+ (option) => option.label === label
);
if (selected) {
setValue(selected.weight);
diff --git a/apps/designer/app/designer/features/style-panel/controls/image/image-control.tsx b/apps/designer/app/designer/features/style-panel/controls/image/image-control.tsx
index 3a7f433064..b60f4f70e5 100644
--- a/apps/designer/app/designer/features/style-panel/controls/image/image-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/image/image-control.tsx
@@ -19,7 +19,9 @@ export const ImageControl = ({
property: styleConfig.property,
});
- if (value === undefined) return null;
+ if (value === undefined) {
+ return null;
+ }
const setValue = setProperty(styleConfig.property);
diff --git a/apps/designer/app/designer/features/style-panel/controls/menu/menu-control.tsx b/apps/designer/app/designer/features/style-panel/controls/menu/menu-control.tsx
index 6f8b2ddd80..34aa7c8f3e 100644
--- a/apps/designer/app/designer/features/style-panel/controls/menu/menu-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/menu/menu-control.tsx
@@ -19,7 +19,9 @@ export const MenuControl = ({
styleConfig.property
);
- if (value === undefined) return null;
+ if (value === undefined) {
+ return null;
+ }
const setValue = setProperty(styleConfig.property);
const currentValue = value.value as string;
diff --git a/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx b/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx
index bf42d714e1..c0e3fdbc68 100644
--- a/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx
+++ b/apps/designer/app/designer/features/style-panel/controls/select/select-control.tsx
@@ -15,7 +15,9 @@ export const SelectControl = ({
property: styleConfig.property,
});
- if (value === undefined) return null;
+ if (value === undefined) {
+ return null;
+ }
const setValue = setProperty(styleConfig.property);
diff --git a/apps/designer/app/designer/features/style-panel/sections/flex-child/flex-child.tsx b/apps/designer/app/designer/features/style-panel/sections/flex-child/flex-child.tsx
index ab423faca0..5f64c483a3 100644
--- a/apps/designer/app/designer/features/style-panel/sections/flex-child/flex-child.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/flex-child/flex-child.tsx
@@ -270,8 +270,14 @@ const FlexChildSectionOrderPopover = (props: RenderCategoryProps) => {
};
const getSizingValue = (flexGrow: string, flexShrink: string) => {
- if (flexGrow === "0" && flexShrink === "0") return "none";
- if (flexGrow === "1" && flexShrink === "0") return "grow";
- if (flexGrow === "0" && flexShrink === "1") return "shrink";
+ if (flexGrow === "0" && flexShrink === "0") {
+ return "none";
+ }
+ if (flexGrow === "1" && flexShrink === "0") {
+ return "grow";
+ }
+ if (flexGrow === "0" && flexShrink === "1") {
+ return "shrink";
+ }
return "";
};
diff --git a/apps/designer/app/designer/features/style-panel/sections/layout/shared/lock.tsx b/apps/designer/app/designer/features/style-panel/sections/layout/shared/lock.tsx
index 5f0ce47922..4d302db14c 100644
--- a/apps/designer/app/designer/features/style-panel/sections/layout/shared/lock.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/layout/shared/lock.tsx
@@ -24,8 +24,12 @@ export const Lock = ({
const [isPaired, setIsPaired] = useState(aVal === bVal);
useEffect(() => {
- if (isPaired === false) return;
- if (aVal === bVal) return;
+ if (isPaired === false) {
+ return;
+ }
+ if (aVal === bVal) {
+ return;
+ }
batchUpdate.setProperty(aKey)(aVal);
batchUpdate.setProperty(bKey)(aVal);
batchUpdate.publish();
diff --git a/apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx b/apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx
index 86f81bea60..a67489c5b6 100644
--- a/apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx
+++ b/apps/designer/app/designer/features/style-panel/sections/spacing/spacing.tsx
@@ -150,7 +150,9 @@ const toCss = (style: SpacingSingularStyle) => {
let property: SpacingProperty;
for (property in style) {
const value = style[property];
- if (value === undefined) continue;
+ if (value === undefined) {
+ continue;
+ }
css[property] = toValue(value);
}
return css;
diff --git a/apps/designer/app/designer/features/style-panel/shared/color-picker.tsx b/apps/designer/app/designer/features/style-panel/shared/color-picker.tsx
index fd3104aaac..b27074b909 100644
--- a/apps/designer/app/designer/features/style-panel/shared/color-picker.tsx
+++ b/apps/designer/app/designer/features/style-panel/shared/color-picker.tsx
@@ -49,7 +49,9 @@ export const ColorPicker = ({
}: ColorPickerProps) => {
const [displayColorPicker, setDisplayColorPicker] = useState(false);
// Color picker will use 0 as alpha value, which will force user to set alpha every time they have to change from transparent
- if (value === "transparent") value = "";
+ if (value === "transparent") {
+ value = "";
+ }
const prefix = (
<Popover
diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
index ec7ae43fd7..de425c3448 100644
--- a/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
+++ b/apps/designer/app/designer/features/style-panel/shared/css-value-input/css-value-input.tsx
@@ -30,7 +30,7 @@ import {
} from "react";
import { useIsFromCurrentBreakpoint } from "../use-is-from-current-breakpoint";
import { useUnitSelect } from "./unit-select";
-import { unstable_batchedUpdates } from "react-dom";
+import { unstable_batchedUpdates as unstableBatchedUpdates } from "react-dom";
import { parseIntermediateOrInvalidValue } from "./parse-intermediate-or-invalid-value";
const unsetValue: UnsetValue = { type: "unset", value: "" };
@@ -118,7 +118,7 @@ const useScrub = ({
onValueChange(event) {
// Will work without but depends on order of setState updates
// at text-control, now fixed in both places (order of updates is right, and batched here)
- unstable_batchedUpdates(() => {
+ unstableBatchedUpdates(() => {
onChangeCompleteRef.current({
type,
unit,
@@ -310,7 +310,9 @@ export const CssValueInput = ({
const handleOnBlur: KeyboardEventHandler = (event) => {
// When select is open, onBlur is triggered,though we don't want a change event in this case.
- if (isUnitsOpen || isOpen) return;
+ if (isUnitsOpen || isOpen) {
+ return;
+ }
onChangeComplete(value);
inputProps.onBlur(event);
@@ -329,7 +331,7 @@ export const CssValueInput = ({
const prefix = icon && (
<CssValueInputIconButton
state={isCurrentBreakpoint ? "set" : undefined}
- css={value.type == "unit" ? { cursor: "ew-resize" } : undefined}
+ css={value.type === "unit" ? { cursor: "ew-resize" } : undefined}
>
{icon}
</CssValueInputIconButton>
@@ -365,7 +367,9 @@ export const CssValueInput = ({
{...inputProps}
onFocus={() => {
const isFocused = document.activeElement === inputRef.current;
- if (isFocused) inputRef.current?.select();
+ if (isFocused) {
+ inputRef.current?.select();
+ }
}}
onBlur={handleOnBlur}
onKeyDown={handleKeyDown}
diff --git a/apps/designer/app/designer/features/style-panel/shared/css-value-input/unit-select.tsx b/apps/designer/app/designer/features/style-panel/shared/css-value-input/unit-select.tsx
index 7e9bc56036..d4608970c3 100644
--- a/apps/designer/app/designer/features/style-panel/shared/css-value-input/unit-select.tsx
+++ b/apps/designer/app/designer/features/style-panel/shared/css-value-input/unit-select.tsx
@@ -78,7 +78,7 @@ export const useUnitSelect = ({
if (
value === undefined ||
- renderUnits == undefined ||
+ renderUnits === undefined ||
renderValue === undefined ||
renderUnits.length < 2
) {
@@ -94,7 +94,9 @@ export const useUnitSelect = ({
onOpenChange={setIsOpen}
onChange={(option) => {
const unit = renderUnitMap.get(option);
- if (unit === undefined) return;
+ if (unit === undefined) {
+ return;
+ }
onChange?.({
...value,
unit,
diff --git a/apps/designer/app/designer/features/style-panel/shared/get-css-rule-for-breakpoint.ts b/apps/designer/app/designer/features/style-panel/shared/get-css-rule-for-breakpoint.ts
index 4d5acd6546..f548a2bd67 100644
--- a/apps/designer/app/designer/features/style-panel/shared/get-css-rule-for-breakpoint.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/get-css-rule-for-breakpoint.ts
@@ -7,6 +7,8 @@ export const getCssRuleForBreakpoint = (
cssRules: Array<CssRule> = [],
breakpoint?: Breakpoint
) => {
- if (breakpoint === undefined) return;
+ if (breakpoint === undefined) {
+ return;
+ }
return cssRules.find((cssRule) => cssRule.breakpoint === breakpoint.id);
};
diff --git a/apps/designer/app/designer/features/style-panel/shared/show-more.tsx b/apps/designer/app/designer/features/style-panel/shared/show-more.tsx
index 0ea0b7fa4c..11484c84ef 100644
--- a/apps/designer/app/designer/features/style-panel/shared/show-more.tsx
+++ b/apps/designer/app/designer/features/style-panel/shared/show-more.tsx
@@ -8,7 +8,9 @@ export const ShowMore = ({
styleConfigs: Array<JSX.Element | null>;
}) => {
const [isOpen, setIsOpen] = useState(false);
- if (styleConfigs.length === 0) return null;
+ if (styleConfigs.length === 0) {
+ return null;
+ }
return (
<Collapsible.Root asChild onOpenChange={setIsOpen}>
<Flex direction="column" gap="3">
diff --git a/apps/designer/app/designer/features/style-panel/shared/use-is-from-current-breakpoint.ts b/apps/designer/app/designer/features/style-panel/shared/use-is-from-current-breakpoint.ts
index ba69bcf057..4f326e6224 100644
--- a/apps/designer/app/designer/features/style-panel/shared/use-is-from-current-breakpoint.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/use-is-from-current-breakpoint.ts
@@ -22,8 +22,11 @@ export const useIsFromCurrentBreakpoint = (
),
[selectedInstanceData, selectedBreakpoint]
);
- if (cssRule === undefined) return false;
- if (Array.isArray(property))
+ if (cssRule === undefined) {
+ return false;
+ }
+ if (Array.isArray(property)) {
return property.some((property) => property in cssRule.style);
+ }
return property in cssRule.style;
};
diff --git a/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts b/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts
index 3e6741ef68..3ea42e34fa 100644
--- a/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts
+++ b/apps/designer/app/designer/features/style-panel/shared/use-style-data.ts
@@ -82,7 +82,7 @@ export const useStyleData = ({
if (
updates.length === 0 ||
selectedInstanceData === undefined ||
- selectedBreakpoint == undefined
+ selectedBreakpoint === undefined
) {
return;
}
@@ -107,7 +107,9 @@ export const useStyleData = ({
const setProperty: SetProperty = (property) => {
return (inputOrStyle, options = { isEphemeral: false }) => {
- if (currentStyle === undefined) return;
+ if (currentStyle === undefined) {
+ return;
+ }
warnOnce(
typeof inputOrStyle === "string",
@@ -137,7 +139,9 @@ export const useStyleData = ({
const setProperty = (property: StyleProperty) => {
const setValue = (inputOrStyle: string | StyleValue) => {
- if (currentStyle === undefined) return;
+ if (currentStyle === undefined) {
+ return;
+ }
warnOnce(
typeof inputOrStyle === "string",
@@ -159,7 +163,9 @@ export const useStyleData = ({
};
const publish = () => {
- if (!updates.length) return;
+ if (!updates.length) {
+ return;
+ }
publishUpdates("update", updates);
const nextStyle = updates.reduce(
(currentStyle, { property, value }) => {
diff --git a/apps/designer/app/designer/features/style-panel/style-sections.tsx b/apps/designer/app/designer/features/style-panel/style-sections.tsx
index db089bdbb6..de9cef54c3 100644
--- a/apps/designer/app/designer/features/style-panel/style-sections.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-sections.tsx
@@ -64,7 +64,9 @@ export const renderProperty = ({
}: RenderPropertyProps) => {
const Control = controls[styleConfig.control];
const { property } = styleConfig;
- if (!Control) return null;
+ if (!Control) {
+ return null;
+ }
return (
<Grid key={category + property} css={{ gridTemplateColumns: "4fr 6fr" }}>
diff --git a/apps/designer/app/designer/features/style-panel/style-settings.tsx b/apps/designer/app/designer/features/style-panel/style-settings.tsx
index 4d2f35efe2..0a6e750ea7 100644
--- a/apps/designer/app/designer/features/style-panel/style-settings.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-settings.tsx
@@ -22,8 +22,12 @@ import { type RenderPropertyProps } from "./style-sections";
const filterProperties = (properties: Array<string>, search: string) => {
const searchParts = search.split(" ").map((part) => part.trim());
const includes = (property: string) => {
- if (property.toLowerCase().includes(search)) return true;
- if (hyphenate(property).includes(search)) return true;
+ if (property.toLowerCase().includes(search)) {
+ return true;
+ }
+ if (hyphenate(property).includes(search)) {
+ return true;
+ }
// Enables "ba co" to match "background color"
return searchParts.every((searchPart) =>
property.toLowerCase().includes(searchPart)
@@ -31,9 +35,15 @@ const filterProperties = (properties: Array<string>, search: string) => {
};
return properties.filter((property) => {
for (const styleConfig of styleConfigs) {
- if (styleConfig.property !== property) continue;
- if (includes(styleConfig.property)) return true;
- if (includes(styleConfig.label)) return true;
+ if (styleConfig.property !== property) {
+ continue;
+ }
+ if (includes(styleConfig.property)) {
+ return true;
+ }
+ if (includes(styleConfig.label)) {
+ return true;
+ }
for (const item of styleConfig.items) {
if (includes(item.name) || includes(item.label)) {
return true;
@@ -48,9 +58,13 @@ const appliesTo = (styleConfig: StyleConfig, currentStyle: Style): boolean => {
const { appliesTo } = styleConfig;
if (appliesTo in dependencies) {
const dependency = dependencies[appliesTo];
- if (dependency === undefined) return false;
+ if (dependency === undefined) {
+ return false;
+ }
const currentValue = currentStyle[dependency.property]?.value;
- if (currentValue === undefined) return false;
+ if (currentValue === undefined) {
+ return false;
+ }
if (Array.isArray(dependency.values)) {
return dependency.values.includes(String(currentValue));
}
@@ -135,7 +149,9 @@ export const StyleSettings = ({
}
}
- if (styleConfigsByCategory.length === 0) continue;
+ if (styleConfigsByCategory.length === 0) {
+ continue;
+ }
const categoryProps = {
...rest,
setProperty,
@@ -146,7 +162,7 @@ export const StyleSettings = ({
styleConfigsByCategory,
moreStyleConfigsByCategory,
};
- if (shouldRenderCategory(categoryProps))
+ if (shouldRenderCategory(categoryProps)) {
all.push(
<CollapsibleSection
isOpen={isSearchMode ? true : undefined}
@@ -156,6 +172,7 @@ export const StyleSettings = ({
<>{renderCategory(categoryProps)}</>
</CollapsibleSection>
);
+ }
}
return <>{all}</>;
};
diff --git a/apps/designer/app/designer/features/topbar/menu/shortcut-hint.tsx b/apps/designer/app/designer/features/topbar/menu/shortcut-hint.tsx
index a7889447dd..2ceb02cf6d 100644
--- a/apps/designer/app/designer/features/topbar/menu/shortcut-hint.tsx
+++ b/apps/designer/app/designer/features/topbar/menu/shortcut-hint.tsx
@@ -20,7 +20,9 @@ type ShortcutDefinition = Array<string>;
// @todo check what linux needs
// Converts commands to OS specific equivalent, e.g. cmd on mac to ctrl on win
const mapToOs = (value: ShortcutDefinition) => {
- if (isMac) return value;
+ if (isMac) {
+ return value;
+ }
return value.map((key) => shortcutWinMap[key] || key);
};
diff --git a/apps/designer/app/designer/features/workspace/canvas-tools/outline/label.tsx b/apps/designer/app/designer/features/workspace/canvas-tools/outline/label.tsx
index a301856f64..da91d9f2dd 100644
--- a/apps/designer/app/designer/features/workspace/canvas-tools/outline/label.tsx
+++ b/apps/designer/app/designer/features/workspace/canvas-tools/outline/label.tsx
@@ -18,7 +18,9 @@ const useLabelPosition = (
const ref = useCallback(
(element) => {
- if (element === null || instanceRect === undefined) return;
+ if (element === null || instanceRect === undefined) {
+ return;
+ }
const labelRect = element.getBoundingClientRect();
let nextPosition: LabelPosition = "top";
if (labelRect.height > instanceRect.top) {
diff --git a/apps/designer/app/designer/features/workspace/canvas-tools/outline/outline.tsx b/apps/designer/app/designer/features/workspace/canvas-tools/outline/outline.tsx
index 7f1e0b0524..288b54ee0e 100644
--- a/apps/designer/app/designer/features/workspace/canvas-tools/outline/outline.tsx
+++ b/apps/designer/app/designer/features/workspace/canvas-tools/outline/outline.tsx
@@ -12,7 +12,9 @@ const OutlineContainer = styled("div", {
const useStyle = (rect?: Rect) => {
return useMemo(() => {
- if (rect === undefined) return;
+ if (rect === undefined) {
+ return;
+ }
return {
transform: `translate3d(${rect.left}px, ${rect.top}px, 0)`,
width: rect.width,
diff --git a/apps/designer/app/designer/features/workspace/use-read-canvas-rect.ts b/apps/designer/app/designer/features/workspace/use-read-canvas-rect.ts
index b84b7583a4..98948d514c 100644
--- a/apps/designer/app/designer/features/workspace/use-read-canvas-rect.ts
+++ b/apps/designer/app/designer/features/workspace/use-read-canvas-rect.ts
@@ -21,7 +21,9 @@ export const useReadCanvasRect = () => {
const readRect = useCallback(
() => {
- if (iframeElement === null) return;
+ if (iframeElement === null) {
+ return;
+ }
requestAnimationFrame(() => {
const rect = iframeElement.getBoundingClientRect();
setCanvasRect(rect);
diff --git a/apps/designer/app/designer/shared/assets/asset-upload.tsx b/apps/designer/app/designer/shared/assets/asset-upload.tsx
index ffec2741a5..f162b785dc 100644
--- a/apps/designer/app/designer/shared/assets/asset-upload.tsx
+++ b/apps/designer/app/designer/shared/assets/asset-upload.tsx
@@ -12,7 +12,9 @@ const useUpload = (type: AssetType) => {
const onChange = (event: ChangeEvent<HTMLFormElement>) => {
const form = event.currentTarget;
const input = inputRef.current;
- if (input === null) return;
+ if (input === null) {
+ return;
+ }
handleSubmit(input);
form.reset();
};
diff --git a/apps/designer/app/designer/shared/assets/use-assets.ts b/apps/designer/app/designer/shared/assets/use-assets.ts
index 3c7bf3ac82..000c4dfafc 100644
--- a/apps/designer/app/designer/shared/assets/use-assets.ts
+++ b/apps/designer/app/designer/shared/assets/use-assets.ts
@@ -47,7 +47,9 @@ const maxSize = toBytes(MAX_UPLOAD_SIZE);
const toFormData = (type: AssetType, input: HTMLInputElement) => {
const files = Array.from(input?.files ?? []);
const formData = new FormData();
- if (files.length === 0) return formData;
+ if (files.length === 0) {
+ return formData;
+ }
for (const file of files) {
if (file.size > maxSize) {
toast.error(
diff --git a/apps/designer/app/designer/shared/assets/use-search.tsx b/apps/designer/app/designer/shared/assets/use-search.tsx
index e8890d4756..2f7e8f3baa 100644
--- a/apps/designer/app/designer/shared/assets/use-search.tsx
+++ b/apps/designer/app/designer/shared/assets/use-search.tsx
@@ -15,7 +15,9 @@ export const useSearch = ({ onSearch, onSelect, onCancel }: UseSearch) => {
Enter: "current",
} as const;
const direction = keyMap[code as keyof typeof keyMap];
- if (direction !== undefined) onSelect(direction);
+ if (direction !== undefined) {
+ onSelect(direction);
+ }
};
const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {
diff --git a/apps/designer/app/designer/shared/client-settings/settings.ts b/apps/designer/app/designer/shared/client-settings/settings.ts
index 500f3ff636..4ede2d5dca 100644
--- a/apps/designer/app/designer/shared/client-settings/settings.ts
+++ b/apps/designer/app/designer/shared/client-settings/settings.ts
@@ -25,7 +25,9 @@ const read = (): Settings => {
// We don't need to handle this one.
}
- if (settingsString == null) return defaultSettings;
+ if (settingsString == null) {
+ return defaultSettings;
+ }
try {
// @todo add zod schema
@@ -55,7 +57,9 @@ export const getSetting = (name: Name) => {
const validValues = config[name].values;
const value = settings[name];
const isValidValue = value !== undefined && validValues.includes(value);
- if (isValidValue) return value;
+ if (isValidValue) {
+ return value;
+ }
return config[name].defaultValue;
};
@@ -63,7 +67,9 @@ export const setSetting = (name: Name, value: Value) => {
const settings = read();
const validValues = config[name].values;
const isValidValue = validValues.includes(value);
- if (isValidValue) write({ ...settings, [name]: value });
+ if (isValidValue) {
+ write({ ...settings, [name]: value });
+ }
};
const settingsContainer = createValueContainer<Settings>(defaultSettings);
@@ -80,7 +86,9 @@ export const useClientSettings = (): [Settings, typeof setSetting, boolean] => {
}, [setSettings]);
const setSettingValue = (name: Name, value: Value) => {
- if (settings[name] === value) return;
+ if (settings[name] === value) {
+ return;
+ }
setSettings({ ...settings, [name]: value });
setSetting(name, value);
};
diff --git a/apps/designer/app/designer/shared/design-tokens-manager/item-menu.tsx b/apps/designer/app/designer/shared/design-tokens-manager/item-menu.tsx
index f8a39e8f6f..4c8ac5c6b3 100644
--- a/apps/designer/app/designer/shared/design-tokens-manager/item-menu.tsx
+++ b/apps/designer/app/designer/shared/design-tokens-manager/item-menu.tsx
@@ -123,7 +123,9 @@ export const useMenu = ({
openMenu.current === index ||
focusedMenuTrigger.current === index;
- if (show === false) return;
+ if (show === false) {
+ return;
+ }
return (
<ItemMenu
diff --git a/apps/designer/app/designer/shared/design-tokens-manager/token-editor.tsx b/apps/designer/app/designer/shared/design-tokens-manager/token-editor.tsx
index d4b54337ae..526b1b2d8e 100644
--- a/apps/designer/app/designer/shared/design-tokens-manager/token-editor.tsx
+++ b/apps/designer/app/designer/shared/design-tokens-manager/token-editor.tsx
@@ -109,7 +109,9 @@ export const TokenEditor = ({
};
const submit = (ignoreErrors = false) => {
- if (formRef.current === null) return;
+ if (formRef.current === null) {
+ return;
+ }
const updatedToken = getToken(formRef.current, token ?? seed);
const nextValidationResult = validate(tokens, updatedToken, token);
setValidationResult(nextValidationResult);
diff --git a/apps/designer/app/designer/shared/fonts-manager/item-menu.tsx b/apps/designer/app/designer/shared/fonts-manager/item-menu.tsx
index b89c47c709..360baba513 100644
--- a/apps/designer/app/designer/shared/fonts-manager/item-menu.tsx
+++ b/apps/designer/app/designer/shared/fonts-manager/item-menu.tsx
@@ -102,7 +102,9 @@ export const useMenu = ({ selectedIndex, onSelect, onDelete }: UseMenu) => {
openMenu.current === index ||
focusedMenuTrigger.current === index;
- if (show === false) return;
+ if (show === false) {
+ return;
+ }
return (
<ItemMenu
diff --git a/apps/designer/app/designer/shared/image-manager/image-thumbnail.tsx b/apps/designer/app/designer/shared/image-manager/image-thumbnail.tsx
index 54020b59c1..587fd01a2f 100644
--- a/apps/designer/app/designer/shared/image-manager/image-thumbnail.tsx
+++ b/apps/designer/app/designer/shared/image-manager/image-thumbnail.tsx
@@ -111,7 +111,9 @@ export const ImageThumbnail = ({
<Thumbnail
css={{ backgroundImage: `url("${src}")` }}
onClick={() => {
- if (isUploadedAsset) onChange?.(asset);
+ if (isUploadedAsset) {
+ onChange?.(asset);
+ }
}}
/>
<Box
diff --git a/apps/designer/app/routes/auth/dev.tsx b/apps/designer/app/routes/auth/dev.tsx
index 3d2e77bc51..b6da7294eb 100644
--- a/apps/designer/app/routes/auth/dev.tsx
+++ b/apps/designer/app/routes/auth/dev.tsx
@@ -15,7 +15,9 @@ export const action: ActionFunction = async ({ request }) => {
});
} catch (error: unknown) {
// all redirects are basically errors and in that case we don't want to catch it
- if (error instanceof Response) return error;
+ if (error instanceof Response) {
+ return error;
+ }
if (error instanceof Error) {
return redirect(
loginPath({ error: AUTH_PROVIDERS.LOGIN_DEV, message: error?.message })
diff --git a/apps/designer/app/routes/auth/github.tsx b/apps/designer/app/routes/auth/github.tsx
index 829b04c8da..f6b80386e0 100644
--- a/apps/designer/app/routes/auth/github.tsx
+++ b/apps/designer/app/routes/auth/github.tsx
@@ -16,7 +16,9 @@ export const action: ActionFunction = async ({ request }) => {
});
} catch (error: unknown) {
// all redirects are basically errors and in that case we don't want to catch it
- if (error instanceof Response) return error;
+ if (error instanceof Response) {
+ return error;
+ }
if (error instanceof Error) {
sentryException({
error,
diff --git a/apps/designer/app/routes/auth/github/callback.tsx b/apps/designer/app/routes/auth/github/callback.tsx
index 4dcbf0e4ad..6eed9c0839 100644
--- a/apps/designer/app/routes/auth/github/callback.tsx
+++ b/apps/designer/app/routes/auth/github/callback.tsx
@@ -6,12 +6,12 @@ import { AUTH_PROVIDERS } from "~/shared/session";
export const loader: LoaderFunction = async ({ request }) => {
const url = new URL(request.url);
const error = url.searchParams.get("error");
- const error_description = url.searchParams.get("error_description");
+ const errorDescription = url.searchParams.get("error_description");
if (error) {
return redirect(
loginPath({
error: AUTH_PROVIDERS.LOGIN_GITHUB,
- message: error_description || error,
+ message: errorDescription || error,
})
);
}
diff --git a/apps/designer/app/routes/auth/google.tsx b/apps/designer/app/routes/auth/google.tsx
index 8ffc35f693..5d8b5982bc 100644
--- a/apps/designer/app/routes/auth/google.tsx
+++ b/apps/designer/app/routes/auth/google.tsx
@@ -18,7 +18,9 @@ export const action: ActionFunction = async ({ request }) => {
});
} catch (error: unknown) {
// all redirects are basically errors and in that case we don't want to catch it
- if (error instanceof Response) return error;
+ if (error instanceof Response) {
+ return error;
+ }
if (error instanceof Error) {
sentryException({
error,
diff --git a/apps/designer/app/routes/rest/assets.$projectId.tsx b/apps/designer/app/routes/rest/assets.$projectId.tsx
index 07481e3023..cc9de4afd2 100644
--- a/apps/designer/app/routes/rest/assets.$projectId.tsx
+++ b/apps/designer/app/routes/rest/assets.$projectId.tsx
@@ -18,7 +18,9 @@ export const action: ActionFunction = async ({
request,
params,
}): Promise<ActionData | undefined> => {
- if (params.projectId === undefined) throw new Error("Project id undefined");
+ if (params.projectId === undefined) {
+ throw new Error("Project id undefined");
+ }
try {
if (request.method === "DELETE") {
const { assetId: ids } = DeleteAssets.parse(await request.formData());
diff --git a/apps/designer/app/routes/rest/pages.$projectId.ts b/apps/designer/app/routes/rest/pages.$projectId.ts
index af8f10ab16..e3493e27c4 100644
--- a/apps/designer/app/routes/rest/pages.$projectId.ts
+++ b/apps/designer/app/routes/rest/pages.$projectId.ts
@@ -13,8 +13,8 @@ import { type FetcherData, makeFieldError } from "~/shared/form-utils";
const nonEmptyString = z
.string({
- invalid_type_error: "Can't be empty",
- required_error: "Can't be empty",
+ invalid_type_error: "Can't be empty", // eslint-disable-line
+ required_error: "Can't be empty", // eslint-disable-line
})
.transform((value) => value.trim())
.refine((value) => value !== "", "Can't be empty");
diff --git a/apps/designer/app/routes/rest/patch.ts b/apps/designer/app/routes/rest/patch.ts
index 5c5a2fa379..930e8f110f 100644
--- a/apps/designer/app/routes/rest/patch.ts
+++ b/apps/designer/app/routes/rest/patch.ts
@@ -13,8 +13,12 @@ type PatchData = {
export const action: ActionFunction = async ({ request }) => {
const { treeId, buildId, transactions }: PatchData = await request.json();
- if (treeId === undefined) return { errors: "Tree id required" };
- if (buildId === undefined) return { errors: "Build id required" };
+ if (treeId === undefined) {
+ return { errors: "Tree id required" };
+ }
+ if (buildId === undefined) {
+ return { errors: "Build id required" };
+ }
// @todo parallelize the updates
// currently not possible because we fetch the entire tree
// and parallelized updates will cause unpredictable side effects
diff --git a/apps/designer/app/routes/rest/project/clone.$domain.ts b/apps/designer/app/routes/rest/project/clone.$domain.ts
index 1a55ef20e7..655a812f12 100644
--- a/apps/designer/app/routes/rest/project/clone.$domain.ts
+++ b/apps/designer/app/routes/rest/project/clone.$domain.ts
@@ -15,7 +15,9 @@ const ensureProject = async ({
domain: string;
}): Promise<Project> => {
const projects = await projectDb.project.loadManyByUserId(userId);
- if (projects.length !== 0) return projects[0];
+ if (projects.length !== 0) {
+ return projects[0];
+ }
return await projectDb.project.clone(domain, userId);
};
@@ -29,7 +31,9 @@ const ensureProject = async ({
* 3. Redirect user to the designer with the cloned project
*/
export const loader: LoaderFunction = async ({ request, params }) => {
- if (params.domain === undefined) return { errors: "Domain required" };
+ if (params.domain === undefined) {
+ return { errors: "Domain required" };
+ }
const user = await authenticator.isAuthenticated(request);
const { headers, userId: generatedUserId } = await ensureUserCookie(request);
try {
diff --git a/apps/designer/app/shared/css-utils/delete-css-rules-by-breakpoint.ts b/apps/designer/app/shared/css-utils/delete-css-rules-by-breakpoint.ts
index 8d53144806..be6c29b861 100644
--- a/apps/designer/app/shared/css-utils/delete-css-rules-by-breakpoint.ts
+++ b/apps/designer/app/shared/css-utils/delete-css-rules-by-breakpoint.ts
@@ -13,7 +13,9 @@ export const deleteCssRulesByBreakpoint = (
});
for (const child of instance.children) {
- if (typeof child === "string") continue;
+ if (typeof child === "string") {
+ continue;
+ }
deleteCssRulesByBreakpoint(child, breakpointId);
}
};
diff --git a/apps/designer/app/shared/dom-hooks/use-scroll-state.ts b/apps/designer/app/shared/dom-hooks/use-scroll-state.ts
index 1ba67a8b03..c3f950e938 100644
--- a/apps/designer/app/shared/dom-hooks/use-scroll-state.ts
+++ b/apps/designer/app/shared/dom-hooks/use-scroll-state.ts
@@ -26,7 +26,9 @@ if (typeof window === "object") {
emitter.emit("scrollStart");
clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => {
- if (isScrolling === false) return;
+ if (isScrolling === false) {
+ return;
+ }
isScrolling = false;
emitter.emit("scrollEnd");
}, 150);
diff --git a/apps/designer/app/shared/hook-utils/use-sync-initialize-once.ts b/apps/designer/app/shared/hook-utils/use-sync-initialize-once.ts
index 0c49261657..a625172842 100644
--- a/apps/designer/app/shared/hook-utils/use-sync-initialize-once.ts
+++ b/apps/designer/app/shared/hook-utils/use-sync-initialize-once.ts
@@ -8,7 +8,9 @@ import { useRef } from "react";
// Can't use useState initializer because it can be called twice in strict mode and also isn't designed for this.
export const useSyncInitializeOnce = (fn: () => void) => {
const ref = useRef(false);
- if (ref.current) return;
+ if (ref.current) {
+ return;
+ }
ref.current = true;
fn();
};
diff --git a/apps/designer/app/shared/props-utils/delete-prop.ts b/apps/designer/app/shared/props-utils/delete-prop.ts
index 8252b54296..6febc1d340 100644
--- a/apps/designer/app/shared/props-utils/delete-prop.ts
+++ b/apps/designer/app/shared/props-utils/delete-prop.ts
@@ -5,9 +5,13 @@ export const deletePropMutable = (
deleteProp: DeleteProp
) => {
const prop = allProps[deleteProp.instanceId];
- if (prop === undefined) return false;
+ if (prop === undefined) {
+ return false;
+ }
const index = prop.props.findIndex(({ id }) => id === deleteProp.propId);
- if (index === -1) return false;
+ if (index === -1) {
+ return false;
+ }
prop.props.splice(index, 1);
return true;
};
diff --git a/apps/designer/app/shared/sentry.ts b/apps/designer/app/shared/sentry.ts
index 28562002b0..c5afda9c66 100644
--- a/apps/designer/app/shared/sentry.ts
+++ b/apps/designer/app/shared/sentry.ts
@@ -26,7 +26,9 @@ export const sentryMessage = ({
}: SentryHelperProps & { message: string }) => {
if (env.SENTRY_DSN) {
Sentry.withScope((scope) => {
- if (extras) scope.setExtras(extras);
+ if (extras) {
+ scope.setExtras(extras);
+ }
Sentry.captureMessage(message);
});
}
@@ -44,7 +46,9 @@ export const sentryException = ({
}: SentryHelperProps & { error: unknown }) => {
if (env.SENTRY_DSN) {
Sentry.withScope((scope) => {
- if (extras) scope.setExtras(extras);
+ if (extras) {
+ scope.setExtras(extras);
+ }
Sentry.captureException(error);
});
}
diff --git a/apps/designer/app/shared/session/user.server.ts b/apps/designer/app/shared/session/user.server.ts
index 6b0d029b6e..28891cfcd1 100644
--- a/apps/designer/app/shared/session/user.server.ts
+++ b/apps/designer/app/shared/session/user.server.ts
@@ -10,7 +10,9 @@ export const ensureUserCookie = async (
): Promise<{ userId: string; headers?: { [key: string]: string } }> => {
const cookieString = request.headers.get("Cookie");
const userId = await userIdParser.parse(cookieString);
- if (userId !== null) return { userId };
+ if (userId !== null) {
+ return { userId };
+ }
// We use a generated id temporarily as a way to demonstrate the designer
// to a new user without a signup.
const generatedUserId = ObjectId().toString();
diff --git a/apps/designer/app/shared/theme/theme.ts b/apps/designer/app/shared/theme/theme.ts
index 3fe0d4a915..f933fd4a85 100644
--- a/apps/designer/app/shared/theme/theme.ts
+++ b/apps/designer/app/shared/theme/theme.ts
@@ -13,7 +13,9 @@ let system: ColorScheme;
* Subscribes color scheme change event and rerenders
*/
const subscribeSystemTheme = () => {
- if (typeof matchMedia === "undefined") return;
+ if (typeof matchMedia === "undefined") {
+ return;
+ }
const query = matchMedia("(prefers-color-scheme: light)");
const queryColorScheme = (query: MediaQueryList | MediaQueryListEvent) =>
query.matches ? "light" : "dark";
@@ -67,8 +69,12 @@ export const setThemeSetting = (nextSetting: ThemeSetting) => {
*/
export const useThemeProps = () => {
const data = useLoaderData();
- if (data.theme.setting) setting = data.theme.setting;
- if (data.theme.system) system = data.theme.system;
+ if (data.theme.setting) {
+ setting = data.theme.setting;
+ }
+ if (data.theme.system) {
+ system = data.theme.system;
+ }
const theme = getColorScheme();
return {
className: theme === "dark" ? darkTheme.className : undefined,
diff --git a/packages/eslint-config-custom/index.js b/packages/eslint-config-custom/index.js
index 4dcfefdb35..c0d2183333 100644
--- a/packages/eslint-config-custom/index.js
+++ b/packages/eslint-config-custom/index.js
@@ -9,6 +9,7 @@ module.exports = {
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
+ "plugin:react/jsx-runtime",
],
parser: "@typescript-eslint/parser",
parserOptions: {
@@ -29,7 +30,6 @@ module.exports = {
// It's too dumb to understand properly what's defined in ts
"react/prop-types": 0,
"no-unused-vars": "off",
- "react/react-in-jsx-scope": "off",
"@typescript-eslint/no-unused-vars": "off",
"func-style": ["error", "expression", { allowArrowFunctions: true }],
"unicorn/filename-case": [
@@ -40,5 +40,8 @@ module.exports = {
ignore: ["\\$"],
},
],
+ curly: 2,
+ eqeqeq: ["error", "always", { null: "ignore" }],
+ camelcase: 2,
},
};
diff --git a/packages/eslint-config-custom/package.json b/packages/eslint-config-custom/package.json
index 0d544756ff..cfde87a377 100644
--- a/packages/eslint-config-custom/package.json
+++ b/packages/eslint-config-custom/package.json
@@ -1,6 +1,6 @@
{
"name": "@webstudio-is/eslint-config-custom",
- "version": "1.0.1",
+ "version": "1.0.2",
"main": "index.js",
"license": "MIT",
"scripts": {