diff --git a/crates/rome_js_formatter/src/js/module/import_named_clause.rs b/crates/rome_js_formatter/src/js/module/import_named_clause.rs index 342c8834822..3ad37a56466 100644 --- a/crates/rome_js_formatter/src/js/module/import_named_clause.rs +++ b/crates/rome_js_formatter/src/js/module/import_named_clause.rs @@ -81,6 +81,27 @@ impl FormatNodeRule for FormatJsImportNamedClause { write!(f, [space(), r_curly_token.format()]) } } + ( + Ok(JsAnyNamedImportSpecifier::JsNamedImportSpecifier(specifier)), + Ok(separator), + ) => { + if f.comments().has_comments(specifier.syntax()) { + write!(f, [named_import.format()]) + } else { + let JsNamedImportSpecifiersFields { + l_curly_token, + specifiers: _, + r_curly_token, + } = specifiers.as_fields(); + write!(f, [l_curly_token.format(), space(), specifier.format(),])?; + + if let Some(separator) = separator { + format_removed(separator).fmt(f)?; + } + + write!(f, [space(), r_curly_token.format()]) + } + } _ => write![f, [named_import.format()]], } } diff --git a/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js b/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js index 168e7b60417..a8f3ac2e077 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js +++ b/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js @@ -15,4 +15,6 @@ export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "looooooo export { // comment -loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" \ No newline at end of file +loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" \ No newline at end of file diff --git a/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js.snap b/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js.snap index 8ca6cd3dd94..d306bffd511 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/export/named_from_clause.js.snap @@ -24,6 +24,8 @@ export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "looooooo export { // comment loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" ``` @@ -64,11 +66,14 @@ export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong"; +export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"; + ## Lines exceeding width of 80 characters 13: export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"; 15: export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"; + 22: export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"; ``` diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js b/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js index e88fb5ce030..d2223d44ec3 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js @@ -25,4 +25,8 @@ import { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "looooooo import { // comment -loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" \ No newline at end of file +loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +import { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" + +import a, { loooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooooonnoong" diff --git a/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js.snap b/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js.snap index d62d31d8621..3a8a4ed9c49 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/import/import_specifiers.js.snap @@ -34,6 +34,11 @@ import { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "looooooo import { // comment loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +import { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" + +import a, { loooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooooonnoong" + ``` @@ -90,11 +95,18 @@ import { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong"; +import { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"; + +import a, { + loooooooooooooooooooooong, +} from "loooooooooooooooooooooooooooooooooooooooooooooooonnoong"; + ## Lines exceeding width of 80 characters 29: import { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"; 31: import { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"; + 38: import { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"; ```