Skip to content

Fix no-unnecessary-key false positives on render function - #1402

Merged
Rel1cx merged 1 commit into
mainfrom
no-unnecessary-key-3
Jan 14, 2026
Merged

Fix no-unnecessary-key false positives on render function#1402
Rel1cx merged 1 commit into
mainfrom
no-unnecessary-key-3

Conversation

@Rel1cx

@Rel1cx Rel1cx commented Jan 14, 2026

Copy link
Copy Markdown
Owner

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • Test
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • I have added a convincing reason for adding this feature, if necessary

Other information

@Rel1cx
Rel1cx requested a review from Copilot January 14, 2026 15:22
@vercel

vercel Bot commented Jan 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
eslint-react Building Building Preview, Comment Jan 14, 2026 3:22pm

@Rel1cx
Rel1cx merged commit 21ae7db into main Jan 14, 2026
12 of 13 checks passed
@Rel1cx
Rel1cx deleted the no-unnecessary-key-3 branch January 14, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes false positives in the no-unnecessary-key rule by improving detection of render functions and correcting a critical logic bug in array method callback detection.

Changes:

  • Fixed critical logic error in isArrayMethodCallback that changed OR to AND operator, correcting the array method detection
  • Added early-exit check to skip unnecessary key validation inside render functions, preventing false positives in render prop scenarios
  • Refactored isRenderFunctionLoose to use naming-based detection (functions/props starting with "render") instead of JSX content analysis

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/plugins/eslint-plugin-react-x/src/rules/no-unnecessary-key.ts Added render function check to skip key validation and fixed logical operator bug in isArrayMethodCallback
packages/plugins/eslint-plugin-react-x/src/rules/no-unnecessary-key.spec.ts Removed test cases for false positives that are now fixed, added FIXME comment for remaining edge case
packages/core/src/component/component-render-prop.ts Refactored isRenderFunctionLoose to accept any Node type and use naming-based detection, removed unused JSX detection imports
packages/core/docs/functions/isRenderFunctionLoose.md Updated documentation to reflect new function signature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants