Fix operator precedence and unused variable lint errors in App.tsx#1
Fix operator precedence and unused variable lint errors in App.tsx#1
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: Achbelsdn <191762831+Achbelsdn@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes two lint/static analysis errors in src/App.tsx: one requiring explicit operator precedence for mixed ??/|| operators, and one for an unused variable declaration.
Changes:
- Added parentheses to clarify operator precedence in the
custom_goalexpression when invoking the 'associate' function - Renamed unused
categoriesvariable to_categoriesto suppress the unused variable lint error
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| activeTemplate: MarketTemplate | null; | ||
| }) { | ||
| const categories = [...new Set(templates.map(t => t.category))]; | ||
| const _categories = [...new Set(templates.map(t => t.category))]; |
There was a problem hiding this comment.
The variable _categories is computed but never used. While prefixing with underscore suppresses the lint error, consider whether this computation is needed at all. If it was intended for future use (e.g., filtering or displaying categories), it should either be implemented or removed entirely to avoid unnecessary computation on every render of the MarketTab component.
If this variable is truly not needed, delete the line entirely rather than keeping dead code.
| const _categories = [...new Set(templates.map(t => t.category))]; |
| try { | ||
| const { data, error: fnErr } = await sb.functions.invoke('associate', { | ||
| body: { repo_ids: sel, custom_goal: goalOverride ?? assocGoal || undefined }, | ||
| body: { repo_ids: sel, custom_goal: (goalOverride ?? assocGoal) || undefined }, |
There was a problem hiding this comment.
The expression (goalOverride ?? assocGoal) || undefined will convert empty strings to undefined. This means if both goalOverride and assocGoal are empty strings, or if goalOverride is not provided and assocGoal is an empty string, the custom_goal will be undefined.
Verify this is the intended behavior. If empty strings should be preserved and sent to the API, use goalOverride ?? assocGoal instead. If empty values should be filtered out, the current implementation is correct.
| body: { repo_ids: sel, custom_goal: (goalOverride ?? assocGoal) || undefined }, | |
| body: { repo_ids: sel, custom_goal: goalOverride ?? assocGoal }, |
Two static analysis errors in
src/App.tsx: mixed??/||without explicit precedence grouping, and a declared-but-never-used variable.Changes
Line 261 – operator precedence: Wrap the
??expression in parentheses so||applies to the result, not just the right operand of??Line 607 – unused variable: Rename
categories→_categoriesto signal intentional non-use and suppress the lint errorOriginal prompt
This pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.