unicorn/no-canvas-to-image
eslint-plugin-unicorn
No autofix
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-canvas-to-image": "error",
},
},
];Prefer drawing canvases directly instead of converting them to images.
const image = await loadImage(canvas.toDataURL());
context.drawImage(image, 0, 0);const imageData = sourceContext.getImageData(0, 0, width, height);
targetContext.putImageData(imageData, 0, 0);context.drawImage(canvas, 0, 0);targetContext.drawImage(sourceCanvas, 0, 0);const imageData = context.getImageData(0, 0, width, height);
imageData.data[0] = 0;
context.putImageData(imageData, 0, 0);Examples from the ESLint documentation.
unicorn/no-canvas-to-image
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-canvas-to-image": "error",
},
},
];Oxlint does not have this rule.
nursery/noCanvasToImage
nursery · since 2.6.9
{
"linter": {
"rules": {
"nursery": {
"noCanvasToImage": "error"
}
}
}
}Disallow arithmetic and bitwise operations that always evaluate to 0.
Prefer top-level await over top-level promises and async function calls.
Disallow interpolation into SQL strings passed to Node’s node:sqlite APIs.
Prefer using the String.raw tag to avoid escaping \.
Disallow useless concatenation of literals.