chore: Add typescript check for form component library#18899
chore: Add typescript check for form component library#18899phlipsterit wants to merge 11 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughForm component modules remove default React imports or switch to named imports; Button mapping now returns {data-color, className} with a local success class; Card typing aligns to design-system ChangesForm component library updates
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx (1)
26-29:⚠️ Potential issue | 🟠 Major | ⚡ Quick winThe mock function is overridden and never called.
The
onValueChange: fn()mock added to the story args (line 39) is immediately overridden by the explicitonValueChange={setValue}prop in the Wrapper component (line 28). This means the mock function will never be invoked, defeating the purpose of adding it for interaction tracking in Storybook.Consider one of these solutions:
Option 1: Remove the override and rely on args:
📝 Remove explicit onValueChange override
const Wrapper = (args: React.ComponentProps<typeof DatePickerControl>) => { const [value, setValue] = useState(args.value); - return <DatePickerControl {...args} value={value} onValueChange={setValue} />; + return <DatePickerControl {...args} value={value} onValueChange={(val) => { + setValue(val); + args.onValueChange?.(val); + }} />; };Option 2: Call both handlers:
This ensures local state updates whilst also invoking the mock for Storybook's Actions addon.Also applies to: 39-39
🤖 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 `@libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx` around lines 26 - 29, The Wrapper currently overrides the storybook mock onValueChange (fn()) by passing onValueChange={setValue} so the mock is never called; fix by either removing the explicit override (let DatePickerControl receive value and onValueChange from args and use args.value as initial state) or change the handler in Wrapper to a composed function that calls setValue(newVal) and then calls args.onValueChange?.(newVal) (reference Wrapper, DatePickerControl, setValue, args.onValueChange, fn()) so the mock/action is invoked while still updating local state.
🤖 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.
Outside diff comments:
In `@libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx`:
- Around line 26-29: The Wrapper currently overrides the storybook mock
onValueChange (fn()) by passing onValueChange={setValue} so the mock is never
called; fix by either removing the explicit override (let DatePickerControl
receive value and onValueChange from args and use args.value as initial state)
or change the handler in Wrapper to a composed function that calls
setValue(newVal) and then calls args.onValueChange?.(newVal) (reference Wrapper,
DatePickerControl, setValue, args.onValueChange, fn()) so the mock/action is
invoked while still updating local state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: db35f921-a111-477d-adbc-c1d0d9a59e1d
📒 Files selected for processing (7)
libs/form-component/src/app-components/Button/Button.tsxlibs/form-component/src/app-components/Datepicker/DatePickerCalendar.tsxlibs/form-component/src/app-components/Datepicker/Datepicker.stories.tsxlibs/form-component/src/app-components/Datepicker/DatepickerDialog.tsxlibs/form-component/src/app-components/Input/FormattedInput.tsxlibs/form-component/src/app-components/Input/NumericInput.tsxlibs/form-component/src/app-components/Spinner/Spinner.tsx
💤 Files with no reviewable changes (4)
- libs/form-component/src/app-components/Input/NumericInput.tsx
- libs/form-component/src/app-components/Datepicker/DatePickerCalendar.tsx
- libs/form-component/src/app-components/Input/FormattedInput.tsx
- libs/form-component/src/app-components/Spinner/Spinner.tsx
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@libs/form-component/src/app-components/Button/Button.tsx`:
- Line 63: The explicit type assertion on data-color is bypassing TypeScript
safety: locate the usage of mapColorNames in Button.tsx and remove the cast to
DesignSystemButtonProps['data-color']; then either (A) if 'success' is an
allowed design-system token, add 'success' to the DesignSystemButtonProps
type/union so mapColorNames returns a valid value, or (B) if 'success' is not
supported, stop asserting the return type and handle 'success' separately (e.g.
filter/translate it to a supported token or apply the manual CSS override
mentioned in the comment) so only valid values are passed to the design-system
data-color prop.
In `@libs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx`:
- Line 28: Rename the misspelled function handleVAlueChange to handleValueChange
everywhere it's defined and referenced in the Datepicker stories; update the
function declaration and any event handlers or props that call handleVAlueChange
to use handleValueChange so identifiers stay consistent.
🪄 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
Run ID: 1aab7886-009f-4316-9960-396e46b19146
📒 Files selected for processing (4)
.github/workflows/libs-form-component-unit-tests.ymllibs/form-component/src/app-components/Button/Button.tsxlibs/form-component/src/app-components/Card/Card.tsxlibs/form-component/src/app-components/Datepicker/Datepicker.stories.tsx
✅ Files skipped from review due to trivial changes (1)
- libs/form-component/src/app-components/Card/Card.tsx
framitdavid
left a comment
There was a problem hiding this comment.
Nå snakket vi om denne på forhånd, men tok review likevel og synes dette ble pent. 🥇Godt jobbet. 💪
Fixes such that "yarn typecheck" runs without error in libs/form-component and also runs this in form-component CI action
Description
Verification
Summary by CodeRabbit
Bug Fixes
Refactoring
Documentation
Chores