Skip to content

Conversation

sethamus
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

This PR adds new options to the no-restricted-globals rule to allow detection of restricted globals accessed via global objects (such as window.Promise). Specifically:

  • Introduces the checkGlobalObjectAccess boolean option, which, when enabled, reports usage of restricted globals as properties of known global objects (window, global, globalThis).
  • Adds the globalObjects option, allowing users to specify additional global object names to check.
  • Updates the rule schema and implementation to support three configuration styles: an array of strings, an array of objects, or a single options object with a globals array and the new options.
  • Updates documentation and tests to cover the new options and usage patterns.

Fixes #19804

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

@sethamus sethamus requested a review from a team as a code owner July 14, 2025 16:32
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jul 14, 2025
Copy link

netlify bot commented Jul 14, 2025

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit 90395c0
🔍 Latest deploy log https://app.netlify.com/projects/docs-eslint/deploys/68835197bdd20b0008c62df2
😎 Deploy Preview https://deploy-preview-19939--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label Jul 14, 2025
@github-actions github-actions bot added the rule Relates to ESLint's core rules label Jul 14, 2025
@lumirlumir lumirlumir added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jul 15, 2025
@snitin315 snitin315 moved this from Needs Triage to Implementing in Triage Jul 15, 2025
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just left some notes to help clarify things a bit.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@nzakas nzakas merged commit e07820e into eslint:main Jul 31, 2025
31 checks passed
@github-project-automation github-project-automation bot moved this from Implementing to Complete in Triage Jul 31, 2025
@tanvi22434
Copy link

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update [ ] Bug fix (template) [ ] New rule (template) [x] Changes an existing rule (template) [ ] Add autofix to a rule [ ] Add a CLI option [ ] Add something to the core [ ] Other, please explain:

What changes did you make? (Give an overview)

This PR adds new options to the no-restricted-globals rule to allow detection of restricted globals accessed via global objects (such as window.Promise). Specifically:

  • Introduces the checkGlobalObjectAccess boolean option, which, when enabled, reports usage of restricted globals as properties of known global objects (window, global, globalThis).
  • Adds the globalObjects option, allowing users to specify additional global object names to check.
  • Updates the rule schema and implementation to support three configuration styles: an array of strings, an array of objects, or a single options object with a globals array and the new options.
  • Updates documentation and tests to cover the new options and usage patterns.

Fixes #19804

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion contributor pool feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

Rule Change: no-restricted-globals should detect restricted globals accessed via global object
5 participants