Skip to content

Chore/better lint rules v2#121

Merged
henri318 merged 4 commits into
mainfrom
chore/better_lint_rules_v2
Jul 6, 2026
Merged

Chore/better lint rules v2#121
henri318 merged 4 commits into
mainfrom
chore/better_lint_rules_v2

Conversation

@henri318

@henri318 henri318 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

better lint rules

Summary by CodeRabbit

  • New Features

    • La pantalla de restablecimiento de contraseña muestra antes el aviso si falta el token y ofrece un enlace para solicitar uno nuevo.
    • El perfil ahora presenta de forma más clara el estado de carga.
  • Bug Fixes

    • Se mejora la estabilidad del carrito al revertir cambios si falla una actualización.
    • El proceso de compra gestiona mejor los cambios de precio y el guardado de la vista previa.
    • Se ajustan varias validaciones de archivos, cantidades, correos y formularios para un comportamiento más consistente.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@henri318, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 48bdfb8e-1b32-4326-b410-f44c72aa4c62

📥 Commits

Reviewing files that changed from the base of the PR and between e871120 and ea2c4ad.

📒 Files selected for processing (2)
  • app/api/uploads/local/[...storageKey]/route.ts
  • scripts/optimize-sprites.mjs
📝 Walkthrough

Walkthrough

Este PR combina cambios funcionales pequeños (guard de reset-password, resolución segura de rutas de uploads locales, validación de email, reversión optimista en el botón de carrito, orden de validación de personalizaciones, cálculo de totales de checkout, validación de cantidad) con numerosos refactors de estilo y supresiones de reglas de lint en componentes, scripts y tests.

Changes

Autenticación y seguridad

Layer / File(s) Summary
Guard temprano de reset-password
app/[locale]/auth/reset-password/page.tsx
Se añade un retorno anticipado cuando falta el token y se elimina la verificación tardía duplicada.
Validación de email y redirecciones
shared/kernel/domain/value-objects/email.ts, shared/layout/login-modal.tsx
Se actualiza la regex de email y se sustituye location.href por location.assign en redirecciones por rol.
Flujo de carga y borrado en perfil
app/[locale]/profile/page.tsx
Se reordena el bloque de "loading" y se usa location.assign tras eliminar la cuenta.
Resolución segura de rutas de almacenamiento
app/api/uploads/local/[...storageKey]/route.ts
Se migra a path.* de node:path y se refuerza la validación anti path-traversal.
TTL de tokens y envío de emails
modules/auth/infrastructure/memory-used-reset-token-store.ts, modules/uploads/infrastructure/prisma-upload-repository.ts, modules/users/application/use-cases/forgot-password-use-case.ts, shared/infrastructure/used-reset-token-store.ts, composition-root/container.ts, modules/events/domain/event-registry.ts
Se reformatean literales numéricos de TTL, se usa ternario para el email sender y se suprime lint en eventos de contraseña.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Lógica de carrito y personalización

Layer / File(s) Summary
Validación de personalizaciones al añadir al carrito
modules/cart/application/add-item-to-cart.ts
Se renombra sellerId a _sellerId y se elimina la sentencia dummy void sellerId.
Refactor de totales en checkout
modules/cart/application/checkout-cart.ts
preview simplifica su destructuring y buildTotals calcula liveCart con un ternario.
Validación de cantidad segura
modules/cart/domain/value-objects/quantity.ts
Quantity.create usa Number.isSafeInteger para validar enteros.
Reversión optimista en botón de carrito
modules/cart/presentation/components/add-to-cart-button.tsx, modules/cart/presentation/components/cart-icon.tsx, app/[locale]/cart/page.tsx
Se capturan snapshots previos para revertir en incrementos/decrementos fallidos, se ajusta la invocación de fetchCount y la construcción de productMap.
Reordenación de validaciones de personalización
modules/customizations/application/create-customer-customization.ts, modules/customizations/domain/value-objects/customization-options.ts
Se reordenan las validaciones de capacidad de foto, estilo, texto y designPosition.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Refactors de estilo y limpieza de lint

Layer / File(s) Summary
Manejadores de carga de imagen
app/[locale]/cart/design-preview.tsx, modules/presentation/components/design-preview.tsx
loadImage pasa de onload/onerror a addEventListener.
forEach a for...of
app/[locale]/layout.tsx, scripts/optimize-sprites.mjs
Se sustituyen bucles forEach por for...of en construcción de alternates y logging.
Limpieza en formularios de producto
app/[locale]/products/[id]/customization-form.tsx, app/[locale]/products/[id]/photo-upload-field.tsx
Se elimina una constante no usada y se retorna la promesa de subida sin void.
Manejo de variables no usadas en destructuring
modules/orders/application/list-seller-orders-use-case.ts, modules/sellers/application/use-cases/list-seller-products-use-case.ts, modules/users/infrastructure/prisma-user-repository.ts, modules/users/application/use-cases/register-user-use-case.ts
Se cambia el patrón de exclusión de variables a destructuring con eslint-disable o ternario inline.
Refactors de formateo numérico y URLs
shared/kernel/config.ts, shared/presentation/components/file-upload-dropzone.tsx, shared/ui/file-upload-dropzone.tsx, modules/products/infrastructure/prisma-product-repository.ts
Se ajusta formatBytes, la normalización de APP_BASE_URL y el escapado de comodines SQL.
Scripts de build y configuración
scripts/optimize-sprites.mjs, proxy.ts, eslint.config.mjs
Se migra a import por defecto de path, se reescribe el parseo CSS, se ajusta el matcher de proxy y reglas de lint.
Supresiones de lint en tests y fixtures
tests/doubles/memory-storage-adapter.ts, tests/e2e/admin/credentials.ts, tests/unit/app/[locale]/products/[id]/*.test.tsx, tests/unit/app/[locale]/seller/products/product-form.test.tsx
Se añaden comentarios eslint-disable en credenciales y mocks de next/image.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Possibly related PRs

  • henri318/728-store#88: Ambos PRs modifican el manejo de fallos de PATCH/DELETE con reversión de estado en add-to-cart-button.tsx.
  • henri318/728-store#105: Ambos PRs tocan la lógica de loadImage/manejadores de carga en design-preview.tsx.
  • henri318/728-store#107: Ambos PRs modifican el renderizado condicional al faltar el token en reset-password/page.tsx.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed El título refleja correctamente el objetivo principal del PR: mejoras incrementales en reglas de lint.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/better_lint_rules_v2

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
shared/presentation/components/file-upload-dropzone.tsx (1)

156-165: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicación de formatBytes entre dos componentes.

Esta función es idéntica a formatBytes en shared/ui/file-upload-dropzone.tsx (mismo cambio aplicado en ambos archivos). Sería más mantenible extraerla a un helper compartido (p. ej. shared/kernel/format-bytes.ts) e importarla en ambos componentes.

♻️ Propuesta
+// shared/kernel/format-bytes.ts
+export function formatBytes(bytes: number): string {
+  if (bytes < 1024) return `${bytes} B`;
+  if (bytes < 1024 * 1024) {
+    const value = bytes / 1024;
+    return `${Number.isSafeInteger(value) ? value.toFixed(0) : value.toFixed(1)} KB`;
+  }
+
+  const value = bytes / (1024 * 1024);
+  return `${Number.isSafeInteger(value) ? value.toFixed(0) : value.toFixed(1)} MB`;
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shared/presentation/components/file-upload-dropzone.tsx` around lines 156 -
165, The formatBytes helper is duplicated in file-upload-dropzone components, so
centralize it in a shared helper and reuse it from both places. Extract the
logic from the local formatBytes function into a shared utility (for example, a
kernel-level helper) and update both file-upload-dropzone components to import
that single implementation instead of keeping two copies.
app/[locale]/products/[id]/photo-upload-field.tsx (1)

57-61: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Haz async el callback de startTransition y captura el fallo de onUpload

onUpload(file) queda como promesa flotante: isPending puede terminar antes de que acabe la subida y un rechazo se queda sin manejar. Conviene await/return la promesa dentro de startTransition y mostrar un error de subida si falla, como en mockup-canvas-control.tsx.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/`[locale]/products/[id]/photo-upload-field.tsx around lines 57 - 61, Make
the startTransition callback in photo-upload-field.tsx handle the upload promise
instead of leaving onUpload(file) floating: update the logic around onUpload and
onUploaded so the transition awaits/returns the upload work, keeps isPending
aligned with the actual upload, and catches rejections to surface a proper
upload error message. Use the existing upload flow in photo-upload-field and
mirror the error-handling approach from mockup-canvas-control.tsx so failures
are not unhandled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/api/uploads/local/`[...storageKey]/route.ts:
- Line 29: The path validation in the storage key parsing logic is rejecting
valid filenames that merely start with two dots. Update the check in the route
handler’s relative path handling to only block traversal segments by matching
exactly ".." or paths that begin with ".." followed by the path separator, while
still keeping the absolute-path guard in place.

In `@scripts/optimize-sprites.mjs`:
- Around line 12-19: The optimize-sprites.mjs script now imports path as a
default object, but the existing `join(ICONS_DIR, file)` calls in the sprite
generation flow still reference `join` directly. Update the path usage in the
affected logic so it consistently uses the `path` module (or restore the named
import) in the code paths around the icon iteration and output assembly,
especially the functions or blocks that build sprite file paths and write the
CSS/SVG outputs.

---

Nitpick comments:
In `@app/`[locale]/products/[id]/photo-upload-field.tsx:
- Around line 57-61: Make the startTransition callback in photo-upload-field.tsx
handle the upload promise instead of leaving onUpload(file) floating: update the
logic around onUpload and onUploaded so the transition awaits/returns the upload
work, keeps isPending aligned with the actual upload, and catches rejections to
surface a proper upload error message. Use the existing upload flow in
photo-upload-field and mirror the error-handling approach from
mockup-canvas-control.tsx so failures are not unhandled.

In `@shared/presentation/components/file-upload-dropzone.tsx`:
- Around line 156-165: The formatBytes helper is duplicated in
file-upload-dropzone components, so centralize it in a shared helper and reuse
it from both places. Extract the logic from the local formatBytes function into
a shared utility (for example, a kernel-level helper) and update both
file-upload-dropzone components to import that single implementation instead of
keeping two copies.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: debd9fe0-b573-4fec-98d9-f15d9915777d

📥 Commits

Reviewing files that changed from the base of the PR and between fdf1414 and e871120.

📒 Files selected for processing (40)
  • app/[locale]/auth/reset-password/page.tsx
  • app/[locale]/cart/design-preview.tsx
  • app/[locale]/cart/page.tsx
  • app/[locale]/layout.tsx
  • app/[locale]/products/[id]/customization-form.tsx
  • app/[locale]/products/[id]/photo-upload-field.tsx
  • app/[locale]/profile/page.tsx
  • app/api/uploads/local/[...storageKey]/route.ts
  • composition-root/container.ts
  • eslint.config.mjs
  • modules/auth/infrastructure/memory-used-reset-token-store.ts
  • modules/cart/application/add-item-to-cart.ts
  • modules/cart/application/checkout-cart.ts
  • modules/cart/domain/value-objects/quantity.ts
  • modules/cart/presentation/components/add-to-cart-button.tsx
  • modules/cart/presentation/components/cart-icon.tsx
  • modules/customizations/application/create-customer-customization.ts
  • modules/customizations/domain/value-objects/customization-options.ts
  • modules/events/domain/event-registry.ts
  • modules/orders/application/list-seller-orders-use-case.ts
  • modules/presentation/components/design-preview.tsx
  • modules/products/infrastructure/prisma-product-repository.ts
  • modules/sellers/application/use-cases/list-seller-products-use-case.ts
  • modules/uploads/infrastructure/prisma-upload-repository.ts
  • modules/users/application/use-cases/forgot-password-use-case.ts
  • modules/users/application/use-cases/register-user-use-case.ts
  • modules/users/infrastructure/prisma-user-repository.ts
  • proxy.ts
  • scripts/optimize-sprites.mjs
  • shared/infrastructure/used-reset-token-store.ts
  • shared/kernel/config.ts
  • shared/kernel/domain/value-objects/email.ts
  • shared/layout/login-modal.tsx
  • shared/presentation/components/file-upload-dropzone.tsx
  • shared/ui/file-upload-dropzone.tsx
  • tests/doubles/memory-storage-adapter.ts
  • tests/e2e/admin/credentials.ts
  • tests/unit/app/[locale]/products/[id]/customization-experience.test.tsx
  • tests/unit/app/[locale]/products/[id]/customization-preview.test.tsx
  • tests/unit/app/[locale]/seller/products/product-form.test.tsx
💤 Files with no reviewable changes (1)
  • app/[locale]/products/[id]/customization-form.tsx

Comment thread app/api/uploads/local/[...storageKey]/route.ts Outdated
Comment thread scripts/optimize-sprites.mjs
@henri318 henri318 merged commit 42273b4 into main Jul 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant