Enforce curly bracket usage for one-statement ifs

This commit is contained in:
Damien Elmes 2023-10-23 09:19:23 +10:00
parent a53806e24a
commit 9740393d72
7 changed files with 22 additions and 8 deletions

View file

@ -24,6 +24,7 @@ module.exports = {
"simple-import-sort/exports": "warn",
"prefer-const": "warn",
"no-nested-ternary": "warn",
"curly": "error",
"@typescript-eslint/consistent-type-imports": "error",
},
overrides: [

View file

@ -24,7 +24,9 @@
bind:this={spanRef}
for={forId}
on:click={(e) => {
if (preventMouseClick) e.preventDefault();
if (preventMouseClick) {
e.preventDefault();
}
}}
>
<slot />

View file

@ -35,7 +35,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
}
function decimalPlaces(value: number) {
if (Math.floor(value) === value) return 0;
if (Math.floor(value) === value) {
return 0;
}
return value.toString().split(".")[1].length || 0;
}

View file

@ -43,8 +43,9 @@ export const drawEllipse = (canvas: fabric.Canvas): void => {
});
canvas.on("mouse:move", function(o) {
if (!isDown) return;
if (!isDown) {
return;
}
const pointer = canvas.getPointer(o.e);
let rx = Math.abs(origX - pointer.x) / 2;
let ry = Math.abs(origY - pointer.y) / 2;

View file

@ -44,7 +44,9 @@ export const drawRectangle = (canvas: fabric.Canvas): void => {
});
canvas.on("mouse:move", function(o) {
if (!isDown) return;
if (!isDown) {
return;
}
const pointer = canvas.getPointer(o.e);
let x = pointer.x;
let y = pointer.y;

View file

@ -20,8 +20,12 @@ type UndoState = {
const shapeType = ["rect", "ellipse", "i-text"];
const validShape = (shape: fabric.Object): boolean => {
if (shape.width <= 5 || shape.height <= 5) return false;
if (shapeType.indexOf(shape.type) === -1) return false;
if (shape.width <= 5 || shape.height <= 5) {
return false;
}
if (shapeType.indexOf(shape.type) === -1) {
return false;
}
return true;
};

View file

@ -105,7 +105,9 @@ export async function preloadResources(html: string): Promise<void> {
timeout = 500;
} else if (images.length) {
timeout = 200;
} else return;
} else {
return;
}
await Promise.race([
Promise.all([...styleSheets, ...images, ...fonts]),