chore(lint): biome config + auto-fix sweep + translation hot-path quality fixes

- biome: enable unsafeParameterDecoratorsEnabled (NestJS @Body/@Query); ignore *.gen.ts; spec files override noExplicitAny
- translations: remove dictionary fallback DB write — was producing half-translated strings (e.g. "Body frame" → "Kaporta frame") that poisoned future lookups; now misses fall through to bootstrap script
- categories: add translateMany() to PCAT root/subgroup/parts insert paths (was only EMEX)
- auto-fix: organize imports, type-only imports, node: protocol on stdlib imports, and template-literal cleanups across 24 files

Drops lint count from 769 → 257; remaining are legacy noNonNullAssertion / noArrayIndexKey / useExhaustiveDependencies that need manual review.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sase Dev
2026-05-09 16:26:13 +00:00
parent 3184e4c619
commit 247efecca6
24 changed files with 219 additions and 138 deletions

View File

@@ -1,4 +1,4 @@
import { resolve } from "path";
import { resolve } from "node:path";
import { Module } from "@nestjs/common";
import { ConfigModule } from "@nestjs/config";
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR } from "@nestjs/core";

View File

@@ -1,4 +1,4 @@
import { randomUUID } from "crypto";
import { randomUUID } from "node:crypto";
import { generateReferralCode } from "@sase/shared";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";

View File

@@ -84,7 +84,7 @@ export class CatalogService {
const brandServices = new Map<string, string[]>();
for (const [serviceName, brandName] of Object.entries(SERVICE_TO_BRAND)) {
if (!brandServices.has(brandName)) brandServices.set(brandName, []);
brandServices.get(brandName)!.push(serviceName);
brandServices.get(brandName)?.push(serviceName);
}
for (const brandName of Array.from(brandNames).sort()) {
@@ -1285,7 +1285,7 @@ export class CatalogService {
for (const item of items) {
const node = map.get(item.id)!;
if (item.parentId && map.has(item.parentId)) {
map.get(item.parentId)!.children.push(node);
map.get(item.parentId)?.children.push(node);
} else {
roots.push(node);
}
@@ -1293,7 +1293,7 @@ export class CatalogService {
for (const node of map.values()) {
if (node.children.length === 0) {
delete node.children;
node.children = undefined;
}
}

View File

@@ -1105,7 +1105,7 @@ export class CategoriesService {
for (const item of items) {
const node = map.get(item.id)!;
if (item.parentId && map.has(item.parentId)) {
map.get(item.parentId)!.children.push(node);
map.get(item.parentId)?.children.push(node);
} else {
roots.push(node);
}
@@ -1115,7 +1115,7 @@ export class CategoriesService {
// leaf nodes (children: []) from unexplored nodes (children: undefined)
for (const node of map.values()) {
if (node.children.length === 0) {
delete node.children;
node.children = undefined;
}
}

View File

@@ -35,49 +35,49 @@ describe("CorgiService", () => {
// WBA = BMW, position 10 (index 9) = 'K' = 2019
const result = service.decodeVin("WBAPH5C55BA123456");
expect(result).not.toBeNull();
expect(result!.brandName).toBe("BMW");
expect(result!.wmi).toBe("WBA");
expect(result!.isKnown).toBe(true);
expect(result!.modelYear).toBe(2011); // 'B' at position 10
expect(result?.brandName).toBe("BMW");
expect(result?.wmi).toBe("WBA");
expect(result?.isKnown).toBe(true);
expect(result?.modelYear).toBe(2011); // 'B' at position 10
});
it("should extract model year 'A' as 2010", () => {
// Position 10 (index 9) = 'A' = 2010
const result = service.decodeVin("WBAPH5C55AA123456");
expect(result).not.toBeNull();
expect(result!.modelYear).toBe(2010);
expect(result?.modelYear).toBe(2010);
});
it("should extract model year 'J' as 2018", () => {
const result = service.decodeVin("WBAPH5C55JA123456");
expect(result).not.toBeNull();
expect(result!.modelYear).toBe(2018);
expect(result?.modelYear).toBe(2018);
});
it("should extract model year '1' as 2001", () => {
const result = service.decodeVin("WBAPH5C5510123456");
expect(result).not.toBeNull();
expect(result!.modelYear).toBe(2001);
expect(result?.modelYear).toBe(2001);
});
it("should extract model year '9' as 2009", () => {
const result = service.decodeVin("WBAPH5C5590123456");
expect(result).not.toBeNull();
expect(result!.modelYear).toBe(2009);
expect(result?.modelYear).toBe(2009);
});
it("should return null modelYear for unrecognized year character", () => {
// Position 10 (index 9) = '0' is not in YEAR_MAP
const result = service.decodeVin("WBAPH5C550A123456");
expect(result).not.toBeNull();
expect(result!.modelYear).toBeNull();
expect(result?.modelYear).toBeNull();
});
it("should return isKnown=false for unknown WMI", () => {
const result = service.decodeVin("ZZZPH5C55KA123456");
expect(result).not.toBeNull();
expect(result!.brandName).toBe("Unknown");
expect(result!.isKnown).toBe(false);
expect(result?.brandName).toBe("Unknown");
expect(result?.isKnown).toBe(false);
});
it("should return null for VIN with wrong length", () => {
@@ -89,33 +89,33 @@ describe("CorgiService", () => {
it("should handle lowercase VIN input", () => {
const result = service.decodeVin("wbaph5c55ka123456");
expect(result).not.toBeNull();
expect(result!.brandName).toBe("BMW");
expect(result!.wmi).toBe("WBA");
expect(result?.brandName).toBe("BMW");
expect(result?.wmi).toBe("WBA");
});
it("should decode a Toyota VIN correctly", () => {
const result = service.decodeVin("JTDKN3DU5LA123456");
expect(result).not.toBeNull();
expect(result!.brandName).toBe("Toyota");
expect(result!.wmi).toBe("JTD");
expect(result!.isKnown).toBe(true);
expect(result!.modelYear).toBe(2020); // 'L' at position 10
expect(result?.brandName).toBe("Toyota");
expect(result?.wmi).toBe("JTD");
expect(result?.isKnown).toBe(true);
expect(result?.modelYear).toBe(2020); // 'L' at position 10
});
it("should decode a Volkswagen VIN with numeric WMI prefix", () => {
const result = service.decodeVin("3VWFE21C55M123456");
expect(result).not.toBeNull();
expect(result!.brandName).toBe("Volkswagen");
expect(result!.wmi).toBe("3VW");
expect(result!.isKnown).toBe(true);
expect(result?.brandName).toBe("Volkswagen");
expect(result?.wmi).toBe("3VW");
expect(result?.isKnown).toBe(true);
});
it("should decode a VW Commercial VIN correctly", () => {
const result = service.decodeVin("WV2ZZZ2KZ5X071795");
expect(result).not.toBeNull();
expect(result!.brandName).toBe("Volkswagen");
expect(result!.wmi).toBe("WV2");
expect(result!.isKnown).toBe(true);
expect(result?.brandName).toBe("Volkswagen");
expect(result?.wmi).toBe("WV2");
expect(result?.isKnown).toBe(true);
});
});
});

View File

@@ -9,7 +9,7 @@
* QuickGroups.aspx, or QuickDetails.aspx — plain HTTP GET works.
*/
import * as path from "path";
import * as path from "node:path";
import {
BadRequestException,
Injectable,
@@ -167,7 +167,7 @@ export class EmexService {
try {
this.logger.log(`Loading EMEX scraper module from: ${this.scraperPath}`);
const fs = require("fs");
const fs = require("node:fs");
if (!fs.existsSync(this.scraperPath)) {
this.logger.error(`Scraper file not found at: ${this.scraperPath}`);
this.logger.error(`Current working directory: ${process.cwd()}`);
@@ -600,7 +600,7 @@ export class EmexService {
if (!response.success) {
this.logger.warn(`EMEX browser search unsuccessful: ${response.message || response.error}`);
if (response.vehicle && response.vehicle.brand) {
if (response.vehicle?.brand) {
return mapEmexResponse(response);
}
return createEmptyDecodedVehicle(cleanVin, response.message || response.error);

View File

@@ -24,6 +24,6 @@ export abstract class BasePL24Parser {
protected safeNumber(value: unknown): number {
if (typeof value === "number") return value;
const parsed = Number(value);
return isNaN(parsed) ? 0 : parsed;
return Number.isNaN(parsed) ? 0 : parsed;
}
}

View File

@@ -5,7 +5,7 @@
* P5 Modern architecture only (JSON API). Legacy scraping is deferred.
*/
import { createHash } from "crypto";
import { createHash } from "node:crypto";
import {
BadRequestException,
Injectable,

View File

@@ -76,17 +76,15 @@ describe("PaymentsService", () => {
select: vi.fn().mockReturnValue({
from: vi.fn().mockReturnThis(),
where: vi.fn().mockReturnThis(),
limit: vi
.fn()
.mockReturnValue([
{
id: "plan-1",
brandCount: 1,
priceMonthly: 20000,
priceYearly: 200000,
isActive: true,
},
]),
limit: vi.fn().mockReturnValue([
{
id: "plan-1",
brandCount: 1,
priceMonthly: 20000,
priceYearly: 200000,
isActive: true,
},
]),
}),
insert: vi.fn().mockReturnValue({
values: vi.fn().mockReturnThis(),
@@ -175,17 +173,15 @@ describe("PaymentsService", () => {
select: vi.fn().mockReturnValue({
from: vi.fn().mockReturnThis(),
where: vi.fn().mockReturnThis(),
limit: vi
.fn()
.mockReturnValue([
{
id: "plan-1",
brandCount: 0,
priceMonthly: 99900,
priceYearly: 999000,
isActive: true,
},
]),
limit: vi.fn().mockReturnValue([
{
id: "plan-1",
brandCount: 0,
priceMonthly: 99900,
priceYearly: 999000,
isActive: true,
},
]),
}),
insert: vi.fn().mockReturnValue({
values: vi.fn().mockReturnThis(),

View File

@@ -14,7 +14,7 @@ describe("Telemetry module", () => {
describe("isOtelEnabled", () => {
it("should be false when OTEL_ENABLED is not set", async () => {
delete process.env.OTEL_ENABLED;
process.env.OTEL_ENABLED = undefined;
const { isOtelEnabled } = await import("../index");
expect(isOtelEnabled).toBe(false);
});
@@ -53,7 +53,7 @@ describe("Telemetry module", () => {
describe("sdk-factory", () => {
it("should not throw when OTel is enabled but endpoint is missing", async () => {
process.env.OTEL_ENABLED = "true";
delete process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
process.env.OTEL_EXPORTER_OTLP_ENDPOINT = undefined;
const { createNodeSDK } = await import("../sdk-factory");
expect(() =>
createNodeSDK({
@@ -64,7 +64,7 @@ describe("Telemetry module", () => {
});
it("should return null when endpoint is not configured", async () => {
delete process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
process.env.OTEL_EXPORTER_OTLP_ENDPOINT = undefined;
const { createNodeSDK } = await import("../sdk-factory");
const sdk = createNodeSDK({
serviceName: "test",

View File

@@ -32,7 +32,7 @@ function parseHeaders(headerString: string): Record<string, string> {
export function createNodeSDK(config: SDKConfig): NodeSDK | null {
const endpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
if (!endpoint) {
console.log(`[otel] No OTLP endpoint configured — telemetry will not be exported`);
console.log("[otel] No OTLP endpoint configured — telemetry will not be exported");
return null;
}

View File

@@ -247,57 +247,52 @@ function AdminCopyLogsPage() {
</>
)}
{tab === "top" && (
<>
{topLoading ? (
<div className="space-y-3">
{Array.from({ length: 10 }).map((_, i) => (
<Skeleton key={`top-skel-${i}`} className="h-12 w-full" />
))}
</div>
) : !topCodes || topCodes.length === 0 ? (
<Card>
<CardContent className="flex flex-col items-center gap-3 py-16 text-center">
<TrendingUp className="h-12 w-12 text-muted-foreground" />
<p className="text-lg font-medium">Veri bulunamadi</p>
<p className="text-sm text-muted-foreground">
Son 30 gunde kopyalanan OEM kodu yok
</p>
</CardContent>
</Card>
) : (
<Card>
<CardContent className="overflow-x-auto p-0">
<div className="min-w-[500px]">
<div className="grid grid-cols-4 items-center gap-4 border-b px-6 py-3 text-sm font-medium text-muted-foreground">
<span>#</span>
<span>OEM Kodu</span>
<span className="text-center">Kopyalanma</span>
<span className="text-center">Benzersiz Kullanici</span>
</div>
<div className="divide-y">
{topCodes.map((item, idx) => (
<div
key={item.oemCode}
className="grid grid-cols-4 items-center gap-4 px-6 py-3 text-sm"
>
<span className="text-muted-foreground">{idx + 1}</span>
<div>
<code className="rounded bg-muted px-1.5 py-0.5 text-xs font-semibold">
{item.oemCode}
</code>
</div>
<div className="text-center font-medium">{item.copyCount}</div>
<div className="text-center text-muted-foreground">{item.uniqueUsers}</div>
</div>
))}
</div>
{tab === "top" &&
(topLoading ? (
<div className="space-y-3">
{Array.from({ length: 10 }).map((_, i) => (
<Skeleton key={`top-skel-${i}`} className="h-12 w-full" />
))}
</div>
) : !topCodes || topCodes.length === 0 ? (
<Card>
<CardContent className="flex flex-col items-center gap-3 py-16 text-center">
<TrendingUp className="h-12 w-12 text-muted-foreground" />
<p className="text-lg font-medium">Veri bulunamadi</p>
<p className="text-sm text-muted-foreground">Son 30 gunde kopyalanan OEM kodu yok</p>
</CardContent>
</Card>
) : (
<Card>
<CardContent className="overflow-x-auto p-0">
<div className="min-w-[500px]">
<div className="grid grid-cols-4 items-center gap-4 border-b px-6 py-3 text-sm font-medium text-muted-foreground">
<span>#</span>
<span>OEM Kodu</span>
<span className="text-center">Kopyalanma</span>
<span className="text-center">Benzersiz Kullanici</span>
</div>
</CardContent>
</Card>
)}
</>
)}
<div className="divide-y">
{topCodes.map((item, idx) => (
<div
key={item.oemCode}
className="grid grid-cols-4 items-center gap-4 px-6 py-3 text-sm"
>
<span className="text-muted-foreground">{idx + 1}</span>
<div>
<code className="rounded bg-muted px-1.5 py-0.5 text-xs font-semibold">
{item.oemCode}
</code>
</div>
<div className="text-center font-medium">{item.copyCount}</div>
<div className="text-center text-muted-foreground">{item.uniqueUsers}</div>
</div>
))}
</div>
</div>
</CardContent>
</Card>
))}
</div>
);
}