diff --git a/CHANGELOG.md b/CHANGELOG.md index 8442cc65169a..5386d6e9bf1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,11 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b ### CLI +#### Bug fixes + +- `biome migrate eslint` now correctly resolves scoped package named `eslint-config` with a path. + Contributed by @Conaclos + ### Configuration ### Editors diff --git a/crates/biome_cli/src/execute/migrate/eslint.rs b/crates/biome_cli/src/execute/migrate/eslint.rs index 255224bcf4ed..d41f753dcf6d 100644 --- a/crates/biome_cli/src/execute/migrate/eslint.rs +++ b/crates/biome_cli/src/execute/migrate/eslint.rs @@ -377,12 +377,13 @@ impl EslintPackage { EslintPackage::Plugin => "eslint-plugin-", }; if name.starts_with('@') { - // handle scoped module - if let Some((scope, scoped)) = name.split_once('/') { - if scoped.starts_with(artifact) || scoped == artifact.trim_end_matches('-') { + // handle scoped package + if let Some((scope, rest)) = name.split_once('/') { + let package = rest.split('/').next().unwrap_or(rest); + if rest.starts_with(artifact) || package == artifact.trim_end_matches('-') { Cow::Borrowed(name) } else { - Cow::Owned(format!("{scope}/{artifact}{scoped}")) + Cow::Owned(format!("{scope}/{artifact}{rest}")) } } else { let artifact = artifact.trim_end_matches('-'); @@ -395,3 +396,46 @@ impl EslintPackage { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn eslint_package_resolve_name() { + assert_eq!( + EslintPackage::Config.resolve_name("@scope/package"), + "@scope/eslint-config-package" + ); + assert_eq!( + EslintPackage::Config.resolve_name("@scope/eslint-config-package"), + "@scope/eslint-config-package" + ); + assert_eq!( + EslintPackage::Config.resolve_name("@scope/eslint-config"), + "@scope/eslint-config" + ); + + assert_eq!( + EslintPackage::Config.resolve_name("@scope/package/path"), + "@scope/eslint-config-package/path" + ); + assert_eq!( + EslintPackage::Config.resolve_name("@scope/eslint-config-package/path"), + "@scope/eslint-config-package/path" + ); + assert_eq!( + EslintPackage::Config.resolve_name("@scope/eslint-config/path"), + "@scope/eslint-config/path" + ); + + assert_eq!( + EslintPackage::Config.resolve_name("package"), + "eslint-config-package" + ); + assert_eq!( + EslintPackage::Config.resolve_name("eslint-config-package"), + "eslint-config-package" + ); + } +}