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:
Lipis 2020-02-02 20:04:35 +02:00 committed by GitHub
parent 814299321e
commit 53994e71e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 201 additions and 77 deletions

View file

@ -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}`);
}
}
}

View file

@ -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