chore: enforce brackets for if clause and for/while loops
This commit is contained in:
@@ -95,16 +95,22 @@ export class ComparisonStore {
|
||||
// Effect 1: Sync batch results → fontA / fontB
|
||||
$effect(() => {
|
||||
const fonts = this.#batchStore.fonts;
|
||||
if (fonts.length === 0) return;
|
||||
if (fonts.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { fontAId: aId, fontBId: bId } = storage.value;
|
||||
if (aId) {
|
||||
const fa = fonts.find(f => f.id === aId);
|
||||
if (fa) this.#fontA = fa;
|
||||
if (fa) {
|
||||
this.#fontA = fa;
|
||||
}
|
||||
}
|
||||
if (bId) {
|
||||
const fb = fonts.find(f => f.id === bId);
|
||||
if (fb) this.#fontB = fb;
|
||||
if (fb) {
|
||||
this.#fontB = fb;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -114,7 +120,9 @@ export class ComparisonStore {
|
||||
const fb = this.#fontB;
|
||||
const weight = typographySettingsStore.weight;
|
||||
|
||||
if (!fa || !fb) return;
|
||||
if (!fa || !fb) {
|
||||
return;
|
||||
}
|
||||
|
||||
const configs: FontLoadRequestConfig[] = [];
|
||||
[fa, fb].forEach(f => {
|
||||
@@ -138,7 +146,9 @@ export class ComparisonStore {
|
||||
|
||||
// Effect 3: Set default fonts when storage is empty
|
||||
$effect(() => {
|
||||
if (this.#fontA && this.#fontB) return;
|
||||
if (this.#fontA && this.#fontB) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fonts = fontStore.fonts;
|
||||
if (fonts.length >= 2) {
|
||||
@@ -156,11 +166,19 @@ export class ComparisonStore {
|
||||
const fa = this.#fontA;
|
||||
const fb = this.#fontB;
|
||||
const w = typographySettingsStore.weight;
|
||||
if (fa) appliedFontsManager.pin(fa.id, w, fa.features?.isVariable);
|
||||
if (fb) appliedFontsManager.pin(fb.id, w, fb.features?.isVariable);
|
||||
if (fa) {
|
||||
appliedFontsManager.pin(fa.id, w, fa.features?.isVariable);
|
||||
}
|
||||
if (fb) {
|
||||
appliedFontsManager.pin(fb.id, w, fb.features?.isVariable);
|
||||
}
|
||||
return () => {
|
||||
if (fa) appliedFontsManager.unpin(fa.id, w, fa.features?.isVariable);
|
||||
if (fb) appliedFontsManager.unpin(fb.id, w, fb.features?.isVariable);
|
||||
if (fa) {
|
||||
appliedFontsManager.unpin(fa.id, w, fa.features?.isVariable);
|
||||
}
|
||||
if (fb) {
|
||||
appliedFontsManager.unpin(fb.id, w, fb.features?.isVariable);
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
@@ -183,7 +201,9 @@ export class ComparisonStore {
|
||||
const fontAName = this.#fontA?.name;
|
||||
const fontBName = this.#fontB?.name;
|
||||
|
||||
if (!fontAName || !fontBName) return;
|
||||
if (!fontAName || !fontBName) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fontAString = `${weight} ${size}px "${fontAName}"`;
|
||||
const fontBString = `${weight} ${size}px "${fontBName}"`;
|
||||
|
||||
@@ -35,7 +35,9 @@ const displayChar = $derived(char === ' ' ? '\u00A0' : char);
|
||||
const targetFont = $derived(isPast ? fontA?.name ?? '' : fontB?.name ?? '');
|
||||
|
||||
$effect(() => {
|
||||
if (!targetFont || slotFonts[slot] === targetFont) return;
|
||||
if (!targetFont || slotFonts[slot] === targetFont) {
|
||||
return;
|
||||
}
|
||||
const next = slot === 0 ? 1 : 0;
|
||||
slotFonts[next] = targetFont;
|
||||
slot = next;
|
||||
|
||||
@@ -65,7 +65,9 @@ const sliderSpring = new Spring(50, {
|
||||
const sliderPos = $derived(sliderSpring.current);
|
||||
|
||||
function handleMove(e: PointerEvent) {
|
||||
if (!isDragging || !container) return;
|
||||
if (!isDragging || !container) {
|
||||
return;
|
||||
}
|
||||
const rect = container.getBoundingClientRect();
|
||||
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
||||
const percentage = (x / rect.width) * 100;
|
||||
@@ -87,7 +89,9 @@ $effect(() => {
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!responsive) return;
|
||||
if (!responsive) {
|
||||
return;
|
||||
}
|
||||
switch (true) {
|
||||
case responsive.isMobile:
|
||||
typography.multiplier = 0.5;
|
||||
@@ -143,7 +147,9 @@ $effect(() => {
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
if (typeof window === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const handleResize = () => {
|
||||
if (container && fontA && fontB) {
|
||||
const width = container.offsetWidth;
|
||||
|
||||
@@ -46,7 +46,9 @@ let isAboveMiddle = $state(false);
|
||||
let containerWidth = $state(0);
|
||||
|
||||
const checkPosition = throttle(() => {
|
||||
if (!wrapper) return;
|
||||
if (!wrapper) {
|
||||
return;
|
||||
}
|
||||
|
||||
const rect = wrapper.getBoundingClientRect();
|
||||
const viewportMiddle = innerHeight / 2;
|
||||
|
||||
Reference in New Issue
Block a user