-
-
Notifications
You must be signed in to change notification settings - Fork 32
Fix no-leaked-event-listener false positive when using React NativeBackHandler, closes #1323
#1336
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
Conversation
… `BackHandler`, closes #1323
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
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
isInitializedFromSourceutility function - Added React Native detection to skip false positives in
no-leaked-event-listenerrule - 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.
packages/plugins/eslint-plugin-react-web-api/src/rules/no-leaked-event-listener.spec.ts
Outdated
Show resolved
Hide resolved
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>
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___)Other information