Skip to content

feat(linter): verify eslint/no-restricted-globals config schema#24598

Merged
Sysix merged 3 commits into
oxc-project:mainfrom
vignesh2027:feat/no-restricted-globals-schema
Jul 26, 2026
Merged

feat(linter): verify eslint/no-restricted-globals config schema#24598
Sysix merged 3 commits into
oxc-project:mainfrom
vignesh2027:feat/no-restricted-globals-schema

Conversation

@vignesh2027

Copy link
Copy Markdown
Contributor

Part of #22955. Follow-up to the resolved #23617.

What

eslint/no-restricted-globals stayed in NO_VERIFIED_VALID_SCHEMA after #23617 was resolved, because the derived schema described the internal NoRestrictedGlobalsConfig struct (a globals hash map) rather than the user-facing positional-array format the rule actually parses.

This PR adds a hand-written JsonSchema following the existing no-restricted-imports pattern, describing the three accepted positional item forms:

  1. "event" — a global name string
  2. { "name": "event", "message": "…" } — a name/message object
  3. { "globals": [ … ], "checkGlobalObject": true, "globalObjects": [ … ] } — the object form added in linter: support eslint/no-restricted-globals new option enum #23617

Generated TS declaration:

"no-restricted-globals"?:
  RuleNoConfig | [AllowWarnDeny, NoRestrictedGlobalsConfigEnum, ...NoRestrictedGlobalsConfigEnum[]];
export type NoRestrictedGlobalsConfigEnum = string | RestrictedGlobal | NoRestrictedGlobalsObjectConfig;

Verified against the #22955 checklist: reflects all accepted user configuration forms, denies unknown fields on object forms, and produces no [k: string]: unknown in the TS declaration. from_configuration and rule behavior are unchanged; rule tests pass.

Note: this branch removes only the no-restricted-globals entry from NO_VERIFIED_VALID_SCHEMA; #24586 (separate PR) removes the filename-case entry, so whichever merges second will have a trivial conflict in that array.

Disclosure

This contribution was developed with assistance from Claude Code (Anthropic); I have reviewed and tested all changes.

The blocker issue oxc-project#23617 (missing checkGlobalObject/globalObjects
options) was resolved, but the rule remained in
NO_VERIFIED_VALID_SCHEMA because the derived schema described the
internal config struct rather than the user-facing positional-array
format.

Adds a hand-written JsonSchema (following the no-restricted-imports
pattern) describing the three accepted item forms: a global name
string, a { name, message } object, and the object form with globals /
checkGlobalObject / globalObjects. Removes the rule from
NO_VERIFIED_VALID_SCHEMA and regenerates the configuration schema and
TS types.

Part of oxc-project#22955
@vignesh2027
vignesh2027 requested a review from camc314 as a code owner July 16, 2026 14:54
@camc314 camc314 added the A-linter Area - Linter label Jul 22, 2026
@Sysix Sysix self-assigned this Jul 26, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 26, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 71 skipped benchmarks1


Comparing vignesh2027:feat/no-restricted-globals-schema (06ad903) with main (4618300)

Open in CodSpeed

Footnotes

  1. 71 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 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@Sysix
Sysix merged commit 8d31dfa into oxc-project:main Jul 26, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: support eslint/no-restricted-globals new option enum

3 participants