Skip to content

docs: clarify skipping pristine calculations#66

Open
erikras-richard-agent wants to merge 1 commit into
masterfrom
fix/oss-110-update-on-pristine-docs
Open

docs: clarify skipping pristine calculations#66
erikras-richard-agent wants to merge 1 commit into
masterfrom
fix/oss-110-update-on-pristine-docs

Conversation

@erikras-richard-agent

@erikras-richard-agent erikras-richard-agent commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • document updateOnPristine: false for avoiding initial calculations with initialValues
  • add regression coverage for function-style updates with updateOnPristine: false
  • refresh stale README type entries for calculation/update types

Test Plan

  • yarn test

Refs #26

Summary by CodeRabbit

  • Documentation
    • Expanded API documentation with comprehensive type definitions for Calculation, FieldName, FieldPattern, and Updates variants
    • Added detailed examples demonstrating updateOnPristine behavior and parameter signatures for calculations

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR documents and tests the updateOnPristine feature in the Calculation API. The README is expanded with type definitions (Calculation, FieldName, FieldPattern, Updates, UpdatesByName, UpdatesForAll) and an example showing updateOnPristine behavior. A new test verifies that when updateOnPristine is false, an updates function is not invoked on initial render but is invoked after field changes.

Changes

Documentation and Testing of updateOnPristine Feature

Layer / File(s) Summary
API Documentation
README.md
Type definitions added to TOC: Calculation, FieldName, FieldPattern, Updates, UpdatesByName, UpdatesForAll. New Calculation type section documents optional isEqual and updateOnPristine flags with a usage example.
Test Implementation
src/decorator.test.ts
New test validates that when updateOnPristine is false, the updates function is not called on initial render but is called after a field value change with correct arguments (value, field, newAllValues, prevAllValues).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • erikras

Poem

🐰 The form now knows when pristine fields should wake,
New docs and tests make features crystal-clear,
With updateOnPristine leading the way,
No calculations bloom on the first appear! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs: clarify skipping pristine calculations' clearly refers to the main change of the PR, which is documenting the updateOnPristine feature in the README to help users understand how to skip calculations during pristine form states.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/oss-110-update-on-pristine-docs

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@README.md`:
- Line 108: Update the README TOC entry for FieldPattern so the displayed type
matches the documented signature by including the array suffix; change the link
text that currently shows `(FieldName | RegExp)` to `(FieldName | RegExp)[]`
(the entry refers to FieldPattern and the anchor
`#fieldpattern-fieldname--regexp--fieldname--regexp`), ensuring the visible TOC
label and linked heading are consistent with the documented `(FieldName |
RegExp)[]` type in the body.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 03c81510-f383-4e28-b97d-2f7af96ae13a

📥 Commits

Reviewing files that changed from the base of the PR and between f803ce5 and fcf3939.

📒 Files selected for processing (2)
  • README.md
  • src/decorator.test.ts

Comment thread README.md
- [`FieldName: string`](#fieldname-string)
- [`FieldPattern: FieldName | RegExp`](#fieldpattern-fieldname--regexp)
- [`Updates: { [FieldName]: (value: any, allValues: Object, prevValues: Object) => any }`](#updates--fieldname-value-any-allvalues-object--any-)
- [`FieldPattern: FieldName | RegExp | (FieldName | RegExp)[]`](#fieldpattern-fieldname--regexp--fieldname--regexp)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix FieldPattern TOC signature mismatch.

Line 108 drops the array suffix in the displayed type ((FieldName | RegExp)), but Line 151 correctly documents (FieldName | RegExp)[]. Please align the TOC entry to avoid misleading API docs.

Suggested doc fix
-  - [`FieldPattern: FieldName | RegExp | (FieldName | RegExp)`](`#fieldpattern-fieldname--regexp--fieldname--regexp`)
+  - [`FieldPattern: FieldName | RegExp | (FieldName | RegExp)[]`](`#fieldpattern-fieldname--regexp--fieldname--regexp`)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- [`FieldPattern: FieldName | RegExp | (FieldName | RegExp)[]`](#fieldpattern-fieldname--regexp--fieldname--regexp)
- [`FieldPattern: FieldName | RegExp | (FieldName | RegExp)[]`](`#fieldpattern-fieldname--regexp--fieldname--regexp`)
🤖 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 `@README.md` at line 108, Update the README TOC entry for FieldPattern so the
displayed type matches the documented signature by including the array suffix;
change the link text that currently shows `(FieldName | RegExp)` to `(FieldName
| RegExp)[]` (the entry refers to FieldPattern and the anchor
`#fieldpattern-fieldname--regexp--fieldname--regexp`), ensuring the visible TOC
label and linked heading are consistent with the documented `(FieldName |
RegExp)[]` type in the body.

@erikras-richard-agent

Copy link
Copy Markdown
Contributor Author

The FieldPattern TOC entry already matches the documented signature now: FieldName | RegExp | (FieldName | RegExp)[].

Validation: yarn jest --runInBand; nps lint; nps typescript; nps build.

@erikras-richard-agent

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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