refactor(linter/plugins): improve calculating plugin name#15811
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 refactoring improves plugin name calculation and validation by extracting the logic into a dedicated function with better error handling. The changes align the TypeScript types with the actual values passed from Rust (changing string | undefined to string | null for the packageName parameter), and optimize null checking.
- Extracted plugin name calculation into a separate
getPluginNamefunction with enhanced validation - Updated
packageNameparameter type fromstring | undefinedtostring | nullto match NAPI-rs conversion of Rust'sOption<String> - Added type validation to ensure
plugin.meta.nameis a string if defined - Improved error messages for better clarity
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/oxlint/src-js/plugins/load.ts | Refactored plugin name extraction into getPluginName function with better validation, updated parameter types to reflect actual values from Rust, and improved error messages |
| apps/oxlint/src-js/cli.ts | Updated loadPluginWrapper signature to match the corrected packageName parameter type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
Provide better errors when validating plugin names, correct type of `packageName` passed from Rust, and use cheaper check `packageName !== null`.
3a1d6fe to
61650f9
Compare
…t#15811) Provide better errors when validating plugin names, correct type of `packageName` passed from Rust, and use cheaper check `packageName !== null`.

Provide better errors when validating plugin names, correct type of
packageNamepassed from Rust, and use cheaper checkpackageName !== null.