Skip to content

fix: exhaustive TS/ESLint bug fixes — items #9–#17#164

Merged
adm01-debug merged 4 commits into
mainfrom
claude/dreamy-tesla-PtPVV
May 24, 2026
Merged

fix: exhaustive TS/ESLint bug fixes — items #9–#17#164
adm01-debug merged 4 commits into
mainfrom
claude/dreamy-tesla-PtPVV

Conversation

@adm01-debug
Copy link
Copy Markdown
Owner

@adm01-debug adm01-debug commented May 23, 2026

Summary

Exhaustive fix batch covering all 9 open items (#9#17). All changes pass the TSC baseline gate (1065 errors frozen) and ESLint baseline gate (405 errors frozen — 4 extra errors eliminated vs baseline).

#9price-response.adapter.ts (61 TS errors)

  • Added typed helper functions (asRec, str, num, bool, optStr) to safely navigate the mixed snake/camelCase response structure
  • Eliminated all null-safety and implicit-any errors without changing runtime behaviour

#10AdminProductFormPage.tsx (60 TS errors)

  • Expanded PromobrindProduct in product-types.ts with ~50 optional fields matching the real API response
  • Fixed all field accesses in the admin form page

#11AddressTab.tsx (56 TS errors)

  • Replaced Record<string, unknown> form prop with typed interfaces, unblocking TypeScript narrowing throughout the component

#12BasicDataTab.tsx (32 TS errors)

#13CompareTableView.tsx (26 TS errors)

  • Changed Product import from @/types/product.ts (DB snake_case) to @/types/product-catalog.ts (UI camelCase), aligning with how the component actually uses the data

#14SupabaseConnectionsTab.tsx (17 ESLint warnings)

  • Replaced all 17 non-null assertions (!) with nullish coalescing (?? '' / ?? 'promobrind') and as NonNullable<...> type casts
  • Extracted local vars (urlSecretName, anonSecretName, serviceSecretName, envKeyName) for safe reuse throughout JSX

#15CatalogContent.tsx + ProductQuickView.tsx (32 ESLint warnings)

  • Removed all unused imports, variables, and dead code paths

#16useSimulatorWizard.ts + useGlobalSearch.ts (27 ESLint warnings)

  • useSimulatorWizard: Added dispatch to all 15 useCallback/useEffect dependency arrays (stable ref from useReducer)
  • useGlobalSearch: Removed unused imports (playTtsAudio, processVoiceTranscript, CommandDefinition, useSearch); extracted onClosePalette to useCallback to stabilise commands; fixed non-null assertions on action.data.route; corrected all missing hook dependencies

#17 — T-FIX-5b ESLint guardrail

  • Added no-restricted-syntax rule to eslint.config.js (both src/**/__tests__/** and tests/** blocks) detecting forEach calls containing expect() — the anti-pattern that causes silent test pass when the array is empty
  • Added expect(array).not.toHaveLength(0) guards before all forEach+expect loops in tests/components/intelligence/commercial-intelligence.test.ts (14 violations, now guarded)
  • Existing violations in magic-up tests (93 cases using getAllByRole which throws on empty) captured in updated ESLint baseline — guardrail prevents new violations going forward

Test plan

  • npm run typecheck — TSC baseline gate passes (no new regressions)
  • npm run lint:baseline — ESLint baseline gate passes (positive drift: -4 errors)
  • npm run lint:check — overall lint check passes
  • Verify SupabaseConnectionsTab admin UI renders without runtime errors
  • Verify ProductQuickView modal opens and color selector works
  • Verify simulator wizard step navigation and undo/redo work correctly

Generated by Claude Code


Summary by cubic

Fixes TypeScript and ESLint issues across items #9#17, aligns types with real API data, and finalizes the test lint guardrail to prevent false-green tests. TSC baseline reduced to 1065 (from 1333) and ESLint baseline to 401 (from 442).

  • Bug Fixes

    • Pricing adapter: added typed helpers and safe snake/camel handling; removed implicit-any and null-safety errors.
    • Admin product forms: expanded PromobrindProduct; added typed form interfaces in Address/Basic tabs; fixed field access in AdminProductFormPage.
    • Compare table: switched to @/types/product-catalog.ts (camelCase) to match UI usage.
    • Supabase connections: replaced non-null assertions with ?? and NonNullable; extracted safe local vars.
    • Hooks: added missing deps in useSimulatorWizard; stabilized callbacks and removed unused imports in useGlobalSearch.
    • UI cleanup: normalized quotes/classes and polished skeleton grid in CatalogContent; removed unused imports/vars in ProductQuickView.
    • Tests (T-FIX-5b complete): added expect(array).not.toHaveLength(0) guards and, where arrays are provably non-empty, added scoped eslint-disable-next-line in commercial-intelligence.test.ts, magic-up-onda5.test.tsx, and magic-up-result-panel-keyboard.test.tsx; 0 T-FIX-5b violations remain.
  • Migration

    • New ESLint guardrail in eslint.config.js (applies to src/**/__tests__/** and tests/**):
      • Blocks forEach that declares it/test/describe.
      • Blocks forEach with expect inside tests. Add expect(array).not.toHaveLength(0) before forEach or use it.each/test.each. Tests updated in this PR to follow this rule.

Written for commit 5672c70. Summary will update on new commits. Review in cubic

#9 price-response.adapter.ts — typed 4 helper fns (asRec/str/num/bool/optStr)
to eliminate 61 TS errors from snake/camelCase + null-safety issues

#10 AdminProductFormPage.tsx — fixed PromobrindProduct field access after
expanding ~50 optional fields in product-types.ts

#11 AddressTab.tsx — replaced Record<string,unknown> form props with typed
interfaces, eliminating 56 TS errors

#12 BasicDataTab.tsx — same root cause as #11, typed interfaces applied,
32 TS errors resolved

#13 CompareTableView.tsx — changed import from @/types/product.ts (DB
snake_case) to @/types/product-catalog.ts (UI camelCase), fixing 26 TS errors

#14 SupabaseConnectionsTab.tsx — replaced 17 non-null assertions (!) with
nullish coalescing (??) + type casts

#15 CatalogContent.tsx + ProductQuickView.tsx — removed unused imports/vars,
resolving 32 ESLint warnings

#16 useSimulatorWizard.ts — added dispatch to all 15 useCallback/useEffect
dep arrays; useGlobalSearch.ts — removed unused imports, stabilised callback,
fixed non-null assertions and missing deps

#17 T-FIX-5b ESLint guardrail added to eslint.config.js; guards added before
forEach+expect loops in commercial-intelligence.test.ts; baselines updated
to grandfather existing violations in magic-up tests

Baselines: .tsc-baseline.json (1065 errors frozen), .eslint-baseline.json (405)
@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

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

Project Deployment Actions Updated (UTC)
we-dream-big Error Error May 24, 2026 3:12pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Warning

Review limit reached

@adm01-debug, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 28 minutes and 56 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

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

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ed843aaf-05de-4901-8449-aeccde2204cc

📥 Commits

Reviewing files that changed from the base of the PR and between 5ab4358 and 5672c70.

📒 Files selected for processing (5)
  • eslint.config.js
  • src/components/catalog/CatalogContent.tsx
  • tests/components/intelligence/commercial-intelligence.test.ts
  • tests/components/magic-up-onda5.test.tsx
  • tests/components/magic-up-result-panel-keyboard.test.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/dreamy-tesla-PtPVV

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

@supabase
Copy link
Copy Markdown

supabase Bot commented May 23, 2026

This pull request has been ignored for the connected project doufsxqlfjyuvxuezpln because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

- magic-up-result-panel-keyboard.test.tsx: 64 violations fixed
  - getDots()/getThumbs() forEach (getAllByRole throws on empty): eslint-disable-next-line
  - Literal arrays [prev,next], [0,1,2]: eslint-disable-next-line
  - calls/elements/observedIndices: expect(var).not.toHaveLength(0) guards added
  - REQUIRED_*_CLASSES consts: eslint-disable-next-line
  - ids/thumbNames/liveRegions: guards added

- magic-up-onda5.test.tsx: 29 violations fixed
  - required/select.allCards/allMarcar/literal arrays: eslint-disable-next-line
  - cards/listitems/winnerButtons/buttons/tabIndices: guards added
  - REQUIRED_FOCUS_CLASSES const: eslint-disable-next-line

ESLint baseline updated: 405 → 401 errors (positive drift on all T-FIX-5b work)
@adm01-debug adm01-debug marked this pull request as ready for review May 23, 2026 20:54
Copilot AI review requested due to automatic review settings May 23, 2026 20:54
@adm01-debug adm01-debug review requested due to automatic review settings May 23, 2026 20:54
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 17 files

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/lib/personalization/adapters/price-response.adapter.ts">

<violation number="1" location="src/lib/personalization/adapters/price-response.adapter.ts:96">
P2: The numeric coercion helper incorrectly uses `|| fallback`, causing valid `0` values to be replaced by the fallback (e.g., `num(..., 1)` turns `0` into `1`).</violation>
</file>

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

return typeof v === 'string' ? v : fallback;
}
function num(v: unknown, fallback = 0): number {
return typeof v === 'number' ? v : Number(v) || fallback;
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.

P2: The numeric coercion helper incorrectly uses || fallback, causing valid 0 values to be replaced by the fallback (e.g., num(..., 1) turns 0 into 1).

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/personalization/adapters/price-response.adapter.ts, line 96:

<comment>The numeric coercion helper incorrectly uses `|| fallback`, causing valid `0` values to be replaced by the fallback (e.g., `num(..., 1)` turns `0` into `1`).</comment>

<file context>
@@ -76,77 +86,118 @@ function normalizeV7Aliases(resp: Record<string, unknown>): Record<string, unkno
+  return typeof v === 'string' ? v : fallback;
+}
+function num(v: unknown, fallback = 0): number {
+  return typeof v === 'number' ? v : Number(v) || fallback;
+}
+function bool(v: unknown, fallback = false): boolean {
</file context>
Suggested change
return typeof v === 'number' ? v : Number(v) || fallback;
const parsed = typeof v === 'number' ? v : Number(v);
return Number.isNaN(parsed) ? fallback : parsed;

Comment thread src/components/compare/CompareTableView.tsx Outdated
…y in place)

All 14 remaining forEach+expect violations suppressed with
// eslint-disable-next-line no-restricted-syntax after the existing
expect(array).not.toHaveLength(0) guards. Arrays are provably non-empty
static constants (PERIOD_OPTIONS=9, MOCK_TRENDING=4, MOCK_OPPORTUNITIES=4)
or deterministic generators (generateDateMap(30), generateMockMarketData(360)).

Pattern applied consistently with magic-up test fixes from previous commit:
- Guard documents intent (catches accidental empty-array mutation)
- Disable comment acknowledges guard is in place and suppresses the lint rule

Result: 0 T-FIX-5b errors in all 3 test files. T-FIX-5b work fully complete.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR batches a set of TypeScript and ESLint baseline fixes across multiple UI/admin areas, and introduces an ESLint guardrail intended to prevent false-green tests caused by forEach(() => expect(...)) patterns.

Changes:

  • Tightens typing / removes TS errors in pricing adapter, admin product form, supplier tabs, compare UI, and simulator/search hooks.
  • Cleans unused imports/vars and replaces non-null assertions / missing hook deps in several components.
  • Adds an ESLint no-restricted-syntax rule to flag forEach with expect() in tests, and updates/guards affected tests + regenerates lint/tsc baselines.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/lib/personalization/adapters/price-response.adapter.ts Adds typed helper accessors to parse mixed-shape RPC payloads.
src/pages/admin/AdminProductFormPage.tsx Fixes TS issues and refactors loading/header/content rendering structure.
src/lib/external-db/product-types.ts Expands PromobrindProduct shape and improves fallback select error detection formatting.
src/components/admin/products/new-supplier/tabs/AddressTab.tsx Replaces untyped form prop with a typed interface and tightens carrier result typing.
src/components/admin/products/new-supplier/tabs/BasicDataTab.tsx Introduces typed form interface and normalizes JSX/formatting.
src/components/compare/CompareTableView.tsx Switches to UI Product type (product-catalog) and adjusts comparisons/rendering accordingly.
src/components/admin/connections/SupabaseConnectionsTab.tsx Removes non-null assertions and normalizes derived secret/env key variables.
src/components/catalog/CatalogContent.tsx Removes unused imports/props and tidies rendering branches.
src/components/products/ProductQuickView.tsx Removes unused imports/dead paths; streamlines quick view state and rendering.
src/hooks/simulator/useSimulatorWizard.ts Fixes exhaustive-deps issues and normalizes formatting/handlers.
src/components/search/useGlobalSearch.ts Removes unused imports, stabilizes some callbacks, and fixes missing deps/non-null assertions.
tests/components/intelligence/commercial-intelligence.test.ts Adds non-empty guards before forEach assertions per new lint guardrail.
tests/components/magic-up-onda5.test.tsx Adds guard/disable annotations for the new forEach+expect lint rule.
tests/components/magic-up-result-panel-keyboard.test.tsx Adds guards/disable annotations for the new forEach+expect lint rule.
eslint.config.js Adds no-restricted-syntax selector to flag forEach containing expect() in tests.
.tsc-baseline.json Regenerates the frozen TS error baseline.
.eslint-baseline.json Regenerates the frozen ESLint error baseline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +95 to +100
function num(v: unknown, fallback = 0): number {
return typeof v === 'number' ? v : Number(v) || fallback;
}
function bool(v: unknown, fallback = false): boolean {
return typeof v === 'boolean' ? v : fallback;
}
Comment on lines 764 to +771
}
},
[commands],
);

if (controller.signal.aborted) return;

// ── Re-rank text-rich entities via pg_trgm RPC ──
const RERANK_TYPES: SearchResultType[] = ["quote", "conversation", "reminder"];
const candidates = allResults
.filter(r => RERANK_TYPES.includes(r.type))
.map(r => ({ id: r.id, label: r.title, sublabel: r.subtitle ?? "" }));

let finalResults = allResults;
if (candidates.length > 1) {
try {
const { data: ranked } = await supabase.rpc("search_records_rerank", {
_query: searchQuery,
_candidates: candidates,
});
if (ranked && Array.isArray(ranked) && ranked.length > 0) {
const scoreMap = new Map<string, number>();
(ranked as Array<{ id: string; score: number }>).forEach(r => scoreMap.set(r.id, r.score));
// Reorder only the rerank-eligible results, keep others in original order
const others = allResults.filter(r => !RERANK_TYPES.includes(r.type));
const reranked = allResults
.filter(r => RERANK_TYPES.includes(r.type))
.sort((a, b) => (scoreMap.get(b.id) ?? 0) - (scoreMap.get(a.id) ?? 0));
finalResults = [...others, ...reranked];
}
} catch { /* silent rerank failure */ }
useEffect(() => {
performSemanticSearch(debouncedQuery);
}, [debouncedQuery, performSemanticSearch]);
Comment on lines +326 to +330
render={(p) => (
<div className="flex items-center justify-center gap-1.5">
<ShieldCheck className="h-3.5 w-3.5 text-success" />
<span>{p.supplier.name}</span>
</div>
Comment on lines +575 to 578
expect(thumbNames).not.toHaveLength(0);
thumbNames.forEach((name) => {
expect(dotNames).not.toContain(name);
});
Comment on lines +82 to 85
// eslint-disable-next-line no-restricted-syntax
required.forEach((cls) => {
expect(el.className).toContain(cls);
});
@adm01-debug adm01-debug merged commit a4832fc into main May 24, 2026
18 of 26 checks passed
@adm01-debug adm01-debug deleted the claude/dreamy-tesla-PtPVV branch May 24, 2026 15:29
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.

3 participants