diff --git a/crates/biome_js_formatter/tests/specs/js/module/import/import_defer_attribute.js b/crates/biome_js_formatter/tests/specs/js/module/import/import_defer_attribute.js new file mode 100644 index 000000000000..5ba99b257a53 --- /dev/null +++ b/crates/biome_js_formatter/tests/specs/js/module/import/import_defer_attribute.js @@ -0,0 +1 @@ +import defer * as ns from "x"; \ No newline at end of file diff --git a/crates/biome_js_formatter/tests/specs/js/module/import/import_defer_attribute.js.snap b/crates/biome_js_formatter/tests/specs/js/module/import/import_defer_attribute.js.snap new file mode 100644 index 000000000000..0f73db00de05 --- /dev/null +++ b/crates/biome_js_formatter/tests/specs/js/module/import/import_defer_attribute.js.snap @@ -0,0 +1,36 @@ +--- +source: crates/biome_formatter_test/src/snapshot_builder.rs +info: js/module/import/import_defer_attribute.js +--- +# Input + +```js +import defer * as ns from "x"; +``` + + +============================= + +# Outputs + +## Output 1 + +----- +Indent style: Tab +Indent width: 2 +Line ending: LF +Line width: 80 +Quote style: Double Quotes +JSX quote style: Double Quotes +Quote properties: As needed +Trailing commas: All +Semicolons: Always +Arrow parentheses: Always +Bracket spacing: true +Bracket same line: false +Attribute Position: Auto +----- + +```js +import defer * as ns from "x"; +``` diff --git a/crates/biome_js_parser/src/syntax/module.rs b/crates/biome_js_parser/src/syntax/module.rs index 937523046f5a..ef979a84fbf5 100644 --- a/crates/biome_js_parser/src/syntax/module.rs +++ b/crates/biome_js_parser/src/syntax/module.rs @@ -296,23 +296,7 @@ fn parse_import_clause(p: &mut JsParser) -> ParsedSyntax { // test js import_defer_clause // import defer * as yNamespace from "y"; - let is_defer = 'is_defer: { - if !p.at(T![defer]) { - break 'is_defer false; - } - - if matches!(p.nth(1), T![*] | T!['{']) { - break 'is_defer true; - } - - if !is_nth_at_identifier_binding(p, 1) { - break 'is_defer false; - } - - !p.nth_at(1, T![from]) || p.nth_at(2, T![from]) - }; - - if is_defer { + if p.at(T![defer]) && p.nth_at(1, T![*]) { p.eat(T![defer]); }