Skip to content

Conversation

@Rel1cx
Copy link
Owner

@Rel1cx Rel1cx commented Dec 3, 2025

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

@vercel
Copy link

vercel bot commented Dec 3, 2025

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

Project Deployment Preview Comments Updated (UTC)
eslint-react Ready Ready Preview Comment Dec 3, 2025 8:24am

Copy link
Contributor

Copilot AI left a comment

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 a false positive in the no-leaked-event-listener rule when using React Native's BackHandler.addEventListener API. The fix involves extracting common logic from isInitializedFromReact into a new generic utility function isInitializedFromSource, which can check if an identifier is initialized from any source package.

  • Refactored source-checking logic into a reusable isInitializedFromSource utility function
  • Added React Native detection to skip false positives in no-leaked-event-listener rule
  • Updated public API documentation for isInitializedFromReact

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-event-listener.ts Added check to skip React Native addEventListener calls to prevent false positives
packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-event-listener.spec.ts Added test case verifying React Native BackHandler.addEventListener is allowed
packages/core/src/utils/is-from-source.ts New generic utility function to check if an identifier is initialized from any source package
packages/core/src/utils/is-from-react.ts Refactored to use the new isInitializedFromSource utility, maintaining the React-specific name check
packages/core/src/utils/index.ts Exported the new isInitializedFromSource utility
packages/core/docs/functions/isInitializedFromReact.md Added public API documentation for isInitializedFromReact function
packages/core/docs/README.md Added reference to isInitializedFromReact documentation

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

Rel1cx and others added 2 commits December 3, 2025 16:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: REL1CX <rel1cx@proton.me>
…ed-event-listener.spec.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: REL1CX <rel1cx@proton.me>
@Rel1cx Rel1cx merged commit 821509b into main Dec 3, 2025
10 of 11 checks passed
@Rel1cx Rel1cx deleted the no-leaked-event-listener-2 branch December 3, 2025 08:19
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