Skip to content

Refactor: unused parameter conventions, import alias clarity, null safety, and DRY helpers#406

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-user-parameter-warning
Draft

Refactor: unused parameter conventions, import alias clarity, null safety, and DRY helpers#406
Copilot wants to merge 2 commits intomainfrom
copilot/fix-user-parameter-warning

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

Several code quality issues across inventory, landing page, and subscription modules: void param anti-pattern, a confusing import alias shadowing a local function, unsafe as Promise<T> casts, and duplicated date math.

src/app/api/inventory/route.ts

  • Replace void user; suppression with _user naming convention in handleConfirm, handleRelease, handleCheck

src/lib/services/landing-page-service.ts

  • Rename import alias sanitizeRichHtmlsanitizeRichTextFromXssProtection to eliminate ambiguity with the local sanitizeRichText wrapper
  • Extract MAX_RICH_TEXT_LENGTH = 10_000 constant to replace inline magic number
  • Replace four as Promise<LandingPageDetail> unsafe casts with explicit await + null checks:
// before
return getLandingPage(storeId, p.id) as Promise<LandingPageDetail>;

// after
const page = await getLandingPage(storeId, p.id);
if (!page) throw new Error(`Failed to load landing page after creation: storeId=${storeId}, pageId=${p.id}`);
return page;

src/lib/subscription/feature-enforcer.ts

  • Add FeatureFlag type alias replacing the verbose keyof Pick<FeatureLimits, '...' | '...'> signature in canUseFeature; also narrows featureNames record to Record<FeatureFlag, string>
  • Extract getStartOfMonth() helper eliminating identical 3-line date setup duplicated in canCreateOrder and getUsageStats

src/test/services/search.service.test.ts

  • Fix misleading comment: Mock elasticsearch clientMock search engine client
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"The `void user;` statement is used to suppress unused variable warnings, but it's clearer to use a more conventional approach. Consider either removing the `user` parameter if it's not needed, or using a TypeScript convention like prefixing the parameter name with an underscore (`_user`) to indicate it's intentionally unused.","fixFiles":[{"filePath":"src/app/api/inventory/route.ts","diff":"diff --git a/src/app/api/inventory/route.ts b/src/app/api/inventory/route.ts\n--- a/src/app/api/inventory/route.ts\n+++ b/src/app/api/inventory/route.ts\n@@ -179,12 +179,12 @@\n /**\n  * Handle confirm action\n  */\n-async function handleConfirm(body: unknown, user: InventorySessionUser) {\n-  void user;\n-\n+async function handleConfirm(body: unknown, _user: InventorySessionUser) {\n   const validated = confirmSchema.parse(body);\n \n   const { prisma } = await import('@/lib/prisma');\n+\n+  const { prisma } = await import('@/lib/prisma');\n   const reservation = await prisma.inventoryReservation.findUnique({\n     where: { id: validated.reservationId },\n     select: { storeId: true },\n"}]},{"message":"The `void user;` statement is used to suppress unused variable warnings, but it's clearer to use a more conventional approach. Consider either removing the `user` parameter if it's not needed, or using a TypeScript convention like prefixing the parameter name with an underscore (`_user`) to indicate it's intentionally unused.","fixFiles":[{"filePath":"src/app/api/inventory/route.ts","diff":"diff --git a/src/app/api/inventory/route.ts b/src/app/api/inventory/route.ts\n--- a/src/app/api/inventory/route.ts\n+++ b/src/app/api/inventory/route.ts\n@@ -179,8 +179,7 @@\n /**\n  * Handle confirm action\n  */\n-async function handleConfirm(body: unknown, user: InventorySessionUser) {\n-  void user;\n+async function handleConfirm(body: unknown, _user: InventorySessionUser) {\n \n   const validated = confirmSchema.parse(body);\n \n@@ -215,8 +214,7 @@\n /**\n  * Handle release action\n  */\n-async function handleRelease(body: unknown, user: InventorySessionUser) {\n-  void user;\n+async function handleRelease(body: unknown, _user: InventorySessionUser) {\n \n   const validated = releaseSchema.parse(body);\n \n"}]},{"message":"The `void user;` statement is used to suppress unused variable warnings, but it's clearer to use a more conventional approach. Consider either removing the `user` parameter if it's not needed, or using a TypeScript convention like prefixing the parameter name with an underscore (`_user`) to indicate it's intentionally unused.","fixFiles":[{"filePath":"src/app/api/inventory/route.ts","diff":"diff --git a/src/app/api/inventory/route.ts b/src/app/api/inventory/route.ts\n--- a/src/app/api/inventory/route.ts\n+++ b/src/app/api/inventory/route.ts\n@@ -252,8 +252,7 @@\n /**\n  * Handle check action\n  */\n-async function handleCheck(body: unknown, user: InventorySessionUser) {\n-  void user;\n+async function handleCheck(body: unknown, _user: InventorySessionUser) {\n \n   const validated = checkSchema.parse(body);\n \n"}]},{"message":"The import alias `sanitizeRichHtml` is confusing since it conflicts with the local function `sanitizeRichText` (line 62). Consider using a more distinct alias like `sanitizeRichTextFromXssProtection` or importing without an alias to avoid confusion.","fixFiles":[{"filePath":"src/lib/services/landing-page-service.ts","diff":"diff --git a/src/lib/services/landing-page-service.ts b/src/lib/services/landing-page-service.ts\n--- a/src/lib/services/landing-page-service.ts\n+++ b/src/lib/services/landing-page-service.ts\n@@ -20,7 +20,7 @@\n   LandingPageDetail,\n   LandingPageCategory,\n } from \"@/lib/landing-pages/types\";\n-import { sanitizeRichText as sanitizeRichHtml } from \"@/lib/security/xss-protection\";\n+import { sanitizeRichText as sanitizeRichTextFromXssProtection } from \"@/lib/security/xss-protection\";\n \n // ---------------------------------------------------------------------------\n // Helpers\n@@ -60,7 +60,7 @@\n const MAX_CUSTOM_CSS_LENGTH = 20_000;\n \n function sanitizeRichText(value: string): string {\n-  return sanitizeRichHtml(value, 10000);\n+  return sanitizeRichTextFromXssProtection(value, 10000);\n }\n \n function sanitizeCustomData(\n"}]},{"message":"The `sanitizeRichText` function is a thin wrapper around `sanitizeRichHtml` with a hardcoded max length. Consider either removing this wrapper and calling `sanitizeRichHtml` directly with the constant `MAX_CUSTOM_CSS_LENGTH`, or make the max length configurable. This reduces unnecessary indirection.","fixFiles":[{"filePath":"src/lib/services/landing-page-service.ts","diff":"diff --git a/src/lib/services/landing-page-service.ts b/src/lib/services/landing-page-service.ts\n--- a/src/lib/services/landing-page-service.ts\n+++ b/src/lib/services/la...

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stormcomui Ready Ready Preview, Comment Mar 31, 2026 2:37pm

…nd code quality issues

Agent-Logs-Url: https://github.com/CodeStorm-Hub/stormcomui/sessions/d0a6481e-19b4-41f9-8917-b4a1b828ada7

Co-authored-by: syed-reza98 <71028588+syed-reza98@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unused variable warnings for user parameter Refactor: unused parameter conventions, import alias clarity, null safety, and DRY helpers Mar 31, 2026
Copilot AI requested a review from syed-reza98 March 31, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants