-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[NEW]: ensure-matching-remove-event-listener #3442
base: master
Are you sure you want to change the base?
[NEW]: ensure-matching-remove-event-listener #3442
Conversation
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.
I'm a bit confused how why this needs a full lint rule - manually adding event listeners should be exceedingly rare, as the proper approach is generally to add them as jsx props. Obviously window
is a special case, but generally one puts this inside a single component managed by domain experts, and everyone else just uses the component.
Hi, appreciate the review! |
That totally makes sense - but it seems like one way to solve that is to force usage of a sanctioned custom component and ban via eslint any usage of |
That's also an idea, but would be a vastly more complex rule than this, i think. This one is relatively simple and straightforward, and doesn't require any particular setup on part of the developers. |
Hi, @ljharb, i'm not really sure why the CI is failing. What should i do? |
The documentation checker seems to be erroring; there's a generation script to run. |
Codecov Report
@@ Coverage Diff @@
## master #3442 +/- ##
=======================================
Coverage 97.57% 97.58%
=======================================
Files 129 130 +1
Lines 9200 9259 +59
Branches 3336 3372 +36
=======================================
+ Hits 8977 9035 +58
- Misses 223 224 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
59af733
to
865ed16
Compare
41a970a
to
4115a19
Compare
|
||
## When Not To Use It | ||
|
||
You don't need this rules if you want to allow developers to not remove eventListeners added in the DOM. |
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.
what about element.addEventListener
, added with a ref?
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.
I'm not sure what you mean, can you expand?
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.
I mean that addEventListener
isn't just on window, it's also on every DOM element, and the same reasoning you've used for "window" would apply to element-based listeners as well.
069314a
to
181c68f
Compare
author AndreaPontrandolfo <[email protected]> 1664217948 +0200 committer AndreaPontrandolfo <[email protected]> 1668295550 +0100 parent 865ed16 author AndreaPontrandolfo <[email protected]> 1664217948 +0200 committer AndreaPontrandolfo <[email protected]> 1668295511 +0100 parent 865ed16 author AndreaPontrandolfo <[email protected]> 1664217948 +0200 committer AndreaPontrandolfo <[email protected]> 1668295439 +0100 parent 865ed16 author AndreaPontrandolfo <[email protected]> 1664217948 +0200 committer AndreaPontrandolfo <[email protected]> 1668293705 +0100 parent 865ed16 author AndreaPontrandolfo <[email protected]> 1664217948 +0200 committer AndreaPontrandolfo <[email protected]> 1668293608 +0100 parent 865ed16 author AndreaPontrandolfo <[email protected]> 1664217948 +0200 committer AndreaPontrandolfo <[email protected]> 1668293412 +0100 feat: added rule ensure-matching-remove-event-listener fix: fixed docs whitespaces fix: removed a whitespace from the docs fix: added a tab spacing to the docs file fix: added a single traling newline to the docs feat(rule): added ensure-remove-event-listener to config-all docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme docs(readme): updated readme fix(test): fixed rule test fix: removed a whitespace from the docs fix: added a single traling newline to the docs docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme fix: removed a whitespace from the docs fix: added a single traling newline to the docs docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme fix: fixed docs whitespaces fix: removed a whitespace from the docs fix: added a tab spacing to the docs file fix: added a single traling newline to the docs feat(rule): added ensure-remove-event-listener to config-all docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme docs(readme): updated readme fix(test): fixed rule test fix: removed a whitespace from the docs fix: added a single traling newline to the docs docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme fix: fixed docs whitespaces fix: removed a whitespace from the docs fix: added a tab spacing to the docs file fix: added a single traling newline to the docs feat(rule): added ensure-remove-event-listener to config-all docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme docs(readme): updated readme fix(test): fixed rule test fix: fixed docs whitespaces fix: removed a whitespace from the docs fix: added a tab spacing to the docs file fix: added a single traling newline to the docs feat(rule): added ensure-remove-event-listener to config-all docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme docs(readme): updated readme fix(test): fixed rule test fix: removed a whitespace from the docs fix: added a single traling newline to the docs docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme fix: removed a whitespace from the docs fix: added a single traling newline to the docs docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme fix: fixed docs whitespaces fix: removed a whitespace from the docs fix: added a tab spacing to the docs file fix: added a single traling newline to the docs feat(rule): added ensure-remove-event-listener to config-all docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme docs(readme): updated readme fix(test): fixed rule test fix: removed a whitespace from the docs fix: added a single traling newline to the docs docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme fix: fixed docs whitespaces fix: removed a whitespace from the docs fix: added a tab spacing to the docs file fix: added a single traling newline to the docs feat(rule): added ensure-remove-event-listener to config-all docs(readme): updated docs docs(docs): updated documentation for rule updated documentation for ensure-matching-remove-event-listener rule docs(readme): added newline in readme docs(readme): updated readme fix(test): fixed rule test
e685c66
to
bd42395
Compare
Tentative to add a rule that enforce developers to cleanup eventListeners in the useEffect block.