Skip to content

feat: add prefer-global/timers rule#515

Merged
aladdin-add merged 1 commit intoeslint-community:masterfrom
Pixel998:feat/prefer-global-timers
Feb 15, 2026
Merged

feat: add prefer-global/timers rule#515
aladdin-add merged 1 commit intoeslint-community:masterfrom
Pixel998:feat/prefer-global-timers

Conversation

@Pixel998
Copy link

What is the purpose of this pull request?

This PR introduces the prefer-global/timers rule to enforce consistent usage of timer functions—including setImmediate, setInterval, setTimeout, and their clear* counterparts—as either global variables or as imports from the node:timers module.

What changes did you make? (Give an overview)

  • Implemented prefer-global/crypto rule
  • Added Documentation
  • Added Tests

Related Issues

Closes #339

Is there anything you'd like reviewers to focus on?

setInterval: { [READ]: true },
setTimeout: { [READ]: true },
},
},
Copy link

@aladdin-add aladdin-add Feb 10, 2026

Choose a reason for hiding this comment

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

To avoid repetition, we can define a variable first and then reference it:

        const timers = {
            clearImmediate: { [READ]: true },
            clearInterval: { [READ]: true },
            clearTimeout: { [READ]: true },
            setImmediate: { [READ]: true },
            setInterval: { [READ]: true },
            setTimeout: { [READ]: true },
        };

       const traceMap = {
          globals: timers,
          modules: {
              timers: timers,
              "node:timers": timers,
          }, 
        };

Copy link
Author

Choose a reason for hiding this comment

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

Apologies for the delay. I’ve opened #516.

@aladdin-add aladdin-add merged commit 10b24ae into eslint-community:master Feb 15, 2026
29 checks passed
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.

New Rule: prefer-global/timers

2 participants

Comments