-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix react-hooks/exhaustive-deps error on useSheetValue.ts #4278
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
👋 Hi! It looks like this PR has not had any changes for a week now. Would you like someone to review this PR? If so - please remove the "[WIP]" prefix from the PR title. That will let the community know that this PR is open for a review. |
1e1abc9
to
f5bf202
Compare
f5bf202
to
5946ade
Compare
value?: Spreadsheets[SheetName][SheetFieldName] | undefined; | ||
query?: Query | undefined; | ||
}; | ||
|
||
export type Binding< | ||
SheetName extends SheetNames, | ||
SheetFieldName extends SheetFields<SheetName>, | ||
> = | ||
| SheetFieldName | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be same as BindingObject
but TypeScript complains when I union it with BindingObject
vs. delaring it as an object.
WalkthroughThe changes adjust the ESLint configuration and TypeScript type definitions across various spreadsheet-related files. The ESLint configuration is modified by removing specific file overrides for the Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (8)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/desktop-client/src/components/spreadsheet/useSheetValue.ts (1)
93-130
: Consider adding error handling for invalid queries.While the memoization logic is solid, consider adding error handling for invalid query serialization to prevent runtime errors.
const serializedBindingQuery = - typeof key === 'string' ? undefined : key.query?.serializeAsString(); + typeof key === 'string' ? undefined : (() => { + try { + return key.query?.serializeAsString(); + } catch (error) { + console.warn('Failed to serialize query:', error); + return undefined; + } + })();packages/loot-core/src/client/SpreadsheetProvider.tsx (2)
29-29
: Consider adding JSDoc documentation.While the simplified
Binding
type is good, consider adding JSDoc documentation to explain its usage and relationship with the TODO comment above.// TODO: Make this generic and replace the Binding type in the desktop-client package. +/** + * Represents a binding between a spreadsheet cell and its observer. + * @typedef {string | { name: string; query?: Query | undefined }} Binding + */ type Binding = string | { name: string; query?: Query | undefined };
93-93
: Consider using type narrowing for better type safety.The binding transformation could benefit from explicit type narrowing.
- binding = typeof binding === 'string' ? { name: binding } : binding; + const bindingObj: { name: string; query?: Query | undefined } = + typeof binding === 'string' ? { name: binding } : binding;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
upcoming-release-notes/4278.md
is excluded by!**/*.md
📒 Files selected for processing (4)
eslint.config.mjs
(0 hunks)packages/desktop-client/src/components/spreadsheet/index.ts
(1 hunks)packages/desktop-client/src/components/spreadsheet/useSheetValue.ts
(5 hunks)packages/loot-core/src/client/SpreadsheetProvider.tsx
(2 hunks)
💤 Files with no reviewable changes (1)
- eslint.config.mjs
🔇 Additional comments (4)
packages/desktop-client/src/components/spreadsheet/index.ts (2)
92-99
: Well-structured type definition for BindingObject!The new generic type
BindingObject
is well-designed with proper type constraints and explicit optional properties.
108-109
: Good type clarity improvements!Making
undefined
explicit in theBinding
type improves type safety and clarity.packages/desktop-client/src/components/spreadsheet/useSheetValue.ts (2)
32-38
: Good refactor to improve memoization!The use of
useMemoizedBinding
improves the hook's dependency tracking and memoization strategy.
78-78
: Clean dependency array fix!The simplified dependency array
[spreadsheet, sheetName, memoizedBinding]
correctly includes all required dependencies, fixing the react-hooks/exhaustive-deps warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Fix some suppressed react-hooks/exhaustive-deps ESLint errors