feat(linter/plugins): support commonjs source type in RuleTester#18198
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
3b38774 to
ef08b7c
Compare
83866f8 to
e95a4fe
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds native support for the commonjs source type in RuleTester, removing the previous requirement for ESLint compatibility mode. The Oxc parser now properly parses CommonJS code with this source type, treating it distinctly from script mode.
Changes:
- Simplified source type handling logic to treat
commonjsas a first-class source type - Updated tests to validate CommonJS-specific behavior (top-level return statements)
- Improved ESLint conformance test pass rate by 4 tests for the
strictrule
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
apps/oxlint/src-js/package/rule_tester.ts |
Removed the requirement for eslintCompat mode when using commonjs source type and eliminated the commonjs → script conversion logic |
apps/oxlint/test/rule_tester.test.ts |
Simplified tests by removing nested eslintCompat test groups and added return 123; test case to validate CommonJS-specific behavior |
apps/oxlint/conformance/src/rule_tester.ts |
Updated comment to reflect that eslintCompat no longer enables commonjs source type |
apps/oxlint/conformance/snapshot.md |
Updated conformance test results showing 4 additional passing tests for the strict rule |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e95a4fe to
84b352d
Compare
80fc51f to
9a5146e
Compare
84b352d to
8773a73
Compare
Merge activity
|
…18198) `commonjs` source type was previously supported in `RuleTester` only with `eslintCompat` option enabled (and it was then treated as `script`). #18089 added support in Oxc parser for `commonjs`. Accept it in `RuleTester` (either with or without ESLint compatibility mode) and parse properly as CommonJS.
9a5146e to
6e8fa80
Compare
8773a73 to
7c86fc3
Compare

commonjssource type was previously supported inRuleTesteronly witheslintCompatoption enabled (and it was then treated asscript).#18089 added support in Oxc parser for
commonjs. Accept it inRuleTester(either with or without ESLint compatibility mode) and parse properly as CommonJS.