Feature/new rule no polling without visibility check#119
Open
mhammed21 wants to merge 2 commits into
Open
Conversation
MP-Aubay
requested changes
May 20, 2026
| sonar.sources=src | ||
| sonar.projectKey=creedengo-javascript-test-project | ||
| sonar.host.url=http://localhost:9000 | ||
| sonar.token=sqa_31a11e64c69be98c50572f3bcdb3811f0255dfcd |
| peerDependencies: | ||
| eslint: ^9.0.0 || ^10.0.0 | ||
| checksum: 10c0/35357906578cb26b758f44fb8fdb12656de3a6d3297d97002f3a1c755066b81e1321badd1f4a01a9e9d156b0545b5611774c2ed83e80600168c134f0dc0846fd | ||
| checksum: 10c0/672076df8ce6a5d9a44bde94b519c8a00eb3082c7e5ea4cc6384fefec7c8d4c8f697dcb5ec58e0b603f4b3f485e4e3b123db711c06cd2957d0853263f0442c1d |
Contributor
There was a problem hiding this comment.
yarn.lock does not need to be commited
|
|
||
| ### Added | ||
|
|
||
| - Add rule GCI2001 "Avoid polling without checking page visibility" |
Contributor
There was a problem hiding this comment.
Could you add the PR link ?
| @@ -0,0 +1,19 @@ | |||
| // Non compliant: setInterval without visibilitychange listener | |||
Contributor
There was a problem hiding this comment.
Could you add a compliant example here ? Maybe you will need another file to do it ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new ESLint rule no-polling-without-visibility-check (GCI2001) to the creedengo rules specifications.
Problem:
Polling loops using setInterval or recursive setTimeout that run regardless of page visibility waste energy. When a user switches tabs or minimizes the browser, these loops keep firing network requests and executing JavaScript for no reason — consuming CPU, network bandwidth, and battery on mobile devices.
Solution:
The rule detects setInterval and recursive setTimeout calls that are not guarded by a document.addEventListener('visibilitychange', ...) listener. Developers should pause polling when the page is hidden and resume it when visible again.