mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Add more ESLint rules and change the formatting scripts (#626)
* Add curly rule in ESLint for consistency * Fix rules * More rules * REturn * Push * no else return * prefer const * destructing
This commit is contained in:
parent
814299321e
commit
53994e71e5
21 changed files with 201 additions and 77 deletions
|
@ -176,7 +176,7 @@ export function renderElement(
|
|||
context.font = font;
|
||||
context.globalAlpha = 1;
|
||||
} else {
|
||||
throw new Error("Unimplemented type " + element.type);
|
||||
throw new Error(`Unimplemented type ${element.type}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ export function renderElementToSvg(
|
|||
}
|
||||
svgRoot.appendChild(node);
|
||||
} else {
|
||||
throw new Error("Unimplemented type " + element.type);
|
||||
throw new Error(`Unimplemented type ${element.type}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,9 @@ export function renderScene(
|
|||
renderSelection?: boolean;
|
||||
} = {},
|
||||
) {
|
||||
if (!canvas) return false;
|
||||
if (!canvas) {
|
||||
return false;
|
||||
}
|
||||
const context = canvas.getContext("2d")!;
|
||||
|
||||
const fillStyle = context.fillStyle;
|
||||
|
@ -130,7 +132,7 @@ export function renderScene(
|
|||
context.fillStyle = SCROLLBAR_COLOR;
|
||||
context.strokeStyle = "rgba(255,255,255,0.8)";
|
||||
[scrollBars.horizontal, scrollBars.vertical].forEach(scrollBar => {
|
||||
if (scrollBar)
|
||||
if (scrollBar) {
|
||||
roundRect(
|
||||
context,
|
||||
scrollBar.x,
|
||||
|
@ -139,6 +141,7 @@ export function renderScene(
|
|||
scrollBar.height,
|
||||
SCROLLBAR_WIDTH / 2,
|
||||
);
|
||||
}
|
||||
});
|
||||
context.strokeStyle = strokeStyle;
|
||||
context.fillStyle = fillStyle;
|
||||
|
@ -161,14 +164,13 @@ function isVisibleElement(
|
|||
x2 += scrollX;
|
||||
y2 += scrollY;
|
||||
return x2 >= 0 && x1 <= canvasWidth && y2 >= 0 && y1 <= canvasHeight;
|
||||
} else {
|
||||
return (
|
||||
x2 + scrollX >= 0 &&
|
||||
x1 + scrollX <= canvasWidth &&
|
||||
y2 + scrollY >= 0 &&
|
||||
y1 + scrollY <= canvasHeight
|
||||
);
|
||||
}
|
||||
return (
|
||||
x2 + scrollX >= 0 &&
|
||||
x1 + scrollX <= canvasWidth &&
|
||||
y2 + scrollY >= 0 &&
|
||||
y1 + scrollY <= canvasHeight
|
||||
);
|
||||
}
|
||||
|
||||
// This should be only called for exporting purposes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue