feat: allow top level using declaration in "commonjs"#734
Merged
DMartens merged 1 commit intoeslint:mainfrom Mar 3, 2026
Merged
feat: allow top level using declaration in "commonjs"#734DMartens merged 1 commit intoeslint:mainfrom
using declaration in "commonjs"#734DMartens merged 1 commit intoeslint:mainfrom
Conversation
4 tasks
|
Hi @ota-meshi!, thanks for the Pull Request The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.
To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page. Read more about contributing to ESLint here |
using declaration in "commonjs"using declaration in "commonjs"
DMartens
reviewed
Feb 28, 2026
mdjermanovic
reviewed
Mar 1, 2026
Comment on lines
+57
to
+69
| it("should parse top-level using", () => { | ||
| espree.parse("using x = resource;", { | ||
| sourceType: "commonjs", | ||
| ecmaVersion: "latest", | ||
| }); | ||
| }); | ||
|
|
||
| it("should parse top-level new.target", () => { | ||
| espree.parse("new.target;", { | ||
| sourceType: "commonjs", | ||
| ecmaVersion: "latest", | ||
| }); | ||
| }); |
Member
There was a problem hiding this comment.
Are these all the differences between passing sourceType: "commonjs" and passing allowReturnOutsideFunction: true to Acorn?
Member
Author
There was a problem hiding this comment.
Yes, I believe these are the only two top-level additional syntaxes allowed.
mdjermanovic
approved these changes
Mar 3, 2026
Member
mdjermanovic
left a comment
There was a problem hiding this comment.
LGTM, thanks! Leaving open for @DMartens to verify.
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.
Prerequisites checklist
AI acknowledgment
What is the purpose of this pull request?
This PR changes Espree to allow top-level
usingdeclarations when parsed withsourceType: commonjs.What changes did you make? (Give an overview)
Since the
sourceType: commonjsoption was added in acorn, I changed it to use it directly.CHANGELOG: https://github.com/acornjs/acorn/blob/master/acorn/CHANGELOG.md#8160-2026-02-19
PR: acornjs/acorn#1377
Related Issues
close #662
Is there anything you'd like reviewers to focus on?