Skip to content

fix(linter): check globals entry for no-undef, only check es2026 globals for no-extend-native and no-constant-binary-expression#20089

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-07-fix_linter_check_globals_entry_for_no-undef_no-extend-native_and_no-constant-binary-expression_
Mar 9, 2026
Merged

fix(linter): check globals entry for no-undef, only check es2026 globals for no-extend-native and no-constant-binary-expression#20089
graphite-app[bot] merged 1 commit intomainfrom
03-07-fix_linter_check_globals_entry_for_no-undef_no-extend-native_and_no-constant-binary-expression_

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Mar 7, 2026

These 3 rules are the only one which did not checked for "globals" and only lookedup the envs.
In the future PR I want to remove env from the lint context. It should be resolved into "globals" before.

Added one test case where we already tested the "globals" option

Copy link
Member Author

Sysix commented Mar 7, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Mar 7, 2026
@Sysix Sysix requested a review from Copilot March 7, 2026 01:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates eslint rule implementations to treat globals configuration entries as “defined globals” when determining whether identifiers are global for no-undef, no-extend-native, and no-constant-binary-expression.

Changes:

  • Introduces LintContext::is_global_defined to unify “global defined” checks across env globals and globals config.
  • Replaces direct env_contains_var checks in the three rules with is_global_defined.
  • Makes env_contains_var an internal helper.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
crates/oxc_linter/src/rules/eslint/no_undef.rs Switches the rule’s global check to use ctx.is_global_defined.
crates/oxc_linter/src/rules/eslint/no_extend_native.rs Switches the rule’s “is global object” check to use ctx.is_global_defined.
crates/oxc_linter/src/rules/eslint/no_constant_binary_expression.rs Uses ctx.is_global_defined for new <Ident>() constructor global detection.
crates/oxc_linter/src/context/mod.rs Adds is_global_defined and makes env_contains_var private.
Comments suppressed due to low confidence (1)

crates/oxc_linter/src/rules/eslint/no_undef.rs:82

  • After switching to is_global_defined, the subsequent ctx.globals().is_enabled(name) check becomes redundant (since is_global_defined already considers non-"off" entries from globals). Keeping both checks makes the control flow harder to follow and suggests the two conditions differ when they currently do not in this context.
                if ctx.is_global_defined(name) {
                    continue;
                }

                if ctx.globals().is_enabled(name) {
                    continue;
                }

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 7, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 52 skipped benchmarks1


Comparing 03-07-fix_linter_check_globals_entry_for_no-undef_no-extend-native_and_no-constant-binary-expression_ (7269cc0) with main (1735215)

Open in CodSpeed

Footnotes

  1. 52 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Sysix Sysix force-pushed the 03-07-fix_linter_check_globals_entry_for_no-undef_no-extend-native_and_no-constant-binary-expression_ branch 4 times, most recently from 6259879 to 67983f3 Compare March 7, 2026 10:32
@Sysix Sysix force-pushed the 03-07-fix_linter_check_globals_entry_for_no-undef_no-extend-native_and_no-constant-binary-expression_ branch from 67983f3 to ea41224 Compare March 7, 2026 18:30
@Sysix Sysix marked this pull request as ready for review March 7, 2026 19:14
@Sysix Sysix requested a review from camc314 as a code owner March 7, 2026 19:14
@camc314 camc314 self-assigned this Mar 9, 2026
@Sysix Sysix force-pushed the 03-07-fix_linter_check_globals_entry_for_no-undef_no-extend-native_and_no-constant-binary-expression_ branch from ea41224 to 7269cc0 Compare March 9, 2026 19:25
@Sysix Sysix changed the title fix(linter): check globals entry for no-undef, no-extend-native and no-constant-binary-expression fix(linter): check globals entry for no-undef, only check es2026 globals for no-extend-native and no-constant-binary-expression Mar 9, 2026
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

👍

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Mar 9, 2026
Copy link
Contributor

camc314 commented Mar 9, 2026

Merge activity

…globals for `no-extend-native` and `no-constant-binary-expression` (#20089)

These 3 rules are the only one which did not checked for "globals" and only lookedup the envs.
In the future PR I want to remove env from the lint context. It should be resolved into "globals" before.

Added one test case where we already tested the "globals" option
@graphite-app graphite-app bot force-pushed the 03-07-fix_linter_check_globals_entry_for_no-undef_no-extend-native_and_no-constant-binary-expression_ branch from 7269cc0 to a9acb2b Compare March 9, 2026 22:25
@graphite-app graphite-app bot merged commit a9acb2b into main Mar 9, 2026
21 checks passed
@graphite-app graphite-app bot deleted the 03-07-fix_linter_check_globals_entry_for_no-undef_no-extend-native_and_no-constant-binary-expression_ branch March 9, 2026 22:30
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 9, 2026
leaysgur added a commit that referenced this pull request Mar 11, 2026
# Oxlint
### 🚀 Features

- 04a5ce0 oxlint: Support `vite.config.ts` `.lint` field (#20214)
(leaysgur)
- 1735215 linter: Implement `react/no-clone-element` rule. (#20129)
(connorshea)
- 68e6f6f linter: Implement `react/no-react-children` rule. (#20104)
(connorshea)
- fe3b32e linter/plugins: Add `oxlint-plugin-eslint` package (#20009)
(overlookmotel)

### 🐛 Bug Fixes

- 05f6a09 linter/no-inline-comments: Deserialize rule options with serde
(#20207) (camc314)
- c7eb09d linter/default-case: Deserialize rule options with serde
(#20206) (camc314)
- f85e16c linter/plugins: Fix types for visitor compilation (#20203)
(overlookmotel)
- 44e24e0 linter/exhaustive-deps: Ignore type-only typeof deps (#20201)
(camc314)
- 0b04998 linter/no-fallthrough: Deserialize rule options with serde
(#20192) (camc314)
- a1031cb linter/new-cap: Deserialize rule options with serde (#20161)
(camc314)
- ad27fd6 linter: Add help messages to import plugin diagnostics
(#20158) (John Costa)
- 1340307 linter/plugins: Ensure `after` hooks always run (#20167)
(overlookmotel)
- c4812ec linter/plugins: Reset visitor compilation state if error
during compilation (#20166) (overlookmotel)
- 887eecc linter/plugins: Add license notice to `oxlint-plugin-eslint`
package (#20164) (overlookmotel)
- e1713a4 linter/plugins: Include common chunks in
`oxlint-plugin-eslint` package (#20163) (overlookmotel)
- a9acb2b linter: Check `globals` entry for `no-undef`, only check
es2026 globals for `no-extend-native` and
`no-constant-binary-expression` (#20089) (Sysix)
- 5559f0d linter/no-unused-vars: `reportUsedIgnorePattern` should not
report used rest siblings (#20108) (Don Isaac)
- de7c0e2 linter/plugins: Correct error message for `markVariableAsUsed`
(#20152) (overlookmotel)

### ⚡ Performance

- 3a86427 linter/plugins: Pre-populate cache of `EnterExit` objects at
startup (#20194) (overlookmotel)
- d243391 linter/plugins: Replace arrays with `Uint8Array`s (#20190)
(overlookmotel)
- 8742f8b linter/plugins: Pre-populate cache of `VisitProp` objects
(#20189) (overlookmotel)
- 3061acb linter/plugins: Pre-populate cache of `EnterExit` objects
(#20187) (overlookmotel)
- c73912b linter/plugins: Free visit functions earlier (#20186)
(overlookmotel)
- d9f8ff4 linter/plugins: Faster reset of visitor state (#20185)
(overlookmotel)
- 42aff15 oxlint/lsp: Avoid computing diagnostics for non invoked code
actions requests (#20080) (Sysix)

### 📚 Documentation

- a080650 linter/plugins: Fix documentation of visitor compilation
(#20202) (overlookmotel)
- 542a04a linter: Add a link to the cyclomatic complexity Wikipedia
article in `eslint/complexity` (#20174) (connorshea)
# Oxfmt
### 🚀 Features

- 95943aa oxfmt: Support `vite.config.*` `.fmt` field (#20197)
(leaysgur)
- 172fc07 oxfmt: .js/.ts config file support (#20135) (leaysgur)

### 🐛 Bug Fixes

- e483569 oxfmt: Avoid double-escaping in css-in-js (#20211) (leaysgur)

Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants