Skip to content

Comments

refactor(linter/plugins): simplify return value of load_plugin#16459

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-03-refactor_linter_plugins_simplify_return_value_of_load_plugin_
Dec 3, 2025
Merged

refactor(linter/plugins): simplify return value of load_plugin#16459
graphite-app[bot] merged 1 commit intomainfrom
12-03-refactor_linter_plugins_simplify_return_value_of_load_plugin_

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Dec 3, 2025

Previously load_plugin returned a Result<LoadPluginResult>, where LoadPluginResult was an enum with one variant being an error case - so it was essentially Result<Result<Data>>.

Flatten it so that LoadPluginResult is a now struct containing details of success case, and the error case that LoadPluginResult::Failure previously covered becomes Err.

This simplifies the logic, and matches the pattern used by lint_file + LintFileResult.

Copy link
Member Author

overlookmotel commented Dec 3, 2025


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 3, 2025

CodSpeed Performance Report

Merging #16459 will not alter performance

Comparing 12-03-refactor_linter_plugins_simplify_return_value_of_load_plugin_ (0544977) with 12-03-refactor_linter_plugins_rename_loadpluginresult_ (6ccb6a4)1

Summary

✅ 4 untouched
⏩ 41 skipped2

Footnotes

  1. No successful run was found on 12-03-refactor_linter_plugins_rename_loadpluginresult_ (08187e7) during the generation of this report, so 8d6d690 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 41 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@overlookmotel overlookmotel marked this pull request as ready for review December 3, 2025 17:27
Copilot AI review requested due to automatic review settings December 3, 2025 17:27
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 refactors the load_plugin return value handling to simplify the API by flattening a nested Result<Result<Data>> structure. Previously, LoadPluginResult was an enum with Success and Failure variants, creating redundancy with the outer Result type. The refactoring converts LoadPluginResult to a struct representing only the success case, while failures become Err variants of the outer Result.

Key Changes

  • LoadPluginResult changed from enum to struct containing only success case fields (name, offset, rule_names)
  • New LoadPluginReturnValue enum introduced for JS deserialization boundary with Success/Failure variants
  • Simplified error handling in config_builder.rs by removing nested match statement

Reviewed changes

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

File Description
crates/oxc_linter/src/external_linter.rs Converted LoadPluginResult from enum to struct, removing the Failure variant and flattening fields from the former Success variant
crates/oxc_linter/src/config/config_builder.rs Simplified plugin loading logic by removing nested match on LoadPluginResult variants; error handling now occurs at the Result level via .map_err()
apps/oxlint/src/js_plugins/external_linter.rs Added LoadPluginReturnValue enum for JS callback deserialization, mapping Success to Ok(LoadPluginResult) and Failure to Err(String)

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

@overlookmotel overlookmotel force-pushed the 12-03-refactor_linter_plugins_simplify_return_value_of_load_plugin_ branch from 2f8d234 to 0544977 Compare December 3, 2025 17:30
@overlookmotel overlookmotel force-pushed the 12-03-refactor_linter_plugins_rename_loadpluginresult_ branch from 6ccb6a4 to 08187e7 Compare December 3, 2025 17:30
@overlookmotel overlookmotel self-assigned this Dec 3, 2025
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 3, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 3, 2025

Merge activity

)

Previously `load_plugin` returned a `Result<LoadPluginResult>`, where `LoadPluginResult` was an enum with one variant being an error case - so it was essentially `Result<Result<Data>>`.

Flatten it so that `LoadPluginResult` is a now struct containing details of success case, and the error case that `LoadPluginResult::Failure` previously covered becomes `Err`.

This simplifies the logic, and matches the pattern used by `lint_file` + `LintFileResult`.
@graphite-app graphite-app bot force-pushed the 12-03-refactor_linter_plugins_rename_loadpluginresult_ branch from 08187e7 to 0df6e73 Compare December 3, 2025 19:08
@graphite-app graphite-app bot force-pushed the 12-03-refactor_linter_plugins_simplify_return_value_of_load_plugin_ branch from 0544977 to 3cb25e3 Compare December 3, 2025 19:09
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 3, 2025
Base automatically changed from 12-03-refactor_linter_plugins_rename_loadpluginresult_ to main December 3, 2025 19:18
@graphite-app graphite-app bot merged commit 3cb25e3 into main Dec 3, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 12-03-refactor_linter_plugins_simplify_return_value_of_load_plugin_ branch December 3, 2025 19:19
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
…-project#16459)

Previously `load_plugin` returned a `Result<LoadPluginResult>`, where `LoadPluginResult` was an enum with one variant being an error case - so it was essentially `Result<Result<Data>>`.

Flatten it so that `LoadPluginResult` is a now struct containing details of success case, and the error case that `LoadPluginResult::Failure` previously covered becomes `Err`.

This simplifies the logic, and matches the pattern used by `lint_file` + `LintFileResult`.
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 C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant