Skip to content

test(linter/plugins): conformance tester keep other module exports when mocking RuleTester modules#18679

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/01-28-test_linter_plugins_conformance_tester_keep_other_module_exports_when_mocking_ruletester_modules
Jan 28, 2026
Merged

test(linter/plugins): conformance tester keep other module exports when mocking RuleTester modules#18679
graphite-app[bot] merged 1 commit intomainfrom
om/01-28-test_linter_plugins_conformance_tester_keep_other_module_exports_when_mocking_ruletester_modules

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Jan 28, 2026

When mocking modules containing RuleTester, don't replace the whole module, just alter the RuleTester property within it. e.g. when mocking the RuleTester export of eslint package, leave all package's other exports unchanged.

Copy link
Member Author

overlookmotel commented Jan 28, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines how the conformance runner mocks RuleTester so that when a module exposes RuleTester alongside other exports (e.g. eslint), only the RuleTester export is replaced, preserving the rest of the module’s API.

Changes:

  • Redefines TestGroup.ruleTesters from a list of module specifier strings to a list of { specifier, propName } objects, allowing selective replacement of a single export or the entire module.
  • Updates the conformance runner’s runGroup logic to either replace module.exports with the conformance RuleTester or to overwrite a specific property on the loaded module, depending on propName.
  • Migrates the eslint and react-hooks test groups to the new ruleTesters shape so that eslint-v7/v8/v9 retain their non-RuleTester exports while still using the conformance RuleTester.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
apps/oxlint/conformance/src/index.ts Extends TestGroup.ruleTesters to carry specifier and propName, and updates the mocking logic to selectively replace either the whole module or just a named RuleTester export.
apps/oxlint/conformance/src/groups/react_hooks.ts Adapts the React Hooks test group to the new ruleTesters format, targeting the RuleTester property of the eslint-v7/v8/v9 modules instead of replacing those modules entirely.
apps/oxlint/conformance/src/groups/eslint.ts Adapts the ESLint core test group to the new ruleTesters shape while still replacing the dedicated rule-tester module’s exports with the conformance RuleTester.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel self-assigned this Jan 28, 2026
@overlookmotel overlookmotel force-pushed the om/01-28-test_linter_plugins_conformance_tester_catch_errors_in_describe_callbacks branch from 9f89c2d to 8ae77ab Compare January 28, 2026 22:37
@overlookmotel overlookmotel force-pushed the om/01-28-test_linter_plugins_conformance_tester_keep_other_module_exports_when_mocking_ruletester_modules branch from 81d4d84 to f626725 Compare January 28, 2026 22:37
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Jan 28, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 28, 2026

Merge activity

…en mocking `RuleTester` modules (#18679)

When mocking modules containing `RuleTester`, don't replace the whole module, just alter the `RuleTester` property within it. e.g. when mocking the `RuleTester` export of `eslint` package, leave all package's other exports unchanged.
@graphite-app graphite-app bot force-pushed the om/01-28-test_linter_plugins_conformance_tester_catch_errors_in_describe_callbacks branch from 8ae77ab to f9949a0 Compare January 28, 2026 23:03
@graphite-app graphite-app bot force-pushed the om/01-28-test_linter_plugins_conformance_tester_keep_other_module_exports_when_mocking_ruletester_modules branch from f626725 to 70e4bd2 Compare January 28, 2026 23:03
Base automatically changed from om/01-28-test_linter_plugins_conformance_tester_catch_errors_in_describe_callbacks to main January 28, 2026 23:09
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jan 28, 2026
@graphite-app graphite-app bot merged commit 70e4bd2 into main Jan 28, 2026
20 checks passed
@graphite-app graphite-app bot deleted the om/01-28-test_linter_plugins_conformance_tester_keep_other_module_exports_when_mocking_ruletester_modules branch January 28, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants