This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A React library (@42.nl/final-form-field-validation) that wraps react-final-form's Field component to add combined sync + async validation with debouncing. The entire library is a single component in src/Field.tsx exported through src/index.ts.
- Run all checks:
npm test(lint + typecheck + tests with coverage) - Run tests only:
npm run test:coverage - Watch mode:
npm start(vitest --coverage, watch is default) - Lint:
npm run lint - Typecheck:
npm run test:ts - Build:
npm run tsc(outputs tolib/) - Release:
npm run release(build + np)
The library exports one component: Field<FieldValue, T> which extends react-final-form's FieldProps with three additional props:
validators— sync validators run firstasyncValidators— only run when all sync validators passasyncValidatorsDebounce— debounce delay (default 200ms), cancels previous pending async validation via a ref-based promise resolver pattern
- Tests live in
tests/(not co-located with source) - Uses Vitest with jsdom, React Testing Library
- 100% coverage thresholds on branches, functions, lines, and statements — all new code must be fully covered
tests/setupTests.tsrunsclearAllMocks/resetAllMocksbefore each test- Async validation tests use
vi.useFakeTimers()and manual timer advancement
- ESLint flat config with typescript-eslint, react, vitest, and prettier plugins
- Prettier runs on commit via husky + lint-staged
- Zero ESLint warnings allowed (
--max-warnings=0)