--- source: crates/biome_formatter_test/src/snapshot_builder.rs info: js/babel-plugins/throw-expressions.js --- # Input ```js // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions function test(param = throw new Error('required!')) { const test = param === true || throw new Error('Falsy!'); } ``` # Prettier differences ```diff --- Prettier +++ Biome @@ -1,5 +1,8 @@ // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions -function test(param = throw new Error("required!")) { - const test = param === true || throw new Error("Falsy!"); +function test(param = throw new Error('required!') +) +{ + const test = param === true || + throw new Error("Falsy!"); } ``` # Output ```js // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions function test(param = throw new Error('required!') ) { const test = param === true || throw new Error("Falsy!"); } ``` # Errors ``` throw-expressions.js:3:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression, or an assignment but instead found 'throw'. 1 │ // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions 2 │ > 3 │ function test(param = throw new Error('required!')) { │ ^^^^^ 4 │ const test = param === true || throw new Error('Falsy!'); 5 │ } i Expected an expression, or an assignment here. 1 │ // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions 2 │ > 3 │ function test(param = throw new Error('required!')) { │ ^^^^^ 4 │ const test = param === true || throw new Error('Falsy!'); 5 │ } throw-expressions.js:3:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `,` but instead found `Error` 1 │ // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions 2 │ > 3 │ function test(param = throw new Error('required!')) { │ ^^^^^ 4 │ const test = param === true || throw new Error('Falsy!'); 5 │ } i Remove Error throw-expressions.js:3:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected `,` but instead found `(` 1 │ // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions 2 │ > 3 │ function test(param = throw new Error('required!')) { │ ^ 4 │ const test = param === true || throw new Error('Falsy!'); 5 │ } i Remove ( throw-expressions.js:3:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected a function body but instead found ')'. 1 │ // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions 2 │ > 3 │ function test(param = throw new Error('required!')) { │ ^ 4 │ const test = param === true || throw new Error('Falsy!'); 5 │ } i Expected a function body here. 1 │ // https://babeljs.io/docs/en/babel-plugin-proposal-throw-expressions 2 │ > 3 │ function test(param = throw new Error('required!')) { │ ^ 4 │ const test = param === true || throw new Error('Falsy!'); 5 │ } throw-expressions.js:4:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Expected an expression but instead found 'throw'. 3 │ function test(param = throw new Error('required!')) { > 4 │ const test = param === true || throw new Error('Falsy!'); │ ^^^^^ 5 │ } 6 │ i Expected an expression here. 3 │ function test(param = throw new Error('required!')) { > 4 │ const test = param === true || throw new Error('Falsy!'); │ ^^^^^ 5 │ } 6 │ ```