chore: switch from biome to eslint + prettier; fix ton of lint issues

This commit is contained in:
Maze Winther
2026-04-29 00:37:56 +02:00
parent 6ec818fc11
commit d7692b4c79
159 changed files with 5630 additions and 5255 deletions
+31 -11
View File
@@ -330,13 +330,27 @@ function clampUnit(value: number): number {
return Math.min(1, Math.max(0, value));
}
function getDistanceSquared(a: CanvasPoint, b: CanvasPoint): number {
function getDistanceSquared({
a,
b,
}: {
a: CanvasPoint;
b: CanvasPoint;
}): number {
const dx = a.x - b.x;
const dy = a.y - b.y;
return dx * dx + dy * dy;
}
function lerpPoint(a: CanvasPoint, b: CanvasPoint, t: number): CanvasPoint {
function lerpPoint({
a,
b,
t,
}: {
a: CanvasPoint;
b: CanvasPoint;
t: number;
}): CanvasPoint {
return {
x: a.x + (b.x - a.x) * t,
y: a.y + (b.y - a.y) * t,
@@ -483,7 +497,10 @@ export function findClosestPointOnCustomMaskSegment({
const sampleCount = 24;
let bestT = 0;
let bestDistanceSquared = getDistanceSquared(canvasPoint, segment.start);
let bestDistanceSquared = getDistanceSquared({
a: canvasPoint,
b: segment.start,
});
for (let step = 0; step <= sampleCount; step++) {
const t = step / sampleCount;
@@ -494,7 +511,7 @@ export function findClosestPointOnCustomMaskSegment({
p3: segment.end,
t,
});
const distanceSquared = getDistanceSquared(canvasPoint, point);
const distanceSquared = getDistanceSquared({ a: canvasPoint, b: point });
if (distanceSquared < bestDistanceSquared) {
bestDistanceSquared = distanceSquared;
bestT = t;
@@ -516,7 +533,10 @@ export function findClosestPointOnCustomMaskSegment({
}),
}));
for (const candidate of candidates) {
const distanceSquared = getDistanceSquared(canvasPoint, candidate.point);
const distanceSquared = getDistanceSquared({
a: canvasPoint,
b: candidate.point,
});
if (distanceSquared < bestDistanceSquared) {
bestDistanceSquared = distanceSquared;
bestT = candidate.t;
@@ -573,12 +593,12 @@ export function insertPointIntoCustomMaskSegment({
y: endPoint.y + endPoint.inY,
};
const p3 = { x: endPoint.x, y: endPoint.y };
const p01 = lerpPoint(p0, p1, clampedT);
const p12 = lerpPoint(p1, p2, clampedT);
const p23 = lerpPoint(p2, p3, clampedT);
const p012 = lerpPoint(p01, p12, clampedT);
const p123 = lerpPoint(p12, p23, clampedT);
const splitPoint = lerpPoint(p012, p123, clampedT);
const p01 = lerpPoint({ a: p0, b: p1, t: clampedT });
const p12 = lerpPoint({ a: p1, b: p2, t: clampedT });
const p23 = lerpPoint({ a: p2, b: p3, t: clampedT });
const p012 = lerpPoint({ a: p01, b: p12, t: clampedT });
const p123 = lerpPoint({ a: p12, b: p23, t: clampedT });
const splitPoint = lerpPoint({ a: p012, b: p123, t: clampedT });
const nextPoints = [...points];
nextPoints[indices.startIndex] = {
+17 -9
View File
@@ -53,10 +53,13 @@ function splitLineGeometry({
return { normalX, normalY, lineX, lineY };
}
function pointsEqual(
a: { x: number; y: number },
b: { x: number; y: number },
): boolean {
function pointsEqual({
a,
b,
}: {
a: { x: number; y: number };
b: { x: number; y: number };
}): boolean {
return (
Math.abs(a.x - b.x) <= INTERSECTION_EPSILON &&
Math.abs(a.y - b.y) <= INTERSECTION_EPSILON
@@ -101,7 +104,7 @@ export function getSplitMaskStrokeSegment({
y2,
});
if (!hit || intersections.some((point) => pointsEqual(point, hit))) {
if (!hit || intersections.some((point) => pointsEqual({ a: point, b: hit }))) {
continue;
}
@@ -307,13 +310,18 @@ export const splitMaskDefinition: MaskDefinition<SplitMaskParams> = {
[0, height, 0, 0],
];
const isInsideHalfPlane = (x: number, y: number) =>
halfPlaneSign({ lineX, lineY, normalX, normalY, x, y }) >= 0;
const isInsideHalfPlane = ({
x,
y,
}: {
x: number;
y: number;
}) => halfPlaneSign({ lineX, lineY, normalX, normalY, x, y }) >= 0;
const vertices: [number, number][] = [];
for (const [x1, y1, x2, y2] of edges) {
const isVertex1Inside = isInsideHalfPlane(x1, y1);
const isVertex2Inside = isInsideHalfPlane(x2, y2);
const isVertex1Inside = isInsideHalfPlane({ x: x1, y: y1 });
const isVertex2Inside = isInsideHalfPlane({ x: x2, y: y2 });
if (isVertex1Inside && isVertex2Inside) {
vertices.push([x2, y2]);
+4 -1
View File
@@ -115,7 +115,10 @@ export class MasksRegistry extends DefinitionRegistry<
},
icon,
};
this.register(definition.type, withBaseParams);
this.register({
key: definition.type,
definition: withBaseParams,
});
}
}