--- source: crates/rome_formatter_test/src/snapshot_builder.rs info: test_file: 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 +++ Rome @@ -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 │ ```