fix(linter/plugins): report error when two plugins are aliased to the same name#17061
fix(linter/plugins): report error when two plugins are aliased to the same name#17061
Conversation
Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
|
@overlookmotel this is a bug. we don't need to fix before today's release. but should fix before monday |
|
@copilot try and fix this. we should report an error if you have 2x with the same aliased name |
- Add `is_plugin_name_registered` method to ExternalPluginStore - Add `DuplicatePluginAlias` error variant to ConfigBuilderError - Check for duplicate plugin names before registration - Update test snapshot to expect error instead of silent success The fix prevents silent overwriting when two plugins share the same alias, providing a clear error message to help users resolve the conflict. Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
Signed-off-by: Cameron <cameron.clark@hey.com>
CodSpeed Performance ReportMerging #17061 will not alter performanceComparing Summary
Footnotes
|
|
Apart from the lint error, this looks good. But shouldn't we be a bit broader, and disallow these too? {
"jsPlugins": [
"foo",
{ "name": "foo", "specifier": "whatever" },
]
}{
"jsPlugins": [
"foo",
"actually-called-foo",
]
}(when |
|
@copilot review and action overlookmotel 's comment |
- Add test for plugin loaded without alias, then with alias matching its meta.name - Add test for two plugins without explicit aliases that have the same meta.name - Both scenarios are already caught by the existing duplicate detection logic The current implementation correctly validates plugin.meta.name for duplicates, regardless of whether the plugins use explicit aliases or rely on package names. Co-authored-by: camc314 <18101008+camc314@users.noreply.github.com>
The current implementation already handles both scenarios mentioned by @overlookmotel. Added test cases in 5203e68 to verify:
The duplicate detection validates |
Fix for Duplicate Plugin Aliases
Fixed the bug where two different JS plugins could be aliased to the same name, causing the second plugin to silently overwrite the first.
Changes Made
is_plugin_name_registered()method toExternalPluginStoreto check if a plugin name is already in useDuplicatePluginAliasvariant toConfigBuilderErrorwith a helpful error messageload_external_plugin()to check for duplicate plugin names before registration and fail early with a descriptive errormeta.namemeta.nameError Message
When two plugins share the same name, users now see:
How It Works
The implementation catches all duplicate scenarios by validating
plugin.meta.name(the final resolved plugin name) rather than just the initial alias or package name. This ensures duplicates are caught regardless of how the plugin name is determined:Files Changed
crates/oxc_linter/src/external_plugin_store.rs- Added duplicate name detectioncrates/oxc_linter/src/config/config_builder.rs- Added error variant and validation logicapps/oxlint/test/fixtures/plugin_name_duplicate_alias/- Test for explicit duplicate aliasesapps/oxlint/test/fixtures/plugin_name_duplicate_no_alias_then_alias/- Test for no alias then aliasapps/oxlint/test/fixtures/plugin_name_duplicate_same_meta_name/- Test for duplicate meta.nameTesting
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.