Conversation
Safe, no-behavior-change fixes across the monorepo: - Remove 75+ unused imports, variables, and type declarations - Fix no-undef errors by adding eslint-env node to Node.js scripts - Fix react/no-unescaped-entities by escaping apostrophes in JSX - Remove unused catch parameters - Add missing displayName to forwardRef components - Fix missing key props in iterators - Replace empty interfaces with type aliases Packages affected: - @wcpos/core: 82 → 36 problems - @wcpos/components: 43 → 25 problems - @wcpos/web-bundle: 2 → 2 problems (all fixed, remaining are no-undef) - @wcpos/main: 4 → 2 problems - @wcpos/utils: 4 → 3 problems Total reduction: 213 → 138 problems (~35% reduction)
Fixes for hooks dependency issues: - Add eslint-disable comments for intentional patterns (cache busters, identity keys) - Remove unnecessary dependencies where safe - Add txInstance to translations context dependencies - Fix stable ref patterns in collapsible primitives - Remove unused type declarations and imports from query hooks Query hooks cleaned: - categories.tsx, customers.tsx, orders.tsx, products.ts - tags.tsx, tax-rates.tsx, variations.ts Packages affected: - @wcpos/query: 33 → 15 problems - @wcpos/components: Added eslint-disable for intentional patterns Total reduction: 138 → 116 problems
📝 WalkthroughWalkthroughComprehensive cleanup across the monorepo removing unused imports, type declarations, and dependencies. The changes consolidate import statements, add ESLint suppressions for intentional dependency patterns, add display names to components for debugging, escape HTML entities in user-facing text, and remove unused type definitions from query hooks. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
packages/components/src/format-number/format-number.tsx (1)
132-139: Pre-existing bug:indexis undefined.The
getMaskAtIndexfunction referencesindexon line 138, but this variable is never defined. The function is called withgetMaskAtIndex(hashCount)on line 150, but the function signature doesn't accept any parameters.🐛 Proposed fix
- const getMaskAtIndex = React.useCallback(() => { + const getMaskAtIndex = React.useCallback((index: number) => { const { mask = ' ' } = props; if (typeof mask === 'string') { return mask; } return mask[index] || ' '; - }, [props]); + }, [props.mask]);Note: Also narrowed the dependency to
props.masksince that's the only property used.packages/core/src/screens/main/pos/cart/table.tsx (1)
208-210: Replaceconsole.logand tighten theanytype.
Use the logger and avoidanyhere.✅ Proposed fix
import { useObservableEagerState } from 'observable-hooks'; +import log from '@wcpos/utils/logger'; import { ErrorBoundary } from '@wcpos/components/error-boundary'; import { getFlexAlign } from '@wcpos/components/lib/utils'; @@ meta: { - onChange: (data: any) => { - console.log('onChange called without handler', data); + onChange: (data: unknown) => { + log.warn('onChange called without handler', data); },As per coding guidelines, use the logger library exclusively for logging and do not use the
anytype.packages/components/src/numpad/index.tsx (1)
45-56: Improve comment clarity on mount-only effect intent.The useEffect correctly runs only on mount (empty deps), and subsequent selection updates are properly handled by event handlers in
handleButtonPress. The current eslint comment should explicitly clarify that ignoring value changes after mount is intentional:✏️ Suggested improvement
- // eslint-disable-next-line react-hooks/exhaustive-deps -- Intentionally empty - run once on mount + // eslint-disable-next-line react-hooks/exhaustive-deps -- Mount-only focus/selection; ignore later value updates intentionally []This aligns with the coding guideline: "Before using useEffect, verify if the logic can be... If used, add a comment explaining WHY it is necessary." The enhanced comment makes explicit that value changes after mount are intentionally not re-triggering the effect, since selection is managed by event handlers instead.
🧹 Nitpick comments (6)
packages/components/src/format/list.tsx (1)
12-16: Prefer a stable key over array index (Line 14).Using the array index can cause state/DOM mismatches when items are inserted/reordered. If items are strings, prefer a stable key derived from the content (and include the index only as a fallback for duplicates).
♻️ Suggested tweak
- return <Text key={index}>{item}, </Text>; + return <Text key={`${item}-${index}`}>{item}, </Text>;packages/components/src/label/index.tsx (1)
8-10: Import ordering: external dependency import should come before internal import.Per coding guidelines, import order should be: React first → external dependencies →
@wcpos/*internal imports. The@rn-primitives/typesimport (external) is placed after the internal../lib/utilsimport.♻️ Suggested fix for import ordering
import * as LabelPrimitive from '@rn-primitives/label'; import * as Slot from '@rn-primitives/slot'; +import type { SlottablePressableProps } from '@rn-primitives/types'; import { cn } from '../lib/utils'; - -import type { SlottablePressableProps } from '@rn-primitives/types';packages/components/src/format-number/format-number.tsx (1)
186-188: Consider adding explicit type annotation.The
valparameter has an implicitanytype. Per coding guidelines, explicit types should be used instead ofany.♻️ Suggested fix
- const formatInput = React.useCallback((val) => { + const formatInput = React.useCallback((val: string) => { return val; }, []);packages/components/src/data-table/index.web.tsx (1)
87-89: Replaceconsole.logwith the logger library.As per coding guidelines, use
@wcpos/utils/loggerinstead ofconsole.logfor logging.♻️ Proposed fix
Add the import at the top of the file:
import { getLogger } from '@wcpos/utils/logger'; const logger = getLogger(['wcpos', 'components', 'DataTable']);Then replace the console.log:
meta: { expanded$, expandedRef, onChange: (data: any) => { - console.log('onChange called without handler', data); + logger.warn('onChange called without handler', { context: { data } }); }, ...tableMeta, },packages/core/src/screens/main/components/customer-select.tsx (2)
76-81: Consider expanding the useEffect comment to explain WHY.The cleanup effect is a valid use case, but per coding guidelines, the comment should explain WHY it's necessary, not just WHAT it does. For example: "Clear the search when unmounting to prevent stale search state from persisting in the query when the component remounts."
100-100: Avoid usinganytype for thequeryparameter.The
query: anyviolates the coding guideline to not useanytype. Use the return type fromuseQueryor define a proper interface for the query object.♻️ Suggested fix
-export function CustomerList({ query, withGuest }: { query: any; withGuest: boolean }) { +export function CustomerList({ query, withGuest }: { query: ReturnType<typeof useQuery>; withGuest: boolean }) {Alternatively, if
useQueryexports a specific type, import and use that instead.As per coding guidelines: "Do not use 'any' type; use strict types and generics instead"
Summary by CodeRabbit
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.