--- source: crates/biome_formatter_test/src/snapshot_builder.rs info: js/babel-plugins/do-expressions.js --- # Input ```js // https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions let a = do { if(x > 10) { 'big'; } else { 'small'; } }; // is equivalent to: let a = x > 10 ? 'big' : 'small'; ``` # Prettier differences ```diff --- Prettier +++ Biome @@ -1,10 +1,11 @@ // https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions -let a = do { - if (x > 10) { - ("big"); +let a = +do { + if(x > 10) { + 'big'; } else { - ("small"); + 'small'; } }; // is equivalent to: ``` # Output ```js // https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions let a = do { if(x > 10) { 'big'; } else { 'small'; } }; // is equivalent to: let a = x > 10 ? "big" : "small"; ``` # Errors ``` do-expressions.js:3:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression, or an assignment but instead found 'do'. 1 │ // https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions 2 │ > 3 │ let a = do { │ ^^ 4 │ if(x > 10) { 5 │ 'big'; i Expected an expression, or an assignment here. 1 │ // https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions 2 │ > 3 │ let a = do { │ ^^ 4 │ if(x > 10) { 5 │ 'big'; do-expressions.js:9:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `while` but instead found `;` 7 │ 'small'; 8 │ } > 9 │ }; │ ^ 10 │ // is equivalent to: 11 │ let a = x > 10 ? 'big' : 'small'; i Remove ; ```