fix(lint): resolve all biome warnings across API, web, and image-engine

API:
- Replace string concatenation with template literals (batch, pipeline,
  tool-factory, content-aware-resize, passport-photo, remove-background)
- Remove unused imports (teams, color-adjustments, image-enhancement)
- Replace non-null assertions with guard clauses in bg-effects and stitch
- Use optional chaining in docs route

Image-engine:
- Remove unused OutputFormat imports (compress, convert)
- Use local variables instead of reassigning parameters (optimize-for-web, sharpen)

Web:
- Fix useExhaustiveDependencies: remove genuinely redundant deps, add
  biome-ignore comments for intentional patterns (src prop, cleanup fns)
- Replace non-null assertions with null-safe alternatives
- Add accessible titles to inline SVGs (color-settings, image-enhancement-settings)
- Fix noLabelWithoutControl: associate labels via htmlFor/id or use <span>
  (image-to-base64-settings, edit-metadata-settings, qr-generate-settings)
- Replace div[role="button"] with <button> (pdf-to-image-settings)
- Use stable keys instead of array indices (collage-preview, collage-settings)
- Fix noStaticElementInteractions in collage-preview (role="none")
- Remove unused function parameters and imports
This commit is contained in:
Siddharth Kumar Sah
2026-04-14 22:15:37 +08:00
parent 3982ff4136
commit 93c588b239
39 changed files with 212 additions and 117 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ export async function registerBatchRoutes(app: FastifyInstance): Promise<void> {
processBuffer = await decodeHeic(processBuffer);
// Update extension to match decoded format (HEIC/HEIF → PNG)
const ext = processFilename.match(/\.[^.]+$/)?.[0];
if (ext) processFilename = processFilename.slice(0, -ext.length) + ".png";
if (ext) processFilename = `${processFilename.slice(0, -ext.length)}.png`;
}
if (!skipPreprocess) {
processBuffer = await autoOrient(processBuffer);
+1 -1
View File
@@ -81,7 +81,7 @@ function generateLlmsFullTxt(spec: OpenAPISpec): string {
for (const [method, op] of Object.entries(methods)) {
const tag = op.tags?.[0] || "Other";
if (!tagGroups.has(tag)) tagGroups.set(tag, []);
tagGroups.get(tag)!.push({ method: method.toUpperCase(), path, op });
tagGroups.get(tag)?.push({ method: method.toUpperCase(), path, op });
}
}
+2 -2
View File
@@ -106,7 +106,7 @@ export async function registerPipelineRoutes(app: FastifyInstance): Promise<void
fileBuffer = await decodeHeic(fileBuffer);
// Update filename extension to match the decoded format
const ext = filename.match(/\.[^.]+$/)?.[0];
if (ext) filename = filename.slice(0, -ext.length) + ".png";
if (ext) filename = `${filename.slice(0, -ext.length)}.png`;
} catch (err) {
return reply.status(422).send({
error: "Failed to decode HEIC file. Ensure libheif-examples is installed.",
@@ -513,7 +513,7 @@ export async function registerPipelineRoutes(app: FastifyInstance): Promise<void
if (validation.format === "heif") {
currentBuffer = await decodeHeic(currentBuffer);
const ext = currentFilename.match(/\.[^.]+$/)?.[0];
if (ext) currentFilename = currentFilename.slice(0, -ext.length) + ".png";
if (ext) currentFilename = `${currentFilename.slice(0, -ext.length)}.png`;
}
// Normalize EXIF orientation
+1 -1
View File
@@ -11,7 +11,7 @@ import { randomUUID } from "node:crypto";
import { eq, sql } from "drizzle-orm";
import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
import { db, schema } from "../db/index.js";
import { requireAdmin, requireAuth } from "../plugins/auth.js";
import { requireAdmin } from "../plugins/auth.js";
function validateTeamName(name: unknown): string | null {
if (typeof name !== "string") return "Team name is required";
+1 -1
View File
@@ -156,7 +156,7 @@ export function createToolRoute<T>(app: FastifyInstance, config: ToolRouteConfig
try {
fileBuffer = await decodeHeic(fileBuffer);
const ext = filename.match(/\.[^.]+$/)?.[0];
if (ext) filename = filename.slice(0, -ext.length) + ".png";
if (ext) filename = `${filename.slice(0, -ext.length)}.png`;
} catch (err) {
return reply.status(422).send({
error: "Failed to decode HEIC file. Ensure libheif-examples is installed.",
@@ -1,7 +1,6 @@
import {
brightness as adjustBrightness,
contrast as adjustContrast,
saturation as adjustSaturation,
sharpen as adjustSharpen,
colorChannels,
grayscale,
@@ -65,7 +65,7 @@ export function registerContentAwareResize(app: FastifyInstance) {
try {
fileBuffer = await decodeHeic(fileBuffer);
const ext = filename.match(/\.[^.]+$/)?.[0];
if (ext) filename = filename.slice(0, -ext.length) + ".png";
if (ext) filename = `${filename.slice(0, -ext.length)}.png`;
} catch (err) {
return reply.status(422).send({
error: "Failed to decode HEIC/HEIF file",
@@ -4,7 +4,6 @@ import sharp from "sharp";
import { z } from "zod";
import { autoOrient } from "../../lib/auto-orient.js";
import { validateImageBuffer } from "../../lib/file-validation.js";
import { sanitizeFilename } from "../../lib/filename.js";
import { decodeHeic } from "../../lib/heic-converter.js";
import { resolveOutputFormat } from "../../lib/output-format.js";
import { createToolRoute } from "../tool-factory.js";
+1 -1
View File
@@ -160,7 +160,7 @@ export function registerPassportPhoto(app: FastifyInstance) {
if (validation.format === "heif") {
fileBuffer = await decodeHeic(fileBuffer);
const ext = filename.match(/\.[^.]+$/)?.[0];
if (ext) filename = filename.slice(0, -ext.length) + ".png";
if (ext) filename = `${filename.slice(0, -ext.length)}.png`;
}
// Auto-orient to fix EXIF rotation
@@ -83,7 +83,7 @@ export function registerRemoveBackground(app: FastifyInstance) {
if (validation.format === "heif") {
fileBuffer = await decodeHeic(fileBuffer);
const ext = filename.match(/\.[^.]+$/)?.[0];
if (ext) filename = filename.slice(0, -ext.length) + ".png";
if (ext) filename = `${filename.slice(0, -ext.length)}.png`;
}
// Auto-orient to fix EXIF rotation
+3 -2
View File
@@ -205,8 +205,9 @@ export function registerStitch(app: FastifyInstance) {
if (settings.cornerRadius > 0) {
const meta = await sharp(result).metadata();
const w = meta.width!;
const h = meta.height!;
if (!meta.width || !meta.height) throw new Error("Cannot read image dimensions");
const w = meta.width;
const h = meta.height;
const r = Math.min(settings.cornerRadius, Math.floor(Math.min(w, h) / 2));
const mask = Buffer.from(