fix(linter/plugins): rule tester default to module source type in ESLint compat mode#18195
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. |
There was a problem hiding this comment.
Pull request overview
This PR fixes the RuleTester to default to module source type when ESLint compatibility mode is enabled, aligning with ESLint's behavior. Previously, #18124 introduced "unambiguous" parsing (detecting source type from content), which broke several hundred Oxlint JS plugins conformance tests that expected ESLint's default module behavior.
Changes:
- Added default source type of
"module"in ESLint compatibility mode when no explicit source type is provided - Added constant
EMPTY_LANGUAGE_OPTIONSto handle the case when languageOptions is null - Enhanced test coverage with dedicated tests for both default behaviors (with and without eslintCompat)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/oxlint/src-js/package/rule_tester.ts | Added logic to default to "module" source type when eslintCompat is true and no explicit source type is set |
| apps/oxlint/test/rule_tester.test.ts | Refactored and expanded tests to validate both unambiguous parsing (default) and module parsing (ESLint compat mode) behaviors |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
…int compat mode (#18195) #18124 altered parsing behavior to default to `script` / `module` source type depending on whether the file contains ESM syntax (e.g. `import` declarations). This broke a several hundred Oxlint JS plugins conformance tests, because ESLint's behavior is to treat files as `module` source type unless directed otherwise. Fix these conformance tests by reverting the "parse based on content" behavior in `RuleTester`, when `eslintCompat` option is enabled.
ca43660 to
8a2dabc
Compare

#18124 altered parsing behavior to default to
script/modulesource type depending on whether the file contains ESM syntax (e.g.importdeclarations).This broke a several hundred Oxlint JS plugins conformance tests, because ESLint's behavior is to treat files as
modulesource type unless directed otherwise.Fix these conformance tests by reverting the "parse based on content" behavior in
RuleTester, wheneslintCompatoption is enabled.