feat: enforce ECMAScript-only globals in test files via ESLint#30
Merged
legendecas merged 2 commits intonodejs:mainfrom Mar 14, 2026
Merged
Conversation
Add an allowlist-based ESLint config using globals.es2025 plus the CTS harness globals (assert, loadAddon, mustCall, mustNotCall, gcUntil). Any runtime-specific API (setTimeout, process, Buffer, etc.) now triggers a no-undef error in tests/**/*.js files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ests - Add experimentalFeatures to the allowed CTS harness globals - Add no-restricted-syntax rule to flag globalThis.* and global.* access, ensuring tests use CTS harness globals (e.g. gcUntil) instead Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
legendecas
approved these changes
Mar 12, 2026
Member
legendecas
left a comment
There was a problem hiding this comment.
When looking at #31, I was also thinking the same about adding a linter rule for globals. Thanks!
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.
Summary
globals.es2025plus the CTS harness globals (assert,loadAddon,mustCall,mustNotCall,gcUntil,experimentalFeatures)no-undefrule so any runtime-specific API (setTimeout,process,Buffer, etc.) triggers a lint error intests/**/*.jsno-restricted-syntaxrule to banglobalThis.*andglobal.*property access in test files, ensuring tests use CTS harness globals (e.g.gcUntil) instead ofglobalThis.gc()no-restricted-globalsforrequire) with a stricter allowlistThis ensures CTS test files only use ECMAScript language features and harness-provided globals, making them portable across Node-API runtimes.
Test plan
npx eslint tests/passes with no errorssetTimeoutin a test file triggers'setTimeout' is not definederrorglobalThis.gc()in a test file triggersno-restricted-syntaxerror🤖 Generated with Claude Code