diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrays/holes-in-args.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrays/holes-in-args.js.snap index 8e5a3d9b92c..771c2c28b1d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/arrays/holes-in-args.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrays/holes-in-args.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/arrays/holes-in-args.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrays/numbers-negative.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrays/numbers-negative.js.snap index c91476bb41a..a694cf3dd0a 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/arrays/numbers-negative.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrays/numbers-negative.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/arrays/numbers-negative.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow-chain-with-trailing-comments.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow-chain-with-trailing-comments.js new file mode 100644 index 00000000000..e5fc477363f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow-chain-with-trailing-comments.js @@ -0,0 +1,9 @@ +x = (bifornCringerMoshedPerplexSawder) => ((askTrovenaBeenaDependsRowans, glimseGlyphsHazardNoopsTieTie) => (f00) => { + averredBathersBoxroomBuggyNurl(); +} // BOOM +) + +x2 = (a) => ((askTrovenaBeenaDependsRowans1, askTrovenaBeenaDependsRowans2, askTrovenaBeenaDependsRowans3) => { + c(); +} /* ! */ // KABOOM +) diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow-chain-with-trailing-comments.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow-chain-with-trailing-comments.js.prettier-snap new file mode 100644 index 00000000000..beba7505e25 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow-chain-with-trailing-comments.js.prettier-snap @@ -0,0 +1,16 @@ +x = + (bifornCringerMoshedPerplexSawder) => + (askTrovenaBeenaDependsRowans, glimseGlyphsHazardNoopsTieTie) => + (f00) => { + averredBathersBoxroomBuggyNurl(); + }; // BOOM + +x2 = + (a) => + ( + askTrovenaBeenaDependsRowans1, + askTrovenaBeenaDependsRowans2, + askTrovenaBeenaDependsRowans3, + ) => { + c(); + } /* ! */; // KABOOM diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js new file mode 100644 index 00000000000..d2215a73bb0 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js @@ -0,0 +1,34 @@ +(a => {}).length +typeof (() => {}); +export default (() => {})(); +(() => {})()``; +(() => {})``; +new (() => {}); +if ((() => {}) ? 1 : 0) {} +let f = () => ({}()) +let a = () => ({} instanceof a); +a = () => ({} && a); +a = () => ({}() && a); +a = () => ({} && a && b); +a = () => ({} + a); +a = () => ({}()() && a); +a = () => ({}.b && a); +a = () => ({}[b] && a); +a = () => ({}`` && a); +a = () => ({} = 0); +a = () => ({}, a); +a => a instanceof {}; +a => ({}().b && 0) +a => ({}().c = 0) +x => ({}()()) +x => ({}()``) +x => ({}().b); +a = b => c; +x => (y = z); +x => (y += z); +f(a => ({})) + 1; +(a => ({})) || 0; +a = b => c; +a = b => { + return c +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js.prettier-snap new file mode 100644 index 00000000000..b30b8e02c63 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js.prettier-snap @@ -0,0 +1,35 @@ +((a) => {}).length; +typeof (() => {}); +export default (() => {})(); +(() => {})()``; +(() => {})``; +new (() => {})(); +if ((() => {}) ? 1 : 0) { +} +let f = () => ({}()); +let a = () => ({} instanceof a); +a = () => ({} && a); +a = () => ({}() && a); +a = () => ({} && a && b); +a = () => ({} + a); +a = () => ({}()() && a); +a = () => ({}.b && a); +a = () => ({}[b] && a); +a = () => ({}`` && a); +a = () => ({} = 0); +a = () => ({}, a); +(a) => a instanceof {}; +(a) => ({}().b && 0); +(a) => ({}().c = 0); +(x) => ({}()()); +(x) => ({}()``); +(x) => ({}().b); +a = (b) => c; +(x) => (y = z); +(x) => (y += z); +f((a) => ({})) + 1; +((a) => ({})) || 0; +a = (b) => c; +a = (b) => { + return c; +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js.snap new file mode 100644 index 00000000000..dcaee2cf2e9 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/arrow_function_expression.js.snap @@ -0,0 +1,136 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/arrows/arrow_function_expression.js +--- + +# Input + +```js +(a => {}).length +typeof (() => {}); +export default (() => {})(); +(() => {})()``; +(() => {})``; +new (() => {}); +if ((() => {}) ? 1 : 0) {} +let f = () => ({}()) +let a = () => ({} instanceof a); +a = () => ({} && a); +a = () => ({}() && a); +a = () => ({} && a && b); +a = () => ({} + a); +a = () => ({}()() && a); +a = () => ({}.b && a); +a = () => ({}[b] && a); +a = () => ({}`` && a); +a = () => ({} = 0); +a = () => ({}, a); +a => a instanceof {}; +a => ({}().b && 0) +a => ({}().c = 0) +x => ({}()()) +x => ({}()``) +x => ({}().b); +a = b => c; +x => (y = z); +x => (y += z); +f(a => ({})) + 1; +(a => ({})) || 0; +a = b => c; +a = b => { + return c +}; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -6,24 +6,24 @@ + new (() => {})(); + if ((() => {}) ? 1 : 0) { + } +-let f = () => ({}()); +-let a = () => ({} instanceof a); +-a = () => ({} && a); +-a = () => ({}() && a); +-a = () => ({} && a && b); +-a = () => ({} + a); +-a = () => ({}()() && a); +-a = () => ({}.b && a); +-a = () => ({}[b] && a); +-a = () => ({}`` && a); ++let f = () => ({})(); ++let a = () => ({}) instanceof a; ++a = () => ({}) && a; ++a = () => ({})() && a; ++a = () => ({}) && a && b; ++a = () => ({}) + a; ++a = () => ({})()() && a; ++a = () => ({}).b && a; ++a = () => ({})[b] && a; ++a = () => ({})`` && a; + a = () => ({} = 0); +-a = () => ({}, a); ++a = () => (({}), a); + (a) => a instanceof {}; +-(a) => ({}().b && 0); +-(a) => ({}().c = 0); +-(x) => ({}()()); +-(x) => ({}()``); +-(x) => ({}().b); ++(a) => ({})().b && 0; ++(a) => (({})().c = 0); ++(x) => ({})()(); ++(x) => ({})()``; ++(x) => ({})().b; + a = (b) => c; + (x) => (y = z); + (x) => (y += z); +``` + +# Output + +```js +((a) => {}).length; +typeof (() => {}); +export default (() => {})(); +(() => {})()``; +(() => {})``; +new (() => {})(); +if ((() => {}) ? 1 : 0) { +} +let f = () => ({})(); +let a = () => ({}) instanceof a; +a = () => ({}) && a; +a = () => ({})() && a; +a = () => ({}) && a && b; +a = () => ({}) + a; +a = () => ({})()() && a; +a = () => ({}).b && a; +a = () => ({})[b] && a; +a = () => ({})`` && a; +a = () => ({} = 0); +a = () => (({}), a); +(a) => a instanceof {}; +(a) => ({})().b && 0; +(a) => (({})().c = 0); +(x) => ({})()(); +(x) => ({})()``; +(x) => ({})().b; +a = (b) => c; +(x) => (y = z); +(x) => (y += z); +f((a) => ({})) + 1; +((a) => ({})) || 0; +a = (b) => c; +a = (b) => { + return c; +}; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/assignment-chain-with-arrow-chain.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/assignment-chain-with-arrow-chain.js new file mode 100644 index 00000000000..508e6b51a70 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/assignment-chain-with-arrow-chain.js @@ -0,0 +1,44 @@ +bifornCringer = askTrovenaBeenaDepends = glimseGlyphs = ( + argumentOne, + argumentTwo, +) => restOfTheArguments12345678 => { + return "baz"; +}; + +bifornCringer = askTrovenaBeenaDepends = glimseGlyphs = ( + argumentOne, + argumentTwo, + argumentThree +) => restOfTheArguments12345678 => { + return "baz"; +}; + +bifornCringer = askTrovenaBeenaDepends = glimseGlyphs = ( + argumentOne, + argumentTwo, + argumentThree +) => { + return "baz"; +}; + +const bifornCringer1 = + askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo) => (restOfTheArguments12345678) => { + return "baz"; + }; + +const bifornCringer2 = + askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo, argumentThree) => + (restOfTheArguments12345678) => { + return "baz"; + }; + +const bifornCringer3 = + askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo, argumentThree) => { + return "baz"; + }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/assignment-chain-with-arrow-chain.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/assignment-chain-with-arrow-chain.js.prettier-snap new file mode 100644 index 00000000000..6a47e9f2717 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/assignment-chain-with-arrow-chain.js.prettier-snap @@ -0,0 +1,43 @@ +bifornCringer = + askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo) => (restOfTheArguments12345678) => { + return "baz"; + }; + +bifornCringer = + askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo, argumentThree) => + (restOfTheArguments12345678) => { + return "baz"; + }; + +bifornCringer = + askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo, argumentThree) => { + return "baz"; + }; + +const bifornCringer1 = + (askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo) => (restOfTheArguments12345678) => { + return "baz"; + }); + +const bifornCringer2 = + (askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo, argumentThree) => + (restOfTheArguments12345678) => { + return "baz"; + }); + +const bifornCringer3 = + (askTrovenaBeenaDepends = + glimseGlyphs = + (argumentOne, argumentTwo, argumentThree) => { + return "baz"; + }); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/block_like.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/block_like.js new file mode 100644 index 00000000000..a40f53265f6 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/block_like.js @@ -0,0 +1 @@ +a = () => ({} = this); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/block_like.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/block_like.js.prettier-snap new file mode 100644 index 00000000000..a40f53265f6 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/block_like.js.prettier-snap @@ -0,0 +1 @@ +a = () => ({} = this); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/call.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/call.js new file mode 100644 index 00000000000..3e3c38ec820 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/call.js @@ -0,0 +1,398 @@ +Seq(typeDef.interface.groups).forEach(group => + Seq(group.members).forEach((member, memberName) => + markdownDoc( + member.doc, + { typePath: typePath.concat(memberName.slice(1)), + signatures: member.signatures } + ) + ) +) + +const promiseFromCallback = fn => + new Promise((resolve, reject) => + fn((err, result) => { + if (err) return reject(err); + return resolve(result); + }) + ); + +runtimeAgent.getProperties( + objectId, + false, // ownProperties + false, // accessorPropertiesOnly + false, // generatePreview + (error, properties, internalProperties) => { + return 1 + }, +); + +function render() { + return ( + + this.setState({progress: Math.round(100 * e.nativeEvent.loaded / e.nativeEvent.total)})} + /> + + ); +} + +function render() { + return ( + + + this.setState({ + progress: Math.round( + 100 * e.nativeEvent.loaded / e.nativeEvent.total, + ), + })} + /> + + ); +} + +function render() { + return ( + + + this.setState({ + progress: Math.round( + 100 * e.nativeEvent.loaded / e.nativeEvent.total, + ), + })} + /> + + ); +} + +jest.mock( + '../SearchSource', + () => class { + findMatchingTests(pattern) { + return {paths: []}; + } + }, +); + +fooooooooooooooooooooooooooooooooooooooooooooooooooo(action => next => + dispatch(action), +); + +foo( + ({ + a, + + b + }) => {} +); + +foo( + ({ + a, + b + + }) => {} +); + +foo( + ({ + a, + b + }) => {} +); + +foo( + a, + ({ + a, + + b + }) => {} +) + +foo( + ({ + a, + + b + }) => a +); + +foo( + ({ + a, + b + }) => a +); + +foo( + ({ + a, + b + + }) => a +); + +foo( + ({ + a: { + a, + + b + } + }) => {} +); + +foo( + ({ + a: { + b: { + c, + + d + } + } + }) => {} +); + +foo( + ({ + a: { + b: { + c: { + d, + + e + } + } + } + }) => {} +); + +foo( + ({ + a: { + a, + + b + } + }) => a +); + +foo( + ({ + a: { + b: { + c, + + d + } + } + }) => a +); + +foo( + ({ + a: { + b: { + c: { + d, + + e + } + } + } + }) => a +); + +foo( + ([ + { + a: { + b: { + c: { + d, + + e + } + } + } + } + ]) => {} +); + +foo( + ([ + ...{ + a: { + b: { + c: { + d, + + e + } + } + } + } + ]) => {} +); + +foo( + ( + n = { + a: { + b: { + c: { + d, + + e + } + } + } + } + ) => {} +); + +foo( + ({ + x: [ + { + a, + + b + } + ] + }) => {} +); + +foo( + ( + a = [ + { + a, + + b + } + ] + ) => a +); + +foo( + ([ + [ + { + a, + + b + } + ] + ]) => {} +); + +foo( + ([ + [ + [ + [ + { + a, + b: { + c, + d: { + e, + + f + } + } + } + ] + ] + ] + ]) => {} +); + +foo( + ( + ...{ + a, + + b + } + ) => {} +); + +foo( + ( + ...[ + { + a, + + b + } + ] + ) => {} +); + +foo( + ([ + ...[ + { + a, + + b + } + ] + ]) => {} +); + +foo( + ( + a = [{ + a, + + b + }] + ) => {} +); + +foo( + ( + a = (({ + a, + + b + }) => {})() + ) => {} +); + +foo( + ( + a = f({ + a, + + b + }) + ) => {} +); + +foo( + ( + a = ({ + a, + + b + }) => {} + ) => {} +); + +foo( + ( + a = 1 + + f({ + a, + + b + }) + ) => {} +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/call.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/call.js.prettier-snap new file mode 100644 index 00000000000..4da688604be --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/call.js.prettier-snap @@ -0,0 +1,386 @@ +Seq(typeDef.interface.groups).forEach((group) => + Seq(group.members).forEach((member, memberName) => + markdownDoc(member.doc, { + typePath: typePath.concat(memberName.slice(1)), + signatures: member.signatures, + }), + ), +); + +const promiseFromCallback = (fn) => + new Promise((resolve, reject) => + fn((err, result) => { + if (err) return reject(err); + return resolve(result); + }), + ); + +runtimeAgent.getProperties( + objectId, + false, // ownProperties + false, // accessorPropertiesOnly + false, // generatePreview + (error, properties, internalProperties) => { + return 1; + }, +); + +function render() { + return ( + + + this.setState({ + progress: Math.round( + (100 * e.nativeEvent.loaded) / e.nativeEvent.total, + ), + }) + } + /> + + ); +} + +function render() { + return ( + + + this.setState({ + progress: Math.round( + (100 * e.nativeEvent.loaded) / e.nativeEvent.total, + ), + }) + } + /> + + ); +} + +function render() { + return ( + + + this.setState({ + progress: Math.round( + (100 * e.nativeEvent.loaded) / e.nativeEvent.total, + ), + }) + } + /> + + ); +} + +jest.mock( + "../SearchSource", + () => + class { + findMatchingTests(pattern) { + return { paths: [] }; + } + }, +); + +fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => (next) => dispatch(action), +); + +foo( + ({ + a, + + b, + }) => {}, +); + +foo(({ a, b }) => {}); + +foo(({ a, b }) => {}); + +foo( + a, + ({ + a, + + b, + }) => {}, +); + +foo( + ({ + a, + + b, + }) => a, +); + +foo(({ a, b }) => a); + +foo(({ a, b }) => a); + +foo( + ({ + a: { + a, + + b, + }, + }) => {}, +); + +foo( + ({ + a: { + b: { + c, + + d, + }, + }, + }) => {}, +); + +foo( + ({ + a: { + b: { + c: { + d, + + e, + }, + }, + }, + }) => {}, +); + +foo( + ({ + a: { + a, + + b, + }, + }) => a, +); + +foo( + ({ + a: { + b: { + c, + + d, + }, + }, + }) => a, +); + +foo( + ({ + a: { + b: { + c: { + d, + + e, + }, + }, + }, + }) => a, +); + +foo( + ([ + { + a: { + b: { + c: { + d, + + e, + }, + }, + }, + }, + ]) => {}, +); + +foo( + ([ + ...{ + a: { + b: { + c: { + d, + + e, + }, + }, + }, + } + ]) => {}, +); + +foo( + ( + n = { + a: { + b: { + c: { + d, + + e, + }, + }, + }, + }, + ) => {}, +); + +foo( + ({ + x: [ + { + a, + + b, + }, + ], + }) => {}, +); + +foo( + ( + a = [ + { + a, + + b, + }, + ], + ) => a, +); + +foo( + ([ + [ + { + a, + + b, + }, + ], + ]) => {}, +); + +foo( + ([ + [ + [ + [ + { + a, + b: { + c, + d: { + e, + + f, + }, + }, + }, + ], + ], + ], + ]) => {}, +); + +foo( + ( + ...{ + a, + + b, + } + ) => {}, +); + +foo( + ( + ...[ + { + a, + + b, + }, + ] + ) => {}, +); + +foo( + ([ + ...[ + { + a, + + b, + }, + ] + ]) => {}, +); + +foo( + ( + a = [ + { + a, + + b, + }, + ], + ) => {}, +); + +foo( + ( + a = (({ + a, + + b, + }) => {})(), + ) => {}, +); + +foo( + ( + a = f({ + a, + + b, + }), + ) => {}, +); + +foo( + ( + a = ({ + a, + + b, + }) => {}, + ) => {}, +); + +foo( + ( + a = 1 + + f({ + a, + + b, + }), + ) => {}, +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/comment.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/comment.js new file mode 100644 index 00000000000..66b10122963 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/comment.js @@ -0,0 +1,30 @@ +/** + * Curried function that ends with a BEM CSS Selector + * + * @param {String} block - the BEM Block you'd like to select. + * @returns {Function} + */ +export const bem = block => + /** + * @param {String} [element] - the BEM Element within that block; if undefined, selects the block itself. + * @returns {Function} + */ + element => + /** + * @param {?String} [modifier] - the BEM Modifier for the Block or Element; if undefined, selects the Block or Element unmodified. + * @returns {String} + */ + modifier => + [ + ".", + css(block), + element ? `__${css(element)}` : "", + modifier ? `--${css(modifier)}` : "" + ].join(""); + + {info.item.widget.missingProp}} + data={data} +/> diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/comment.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/comment.js.prettier-snap new file mode 100644 index 00000000000..2f1ac32f6e2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/comment.js.prettier-snap @@ -0,0 +1,31 @@ +/** + * Curried function that ends with a BEM CSS Selector + * + * @param {String} block - the BEM Block you'd like to select. + * @returns {Function} + */ +export const bem = + (block) => + /** + * @param {String} [element] - the BEM Element within that block; if undefined, selects the block itself. + * @returns {Function} + */ + (element) => + /** + * @param {?String} [modifier] - the BEM Modifier for the Block or Element; if undefined, selects the Block or Element unmodified. + * @returns {String} + */ + (modifier) => + [ + ".", + css(block), + element ? `__${css(element)}` : "", + modifier ? `--${css(modifier)}` : "", + ].join(""); + + {info.item.widget.missingProp}} + data={data} +/>; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js new file mode 100644 index 00000000000..b65ca394e7b --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js @@ -0,0 +1,208 @@ +const fn1 = a => 3; +const fn2 = a => b => 3; +const fn3 = a => b => c => 3; +const fn4 = a => b => c => d => 3; +const fn5 = a => b => c => d => e => 3; +const fn6 = a => b => c => d => e => g => 3; +const fn7 = a => b => c => d => e => g => f => 3; + +const fn8 = a => ({ foo: bar, bar: baz, baz: foo }); +const fn9 = a => b => ({ foo: bar, bar: baz, baz: foo }); +const fn10 = a => b => c => ({ foo: bar, bar: baz, baz: foo }); +const fn11 = a => b => c => d => ({ foo: bar, bar: baz, baz: foo }); +const fn12 = a => b => c => d => e => ({ foo: bar, bar: baz, baz: foo }); +const fn13 = a => b => c => d => e => g => ({ foo: bar, bar: baz, baz: foo }); +const fn14 = a => b => c => d => e => g => f => ({ foo: bar, bar: baz, baz: foo }); + +const curryTest = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => + ({ + foo: argument1, + bar: argument2, + }); + +let curryTest2 = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +curryTest2 = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +throw (argument1) => +(argument2) => +(argument3) => +(argument4) => +(argument5) => +(argument6) => +(argument7) => +(argument8) => +(argument9) => +(argument10) => +(argument11) => +(argument12) => { + const foo = "foo"; + return foo + "bar"; +}; + +foo((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => 3); + +foo((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: bar, + bar: baz, + baz: foo + })); + +foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + } +); + +((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => 3)(3); + +bar( + foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: bar, + bar: baz, + }) + ) +); + +const baaaz = (aaaaa1, bbbbb1) => (aaaaa2, bbbbb2) => (aaaaa3, bbbbb3) => (aaaaa4, bbbbb4) => ({ + foo: bar +}); + +new Fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => + (next) => + (next) => + (next) => + (next) => + (next) => + (next) => + dispatch(action) +); + +foo?.Fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => + (next) => + (next) => + (next) => + (next) => + (next) => + (next) => + dispatch(action) +); + +foo(action => action => action); + +import( (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js.prettier-snap new file mode 100644 index 00000000000..8c416992d79 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js.prettier-snap @@ -0,0 +1,221 @@ +const fn1 = (a) => 3; +const fn2 = (a) => (b) => 3; +const fn3 = (a) => (b) => (c) => 3; +const fn4 = (a) => (b) => (c) => (d) => 3; +const fn5 = (a) => (b) => (c) => (d) => (e) => 3; +const fn6 = (a) => (b) => (c) => (d) => (e) => (g) => 3; +const fn7 = (a) => (b) => (c) => (d) => (e) => (g) => (f) => 3; + +const fn8 = (a) => ({ foo: bar, bar: baz, baz: foo }); +const fn9 = (a) => (b) => ({ foo: bar, bar: baz, baz: foo }); +const fn10 = (a) => (b) => (c) => ({ foo: bar, bar: baz, baz: foo }); +const fn11 = (a) => (b) => (c) => (d) => ({ foo: bar, bar: baz, baz: foo }); +const fn12 = (a) => (b) => (c) => (d) => (e) => ({ + foo: bar, + bar: baz, + baz: foo, +}); +const fn13 = (a) => (b) => (c) => (d) => (e) => (g) => ({ + foo: bar, + bar: baz, + baz: foo, +}); +const fn14 = (a) => (b) => (c) => (d) => (e) => (g) => (f) => ({ + foo: bar, + bar: baz, + baz: foo, +}); + +const curryTest = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: argument1, + bar: argument2, + }); + +let curryTest2 = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +curryTest2 = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +throw (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => + 3, +); + +foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: bar, + bar: baz, + baz: foo, + }), +); + +foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }, +); + +( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => + 3 +)(3); + +bar( + foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: bar, + bar: baz, + }), + ), +); + +const baaaz = + (aaaaa1, bbbbb1) => + (aaaaa2, bbbbb2) => + (aaaaa3, bbbbb3) => + (aaaaa4, bbbbb4) => ({ + foo: bar, + }); + +new Fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => (next) => (next) => (next) => (next) => (next) => (next) => + dispatch(action), +); + +foo?.Fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => (next) => (next) => (next) => (next) => (next) => (next) => + dispatch(action), +); + +foo((action) => (action) => action); + +import( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + } +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js.snap new file mode 100644 index 00000000000..3d55c89bce2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/curried.js.snap @@ -0,0 +1,596 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/arrows/curried.js +--- + +# Input + +```js +const fn1 = a => 3; +const fn2 = a => b => 3; +const fn3 = a => b => c => 3; +const fn4 = a => b => c => d => 3; +const fn5 = a => b => c => d => e => 3; +const fn6 = a => b => c => d => e => g => 3; +const fn7 = a => b => c => d => e => g => f => 3; + +const fn8 = a => ({ foo: bar, bar: baz, baz: foo }); +const fn9 = a => b => ({ foo: bar, bar: baz, baz: foo }); +const fn10 = a => b => c => ({ foo: bar, bar: baz, baz: foo }); +const fn11 = a => b => c => d => ({ foo: bar, bar: baz, baz: foo }); +const fn12 = a => b => c => d => e => ({ foo: bar, bar: baz, baz: foo }); +const fn13 = a => b => c => d => e => g => ({ foo: bar, bar: baz, baz: foo }); +const fn14 = a => b => c => d => e => g => f => ({ foo: bar, bar: baz, baz: foo }); + +const curryTest = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => + ({ + foo: argument1, + bar: argument2, + }); + +let curryTest2 = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +curryTest2 = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +throw (argument1) => +(argument2) => +(argument3) => +(argument4) => +(argument5) => +(argument6) => +(argument7) => +(argument8) => +(argument9) => +(argument10) => +(argument11) => +(argument12) => { + const foo = "foo"; + return foo + "bar"; +}; + +foo((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => 3); + +foo((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: bar, + bar: baz, + baz: foo + })); + +foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + } +); + +((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => 3)(3); + +bar( + foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: bar, + bar: baz, + }) + ) +); + +const baaaz = (aaaaa1, bbbbb1) => (aaaaa2, bbbbb2) => (aaaaa3, bbbbb3) => (aaaaa4, bbbbb4) => ({ + foo: bar +}); + +new Fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => + (next) => + (next) => + (next) => + (next) => + (next) => + (next) => + dispatch(action) +); + +foo?.Fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => + (next) => + (next) => + (next) => + (next) => + (next) => + (next) => + dispatch(action) +); + +foo(action => action => action); + +import( (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -109,42 +109,38 @@ + 3, + ); + +-foo( +- (argument1) => +- (argument2) => +- (argument3) => +- (argument4) => +- (argument5) => +- (argument6) => +- (argument7) => +- (argument8) => +- (argument9) => +- (argument10) => +- (argument11) => +- (argument12) => ({ +- foo: bar, +- bar: baz, +- baz: foo, +- }), +-); ++foo((argument1) => ++ (argument2) => ++ (argument3) => ++ (argument4) => ++ (argument5) => ++ (argument6) => ++ (argument7) => ++ (argument8) => ++ (argument9) => ++ (argument10) => ++ (argument11) => ++ (argument12) => ({ ++ foo: bar, ++ bar: baz, ++ baz: foo, ++ })); + +-foo( +- (argument1) => +- (argument2) => +- (argument3) => +- (argument4) => +- (argument5) => +- (argument6) => +- (argument7) => +- (argument8) => +- (argument9) => +- (argument10) => +- (argument11) => +- (argument12) => { +- const foo = "foo"; +- return foo + "bar"; +- }, +-); ++foo((argument1) => ++ (argument2) => ++ (argument3) => ++ (argument4) => ++ (argument5) => ++ (argument6) => ++ (argument7) => ++ (argument8) => ++ (argument9) => ++ (argument10) => ++ (argument11) => ++ (argument12) => { ++ const foo = "foo"; ++ return foo + "bar"; ++ }); + + ( + (argument1) => +@@ -163,23 +159,21 @@ + )(3); + + bar( +- foo( +- (argument1) => +- (argument2) => +- (argument3) => +- (argument4) => +- (argument5) => +- (argument6) => +- (argument7) => +- (argument8) => +- (argument9) => +- (argument10) => +- (argument11) => +- (argument12) => ({ +- foo: bar, +- bar: baz, +- }), +- ), ++ foo((argument1) => ++ (argument2) => ++ (argument3) => ++ (argument4) => ++ (argument5) => ++ (argument6) => ++ (argument7) => ++ (argument8) => ++ (argument9) => ++ (argument10) => ++ (argument11) => ++ (argument12) => ({ ++ foo: bar, ++ bar: baz, ++ })), + ); + + const baaaz = +@@ -202,20 +196,18 @@ + + foo((action) => (action) => action); + +-import( +- (argument1) => +- (argument2) => +- (argument3) => +- (argument4) => +- (argument5) => +- (argument6) => +- (argument7) => +- (argument8) => +- (argument9) => +- (argument10) => +- (argument11) => +- (argument12) => { +- const foo = "foo"; +- return foo + "bar"; +- } +-); ++import((argument1) => ++ (argument2) => ++ (argument3) => ++ (argument4) => ++ (argument5) => ++ (argument6) => ++ (argument7) => ++ (argument8) => ++ (argument9) => ++ (argument10) => ++ (argument11) => ++ (argument12) => { ++ const foo = "foo"; ++ return foo + "bar"; ++ }); +``` + +# Output + +```js +const fn1 = (a) => 3; +const fn2 = (a) => (b) => 3; +const fn3 = (a) => (b) => (c) => 3; +const fn4 = (a) => (b) => (c) => (d) => 3; +const fn5 = (a) => (b) => (c) => (d) => (e) => 3; +const fn6 = (a) => (b) => (c) => (d) => (e) => (g) => 3; +const fn7 = (a) => (b) => (c) => (d) => (e) => (g) => (f) => 3; + +const fn8 = (a) => ({ foo: bar, bar: baz, baz: foo }); +const fn9 = (a) => (b) => ({ foo: bar, bar: baz, baz: foo }); +const fn10 = (a) => (b) => (c) => ({ foo: bar, bar: baz, baz: foo }); +const fn11 = (a) => (b) => (c) => (d) => ({ foo: bar, bar: baz, baz: foo }); +const fn12 = (a) => (b) => (c) => (d) => (e) => ({ + foo: bar, + bar: baz, + baz: foo, +}); +const fn13 = (a) => (b) => (c) => (d) => (e) => (g) => ({ + foo: bar, + bar: baz, + baz: foo, +}); +const fn14 = (a) => (b) => (c) => (d) => (e) => (g) => (f) => ({ + foo: bar, + bar: baz, + baz: foo, +}); + +const curryTest = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: argument1, + bar: argument2, + }); + +let curryTest2 = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +curryTest2 = + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +throw (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }; + +foo( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => + 3, +); + +foo((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: bar, + bar: baz, + baz: foo, + })); + +foo((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }); + +( + (argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => + 3 +)(3); + +bar( + foo((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => ({ + foo: bar, + bar: baz, + })), +); + +const baaaz = + (aaaaa1, bbbbb1) => + (aaaaa2, bbbbb2) => + (aaaaa3, bbbbb3) => + (aaaaa4, bbbbb4) => ({ + foo: bar, + }); + +new Fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => (next) => (next) => (next) => (next) => (next) => (next) => + dispatch(action), +); + +foo?.Fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => (next) => (next) => (next) => (next) => (next) => (next) => + dispatch(action), +); + +foo((action) => (action) => action); + +import((argument1) => + (argument2) => + (argument3) => + (argument4) => + (argument5) => + (argument6) => + (argument7) => + (argument8) => + (argument9) => + (argument10) => + (argument11) => + (argument12) => { + const foo = "foo"; + return foo + "bar"; + }); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js new file mode 100644 index 00000000000..6c2c84e3a0e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js @@ -0,0 +1,15 @@ +const a = + (x) => (y) => (z) => + x / 0.123456789 + (y * calculateSomething(z)) / Math.PI; + +request.get('https://preview-9992--prettier.netlify.app', head => body => { + console.log(head, body); +}); + +request.get('https://preview-9992--prettier.netlify.app', head => body => mody => { + console.log(head, body); +}); + +request.get('https://preview-9992--prettier.netlify.app', head => body => modyLoremIpsumDolorAbstractProviderFactoryServiceModule => { + console.log(head, body); +}); \ No newline at end of file diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js.prettier-snap new file mode 100644 index 00000000000..b56d570face --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js.prettier-snap @@ -0,0 +1,22 @@ +const a = (x) => (y) => (z) => + x / 0.123456789 + (y * calculateSomething(z)) / Math.PI; + +request.get("https://preview-9992--prettier.netlify.app", (head) => (body) => { + console.log(head, body); +}); + +request.get( + "https://preview-9992--prettier.netlify.app", + (head) => (body) => (mody) => { + console.log(head, body); + }, +); + +request.get( + "https://preview-9992--prettier.netlify.app", + (head) => + (body) => + (modyLoremIpsumDolorAbstractProviderFactoryServiceModule) => { + console.log(head, body); + }, +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js.snap new file mode 100644 index 00000000000..08e159c0f48 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-2.js.snap @@ -0,0 +1,86 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/arrows/currying-2.js +--- + +# Input + +```js +const a = + (x) => (y) => (z) => + x / 0.123456789 + (y * calculateSomething(z)) / Math.PI; + +request.get('https://preview-9992--prettier.netlify.app', head => body => { + console.log(head, body); +}); + +request.get('https://preview-9992--prettier.netlify.app', head => body => mody => { + console.log(head, body); +}); + +request.get('https://preview-9992--prettier.netlify.app', head => body => modyLoremIpsumDolorAbstractProviderFactoryServiceModule => { + console.log(head, body); +});``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -5,18 +5,14 @@ + console.log(head, body); + }); + +-request.get( +- "https://preview-9992--prettier.netlify.app", +- (head) => (body) => (mody) => { ++request.get("https://preview-9992--prettier.netlify.app", (head) => ++ (body) => ++ (mody) => { + console.log(head, body); +- }, +-); ++ }); + +-request.get( +- "https://preview-9992--prettier.netlify.app", +- (head) => +- (body) => +- (modyLoremIpsumDolorAbstractProviderFactoryServiceModule) => { +- console.log(head, body); +- }, +-); ++request.get("https://preview-9992--prettier.netlify.app", (head) => ++ (body) => ++ (modyLoremIpsumDolorAbstractProviderFactoryServiceModule) => { ++ console.log(head, body); ++ }); +``` + +# Output + +```js +const a = (x) => (y) => (z) => + x / 0.123456789 + (y * calculateSomething(z)) / Math.PI; + +request.get("https://preview-9992--prettier.netlify.app", (head) => (body) => { + console.log(head, body); +}); + +request.get("https://preview-9992--prettier.netlify.app", (head) => + (body) => + (mody) => { + console.log(head, body); + }); + +request.get("https://preview-9992--prettier.netlify.app", (head) => + (body) => + (modyLoremIpsumDolorAbstractProviderFactoryServiceModule) => { + console.log(head, body); + }); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-3.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-3.js new file mode 100644 index 00000000000..e736adb95f2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-3.js @@ -0,0 +1,34 @@ +((b) => (c) => (d) => { + return 3; +})(x); + +function f( + a = (fooLorem) => (bazIpsum) => (barLorem) => { + return 3; + } +) {} + +( + (fooLoremIpsumFactory) => + (bazLoremIpsumFactory) => + (barLoremIpsumServiceFactory) => { + return 3; + } +)(x); + +( + (b) => (c) => (d) => + b + fooLoremIpsumFactory(c) - bazLoremIpsumFactory(b + d) +)(x, fooLoremIpsumFactory, fooLoremIpsumFactory); + +( + (fooLorem) => (bazIpsum) => (barLorem) => + b + fooLoremIpsumFactory(c) - bazLoremIpsumFactory(b + d) +)(boo); + +( + (fooLoremIpsumFactory) => + (bazLoremIpsumFactory) => + (barLoremIpsumServiceFactory) => + b + fooLoremIpsumFactory(c) - bazLoremIpsumFactory(b + d) +)(x); \ No newline at end of file diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-3.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-3.js.prettier-snap new file mode 100644 index 00000000000..3228cbc24f6 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying-3.js.prettier-snap @@ -0,0 +1,34 @@ +((b) => (c) => (d) => { + return 3; +})(x); + +function f( + a = (fooLorem) => (bazIpsum) => (barLorem) => { + return 3; + }, +) {} + +( + (fooLoremIpsumFactory) => + (bazLoremIpsumFactory) => + (barLoremIpsumServiceFactory) => { + return 3; + } +)(x); + +( + (b) => (c) => (d) => + b + fooLoremIpsumFactory(c) - bazLoremIpsumFactory(b + d) +)(x, fooLoremIpsumFactory, fooLoremIpsumFactory); + +( + (fooLorem) => (bazIpsum) => (barLorem) => + b + fooLoremIpsumFactory(c) - bazLoremIpsumFactory(b + d) +)(boo); + +( + (fooLoremIpsumFactory) => + (bazLoremIpsumFactory) => + (barLoremIpsumServiceFactory) => + b + fooLoremIpsumFactory(c) - bazLoremIpsumFactory(b + d) +)(x); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying.js new file mode 100644 index 00000000000..1e3b36d1f17 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying.js @@ -0,0 +1,17 @@ +const fn = b => c => d => { + return 3; +}; + +const foo = (a, b) => c => d => { + return 3; +}; + +const bar = a => b => c => a + b + c + +const mw = store => next => action => { + return next(action) +} + +const middleware = options => (req, res, next) => { + // ... +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying.js.prettier-snap new file mode 100644 index 00000000000..c84b56a56d5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/currying.js.prettier-snap @@ -0,0 +1,17 @@ +const fn = (b) => (c) => (d) => { + return 3; +}; + +const foo = (a, b) => (c) => (d) => { + return 3; +}; + +const bar = (a) => (b) => (c) => a + b + c; + +const mw = (store) => (next) => (action) => { + return next(action); +}; + +const middleware = (options) => (req, res, next) => { + // ... +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js new file mode 100644 index 00000000000..da1b8df9744 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js @@ -0,0 +1,22 @@ +const foobar = (argumentOne, argumentTwo, argumentThree) => + (...restOfTheArguments) => { + return "baz"; + }; + +const foobaz = (argumentOne, argumentTwo, argumentThree) => + (restOfTheArguments123, j) => { + return "baz"; + }; + + +const makeSomeFunction = + (services = {logger:null}) => + (a, b, c) => + services.logger(a,b,c) + +const makeSomeFunction2 = + (services = { + logger: null + }) => + (a, b, c) => + services.logger(a, b, c) diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js.prettier-snap new file mode 100644 index 00000000000..4c9b028cf7c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js.prettier-snap @@ -0,0 +1,24 @@ +const foobar = + (argumentOne, argumentTwo, argumentThree) => + (...restOfTheArguments) => { + return "baz"; + }; + +const foobaz = + (argumentOne, argumentTwo, argumentThree) => (restOfTheArguments123, j) => { + return "baz"; + }; + +const makeSomeFunction = + (services = { logger: null }) => + (a, b, c) => + services.logger(a, b, c); + +const makeSomeFunction2 = + ( + services = { + logger: null, + }, + ) => + (a, b, c) => + services.logger(a, b, c); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js.snap new file mode 100644 index 00000000000..8e74534c82e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-1389-curry.js.snap @@ -0,0 +1,90 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/arrows/issue-1389-curry.js +--- + +# Input + +```js +const foobar = (argumentOne, argumentTwo, argumentThree) => + (...restOfTheArguments) => { + return "baz"; + }; + +const foobaz = (argumentOne, argumentTwo, argumentThree) => + (restOfTheArguments123, j) => { + return "baz"; + }; + + +const makeSomeFunction = + (services = {logger:null}) => + (a, b, c) => + services.logger(a,b,c) + +const makeSomeFunction2 = + (services = { + logger: null + }) => + (a, b, c) => + services.logger(a, b, c) +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,6 +1,5 @@ + const foobar = +- (argumentOne, argumentTwo, argumentThree) => +- (...restOfTheArguments) => { ++ (argumentOne, argumentTwo, argumentThree) => (...restOfTheArguments) => { + return "baz"; + }; + +@@ -9,10 +8,8 @@ + return "baz"; + }; + +-const makeSomeFunction = +- (services = { logger: null }) => +- (a, b, c) => +- services.logger(a, b, c); ++const makeSomeFunction = (services = { logger: null }) => (a, b, c) => ++ services.logger(a, b, c); + + const makeSomeFunction2 = + ( +``` + +# Output + +```js +const foobar = + (argumentOne, argumentTwo, argumentThree) => (...restOfTheArguments) => { + return "baz"; + }; + +const foobaz = + (argumentOne, argumentTwo, argumentThree) => (restOfTheArguments123, j) => { + return "baz"; + }; + +const makeSomeFunction = (services = { logger: null }) => (a, b, c) => + services.logger(a, b, c); + +const makeSomeFunction2 = + ( + services = { + logger: null, + }, + ) => + (a, b, c) => + services.logger(a, b, c); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-4166-curry.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-4166-curry.js new file mode 100644 index 00000000000..c819e0a20a1 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-4166-curry.js @@ -0,0 +1,3 @@ +const myCurriedFn = arg1 => + arg2 => + arg3 => arg1 + arg2 + arg3; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-4166-curry.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-4166-curry.js.prettier-snap new file mode 100644 index 00000000000..14ffc723394 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/issue-4166-curry.js.prettier-snap @@ -0,0 +1 @@ +const myCurriedFn = (arg1) => (arg2) => (arg3) => arg1 + arg2 + arg3; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-call-no-args.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-call-no-args.js new file mode 100644 index 00000000000..8dcb17c8815 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-call-no-args.js @@ -0,0 +1 @@ +veryLongCall(VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_LONG_CONSTANT, () => {}) diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-call-no-args.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-call-no-args.js.prettier-snap new file mode 100644 index 00000000000..445df7a9d08 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-call-no-args.js.prettier-snap @@ -0,0 +1,4 @@ +veryLongCall( + VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_LONG_CONSTANT, + () => {}, +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-contents.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-contents.js new file mode 100644 index 00000000000..e4d78f580a1 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-contents.js @@ -0,0 +1,3 @@ +const foo = () => { + expect(arg1, arg2, arg3).toEqual({message: 'test', messageType: 'SMS', status: 'Unknown', created: '11/01/2017 13:36'}); +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-contents.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-contents.js.prettier-snap new file mode 100644 index 00000000000..ed025b8574c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/long-contents.js.prettier-snap @@ -0,0 +1,8 @@ +const foo = () => { + expect(arg1, arg2, arg3).toEqual({ + message: "test", + messageType: "SMS", + status: "Unknown", + created: "11/01/2017 13:36", + }); +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/parens.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/parens.js new file mode 100644 index 00000000000..33fc3771e0c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/parens.js @@ -0,0 +1,18 @@ +promise.then( + (result) => result, + (err) => err +) + +promise.then( + (result) => { f(); return result }, + (err) => { f(); return err } +) + +foo(a => b) +foo(a => { return b }) +foo(c, a => b) +foo(c, a => b, d) +foo(a => b, d) + +foo(a => (0, 1)); +foo(a => b => (0, 1)); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/parens.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/parens.js.prettier-snap new file mode 100644 index 00000000000..68cd57716e2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/parens.js.prettier-snap @@ -0,0 +1,26 @@ +promise.then( + (result) => result, + (err) => err, +); + +promise.then( + (result) => { + f(); + return result; + }, + (err) => { + f(); + return err; + }, +); + +foo((a) => b); +foo((a) => { + return b; +}); +foo(c, (a) => b); +foo(c, (a) => b, d); +foo((a) => b, d); + +foo((a) => (0, 1)); +foo((a) => (b) => (0, 1)); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/semi/semi.js b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/semi/semi.js new file mode 100644 index 00000000000..58a07e99aa4 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/semi/semi.js @@ -0,0 +1 @@ +a => {} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/arrows/semi/semi.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/semi/semi.js.prettier-snap new file mode 100644 index 00000000000..b906a7ab0b2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/arrows/semi/semi.js.prettier-snap @@ -0,0 +1 @@ +(a) => {}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decorator-auto-accessors.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decorator-auto-accessors.js.snap index c8dfd161e92..23d9f94a924 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decorator-auto-accessors.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decorator-auto-accessors.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\babel-plugins\\decorator-auto-accessors.js" + test_file: js/babel-plugins/decorator-auto-accessors.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/classes/binary.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/classes/binary.js.snap index 429f3ab709a..6101ec8ebde 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/classes/binary.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/classes/binary.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/classes/binary.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/classes/call.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/classes/call.js.snap index e060c9f4d92..e4d37ca55f4 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/classes/call.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/classes/call.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/classes/call.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/classes/member.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/classes/member.js.snap index 799a8ca5d1e..ac044e93bf9 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/classes/member.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/classes/member.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/classes/member.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/classes/ternary.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/classes/ternary.js.snap index c61d6eb97e9..0d345d2c63f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/classes/ternary.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/classes/ternary.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/classes/ternary.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/comments-closure-typecast/styled-components.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/comments-closure-typecast/styled-components.js.snap index 95bab75730e..730640e79e6 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/comments-closure-typecast/styled-components.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/comments-closure-typecast/styled-components.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/comments-closure-typecast/styled-components.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/comments/if.js b/crates/rome_js_formatter/tests/specs/prettier/js/comments/if.js index 47a58e1ed59..ff4043ec1a0 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/comments/if.js +++ b/crates/rome_js_formatter/tests/specs/prettier/js/comments/if.js @@ -43,11 +43,11 @@ else // comment if (10) /* comment */ // comment {true} else if (11) /* comment */ - true +true else if (12) // comment /* comment */ // comment - true +true else if (13) /* comment */ /* comment */ // comment - true +true else /* comment */ {true} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/comments/trailing_space.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/comments/trailing_space.js.snap index c5c2b1ff4cc..4869e66299e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/comments/trailing_space.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/comments/trailing_space.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/comments/trailing_space.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/basic.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/basic.js.snap index 9b2ca8557a3..54ea949ccde 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/basic.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/basic.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\decorator-auto-accessors\\basic.js" + test_file: js/decorator-auto-accessors/basic.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/computed.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/computed.js.snap index 46bb9a04313..659909bc7be 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/computed.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\decorator-auto-accessors\\computed.js" + test_file: js/decorator-auto-accessors/computed.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/private.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/private.js.snap index 0c29b88d8cf..76b97024006 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/private.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/private.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\decorator-auto-accessors\\private.js" + test_file: js/decorator-auto-accessors/private.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static-computed.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static-computed.js.snap index 89966ddec65..d67349bf8b7 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static-computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static-computed.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\decorator-auto-accessors\\static-computed.js" + test_file: js/decorator-auto-accessors/static-computed.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static-private.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static-private.js.snap index 96a8937402b..26212f5146e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static-private.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static-private.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\decorator-auto-accessors\\static-private.js" + test_file: js/decorator-auto-accessors/static-private.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static.js.snap index 7ab3f18e91d..08b9381db78 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/static.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\decorator-auto-accessors\\static.js" + test_file: js/decorator-auto-accessors/static.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/with-semicolon-1.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/with-semicolon-1.js.snap index a17604c7e08..c09a34a3181 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/with-semicolon-1.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/with-semicolon-1.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\decorator-auto-accessors\\with-semicolon-1.js" + test_file: js/decorator-auto-accessors/with-semicolon-1.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/with-semicolon-2.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/with-semicolon-2.js.snap index 9be8ad41a20..014d01174d6 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/with-semicolon-2.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/with-semicolon-2.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\decorator-auto-accessors\\with-semicolon-2.js" + test_file: js/decorator-auto-accessors/with-semicolon-2.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/methods.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/methods.js.snap index 6cd4198f3a0..0704b671230 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/methods.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/methods.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/decorators/methods.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiline.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiline.js.snap index 642b6a18b7a..3de678fd1cc 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiline.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiline.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/decorators/multiline.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap index f73e0486652..43b5c92d960 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/decorators/redux.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/destructuring/destructuring.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/destructuring/destructuring.js.snap index 67fcf321d0c..01a5c651ce7 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/destructuring/destructuring.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/destructuring/destructuring.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/destructuring/destructuring.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/end-of-line/example.js b/crates/rome_js_formatter/tests/specs/prettier/js/end-of-line/example.js new file mode 100644 index 00000000000..9f2e336489a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/end-of-line/example.js @@ -0,0 +1,3 @@ +function f() { + console.log("testing line endings"); +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/end-of-line/example.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/end-of-line/example.js.prettier-snap new file mode 100644 index 00000000000..9f2e336489a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/end-of-line/example.js.prettier-snap @@ -0,0 +1,3 @@ +function f() { + console.log("testing line endings"); +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/export-default/binary_and_template.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/export-default/binary_and_template.js.snap index 4322f88d229..e9407cda893 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/export-default/binary_and_template.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/export-default/binary_and_template.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/export-default/binary_and_template.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/export-default/body.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/export-default/body.js.snap index 36114ba0da4..534cbb3234f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/export-default/body.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/export-default/body.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/export-default/body.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/export-default/class_instance.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/export-default/class_instance.js.snap index 41e86369725..b18604c904f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/export-default/class_instance.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/export-default/class_instance.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/export-default/class_instance.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/export-default/function_tostring.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/export-default/function_tostring.js.snap index 60960dcdb45..07d6ee9dc7e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/export-default/function_tostring.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/export-default/function_tostring.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/export-default/function_tostring.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.prettier-snap index 8856b3df341..82cd20637b6 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.prettier-snap @@ -1,6 +1,7 @@ export { // a foo1, + // b bar1, baz1, @@ -13,6 +14,7 @@ const baz2 = 1; export { // a foo2, + // b bar2, baz2, diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.snap new file mode 100644 index 00000000000..b5e6907cef7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/export/blank-line-between-specifiers.js.snap @@ -0,0 +1,82 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/export/blank-line-between-specifiers.js +--- + +# Input + +```js +export { + // a + foo1, + + // b + bar1, + baz1, +} from "mod"; + +const foo2 = 1; +const bar2 = 1; +const baz2 = 1; + +export { + // a + foo2, + + // b + bar2, + baz2, +}; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,7 +1,6 @@ + export { + // a + foo1, +- + // b + bar1, + baz1, +@@ -14,7 +13,6 @@ + export { + // a + foo2, +- + // b + bar2, + baz2, +``` + +# Output + +```js +export { + // a + foo1, + // b + bar1, + baz1, +} from "mod"; + +const foo2 = 1; +const bar2 = 1; +const baz2 = 1; + +export { + // a + foo2, + // b + bar2, + baz2, +}; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/function/function_expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/function/function_expression.js.snap index da6cd76eff5..c4f07a60a25 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/function/function_expression.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/function/function_expression.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/function/function_expression.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/dynamic-import.js b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/dynamic-import.js new file mode 100644 index 00000000000..2411a524bf1 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/dynamic-import.js @@ -0,0 +1 @@ +import("./foo.json", { assert: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/dynamic-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/dynamic-import.js.prettier-snap new file mode 100644 index 00000000000..2411a524bf1 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/dynamic-import.js.prettier-snap @@ -0,0 +1 @@ +import("./foo.json", { assert: { type: "json" } }); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js new file mode 100644 index 00000000000..f6b005613c7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js @@ -0,0 +1 @@ +export * as bar from "bar.json" assert { } \ No newline at end of file diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.prettier-snap new file mode 100644 index 00000000000..349c495478a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.prettier-snap @@ -0,0 +1 @@ +export * as bar from "bar.json"; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.snap new file mode 100644 index 00000000000..bb83276535d --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/empty.js.snap @@ -0,0 +1,30 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/import-assertions/bracket-spacing/empty.js +--- + +# Input + +```js +export * as bar from "bar.json" assert { }``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1 @@ +-export * as bar from "bar.json"; ++export * as bar from "bar.json" assert {}; +``` + +# Output + +```js +export * as bar from "bar.json" assert {}; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js new file mode 100644 index 00000000000..d17c6989dd4 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js @@ -0,0 +1 @@ +export { default as foo2 } from "foo.json" assert { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js.prettier-snap new file mode 100644 index 00000000000..d17c6989dd4 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/re-export.js.prettier-snap @@ -0,0 +1 @@ +export { default as foo2 } from "foo.json" assert { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js new file mode 100644 index 00000000000..890e4290079 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js @@ -0,0 +1 @@ +import json from "./foo.json" assert { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js.prettier-snap new file mode 100644 index 00000000000..890e4290079 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/bracket-spacing/static-import.js.prettier-snap @@ -0,0 +1 @@ +import json from "./foo.json" assert { type: "json" }; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/empty.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/empty.js.snap index b45457add3e..9ed24d4ecc4 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/empty.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/import-assertions/empty.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/import-assertions/empty.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-11298.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-11298.js.snap index dafd3b544b1..d155c3d6619 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-11298.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-11298.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/method-chain/issue-11298.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/constructor.js b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/constructor.js new file mode 100644 index 00000000000..d7f368719fe --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/constructor.js @@ -0,0 +1,13 @@ +const writer = new BufferStackItem( + new BinaryWriter() + .writeUInt8(StackItemType.ByteArray) + .writeVarBytesLE(Buffer.alloc(10, 1)) + .toBuffer(), +); + +const writer2 = new BufferStackItem( + new Extra.BinaryWriter() + .writeUInt8(StackItemType.ByteArray) + .writeVarBytesLE(Buffer.alloc(10, 1)) + .toBuffer(), +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/constructor.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/constructor.js.prettier-snap new file mode 100644 index 00000000000..d7f368719fe --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/constructor.js.prettier-snap @@ -0,0 +1,13 @@ +const writer = new BufferStackItem( + new BinaryWriter() + .writeUInt8(StackItemType.ByteArray) + .writeVarBytesLE(Buffer.alloc(10, 1)) + .toBuffer(), +); + +const writer2 = new BufferStackItem( + new Extra.BinaryWriter() + .writeUInt8(StackItemType.ByteArray) + .writeVarBytesLE(Buffer.alloc(10, 1)) + .toBuffer(), +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/issue-7884.js b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/issue-7884.js new file mode 100644 index 00000000000..dabe0440d12 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/issue-7884.js @@ -0,0 +1,15 @@ + cy.get(".ready") + .should("have.text", "READY") + .should("have.css", "background-color", "rgb(136, 228, 229)"); + cy.get(".pending") + .should("have.text", "PENDING") + .should("have.css", "background-color", "rgb(253, 212, 90)"); + cy.get(".live") + .should("have.text", "LIVE") + .should("have.css", "background-color", "rgb(175, 221, 255)"); + cy.get(".draft") + .should("have.text", "DRAFT") + .should("have.css", "background-color", "rgb(255, 181, 181)"); + cy.get(".scheduled") + .should("have.text", "SCHEDULED") + .should("have.css", "background-color", "rgb(222, 222, 222)"); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/issue-7884.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/issue-7884.js.prettier-snap new file mode 100644 index 00000000000..a2079794c22 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/print-width-120/issue-7884.js.prettier-snap @@ -0,0 +1,15 @@ +cy.get(".ready") + .should("have.text", "READY") + .should("have.css", "background-color", "rgb(136, 228, 229)"); +cy.get(".pending") + .should("have.text", "PENDING") + .should("have.css", "background-color", "rgb(253, 212, 90)"); +cy.get(".live") + .should("have.text", "LIVE") + .should("have.css", "background-color", "rgb(175, 221, 255)"); +cy.get(".draft") + .should("have.text", "DRAFT") + .should("have.css", "background-color", "rgb(255, 181, 181)"); +cy.get(".scheduled") + .should("have.text", "SCHEDULED") + .should("have.css", "background-color", "rgb(222, 222, 222)"); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/colons-after-substitutions.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/colons-after-substitutions.js.snap index fe5907cdb4e..2e72d7253aa 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/colons-after-substitutions.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/colons-after-substitutions.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/colons-after-substitutions.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/colons-after-substitutions2.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/colons-after-substitutions2.js.snap index c8a49169a02..a4de65aa2a1 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/colons-after-substitutions2.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/colons-after-substitutions2.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/colons-after-substitutions2.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-2883.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-2883.js.snap index 8d65f8926ef..420104caa20 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-2883.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-2883.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/issue-2883.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-5961.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-5961.js.snap index 037f464c746..660631c5d12 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-5961.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-5961.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/issue-5961.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-9072.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-9072.js.snap index b47ec066828..a065984e09b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-9072.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/issue-9072.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/issue-9072.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/styled-components-multiple-expressions.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/styled-components-multiple-expressions.js.snap index 6cf262b261b..d641fd8363b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/styled-components-multiple-expressions.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/styled-components-multiple-expressions.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/styled-components-multiple-expressions.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/styled-components.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/styled-components.js.snap index 085a19e1672..6413e289291 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/styled-components.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/styled-components.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/styled-components.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/url.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/url.js.snap index a5a3c5a1173..3013e9828fc 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/url.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/url.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/url.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/var.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/var.js.snap index dcc96bad81d..3fb9f57b4da 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/var.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-css/var.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-css/var.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/comment-tag.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/comment-tag.js.snap index 4d06a20fd9f..2a2a0adcb82 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/comment-tag.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/comment-tag.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-graphql/comment-tag.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/escape.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/escape.js.snap index 770abdfe9cd..2fe1a85e2d6 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/escape.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/escape.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-graphql/escape.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/expressions.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/expressions.js.snap index 922f3aabd6a..e221f23393a 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/expressions.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/expressions.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-graphql/expressions.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/graphql-tag.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/graphql-tag.js.snap index f4c3b69504e..72a070c7293 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/graphql-tag.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/graphql-tag.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-graphql/graphql-tag.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/graphql.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/graphql.js.snap index 65fa47862ae..bb92fa66c00 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/graphql.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/graphql.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-graphql/graphql.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/react-relay.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/react-relay.js.snap index a48943a15e1..213319034cf 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/react-relay.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-graphql/react-relay.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-graphql/react-relay.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/html-template-literals.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/html-template-literals.js.snap index eb73d9696c7..acc6792ceca 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/html-template-literals.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/html-template-literals.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-html/html-template-literals.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/issue-10691.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/issue-10691.js.prettier-snap index 1bab33df273..2f99703d18c 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/issue-10691.js.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/issue-10691.js.prettier-snap @@ -1,7 +1,7 @@ export default function include_photoswipe(gallery_selector = ".my-gallery") { return /* HTML */ ` `; } diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/issue-10691.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/issue-10691.js.snap index ba4c37ae372..1808041f199 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/issue-10691.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/issue-10691.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-html/issue-10691.js --- # Input @@ -27,7 +29,7 @@ export default function include_photoswipe( export default function include_photoswipe(gallery_selector = ".my-gallery") { - return /* HTML */ ` `; + return /* HTML */ ` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/lit-html.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/lit-html.js.snap index 003bf398251..49cd2d89d04 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/lit-html.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-html/lit-html.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-html/lit-html.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/0-indent.js b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/0-indent.js new file mode 100644 index 00000000000..6968d9ecafb --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/0-indent.js @@ -0,0 +1,19 @@ +md` +This line shouldn't be indented at all in the resulting output. +` + +if (true) { + md` +text1 +- 123 + - 456 + +text2 +- 123 + - 456 + +text3 +- 123 + - 456 +`; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/0-indent.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/0-indent.js.prettier-snap new file mode 100644 index 00000000000..34710f8f574 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/0-indent.js.prettier-snap @@ -0,0 +1,19 @@ +md` +This line shouldn't be indented at all in the resulting output. +`; + +if (true) { + md` +text1 +- 123 + - 456 + +text2 +- 123 + - 456 + +text3 +- 123 + - 456 +`; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/codeblock.js b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/codeblock.js new file mode 100644 index 00000000000..f00c79d6d32 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/codeblock.js @@ -0,0 +1,9 @@ +md` +\`\`\`js +markdown\` + \\\`\\\`\\\`js + console.log('hi'); + \\\`\\\`\\\` +\` +\`\`\` +`; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/codeblock.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/codeblock.js.prettier-snap new file mode 100644 index 00000000000..f00c79d6d32 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/codeblock.js.prettier-snap @@ -0,0 +1,9 @@ +md` +\`\`\`js +markdown\` + \\\`\\\`\\\`js + console.log('hi'); + \\\`\\\`\\\` +\` +\`\`\` +`; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/escape.js b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/escape.js new file mode 100644 index 00000000000..9f603819f50 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/escape.js @@ -0,0 +1,14 @@ +markdown` + const cssString = css\` + background-color: \$\{color('base')\} + \`; +` + +markdown` + - \` + - \\\` + - \\ a + - \\\\ + - \$ + - \u1234 +` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/escape.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/escape.js.prettier-snap new file mode 100644 index 00000000000..e18b41babc3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/escape.js.prettier-snap @@ -0,0 +1,14 @@ +markdown` + const cssString = css\` + background-color: \$\{color('base')\} + \`; +`; + +markdown` + - \` + - \\\` + - \\ a + - \\\\ + - \$ + - \u1234 +`; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/issue-5021.js b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/issue-5021.js new file mode 100644 index 00000000000..80286473726 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/issue-5021.js @@ -0,0 +1,34 @@ +if (true) { + md` +text1 +- 123 + - 456 + +text2 +- 123 + - 456 + +text3 +- 123 + - 456 +`; +} + +if (true) { + md` +text1 + +- 123 + - 456 + +text2 + +- 123 + - 456 + +text3 + +- 123 + - 456 + `; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/issue-5021.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/issue-5021.js.prettier-snap new file mode 100644 index 00000000000..80286473726 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/issue-5021.js.prettier-snap @@ -0,0 +1,34 @@ +if (true) { + md` +text1 +- 123 + - 456 + +text2 +- 123 + - 456 + +text3 +- 123 + - 456 +`; +} + +if (true) { + md` +text1 + +- 123 + - 456 + +text2 + +- 123 + - 456 + +text3 + +- 123 + - 456 + `; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/markdown.js b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/markdown.js new file mode 100644 index 00000000000..e1488d87c8f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/markdown.js @@ -0,0 +1,16 @@ +export default function ReadMe() { + return md` + ## Why Prettier? + + ### Building and enforcing a style guide + + By far the biggest reason for adopting Prettier is to stop all the on-going debates over styles. It is generally accepted that having a common style guide is valuable for a project and team but getting there is a very painful and unrewarding process. People get very emotional around particular ways of writing code and nobody likes spending time writing and receiving nits. + - “We want to free mental threads and end discussions around style. While sometimes fruitful, these discussions are for the most part wasteful.” + - “Literally had an engineer go through a huge effort of cleaning up all of our code because we were debating ternary style for the longest time and were inconsistent about it. It was dumb, but it was a weird on-going "great debate" that wasted lots of little back and forth bits. It's far easier for us all to agree now: just run Prettier, and go with that style.” + - “Getting tired telling people how to style their product code.” + - “Our top reason was to stop wasting our time debating style nits.” + - “Having a githook set up has reduced the amount of style issues in PRs that result in broken builds due to ESLint rules or things I have to nit-pick or clean up later.” + - “I don't want anybody to nitpick any other person ever again.” + - “It reminds me of how Steve Jobs used to wear the same clothes every day because he has a million decisions to make and he didn't want to be bothered to make trivial ones like picking out clothes. I think Prettier is like that.” + `; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/markdown.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/markdown.js.prettier-snap new file mode 100644 index 00000000000..4e02246cb68 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/markdown.js.prettier-snap @@ -0,0 +1,16 @@ +export default function ReadMe() { + return md` + ## Why Prettier? + + ### Building and enforcing a style guide + + By far the biggest reason for adopting Prettier is to stop all the on-going debates over styles. It is generally accepted that having a common style guide is valuable for a project and team but getting there is a very painful and unrewarding process. People get very emotional around particular ways of writing code and nobody likes spending time writing and receiving nits. + - “We want to free mental threads and end discussions around style. While sometimes fruitful, these discussions are for the most part wasteful.” + - “Literally had an engineer go through a huge effort of cleaning up all of our code because we were debating ternary style for the longest time and were inconsistent about it. It was dumb, but it was a weird on-going "great debate" that wasted lots of little back and forth bits. It's far easier for us all to agree now: just run Prettier, and go with that style.” + - “Getting tired telling people how to style their product code.” + - “Our top reason was to stop wasting our time debating style nits.” + - “Having a githook set up has reduced the amount of style issues in PRs that result in broken builds due to ESLint rules or things I have to nit-pick or clean up later.” + - “I don't want anybody to nitpick any other person ever again.” + - “It reminds me of how Steve Jobs used to wear the same clothes every day because he has a million decisions to make and he didn't want to be bothered to make trivial ones like picking out clothes. I think Prettier is like that.” + `; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/single-line.js b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/single-line.js new file mode 100644 index 00000000000..3f4fde27d88 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/single-line.js @@ -0,0 +1 @@ +markdown`# hello` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/single-line.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/single-line.js.prettier-snap new file mode 100644 index 00000000000..212748aa32a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-markdown/single-line.js.prettier-snap @@ -0,0 +1 @@ +markdown`# hello`; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-text/text.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-text/text.js.snap index 689fb5ecdf2..d64f2a5eed0 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-text/text.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/multiparser-text/text.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/multiparser-text/text.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/no-semi/no-semi.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/no-semi/no-semi.js.snap index 0210e9278a5..f88c8b4924f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/no-semi/no-semi.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/no-semi/no-semi.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/no-semi/no-semi.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/object-colon-bug/bug.js b/crates/rome_js_formatter/tests/specs/prettier/js/object-colon-bug/bug.js new file mode 100644 index 00000000000..a49851145c5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/object-colon-bug/bug.js @@ -0,0 +1,4 @@ +const foo = { + bar: props.bar ? props.bar : noop, + baz: props.baz +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/object-colon-bug/bug.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/object-colon-bug/bug.js.prettier-snap new file mode 100644 index 00000000000..12644f3b9b5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/object-colon-bug/bug.js.prettier-snap @@ -0,0 +1,4 @@ +const foo = { + bar: props.bar ? props.bar : noop, + baz: props.baz, +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/objects/assignment-expression/object-property.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/objects/assignment-expression/object-property.js.snap index e1a660cf97a..07a0f73cee0 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/objects/assignment-expression/object-property.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/objects/assignment-expression/object-property.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/objects/assignment-expression/object-property.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/chaining.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/chaining.js.snap index fca4acfee44..582ad54aa53 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/chaining.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/chaining.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/optional-chaining/chaining.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/classes.js b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/classes.js new file mode 100644 index 00000000000..117447136f8 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/classes.js @@ -0,0 +1,17 @@ +class A { + a = "a" +}; + +class B { + 'b' = "b" +}; + +class C { + c1 = "c1" + 'c2' = "c2" +}; + +class D { + d1 = "d1" + 'd-2' = "d2" +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/classes.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/classes.js.prettier-snap new file mode 100644 index 00000000000..40164cabcd2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/classes.js.prettier-snap @@ -0,0 +1,17 @@ +class A { + a = "a"; +} + +class B { + b = "b"; +} + +class C { + c1 = "c1"; + c2 = "c2"; +} + +class D { + d1 = "d1"; + "d-2" = "d2"; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/numeric-separator.js b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/numeric-separator.js new file mode 100644 index 00000000000..e382f3f0fbc --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/numeric-separator.js @@ -0,0 +1,6 @@ +a = { + + 0xb_b: '0xb_b', // 187 + 0xb_b_bn: '0xb_b_bn', // 3003 + 0b100000000000_000000000000000011n: '0b100000000000_000000000000000011n' // 536870915 +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/numeric-separator.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/numeric-separator.js.prettier-snap new file mode 100644 index 00000000000..04cde506d4d --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/numeric-separator.js.prettier-snap @@ -0,0 +1,5 @@ +a = { + 0xb_b: "0xb_b", // 187 + 0xb_b_bn: "0xb_b_bn", // 3003 + 0b100000000000_000000000000000011n: "0b100000000000_000000000000000011n", // 536870915 +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js new file mode 100644 index 00000000000..1320543c4bf --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js @@ -0,0 +1,97 @@ +const a = { + a: "a" +}; + +const b = { + 'b': "b" +}; + +const b2 = { + // Escapes should stay as escapes and not be unquoted. + '\u0062': "b", + '\u0031': "1" +}; + +const c = { + c1: "c1", + 'c2': "c2" +}; + +const d = { + d1: "d1", + 'd-2': "d2" +}; + +// None of these should become quoted, regardless of the quoteProps value. +const e = { + NaN: null, + 1: null, + 1.5: null, + .1: null, + 1.: null, + 1.0: null, + 999999999999999999999: null, + 0.99999999999999999: null, + 1E2: null, + 1e+3: null, + 1e+100: null, + 0b10: null, + 0o10: null, + 0xf: null, + 2n: null, +} + +const f = { + // These should be unquoted for quoteProps=as-needed. + "NaN": null, + "1": null, + "1.5": null, + // These should never be unquoted. `1e+100` technically could (it’s the only + // one where `String(Number(key)) === key`), but we came to the conclusion + // that it is unexpected. + ".1": null, + "1.": null, + "1.0": null, + "999999999999999999999": null, + "0.99999999999999999": null, + "1E2": null, + "1e+3": null, + "1e+100": null, + "0b10": null, + "0o10": null, + "0xf": null, + "2n": null, +} + +Object.entries({ + // To force quotes for quoteProps=consistent. + 'a-': 'a-', + // These can be quoted: + NaN: 'NaN', + 1: '1', + 1.5: '1.5', + // Prettier will normalize these to `0.1` and `1` – then they can be quoted. + .1: '.1', + 1.: '1.', + // These should never be quoted. The _actual_ keys are shown as comments. + // Copy-paste this into the console to verify. If we were to convert these + // numbers into decimal (which completely valid), “information/intent” is + // lost. Either way, writing code like this is super confusing. + 1.0: '1.0', // 1 + 999999999999999999999: '999999999999999999999', // 1e+21 + 0.99999999999999999: '0.99999999999999999', // 1 + 1E2: '1E2', // 100 + 1e+3: '1e+3', // 1000 + 1e+100: '1e+100', // 1e+100 – this one is identical, but would be inconsistent to quote. + 0b10: '0b10', // 2 + 0o10: '0o10', // 8 + 0xf: '0xf', // 15 + 2n: '2n', // 2 + 0xan: '0xan', // 10 +}) + +// Negative numbers cannot be unquoted. +!{ + "-1": null, + "-1.5": null, +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js.prettier-snap new file mode 100644 index 00000000000..cdc29e05a38 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js.prettier-snap @@ -0,0 +1,97 @@ +const a = { + a: "a", +}; + +const b = { + b: "b", +}; + +const b2 = { + // Escapes should stay as escapes and not be unquoted. + "\u0062": "b", + "\u0031": "1", +}; + +const c = { + c1: "c1", + c2: "c2", +}; + +const d = { + d1: "d1", + "d-2": "d2", +}; + +// None of these should become quoted, regardless of the quoteProps value. +const e = { + NaN: null, + 1: null, + 1.5: null, + 0.1: null, + 1: null, + 1.0: null, + 999999999999999999999: null, + 0.99999999999999999: null, + 1e2: null, + 1e3: null, + 1e100: null, + 0b10: null, + 0o10: null, + 0xf: null, + 2n: null, +}; + +const f = { + // These should be unquoted for quoteProps=as-needed. + NaN: null, + 1: null, + 1.5: null, + // These should never be unquoted. `1e+100` technically could (it’s the only + // one where `String(Number(key)) === key`), but we came to the conclusion + // that it is unexpected. + ".1": null, + "1.": null, + "1.0": null, + "999999999999999999999": null, + "0.99999999999999999": null, + "1E2": null, + "1e+3": null, + "1e+100": null, + "0b10": null, + "0o10": null, + "0xf": null, + "2n": null, +}; + +Object.entries({ + // To force quotes for quoteProps=consistent. + "a-": "a-", + // These can be quoted: + NaN: "NaN", + 1: "1", + 1.5: "1.5", + // Prettier will normalize these to `0.1` and `1` – then they can be quoted. + 0.1: ".1", + 1: "1.", + // These should never be quoted. The _actual_ keys are shown as comments. + // Copy-paste this into the console to verify. If we were to convert these + // numbers into decimal (which completely valid), “information/intent” is + // lost. Either way, writing code like this is super confusing. + 1.0: "1.0", // 1 + 999999999999999999999: "999999999999999999999", // 1e+21 + 0.99999999999999999: "0.99999999999999999", // 1 + 1e2: "1E2", // 100 + 1e3: "1e+3", // 1000 + 1e100: "1e+100", // 1e+100 – this one is identical, but would be inconsistent to quote. + 0b10: "0b10", // 2 + 0o10: "0o10", // 8 + 0xf: "0xf", // 15 + 2n: "2n", // 2 + 0xan: "0xan", // 10 +}); + +// Negative numbers cannot be unquoted. +!{ + "-1": null, + "-1.5": null, +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js.snap new file mode 100644 index 00000000000..f1833c67d55 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/objects.js.snap @@ -0,0 +1,285 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/quote-props/objects.js +--- + +# Input + +```js +const a = { + a: "a" +}; + +const b = { + 'b': "b" +}; + +const b2 = { + // Escapes should stay as escapes and not be unquoted. + '\u0062': "b", + '\u0031': "1" +}; + +const c = { + c1: "c1", + 'c2': "c2" +}; + +const d = { + d1: "d1", + 'd-2': "d2" +}; + +// None of these should become quoted, regardless of the quoteProps value. +const e = { + NaN: null, + 1: null, + 1.5: null, + .1: null, + 1.: null, + 1.0: null, + 999999999999999999999: null, + 0.99999999999999999: null, + 1E2: null, + 1e+3: null, + 1e+100: null, + 0b10: null, + 0o10: null, + 0xf: null, + 2n: null, +} + +const f = { + // These should be unquoted for quoteProps=as-needed. + "NaN": null, + "1": null, + "1.5": null, + // These should never be unquoted. `1e+100` technically could (it’s the only + // one where `String(Number(key)) === key`), but we came to the conclusion + // that it is unexpected. + ".1": null, + "1.": null, + "1.0": null, + "999999999999999999999": null, + "0.99999999999999999": null, + "1E2": null, + "1e+3": null, + "1e+100": null, + "0b10": null, + "0o10": null, + "0xf": null, + "2n": null, +} + +Object.entries({ + // To force quotes for quoteProps=consistent. + 'a-': 'a-', + // These can be quoted: + NaN: 'NaN', + 1: '1', + 1.5: '1.5', + // Prettier will normalize these to `0.1` and `1` – then they can be quoted. + .1: '.1', + 1.: '1.', + // These should never be quoted. The _actual_ keys are shown as comments. + // Copy-paste this into the console to verify. If we were to convert these + // numbers into decimal (which completely valid), “information/intent” is + // lost. Either way, writing code like this is super confusing. + 1.0: '1.0', // 1 + 999999999999999999999: '999999999999999999999', // 1e+21 + 0.99999999999999999: '0.99999999999999999', // 1 + 1E2: '1E2', // 100 + 1e+3: '1e+3', // 1000 + 1e+100: '1e+100', // 1e+100 – this one is identical, but would be inconsistent to quote. + 0b10: '0b10', // 2 + 0o10: '0o10', // 8 + 0xf: '0xf', // 15 + 2n: '2n', // 2 + 0xan: '0xan', // 10 +}) + +// Negative numbers cannot be unquoted. +!{ + "-1": null, + "-1.5": null, +} +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -27,14 +27,14 @@ + NaN: null, + 1: null, + 1.5: null, +- 0.1: null, +- 1: null, ++ .1: null, ++ 1.: null, + 1.0: null, + 999999999999999999999: null, + 0.99999999999999999: null, +- 1e2: null, +- 1e3: null, +- 1e100: null, ++ 1E2: null, ++ 1e+3: null, ++ 1e+100: null, + 0b10: null, + 0o10: null, + 0xf: null, +@@ -45,14 +45,14 @@ + // These should be unquoted for quoteProps=as-needed. + NaN: null, + 1: null, +- 1.5: null, ++ "1.5": null, + // These should never be unquoted. `1e+100` technically could (it’s the only + // one where `String(Number(key)) === key`), but we came to the conclusion + // that it is unexpected. + ".1": null, + "1.": null, + "1.0": null, +- "999999999999999999999": null, ++ 999999999999999999999: null, + "0.99999999999999999": null, + "1E2": null, + "1e+3": null, +@@ -71,8 +71,8 @@ + 1: "1", + 1.5: "1.5", + // Prettier will normalize these to `0.1` and `1` – then they can be quoted. +- 0.1: ".1", +- 1: "1.", ++ .1: ".1", ++ 1.: "1.", + // These should never be quoted. The _actual_ keys are shown as comments. + // Copy-paste this into the console to verify. If we were to convert these + // numbers into decimal (which completely valid), “information/intent” is +@@ -80,9 +80,9 @@ + 1.0: "1.0", // 1 + 999999999999999999999: "999999999999999999999", // 1e+21 + 0.99999999999999999: "0.99999999999999999", // 1 +- 1e2: "1E2", // 100 +- 1e3: "1e+3", // 1000 +- 1e100: "1e+100", // 1e+100 – this one is identical, but would be inconsistent to quote. ++ 1E2: "1E2", // 100 ++ 1e+3: "1e+3", // 1000 ++ 1e+100: "1e+100", // 1e+100 – this one is identical, but would be inconsistent to quote. + 0b10: "0b10", // 2 + 0o10: "0o10", // 8 + 0xf: "0xf", // 15 +``` + +# Output + +```js +const a = { + a: "a", +}; + +const b = { + b: "b", +}; + +const b2 = { + // Escapes should stay as escapes and not be unquoted. + "\u0062": "b", + "\u0031": "1", +}; + +const c = { + c1: "c1", + c2: "c2", +}; + +const d = { + d1: "d1", + "d-2": "d2", +}; + +// None of these should become quoted, regardless of the quoteProps value. +const e = { + NaN: null, + 1: null, + 1.5: null, + .1: null, + 1.: null, + 1.0: null, + 999999999999999999999: null, + 0.99999999999999999: null, + 1E2: null, + 1e+3: null, + 1e+100: null, + 0b10: null, + 0o10: null, + 0xf: null, + 2n: null, +}; + +const f = { + // These should be unquoted for quoteProps=as-needed. + NaN: null, + 1: null, + "1.5": null, + // These should never be unquoted. `1e+100` technically could (it’s the only + // one where `String(Number(key)) === key`), but we came to the conclusion + // that it is unexpected. + ".1": null, + "1.": null, + "1.0": null, + 999999999999999999999: null, + "0.99999999999999999": null, + "1E2": null, + "1e+3": null, + "1e+100": null, + "0b10": null, + "0o10": null, + "0xf": null, + "2n": null, +}; + +Object.entries({ + // To force quotes for quoteProps=consistent. + "a-": "a-", + // These can be quoted: + NaN: "NaN", + 1: "1", + 1.5: "1.5", + // Prettier will normalize these to `0.1` and `1` – then they can be quoted. + .1: ".1", + 1.: "1.", + // These should never be quoted. The _actual_ keys are shown as comments. + // Copy-paste this into the console to verify. If we were to convert these + // numbers into decimal (which completely valid), “information/intent” is + // lost. Either way, writing code like this is super confusing. + 1.0: "1.0", // 1 + 999999999999999999999: "999999999999999999999", // 1e+21 + 0.99999999999999999: "0.99999999999999999", // 1 + 1E2: "1E2", // 100 + 1e+3: "1e+3", // 1000 + 1e+100: "1e+100", // 1e+100 – this one is identical, but would be inconsistent to quote. + 0b10: "0b10", // 2 + 0o10: "0o10", // 8 + 0xf: "0xf", // 15 + 2n: "2n", // 2 + 0xan: "0xan", // 10 +}); + +// Negative numbers cannot be unquoted. +!{ + "-1": null, + "-1.5": null, +}; +``` + + +# Lines exceeding max width of 80 characters +``` + 85: 1e+100: "1e+100", // 1e+100 – this one is identical, but would be inconsistent to quote. +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_member_expressions.js b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_member_expressions.js new file mode 100644 index 00000000000..22c838e4621 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_member_expressions.js @@ -0,0 +1,9 @@ +const obj = { + foo: "", + [foo.bar]: "" +}; + +class Foo { + foo() {} + [foo.bar]() {} +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_member_expressions.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_member_expressions.js.prettier-snap new file mode 100644 index 00000000000..ae30932b431 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_member_expressions.js.prettier-snap @@ -0,0 +1,9 @@ +const obj = { + foo: "", + [foo.bar]: "", +}; + +class Foo { + foo() {} + [foo.bar]() {} +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_numbers.js b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_numbers.js new file mode 100644 index 00000000000..436f533284a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_numbers.js @@ -0,0 +1,14 @@ +obj = { + foo: "", + 1: "" +}; + +obj = { + "bar": "", + 1: "" +}; + +obj = { + "foo-bar": "", + 1: "" +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_numbers.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_numbers.js.prettier-snap new file mode 100644 index 00000000000..31ecb3f02c4 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quote-props/with_numbers.js.prettier-snap @@ -0,0 +1,14 @@ +obj = { + foo: "", + 1: "", +}; + +obj = { + bar: "", + 1: "", +}; + +obj = { + "foo-bar": "", + 1: "", +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/quotes/objects.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/quotes/objects.js.snap index 92a0d5fc8cc..02a65a1bc12 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/quotes/objects.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/quotes/objects.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/quotes/objects.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/array.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/array.js.snap index 36dce19d1f4..ce943db3c4e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/array.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/array.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/array.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/boundary-2.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/boundary-2.js.snap index 22b5af998c0..3508089585b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/boundary-2.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/boundary-2.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/boundary-2.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/boundary-3.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/boundary-3.js.snap index 86499925d91..16c0e815faa 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/boundary-3.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/boundary-3.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/boundary-3.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/class-declaration.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/class-declaration.js.snap index 32902f90600..3d57f80f848 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/class-declaration.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/class-declaration.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/class-declaration.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/different-levels.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/different-levels.js.snap index 492e60664ca..cb7badb0517 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/different-levels.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/different-levels.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/different-levels.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/directive.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/directive.js.snap index b101dae7262..6d9062a3e95 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/directive.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/directive.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/directive.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/ignore-indentation.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/ignore-indentation.js.snap index cb3a08d97c9..8d4e386ead9 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/ignore-indentation.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/ignore-indentation.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/ignore-indentation.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/issue-7082.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/issue-7082.js.snap index 83c484021e0..2b7b4646c3c 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/issue-7082.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/issue-7082.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/issue-7082.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export1.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export1.js.snap index 0976b75c460..1c75ec21ae2 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export1.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export1.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/module-export1.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export2.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export2.js.snap index a7bad5fcb38..553a7037818 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export2.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export2.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/module-export2.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export3.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export3.js.snap index b19656a6183..34819bfedb3 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export3.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/module-export3.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/module-export3.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/module-import.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/module-import.js.snap index f0b43f9acf9..5c861f22b82 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/module-import.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/module-import.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/module-import.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/multiple-statements.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/multiple-statements.js.snap index 5d0fc1f6317..948d7339bed 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/multiple-statements.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/multiple-statements.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/multiple-statements.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/multiple-statements2.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/multiple-statements2.js.snap index 5d0fc1f6317..e1d48a5b3de 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/multiple-statements2.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/multiple-statements2.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/multiple-statements2.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/nested2.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/nested2.js.snap index 2f5958be584..f2d0e61e8cd 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/nested2.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/nested2.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/nested2.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/nested3.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/nested3.js.snap index 7135a2bf5bf..fc6a8e029ce 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/nested3.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/nested3.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/nested3.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/object-expression2.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/object-expression2.js.snap index 89d90a4e931..87f7e77dbea 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/object-expression2.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/object-expression2.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/object-expression2.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/range-end.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/range-end.js.snap index 5be93b68280..94257e8cbcc 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/range-end.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/range-end.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/range-end.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/range-start.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/range-start.js.snap index c1bf4cb1493..8bfdf163b68 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/range-start.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/range-start.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/range-start.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/range.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/range.js.snap index a601d4b71ed..d0782310eca 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/range.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/range.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/range.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/range/start-equals-end.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/range/start-equals-end.js.snap index cdbb65468d5..3585aa6ef27 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/range/start-equals-end.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/range/start-equals-end.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/range/start-equals-end.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js b/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js new file mode 100644 index 00000000000..594fa7e9376 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js @@ -0,0 +1,19 @@ +declare class C { + f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args + ): void, +} + +function f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args +) {} + +declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; } + +[superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,,]; + +[veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong, ...a] = []; +var {veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong, ...a} = {}; + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js.prettier-snap new file mode 100644 index 00000000000..7168988943f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js.prettier-snap @@ -0,0 +1,31 @@ +declare class C { + f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args + ): void; +} + +function f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args +) {} + +declare class C { + f( + ...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong + ): void; +} + +[ + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + , +]; + +[ + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong, + ...a +] = []; +var { + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong, + ...a +} = {}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js.snap new file mode 100644 index 00000000000..64eae3f15d8 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/js/rest/trailing-commas.js.snap @@ -0,0 +1,124 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/rest/trailing-commas.js +--- + +# Input + +```js +declare class C { + f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args + ): void, +} + +function f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args +) {} + +declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; } + +[superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,,]; + +[veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong, ...a] = []; +var {veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong, ...a} = {}; + +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -2,7 +2,7 @@ + f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args +- ): void; ++ ): void, + } + + function f( +@@ -10,11 +10,7 @@ + ...args + ) {} + +-declare class C { +- f( +- ...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong +- ): void; +-} ++declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; } + + [ + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, +``` + +# Output + +```js +declare class C { + f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args + ): void, +} + +function f( + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + ...args +) {} + +declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; } + +[ + superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + , +]; + +[ + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong, + ...a +] = []; +var { + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLong, + ...a +} = {}; +``` + + +# Errors +``` +trailing-commas.js:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × The 'declare' modifier can only be used in TypeScript files. + + > 1 │ declare class C { + │ ^^^^^^^ + 2 │ f( + 3 │ superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, + +trailing-commas.js:13:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × The 'declare' modifier can only be used in TypeScript files. + + 11 │ ) {} + 12 │ + > 13 │ declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; } + │ ^^^^^^^ + 14 │ + 15 │ [superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong,,]; + + +``` + +# Lines exceeding max width of 80 characters +``` + 13: declare class C { f(...superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong): void; } + 16: superSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperSuperLong, +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/return-outside-function/return-outside-function.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/return-outside-function/return-outside-function.js.snap index 954ec8e346f..e9727bf204a 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/return-outside-function/return-outside-function.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/return-outside-function/return-outside-function.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\return-outside-function\\return-outside-function.js" + test_file: js/return-outside-function/return-outside-function.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/css-prop.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/css-prop.js.snap index fc9f5fd56b3..e88e8997de5 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/css-prop.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/css-prop.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/template-literals/css-prop.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/styled-components-with-expressions.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/styled-components-with-expressions.js.snap index 6e1a03f8468..286bb1ec769 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/styled-components-with-expressions.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/styled-components-with-expressions.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/template-literals/styled-components-with-expressions.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/styled-jsx.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/styled-jsx.js.snap index 1f57b7f0575..d7c10d95a1b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/styled-jsx.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/styled-jsx.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/template-literals/styled-jsx.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/template/parenthesis.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/template/parenthesis.js.snap index 16e50fa7e37..0796080f555 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/template/parenthesis.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/template/parenthesis.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/template/parenthesis.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/ternaries/func-call.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/ternaries/func-call.js.snap index 649e7f15f15..1e4c23340f0 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/ternaries/func-call.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/ternaries/func-call.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/ternaries/func-call.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/jest-each-template-string.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/jest-each-template-string.js.snap index e141a07c870..1a5d4c29289 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/jest-each-template-string.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/jest-each-template-string.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/test-declarations/jest-each-template-string.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/jest-each.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/jest-each.js.snap index 66624461568..c9f7fa4fa0d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/jest-each.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/jest-each.js.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: js/test-declarations/jest-each.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.prettier-snap index c07928430cd..3bddc7bb29d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.prettier-snap @@ -85,75 +85,43 @@ skip(`does something really long and complicated so I have to write a very long skip("does something really long and complicated so I have to write a very long name for the test", () => {}); -test.step( - "does something really long and complicated so I have to write a very long name for the test", - () => {}, -); +test.step("does something really long and complicated so I have to write a very long name for the test", () => {}); -test.step( - `does something really long and complicated so I have to write a very long name for the test`, - () => {}, -); +test.step(`does something really long and complicated so I have to write a very long name for the test`, () => {}); -test.describe( - "does something really long and complicated so I have to write a very long name for the test", - () => {}, -); +test.describe("does something really long and complicated so I have to write a very long name for the test", () => {}); -test.describe( - `does something really long and complicated so I have to write a very long name for the test`, - () => {}, -); +test.describe(`does something really long and complicated so I have to write a very long name for the test`, () => {}); -test.describe.only( - "does something really long and complicated so I have to write a very long name for the test", - () => {}, -); +test.describe + .only("does something really long and complicated so I have to write a very long name for the test", () => {}); -test.describe.only( - `does something really long and complicated so I have to write a very long name for the test`, - () => {}, -); +test.describe + .only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); -test.describe.parallel( - "does something really long and complicated so I have to write a very long name for the test", - () => {}, -); +test.describe + .parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); -test.describe.parallel( - `does something really long and complicated so I have to write a very long name for the test`, - () => {}, -); +test.describe + .parallel(`does something really long and complicated so I have to write a very long name for the test`, () => {}); -test.describe.parallel.only( - "does something really long and complicated so I have to write a very long name for the testThis is a very", - () => {}, -); +test.describe.parallel + .only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {}); -test.describe.parallel.only( - `does something really long and complicated so I have to write a very long name for the testThis is a very`, - () => {}, -); +test.describe.parallel + .only(`does something really long and complicated so I have to write a very long name for the testThis is a very`, () => {}); -test.describe.serial( - "does something really long and complicated so I have to write a very long name for the test", - () => {}, -); +test.describe + .serial("does something really long and complicated so I have to write a very long name for the test", () => {}); -test.describe.serial( - `does something really long and complicated so I have to write a very long name for the test`, - () => {}, -); +test.describe + .serial(`does something really long and complicated so I have to write a very long name for the test`, () => {}); -test.describe.serial.only( - "does something really long and complicated so I have to write a very long name for the test", - () => {}, -); +test.describe.serial + .only("does something really long and complicated so I have to write a very long name for the test", () => {}); -test.describe.serial.only( - `does something really long and complicated so I have to write a very long name for the test`, - () => {}, -); +test.describe.serial + .only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); // Should break diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.snap index a3b6c802729..87045c50c37 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/test-declarations/test_declarations.js.snap @@ -177,97 +177,53 @@ it( ```diff --- Prettier +++ Rome -@@ -85,75 +85,33 @@ +@@ -93,35 +93,25 @@ - skip("does something really long and complicated so I have to write a very long name for the test", () => {}); + test.describe(`does something really long and complicated so I have to write a very long name for the test`, () => {}); --test.step( -- "does something really long and complicated so I have to write a very long name for the test", -- () => {}, --); -+test.step("does something really long and complicated so I have to write a very long name for the test", () => {}); - --test.step( -- `does something really long and complicated so I have to write a very long name for the test`, -- () => {}, --); -+test.step(`does something really long and complicated so I have to write a very long name for the test`, () => {}); - --test.describe( -- "does something really long and complicated so I have to write a very long name for the test", -- () => {}, --); -+test.describe("does something really long and complicated so I have to write a very long name for the test", () => {}); - --test.describe( -- `does something really long and complicated so I have to write a very long name for the test`, -- () => {}, --); -+test.describe(`does something really long and complicated so I have to write a very long name for the test`, () => {}); - --test.describe.only( -- "does something really long and complicated so I have to write a very long name for the test", -- () => {}, --); +-test.describe +- .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.only("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe.only( -- `does something really long and complicated so I have to write a very long name for the test`, -- () => {}, --); +-test.describe +- .only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe.only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); --test.describe.parallel( -- "does something really long and complicated so I have to write a very long name for the test", -- () => {}, --); +-test.describe +- .parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.parallel("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe.parallel( -- `does something really long and complicated so I have to write a very long name for the test`, -- () => {}, --); +-test.describe +- .parallel(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe.parallel(`does something really long and complicated so I have to write a very long name for the test`, () => {}); --test.describe.parallel.only( -- "does something really long and complicated so I have to write a very long name for the testThis is a very", -- () => {}, --); +-test.describe.parallel +- .only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {}); +test.describe.parallel.only("does something really long and complicated so I have to write a very long name for the testThis is a very", () => {}); --test.describe.parallel.only( -- `does something really long and complicated so I have to write a very long name for the testThis is a very`, -- () => {}, --); +-test.describe.parallel +- .only(`does something really long and complicated so I have to write a very long name for the testThis is a very`, () => {}); +test.describe.parallel.only(`does something really long and complicated so I have to write a very long name for the testThis is a very`, () => {}); --test.describe.serial( -- "does something really long and complicated so I have to write a very long name for the test", -- () => {}, --); +-test.describe +- .serial("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.serial("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe.serial( -- `does something really long and complicated so I have to write a very long name for the test`, -- () => {}, --); +-test.describe +- .serial(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe.serial(`does something really long and complicated so I have to write a very long name for the test`, () => {}); --test.describe.serial.only( -- "does something really long and complicated so I have to write a very long name for the test", -- () => {}, --); +-test.describe.serial +- .only("does something really long and complicated so I have to write a very long name for the test", () => {}); +test.describe.serial.only("does something really long and complicated so I have to write a very long name for the test", () => {}); --test.describe.serial.only( -- `does something really long and complicated so I have to write a very long name for the test`, -- () => {}, --); +-test.describe.serial +- .only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); +test.describe.serial.only(`does something really long and complicated so I have to write a very long name for the test`, () => {}); // Should break -@@ -184,10 +142,7 @@ +@@ -152,10 +142,7 @@ () => {}, ); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/with/indent.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/with/indent.js.snap index b128b130a44..6ce7a957e13 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/with/indent.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/with/indent.js.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "js\\with\\indent.js" + test_file: js/with/indent.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/eslint-disable.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/eslint-disable.js new file mode 100644 index 00000000000..92c0dbc57fd --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/eslint-disable.js @@ -0,0 +1,5 @@ +const render = items => ( +
{ /* eslint-disable */ + items.map(item => null) + /* eslint-enable */ }
+) diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/eslint-disable.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/eslint-disable.js.prettier-snap new file mode 100644 index 00000000000..0fbda8052c2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/eslint-disable.js.prettier-snap @@ -0,0 +1,9 @@ +const render = (items) => ( +
+ { + /* eslint-disable */ + items.map((item) => null) + /* eslint-enable */ + } +
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/in-tags.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/in-tags.js new file mode 100644 index 00000000000..e06914134ef --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/in-tags.js @@ -0,0 +1,28 @@ +
+ {foo} +
; + +
+ {foo} +
; + +
+ {foo} +
; + +
+ {foo} +
; + +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/in-tags.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/in-tags.js.prettier-snap new file mode 100644 index 00000000000..f9bc45bb5d1 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/in-tags.js.prettier-snap @@ -0,0 +1,28 @@ +
+ {foo} +
; + +
+ {foo} +
; + +
+ {foo} +
; + +
+ {foo} +
; + +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/jsx-tag-comment-after-prop.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/jsx-tag-comment-after-prop.js new file mode 100644 index 00000000000..feb701527ff --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/jsx-tag-comment-after-prop.js @@ -0,0 +1,12 @@ +// https://github.com/typescript-eslint/typescript-eslint/pull/703 + +const pure = () => { + return ( + + ); +} \ No newline at end of file diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/jsx-tag-comment-after-prop.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/jsx-tag-comment-after-prop.js.prettier-snap new file mode 100644 index 00000000000..1ea749b4a80 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/jsx-tag-comment-after-prop.js.prettier-snap @@ -0,0 +1,12 @@ +// https://github.com/typescript-eslint/typescript-eslint/pull/703 + +const pure = () => { + return ( + + ); +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/like-a-comment-in-jsx-text.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/like-a-comment-in-jsx-text.js new file mode 100644 index 00000000000..7aae724ab4a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/like-a-comment-in-jsx-text.js @@ -0,0 +1,6 @@ + + text + // comment + text + \ No newline at end of file diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/like-a-comment-in-jsx-text.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/like-a-comment-in-jsx-text.js.prettier-snap new file mode 100644 index 00000000000..27b288fcfbc --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/comments/like-a-comment-in-jsx-text.js.prettier-snap @@ -0,0 +1 @@ +text // comment text; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/deprecated-jsx-bracket-same-line-option/jsx.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/deprecated-jsx-bracket-same-line-option/jsx.js new file mode 100644 index 00000000000..2417fa94b81 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/deprecated-jsx-bracket-same-line-option/jsx.js @@ -0,0 +1,10 @@ + +
and the children go here
+
and here too
+
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/deprecated-jsx-bracket-same-line-option/jsx.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/deprecated-jsx-bracket-same-line-option/jsx.js.prettier-snap new file mode 100644 index 00000000000..76bf87705cd --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/deprecated-jsx-bracket-same-line-option/jsx.js.prettier-snap @@ -0,0 +1,10 @@ + +
and the children go here
+
and here too
+
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/array-iter.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/array-iter.js new file mode 100644 index 00000000000..fc43e17a5c3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/array-iter.js @@ -0,0 +1,30 @@ +const UsersList = ({ users }) => ( +
+

Users list

+
    + {users.map(user => ( +
  • {user.name}
  • + ))} +
+
+) + +const TodoList = ({ todos }) => ( +
+
    {_.map(todos, (todo, i) => )}
+
+); + +
+ {scopes + .filter(scope => scope.value !== '') + .map((scope, i) => ( + + ))} +
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/array-iter.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/array-iter.js.prettier-snap new file mode 100644 index 00000000000..8c0ace288c7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/array-iter.js.prettier-snap @@ -0,0 +1,34 @@ +const UsersList = ({ users }) => ( +
+

Users list

+
    + {users.map((user) => ( +
  • {user.name}
  • + ))} +
+
+); + +const TodoList = ({ todos }) => ( +
+
    + {_.map(todos, (todo, i) => ( + + ))} +
+
+); + +
+ {scopes + .filter((scope) => scope.value !== "") + .map((scope, i) => ( + + ))} +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/attr-comments.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/attr-comments.js new file mode 100644 index 00000000000..236c6f295bc --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/attr-comments.js @@ -0,0 +1,31 @@ + fn(arg) + } + propArrowWithBreak={ + // comment + arg => + fn({ + makeItBreak + }) + } + propArray={ + // comment + [el1, el2] + } + propObj={ + // comment + { key: val } + } + propTemplate={ + // comment + `text` + } +/>; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/attr-comments.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/attr-comments.js.prettier-snap new file mode 100644 index 00000000000..60ca9c9981a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/attr-comments.js.prettier-snap @@ -0,0 +1,31 @@ + fn(arg) + } + propArrowWithBreak={ + // comment + (arg) => + fn({ + makeItBreak, + }) + } + propArray={ + // comment + [el1, el2] + } + propObj={ + // comment + { key: val } + } + propTemplate={ + // comment + `text` + } +/>; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js new file mode 100644 index 00000000000..bf4d9ad1cce --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js @@ -0,0 +1,35 @@ +async function testFunction() { + const short = <> + {await Promise.all( + hierarchyCriticism + )} + {await hierarchyCriticism.ic.me.oa.p} + {await hierarchyCriticism} + + {Promise.all( + hierarchyCriticism + )} + {hierarchyCriticism.ic.me.oa.p} + {hierarchyCriticism} + + + const long = <> + {await Promise.all( + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + )} + {await hierarchyCriticism.IncongruousCooperate.MaterialEducation.OriginalArticulate.Parameter} + {await hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter} + + {Promise.all( + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + )} + {hierarchyCriticism.IncongruousCooperate.MaterialEducation.OriginalArticulate.Parameter} + {hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter} + + + const jsx = <> + {await ( + material education original articulate parameter + )} + +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js.prettier-snap new file mode 100644 index 00000000000..2efcb91e2fb --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js.prettier-snap @@ -0,0 +1,49 @@ +async function testFunction() { + const short = ( + <> + {await Promise.all(hierarchyCriticism)} + {await hierarchyCriticism.ic.me.oa.p} + {await hierarchyCriticism} + + {Promise.all(hierarchyCriticism)} + {hierarchyCriticism.ic.me.oa.p} + {hierarchyCriticism} + + ); + + const long = ( + <> + {await Promise.all( + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter, + )} + { + await hierarchyCriticism.IncongruousCooperate.MaterialEducation + .OriginalArticulate.Parameter + } + { + await hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + } + + {Promise.all( + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter, + )} + { + hierarchyCriticism.IncongruousCooperate.MaterialEducation + .OriginalArticulate.Parameter + } + { + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + } + + ); + + const jsx = ( + <> + {await ( + + material education original articulate parameter + + )} + + ); +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js.snap new file mode 100644 index 00000000000..d111617d700 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/await.js.snap @@ -0,0 +1,156 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/jsx/await.js +--- + +# Input + +```js +async function testFunction() { + const short = <> + {await Promise.all( + hierarchyCriticism + )} + {await hierarchyCriticism.ic.me.oa.p} + {await hierarchyCriticism} + + {Promise.all( + hierarchyCriticism + )} + {hierarchyCriticism.ic.me.oa.p} + {hierarchyCriticism} + + + const long = <> + {await Promise.all( + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + )} + {await hierarchyCriticism.IncongruousCooperate.MaterialEducation.OriginalArticulate.Parameter} + {await hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter} + + {Promise.all( + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + )} + {hierarchyCriticism.IncongruousCooperate.MaterialEducation.OriginalArticulate.Parameter} + {hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter} + + + const jsx = <> + {await ( + material education original articulate parameter + )} + +} +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -13,10 +13,12 @@ + + const long = ( + <> +- {await Promise.all( +- hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter, +- )} + { ++ await Promise.all( ++ hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter, ++ ) ++ } ++ { + await hierarchyCriticism.IncongruousCooperate.MaterialEducation + .OriginalArticulate.Parameter + } +@@ -39,11 +41,13 @@ + + const jsx = ( + <> +- {await ( +- +- material education original articulate parameter +- +- )} ++ { ++ await ( ++ ++ material education original articulate parameter ++ ++ ) ++ } + + ); + } +``` + +# Output + +```js +async function testFunction() { + const short = ( + <> + {await Promise.all(hierarchyCriticism)} + {await hierarchyCriticism.ic.me.oa.p} + {await hierarchyCriticism} + + {Promise.all(hierarchyCriticism)} + {hierarchyCriticism.ic.me.oa.p} + {hierarchyCriticism} + + ); + + const long = ( + <> + { + await Promise.all( + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter, + ) + } + { + await hierarchyCriticism.IncongruousCooperate.MaterialEducation + .OriginalArticulate.Parameter + } + { + await hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + } + + {Promise.all( + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter, + )} + { + hierarchyCriticism.IncongruousCooperate.MaterialEducation + .OriginalArticulate.Parameter + } + { + hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + } + + ); + + const jsx = ( + <> + { + await ( + + material education original articulate parameter + + ) + } + + ); +} +``` + + +# Lines exceeding max width of 80 characters +``` + 18: hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter, + 26: await hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter + 30: hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter, + 37: hierarchyCriticismIncongruousCooperateMaterialEducationOriginalArticulateParameter +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/conditional-expression.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/conditional-expression.js new file mode 100644 index 00000000000..3283d9c6a94 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/conditional-expression.js @@ -0,0 +1,135 @@ +// There are two ways to print ConditionalExpressions: "normal mode" and +// "JSX mode". This is normal mode (when breaking): +// +// test +// ? consequent +// : alternate; +// +// And this is JSX mode (when breaking): +// +// test ? ( +// consequent +// ) : ( +// alternate +// ); +// +// When non-breaking, they look the same: +// +// test ? consequent : alternate; +// +// We only print a conditional expression in JSX mode if its test, +// consequent, or alternate are JSXElements. +// Otherwise, we print in normal mode. + +// This ConditionalExpression has no JSXElements so it prints in normal mode. +// The line does not break. +normalModeNonBreaking ? "a" : "b"; + +// This ConditionalExpression has no JSXElements so it prints in normal mode. +// Its consequent is very long, so it breaks out to multiple lines. +normalModeBreaking + ? johnJacobJingleHeimerSchmidtHisNameIsMyNameTooWheneverWeGoOutThePeopleAlwaysShoutThereGoesJohnJacobJingleHeimerSchmidtYaDaDaDaDaDaDa + : "c"; + +// This ConditionalExpression prints in JSX mode because its test is a +// JSXElement. It is non-breaking. +// Note: I have never, ever seen someone use a JSXElement as the test in a +// ConditionalExpression. But this test is included for completeness. +
? jsxModeFromElementNonBreaking : "a"; + +// This ConditionalExpression prints in JSX mode because its consequent is a +// JSXElement. It is non-breaking. +jsxModeFromElementNonBreaking ?
: "a"; + +// This ConditionalExpression prints in JSX mode because its alternate is a +// JSXElement. It is non-breaking. +jsxModeFromElementNonBreaking ? "a" :
; + +// This ConditionalExpression prints in JSX mode because its test is a +// JSXElement. It is breaking. +// Note: I have never, ever seen someone use a JSXElement as the test in a +// ConditionalExpression. But this test is included for completeness. +
+ thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo +
? ( + "jsx mode from element breaking" +) : ( + "a" +); + +// This ConditionalExpression prints in JSX mode because its consequent is a +// JSXElement. It is breaking. +jsxModeFromElementBreaking ? ( +
+ thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo +
+) : ( + "a" +); + +// This ConditionalExpression prints in JSX mode because its alternate is a +// JSXElement. It is breaking. +jsxModeFromElementBreaking ? ( + "a" +) : ( +
+ thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo +
+); + +// This chain of ConditionalExpressions prints in JSX mode because the parent of +// the outermost ConditionalExpression is a JSXExpressionContainer. It is +// non-breaking. +
+ {a ? "a" : b ? "b" : "c"} +
; + +// This chain of ConditionalExpressions prints in JSX mode because there is a +// JSX element somewhere in the chain. It is non-breaking. +cable ? "satellite" : isPublic ? "affairs" : network ? : "dun"; + +// This chain of ConditionalExpressions prints in JSX mode because there is a +// JSX element somewhere in the chain (in this case, at the end). It is +// breaking; notice the consequents and alternates in the entire chain get +// wrapped in parens. +cable ? ( + "satellite" +) : isPublic ? ( + "affairs" +) : network ? ( +
+ thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo +
+) : "dunno"; + +// This chain of ConditionalExpressions prints in JSX mode because there is a +// JSX element somewhere in the chain (in this case, at the beginning). It is +// breaking; notice the consequents and alternates in the entire chain get +// wrapped in parens. +cable ? ( +
+ thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo +
+) : sateline ? ( + "public" +) : affairs ? ( + "network" +) : "dunno"; + +// This chain of ConditionalExpressions prints in JSX mode because there is a +// JSX element somewhere in the chain. It is breaking; notice the consequents +// and alternates in the entire chain get wrapped in parens. +
+ {properties.length > 1 || + (properties.length === 1 && properties[0].apps.size > 1) ? ( + draggingApp == null || newPropertyName == null ? ( + + ) : ( + + ) + ) : null} +
; + +// #3552 +foo ? loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong jsx : +undefined diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/conditional-expression.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/conditional-expression.js.prettier-snap new file mode 100644 index 00000000000..38a2e2a15b2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/conditional-expression.js.prettier-snap @@ -0,0 +1,150 @@ +// There are two ways to print ConditionalExpressions: "normal mode" and +// "JSX mode". This is normal mode (when breaking): +// +// test +// ? consequent +// : alternate; +// +// And this is JSX mode (when breaking): +// +// test ? ( +// consequent +// ) : ( +// alternate +// ); +// +// When non-breaking, they look the same: +// +// test ? consequent : alternate; +// +// We only print a conditional expression in JSX mode if its test, +// consequent, or alternate are JSXElements. +// Otherwise, we print in normal mode. + +// This ConditionalExpression has no JSXElements so it prints in normal mode. +// The line does not break. +normalModeNonBreaking ? "a" : "b"; + +// This ConditionalExpression has no JSXElements so it prints in normal mode. +// Its consequent is very long, so it breaks out to multiple lines. +normalModeBreaking + ? johnJacobJingleHeimerSchmidtHisNameIsMyNameTooWheneverWeGoOutThePeopleAlwaysShoutThereGoesJohnJacobJingleHeimerSchmidtYaDaDaDaDaDaDa + : "c"; + +// This ConditionalExpression prints in JSX mode because its test is a +// JSXElement. It is non-breaking. +// Note: I have never, ever seen someone use a JSXElement as the test in a +// ConditionalExpression. But this test is included for completeness. +
? jsxModeFromElementNonBreaking : "a"; + +// This ConditionalExpression prints in JSX mode because its consequent is a +// JSXElement. It is non-breaking. +jsxModeFromElementNonBreaking ?
: "a"; + +// This ConditionalExpression prints in JSX mode because its alternate is a +// JSXElement. It is non-breaking. +jsxModeFromElementNonBreaking ? "a" :
; + +// This ConditionalExpression prints in JSX mode because its test is a +// JSXElement. It is breaking. +// Note: I have never, ever seen someone use a JSXElement as the test in a +// ConditionalExpression. But this test is included for completeness. +
+ + thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo + +
? ( + "jsx mode from element breaking" +) : ( + "a" +); + +// This ConditionalExpression prints in JSX mode because its consequent is a +// JSXElement. It is breaking. +jsxModeFromElementBreaking ? ( +
+ + thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo + +
+) : ( + "a" +); + +// This ConditionalExpression prints in JSX mode because its alternate is a +// JSXElement. It is breaking. +jsxModeFromElementBreaking ? ( + "a" +) : ( +
+ + thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo + +
+); + +// This chain of ConditionalExpressions prints in JSX mode because the parent of +// the outermost ConditionalExpression is a JSXExpressionContainer. It is +// non-breaking. +
{a ? "a" : b ? "b" : "c"}
; + +// This chain of ConditionalExpressions prints in JSX mode because there is a +// JSX element somewhere in the chain. It is non-breaking. +cable ? "satellite" : isPublic ? "affairs" : network ? : "dun"; + +// This chain of ConditionalExpressions prints in JSX mode because there is a +// JSX element somewhere in the chain (in this case, at the end). It is +// breaking; notice the consequents and alternates in the entire chain get +// wrapped in parens. +cable ? ( + "satellite" +) : isPublic ? ( + "affairs" +) : network ? ( +
+ + thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo + +
+) : ( + "dunno" +); + +// This chain of ConditionalExpressions prints in JSX mode because there is a +// JSX element somewhere in the chain (in this case, at the beginning). It is +// breaking; notice the consequents and alternates in the entire chain get +// wrapped in parens. +cable ? ( +
+ + thisIsASongAboutYourPoorSickPenguinHeHasAFeverAndHisToesAreBlueButIfISingToYourPoorSickPenguinHeWillFeelBetterInADayOrTwo + +
+) : sateline ? ( + "public" +) : affairs ? ( + "network" +) : ( + "dunno" +); + +// This chain of ConditionalExpressions prints in JSX mode because there is a +// JSX element somewhere in the chain. It is breaking; notice the consequents +// and alternates in the entire chain get wrapped in parens. +
+ {properties.length > 1 || + (properties.length === 1 && properties[0].apps.size > 1) ? ( + draggingApp == null || newPropertyName == null ? ( + + ) : ( + + ) + ) : null} +
; + +// #3552 +foo ? ( + + loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong jsx + +) : undefined; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/expression.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/expression.js new file mode 100644 index 00000000000..0232f42fd99 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/expression.js @@ -0,0 +1,131 @@ +; + +; + + + {() => ( + + + + )} +; + + + {items.map(item => ( + + + + ))} +; + + + {function() { + return ( + + + + ); + }} +; + +; + + + test + +}/>; + + doLogClick("short", "short", data)} +/>; + + + doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) + } +/>; + + { + doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) + }} +/>; + +, + ) => { + this.setState({ + updatedTask: this.state.updatedTask.set(key, value) + }); + }} +/>; + + + {data => doLogClick("short", "short", data)} +; + + + {data => + doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) + } +; + + + {data => { + doLogClick("long_name_long_name_long_name", "long_name_long_name_long_name", data) + }} +; + + + {( + key: "possible_key_1" | "possible_key_2" | "possible_key_3", + value: string | Immutable.List, + ) => { + this.setState({ + updatedTask: this.state.updatedTask.set(key, value) + }); + }} +; + + +
+ {Array(20) + .fill() + .map((_, i) => ( +

{i + 1}

+ ))} +
+
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/expression.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/expression.js.prettier-snap new file mode 100644 index 00000000000..c829ef7965d --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/expression.js.prettier-snap @@ -0,0 +1,143 @@ +; + +; + + + {() => ( + + + + )} +; + + + {items.map((item) => ( + + + + ))} +; + + + {function () { + return ( + + + + ); + }} +; + +; + +test} />; + + doLogClick("short", "short", data)} +/>; + + + doLogClick( + "long_name_long_name_long_name", + "long_name_long_name_long_name", + data, + ) + } +/>; + + { + doLogClick( + "long_name_long_name_long_name", + "long_name_long_name_long_name", + data, + ); + }} +/>; + +, + ) => { + this.setState({ + updatedTask: this.state.updatedTask.set(key, value), + }); + }} +/>; + + + {(data) => doLogClick("short", "short", data)} +; + + + {(data) => + doLogClick( + "long_name_long_name_long_name", + "long_name_long_name_long_name", + data, + ) + } +; + + + {(data) => { + doLogClick( + "long_name_long_name_long_name", + "long_name_long_name_long_name", + data, + ); + }} +; + + + {( + key: "possible_key_1" | "possible_key_2" | "possible_key_3", + value: string | Immutable.List, + ) => { + this.setState({ + updatedTask: this.state.updatedTask.set(key, value), + }); + }} +; + + +
+ {Array(20) + .fill() + .map((_, i) => ( +

{i + 1}

+ ))} +
+
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/flow_fix_me.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/flow_fix_me.js new file mode 100644 index 00000000000..d58071eb824 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/flow_fix_me.js @@ -0,0 +1,6 @@ +const aDiv = ( + /* $FlowFixMe */ +
+ Foo bar +
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/flow_fix_me.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/flow_fix_me.js.prettier-snap new file mode 100644 index 00000000000..891e4358e95 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/flow_fix_me.js.prettier-snap @@ -0,0 +1,4 @@ +const aDiv = ( + /* $FlowFixMe */ +
Foo bar
+); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/html_escape.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/html_escape.js new file mode 100644 index 00000000000..9582d6eaefc --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/html_escape.js @@ -0,0 +1,3 @@ +export default () => ; + +() => ; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/html_escape.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/html_escape.js.prettier-snap new file mode 100644 index 00000000000..9582d6eaefc --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/html_escape.js.prettier-snap @@ -0,0 +1,3 @@ +export default () => ; + +() => ; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/hug.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/hug.js new file mode 100644 index 00000000000..4a04f416faa --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/hug.js @@ -0,0 +1,32 @@ +
+ {__DEV__ + ? this.renderDevApp() + :
+ {routes.map(route => ( + + ))} +
} +
; + +
+ {__DEV__ &&
+ {routes.map(route => ( + + ))} +
} +
; + +
+ {member.memberName.memberSomething + + (member.memberDef.memberSomething.signatures ? '()' : '')} +
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/hug.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/hug.js.prettier-snap new file mode 100644 index 00000000000..dbd78030ef7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/hug.js.prettier-snap @@ -0,0 +1,36 @@ +
+ {__DEV__ ? ( + this.renderDevApp() + ) : ( +
+ {routes.map((route) => ( + + ))} +
+ )} +
; + +
+ {__DEV__ && ( +
+ {routes.map((route) => ( + + ))} +
+ )} +
; + +
+ {member.memberName.memberSomething + + (member.memberDef.memberSomething.signatures ? "()" : "")} +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/logical-expression.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/logical-expression.js new file mode 100644 index 00000000000..948f1cfa0d9 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/logical-expression.js @@ -0,0 +1,31 @@ +
+ {a || "b"} +
; + +
+ {a && "b"} +
; + +
+ {a || } +
; + +
+ {a && } +
; + +
+ {a && make this text just so long enough to break this to the next line} +
; + +
+ {a && b && make this text just so long enough to break this to the next line} +
; + +
+ {a && +
+
+
+
} +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/logical-expression.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/logical-expression.js.prettier-snap new file mode 100644 index 00000000000..f9c8d72b6ab --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/logical-expression.js.prettier-snap @@ -0,0 +1,33 @@ +
{a || "b"}
; + +
{a && "b"}
; + +
{a || }
; + +
{a && }
; + +
+ {a && ( + + make this text just so long enough to break this to the next line + + )} +
; + +
+ {a && b && ( + + make this text just so long enough to break this to the next line + + )} +
; + +
+ {a && ( + +
+
+
+
+ )} +
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/object-property.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/object-property.js new file mode 100644 index 00000000000..b133d524226 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/object-property.js @@ -0,0 +1,13 @@ +const tabs = [ + { + title: "General Info", + content: ( + + ) + } +]; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/object-property.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/object-property.js.prettier-snap new file mode 100644 index 00000000000..a816f340584 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/object-property.js.prettier-snap @@ -0,0 +1,13 @@ +const tabs = [ + { + title: "General Info", + content: ( + + ), + }, +]; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/open-break.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/open-break.js new file mode 100644 index 00000000000..522c8ec292a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/open-break.js @@ -0,0 +1,11 @@ + { + a +}}>{header}{showSort}; + + { + a +}}>{header}; + +{` a very long text that does not break `}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/open-break.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/open-break.js.prettier-snap new file mode 100644 index 00000000000..0063e35bdf9 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/open-break.js.prettier-snap @@ -0,0 +1,19 @@ + { + a; + }} +> + {header} + {showSort} +; + + { + a; + }} +> + {header} + +; + +{` a very long text that does not break `}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js new file mode 100644 index 00000000000..b5b4a5bc490 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js @@ -0,0 +1,19 @@ +a = [ + , + , +]; + +
+ +f?.(
); +(
)(); +(
)?.(); + +new Foo(); +new Foo(()) diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js.prettier-snap new file mode 100644 index 00000000000..c332cf3b643 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js.prettier-snap @@ -0,0 +1,19 @@ +a = [ + , + , +]; + +
; + +f?.(
); +(
)(); +(
)?.(); + +new Foo(); +new Foo(); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js.snap new file mode 100644 index 00000000000..119b33bb0ca --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/parens.js.snap @@ -0,0 +1,85 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/jsx/parens.js +--- + +# Input + +```js +a = [ + , + , +]; + +
+ +f?.(
); +(
)(); +(
)?.(); + +new Foo(); +new Foo(()) +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,11 +1,11 @@ + a = [ + , + , + ]; + +``` + +# Output + +```js +a = [ + , + , +]; + +
; + +f?.(
); +(
)(); +(
)?.(); + +new Foo(); +new Foo(); +``` + + +# Lines exceeding max width of 80 characters +``` + 4: d='M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,' + 8: d='M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,' +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js new file mode 100644 index 00000000000..a4f6090b8da --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js @@ -0,0 +1,42 @@ +
; +
; +
&quot;'} />; +
; +
; +
; +
; + +

+ GitHub Desktop has encountered an unrecoverable error and will need to 1231231 + restart. This has been reported to the team, but if youencounter this121312331 + repeatedly please report this issue to the GitHub 12312312312312313{' '}{' '} +

diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js.prettier-snap new file mode 100644 index 00000000000..a487f6a922f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js.prettier-snap @@ -0,0 +1,34 @@ +
; +
; +
&quot;"} />; +
; +
; +
; +
; + +

+ GitHub Desktop has encountered an unrecoverable error and will need to 1231231 + restart. This has been reported to the team, but if youencounter this121312331 + repeatedly please report this issue to the GitHub 12312312312312313{" "}{" "} +

; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js.snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js.snap new file mode 100644 index 00000000000..6f68d8709a7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/quotes.js.snap @@ -0,0 +1,141 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: jsx/jsx/quotes.js +--- + +# Input + +```js +
; +
; +
&quot;'} />; +
; +
; +
; +
; + +

+ GitHub Desktop has encountered an unrecoverable error and will need to 1231231 + restart. This has been reported to the team, but if youencounter this121312331 + repeatedly please report this issue to the GitHub 12312312312312313{' '}{' '} +

+``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,11 +1,11 @@ +
; +
; +
&quot;"} />; +-
; +-
; ++
; ++
; +
; +
; + +

+``` + +# Output + +```js +

; +
; +
&quot;"} />; +
; +
; +
; +
; + +

+ GitHub Desktop has encountered an unrecoverable error and will need to 1231231 + restart. This has been reported to the team, but if youencounter this121312331 + repeatedly please report this issue to the GitHub 12312312312312313{" "}{" "} +

; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/regex.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/regex.js new file mode 100644 index 00000000000..9f92918c687 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/regex.js @@ -0,0 +1,4 @@ +x =
one
,
two
; +x = {} +x = {1/2} +x = {/w/.test(s)} diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/regex.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/regex.js.prettier-snap new file mode 100644 index 00000000000..51e43f6ab41 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/regex.js.prettier-snap @@ -0,0 +1,4 @@ +(x =
one
), (
two
); +x = {}; +x = {1 / 2}; +x = {/w/.test(s)}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/return-statement.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/return-statement.js new file mode 100644 index 00000000000..8afae7ce1d5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/return-statement.js @@ -0,0 +1,53 @@ +const NonBreakingArrowExpression = () =>
; + +const BreakingArrowExpression = () =>
+
+ bla bla bla +
+
; + +const NonBreakingArrowExpressionWBody = () => { + return ( +
+ ); +}; + +const BreakingArrowExpressionWBody = () => { + return
+
+ bla bla bla +
+
+}; + +const NonBreakingFunction = function() { + return ( +
+ ); +}; + +const BreakingFunction = function() { + return
+
+ bla bla bla +
+
+}; + +class NonBreakingClass extends React.component { + render() { + return ( +
+ ); + } +} + +class BreakingClass extends React.component { + render() { + return
+
+ bla bla bla +
+
; + } +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/return-statement.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/return-statement.js.prettier-snap new file mode 100644 index 00000000000..12c609fbd54 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/return-statement.js.prettier-snap @@ -0,0 +1,47 @@ +const NonBreakingArrowExpression = () =>
; + +const BreakingArrowExpression = () => ( +
+
bla bla bla
+
+); + +const NonBreakingArrowExpressionWBody = () => { + return
; +}; + +const BreakingArrowExpressionWBody = () => { + return ( +
+
bla bla bla
+
+ ); +}; + +const NonBreakingFunction = function () { + return
; +}; + +const BreakingFunction = function () { + return ( +
+
bla bla bla
+
+ ); +}; + +class NonBreakingClass extends React.component { + render() { + return
; + } +} + +class BreakingClass extends React.component { + render() { + return ( +
+
bla bla bla
+
+ ); + } +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/self-closing.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/self-closing.js new file mode 100644 index 00000000000..26e68c617b5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/self-closing.js @@ -0,0 +1,2 @@ +; +; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/self-closing.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/self-closing.js.prettier-snap new file mode 100644 index 00000000000..26e68c617b5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/self-closing.js.prettier-snap @@ -0,0 +1,2 @@ +; +; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/spacing.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/spacing.js new file mode 100644 index 00000000000..4409ae7169e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/spacing.js @@ -0,0 +1,19 @@ +const Labels = { + label1: ( + + Label 1 + + ), + + label2: ( + + Label 2 + + ), + + label3: ( + + Label 3 + + ), +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/spacing.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/spacing.js.prettier-snap new file mode 100644 index 00000000000..9bca2650e3b --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/spacing.js.prettier-snap @@ -0,0 +1,7 @@ +const Labels = { + label1: Label 1, + + label2: Label 2, + + label3: Label 3, +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/template-literal-in-attr.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/template-literal-in-attr.js new file mode 100644 index 00000000000..c7bdbfc8889 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/template-literal-in-attr.js @@ -0,0 +1,8 @@ +
+
+
foo
+
+
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/template-literal-in-attr.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/template-literal-in-attr.js.prettier-snap new file mode 100644 index 00000000000..ab78603cf59 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/template-literal-in-attr.js.prettier-snap @@ -0,0 +1,10 @@ +
+
+
+ foo +
+
+
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/ternary.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/ternary.js new file mode 100644 index 00000000000..26efc1e8743 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/ternary.js @@ -0,0 +1 @@ +a == 3 ? (a =

123

) : (a =

abc

); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/ternary.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/ternary.js.prettier-snap new file mode 100644 index 00000000000..26efc1e8743 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/jsx/ternary.js.prettier-snap @@ -0,0 +1 @@ +a == 3 ? (a =

123

) : (a =

abc

); diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/last_line.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/last_line.js new file mode 100644 index 00000000000..2417fa94b81 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/last_line.js @@ -0,0 +1,10 @@ + +
and the children go here
+
and here too
+
diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/last_line.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/last_line.js.prettier-snap new file mode 100644 index 00000000000..76bf87705cd --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/last_line.js.prettier-snap @@ -0,0 +1,10 @@ + +
and the children go here
+
and here too
+
; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/single_prop_multiline_string.js b/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/single_prop_multiline_string.js new file mode 100644 index 00000000000..541733229dd --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/single_prop_multiline_string.js @@ -0,0 +1,6 @@ +; + +Content; diff --git a/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/single_prop_multiline_string.js.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/single_prop_multiline_string.js.prettier-snap new file mode 100644 index 00000000000..74f720b35ac --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/jsx/last-line/single_prop_multiline_string.js.prettier-snap @@ -0,0 +1,12 @@ +; + + + Content +; diff --git a/crates/rome_js_formatter/tests/specs/prettier/package.json b/crates/rome_js_formatter/tests/specs/prettier/package.json index 3623207b419..b6e73a629fb 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/package.json +++ b/crates/rome_js_formatter/tests/specs/prettier/package.json @@ -4,10 +4,10 @@ "start": "node prepare_tests" }, "dependencies": { - "prettier": "^2.7.0" + "prettier": "^2.7.1" }, "devDependencies": { - "@types/prettier": "^2.6.3" + "@types/prettier": "^2.7.1" }, "engines": { "pnpm": "^7.0.0" diff --git a/crates/rome_js_formatter/tests/specs/prettier/pnpm-lock.yaml b/crates/rome_js_formatter/tests/specs/prettier/pnpm-lock.yaml index 3ce4d77f715..61e598cf0eb 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/pnpm-lock.yaml +++ b/crates/rome_js_formatter/tests/specs/prettier/pnpm-lock.yaml @@ -1,23 +1,23 @@ lockfileVersion: 5.4 specifiers: - '@types/prettier': ^2.6.3 - prettier: ^2.7.0 + '@types/prettier': ^2.7.1 + prettier: ^2.7.1 dependencies: - prettier: 2.7.0 + prettier: 2.7.1 devDependencies: - '@types/prettier': 2.6.3 + '@types/prettier': 2.7.1 packages: - /@types/prettier/2.6.3: - resolution: {integrity: sha512-ymZk3LEC/fsut+/Q5qejp6R9O1rMxz3XaRHDV6kX8MrGAhOSPqVARbDi+EZvInBpw+BnCX3TD240byVkOfQsHg==} + /@types/prettier/2.7.1: + resolution: {integrity: sha512-ri0UmynRRvZiiUJdiz38MmIblKK+oH30MztdBVR95dv/Ubw6neWSb8u1XpRb72L4qsZOhz+L+z9JD40SJmfWow==} dev: true - /prettier/2.7.0: - resolution: {integrity: sha512-nwoX4GMFgxoPC6diHvSwmK/4yU8FFH3V8XWtLQrbj4IBsK2pkYhG4kf/ljF/haaZ/aii+wNJqISrCDPgxGWDVQ==} + /prettier/2.7.1: + resolution: {integrity: sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==} engines: {node: '>=10.13.0'} hasBin: true dev: false diff --git a/crates/rome_js_formatter/tests/specs/prettier/prepare_tests.js b/crates/rome_js_formatter/tests/specs/prettier/prepare_tests.js index 9840ae0e75e..9b90c17dcbc 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/prepare_tests.js +++ b/crates/rome_js_formatter/tests/specs/prettier/prepare_tests.js @@ -3,78 +3,92 @@ const path = require("path"); const prettier = require("prettier"); if (process.argv.length < 3) { - console.error("Usage: node prepare_tests.js "); - process.exit(2); + console.error("Usage: node prepare_tests.js "); + process.exit(2); } const PRETTIER_ROOT = path.resolve(process.argv[2], "tests/format"); // Recursively traverse the test directory to search for snapshots files async function traverseDir(dir, config) { - for (const entry of await fs.readdir(dir, { withFileTypes: true })) { - if (entry.isDirectory()) { - await traverseDir(path.resolve(dir, entry.name), config); - continue; - } - - if (entry.isFile()) { - // Ignore all non-snapshot files - if (entry.name !== "jsfmt.spec.js.snap") { - continue; - } - - // Load the snapshot as CommonJS - const snapshot = require(path.join(dir, entry.name)); - - // Snapshot files are stored in __snapshots__/jsfmt.spec.js.snap, - // iterate on all files in the parent directory - for (const file of await fs.readdir(path.resolve(dir, ".."))) { - // for each file, check it has an associated snapshot (the - // jsfmt.spec.js files don't have one for instance) - const key = `${file} format 1`; - if (key in snapshot && typeof snapshot[key] === "string") { - // Compute a relative path from the Prettier root directory - // to this file, then an absolute path using the rome_js_formatter - // specs directory as a root instead - const filePath = path.resolve(dir, "..", file); - const relPath = path.relative(PRETTIER_ROOT, filePath); - const outPath = path.resolve(__dirname, relPath); - - // Copy the snapshot input file, ensuring the - // parent directory exists - const outDir = path.resolve(outPath, ".."); - await fs.mkdir(outDir, { recursive: true }); - await fs.copyFile(filePath, outPath); - - // Extract the expected output from the snapshot text - const OUTPUT = "=====================================output====================================="; - const FOOTER = "================================================================================"; - - let snapContent = snapshot[key]; - const start = snapContent.match(new RegExp(OUTPUT + "\\n")); - const end = snapContent.match(new RegExp("\\n" + FOOTER)); - - const startOffset = start.index + start[0].length; - const endOffset = end.index; - snapContent = snapContent.substring(startOffset, endOffset); - try { - // We need to reformat prettier snapshot - // because Rome and Prettier have different default options - snapContent = prettier.format(snapContent, config); - } catch (error) { - console.error(`Prettier format error in ${filePath}: ${error}`); - } - // Write the expected output to an additional prettier-snap - // file in the specs directory - const snapFile = path.basename(file) + ".prettier-snap"; - await fs.writeFile( - path.resolve(outDir, snapFile), - snapContent, - ); - } - } - } - } + for (const entry of await fs.readdir(dir, { withFileTypes: true })) { + if (entry.isDirectory()) { + await traverseDir(path.resolve(dir, entry.name), config); + continue; + } + + if (entry.isFile()) { + const file = entry.name; + + // Ignore spec files + if (file.startsWith("jsfmt.spec")) { + continue; + } + + // Compute a relative path from the Prettier root directory + // to this file, then an absolute path using the rome_js_formatter + // specs directory as a root instead + const filePath = path.resolve(dir, file); + const relPath = path.relative(PRETTIER_ROOT, filePath); + const outPath = path.resolve(__dirname, relPath); + const snapshotPath = path.resolve(dir, "__snapshots__", "jsfmt.spec.js.snap") + const snapFile = path.basename(file) + ".prettier-snap"; + + const snapshot = require(snapshotPath); + + const key = `${file} format 1`; + let snapshotContent = snapshot[key]; + + if (snapshotContent !== undefined) { + // Copy the snapshot input file, ensuring the + // parent directory exists + const outDir = path.resolve(outPath, ".."); + await fs.mkdir(outDir, { recursive: true }); + await fs.copyFile(filePath, outPath); + // Extract the expected output from the snapshot text + const OUTPUT = + "=====================================output====================================="; + const FOOTER = + "================================================================================"; + + const start = snapshotContent.match(new RegExp(OUTPUT + "\\n")); + const end = snapshotContent.match(new RegExp("\\n" + FOOTER)); + + const startOffset = start.index + start[0].length; + const endOffset = end.index; + snapshotContent = snapshotContent.substring(startOffset, endOffset); + + try { + // We need to reformat prettier snapshot + // because Rome and Prettier have different default options + snapshotContent = prettier.format(snapshotContent, config); + } catch (error) { + console.error(`Prettier format error in ${filePath}: ${error}`); + } + // Write the expected output to an additional prettier-snap + // file in the specs directory + await fs.writeFile(path.resolve(outDir, snapFile), snapshotContent); + } else { + // Load content from file current fule + const content = await fs.readFile(filePath, { encoding: "utf8" }); + + try { + // Try to format input with prettier + const prettierOutput = prettier.format(content, config); + + const outDir = path.resolve(outPath, ".."); + await fs.mkdir(outDir, { recursive: true }); + await fs.copyFile(filePath, outPath); + + // Write the expected output to an additional prettier-snap + // file in the specs directory + await fs.writeFile(path.resolve(outDir, snapFile), prettierOutput); + } catch (error) { + console.error(`Prettier format error in ${filePath}: ${error}`); + } + } + } + } } const PRETTIER_ROOT_JS = path.resolve(PRETTIER_ROOT, "js"); @@ -82,36 +96,36 @@ const PRETTIER_ROOT_JSX = path.resolve(PRETTIER_ROOT, "jsx"); const PRETTIER_ROOT_TS = path.resolve(PRETTIER_ROOT, "typescript"); const defaultConfig = { - trailingComma: "all", - tabWidth: 2, - printWidth: 80, - singleQuote: false, - useTabs: false, + trailingComma: "all", + tabWidth: 2, + printWidth: 80, + singleQuote: false, + jsxSingleQuote: false, + useTabs: false, + embeddedLanguageFormatting: "off", }; async function main() { - console.log("Extracting tests from %s ...", PRETTIER_ROOT_JS); - await traverseDir(PRETTIER_ROOT_JS, { - ...defaultConfig, - parser: "babel", - }); - - console.log("Extracting tests from %s ...", {PRETTIER_ROOT_JSX}); - await traverseDir(PRETTIER_ROOT_JSX, { - ...defaultConfig, - parser: "babel", - }); - - console.log("Extracting tests from %s ...", PRETTIER_ROOT_TS); - await traverseDir(PRETTIER_ROOT_TS, { - ...defaultConfig, - parser: "typescript" - }); + console.log("Extracting tests from %s ...", PRETTIER_ROOT_JS); + await traverseDir(PRETTIER_ROOT_JS, { + ...defaultConfig, + parser: "babel", + }); + + console.log("Extracting tests from %s ...", { PRETTIER_ROOT_JSX }); + await traverseDir(PRETTIER_ROOT_JSX, { + ...defaultConfig, + parser: "babel", + }); + + console.log("Extracting tests from %s ...", PRETTIER_ROOT_TS); + await traverseDir(PRETTIER_ROOT_TS, { + ...defaultConfig, + parser: "typescript", + }); } -main().catch( - (err) => { - console.error(err); - process.exit(1); - }, -); +main().catch((err) => { + console.error(err); + process.exit(1); +}); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap index 21ce0ffebb5..832fcaa714f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/angular-component-examples/test.component.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/arrow/comments.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrow/comments.ts.snap index 14d52ed8780..3c7a54d7fd4 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/arrow/comments.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrow/comments.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/arrow/comments.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/arrow_function_expression.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/arrow_function_expression.ts new file mode 100644 index 00000000000..4e406bdbc98 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/arrow_function_expression.ts @@ -0,0 +1 @@ +a = (b?) => c; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/arrow_function_expression.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/arrow_function_expression.ts.prettier-snap new file mode 100644 index 00000000000..4e406bdbc98 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/arrow_function_expression.ts.prettier-snap @@ -0,0 +1 @@ +a = (b?) => c; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/short_body.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/short_body.ts new file mode 100644 index 00000000000..f7533b94f4c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/short_body.ts @@ -0,0 +1,6 @@ +const initializeSnapshotState = ( + testFile: Path, + update: boolean, + testPath: string, + expand: boolean, +) => new SnapshotState(testFile, update, testPath, expand); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/short_body.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/short_body.ts.prettier-snap new file mode 100644 index 00000000000..f7533b94f4c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/short_body.ts.prettier-snap @@ -0,0 +1,6 @@ +const initializeSnapshotState = ( + testFile: Path, + update: boolean, + testPath: string, + expand: boolean, +) => new SnapshotState(testFile, update, testPath, expand); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/type_params.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/type_params.ts new file mode 100644 index 00000000000..fae332d3954 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/type_params.ts @@ -0,0 +1 @@ +(a) => { } diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/type_params.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/type_params.ts.prettier-snap new file mode 100644 index 00000000000..37947b85db5 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/arrows/type_params.ts.prettier-snap @@ -0,0 +1 @@ +(a) => {}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/as/as.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/as/as.ts.snap index bec88409655..e0cd0e94bbb 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/as/as.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/as/as.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/as/as.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/as/export_default_as.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/as/export_default_as.ts.snap index 7fd5bfbdf72..531916dc047 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/as/export_default_as.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/as/export_default_as.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/as/export_default_as.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/assert/index.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/assert/index.ts.snap index baee3a253a6..af75b3e99d2 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/assert/index.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/assert/index.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/assert/index.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/class/empty-method-body.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/class/empty-method-body.ts.snap index ce6188d0d30..af1422c1046 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/class/empty-method-body.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/class/empty-method-body.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/class/empty-method-body.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/class/quoted-property.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/class/quoted-property.ts.snap index 461a9db7913..66feb86f166 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/class/quoted-property.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/class/quoted-property.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/class/quoted-property.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/comments/declare_function.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/comments/declare_function.ts.snap index 02adf14017f..91aee4f859d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/comments/declare_function.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/comments/declare_function.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/comments/declare_function.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/compiler/castParentheses.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/compiler/castParentheses.ts.snap index 9278d0afc75..43d2a854256 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/compiler/castParentheses.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/compiler/castParentheses.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/compiler/castParentheses.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts.snap index 694f034cad8..6f7f6985199 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/compiler/commentInNamespaceDeclarationWithIdentifierPathName.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.prettier-snap index de1ccb2859a..8f2955f7318 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.prettier-snap @@ -1 +1 @@ -type Foo = T extends ((...a: any[]) => infer R extends string) ? R : never; +type Foo = T extends (...a: any[]) => infer R extends string ? R : never; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.snap new file mode 100644 index 00000000000..7c7b8e4a858 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conditional-types/issue-13275.ts.snap @@ -0,0 +1,46 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conditional-types/issue-13275.ts +--- + +# Input + +```js +type Foo = T extends ((...a: any[]) => infer R extends string) ? R : never; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1 @@ +-type Foo = T extends (...a: any[]) => infer R extends string ? R : never; ++type Foo = T extends ((...a: any[]) => infer R extends string) ? R : never; +``` + +# Output + +```js +type Foo = T extends ((...a: any[]) => infer R extends string) ? R : never; +``` + + +# Errors +``` +issue-13275.ts:1:65 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `?` but instead found `)` + + > 1 │ type Foo = T extends ((...a: any[]) => infer R extends string) ? R : never; + │ ^ + 2 │ + + i Remove ) + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts.snap index 71d54ad9cde..5dae437ebc3 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "typescript\\conformance\\classes\\classDeclarations\\classAbstractKeyword\\classAbstractInstantiations2.ts" + test_file: typescript/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts.snap index 24c288d7e42..67084e8b357 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/es6/templates/templateStringWithEmbeddedTypeAssertionOnAdditionES6.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/contextualTypeWithTuple.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/contextualTypeWithTuple.ts.snap index b3e999005b7..8cf9a4e4740 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/contextualTypeWithTuple.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/contextualTypeWithTuple.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/tuple/contextualTypeWithTuple.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/indexerWithTuple.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/indexerWithTuple.ts.snap index 2a693892c30..10b47bb0ca2 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/indexerWithTuple.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/indexerWithTuple.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/tuple/indexerWithTuple.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/typeInferenceWithTupleType.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/typeInferenceWithTupleType.ts.snap index 86332c839eb..5d4cd802e36 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/typeInferenceWithTupleType.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/tuple/typeInferenceWithTupleType.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/tuple/typeInferenceWithTupleType.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures.ts.snap index 1e1be231668..3cbb9d4c9ff 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/union/unionTypeCallSignatures.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures3.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures3.ts.snap index 3198777d907..a66300bf3dd 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures3.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures3.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/union/unionTypeCallSignatures3.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures4.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures4.ts.snap index 4da75f92130..173a47dd370 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures4.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeCallSignatures4.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/union/unionTypeCallSignatures4.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeConstructSignatures.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeConstructSignatures.ts.snap index 50fb818fd7d..3ffb593ace1 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeConstructSignatures.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeConstructSignatures.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/union/unionTypeConstructSignatures.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeEquivalence.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeEquivalence.ts.snap index 52ca5ce0fac..5e6a6da7c10 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeEquivalence.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeEquivalence.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/union/unionTypeEquivalence.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeFromArrayLiteral.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeFromArrayLiteral.ts.snap index 89d7c340ee6..33a788075c3 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeFromArrayLiteral.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeFromArrayLiteral.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/union/unionTypeFromArrayLiteral.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeIndexSignature.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeIndexSignature.ts.snap index a23ef76be60..f42be5996d6 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeIndexSignature.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/conformance/types/union/unionTypeIndexSignature.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/conformance/types/union/unionTypeIndexSignature.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts new file mode 100644 index 00000000000..62624cad660 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts @@ -0,0 +1,2 @@ +declare function foo(...args: any[], ) +declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], ) diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts.prettier-snap new file mode 100644 index 00000000000..fbc85167947 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts.prettier-snap @@ -0,0 +1,4 @@ +declare function foo(...args: any[]); +declare function foo( + ...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[] +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts.snap new file mode 100644 index 00000000000..2a509a20f76 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/declare/trailing-comma/function-rest-trailing-comma.ts.snap @@ -0,0 +1,64 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/declare/trailing-comma/function-rest-trailing-comma.ts +--- + +# Input + +```js +declare function foo(...args: any[], ) +declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], ) +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,4 +1,2 @@ +-declare function foo(...args: any[]); +-declare function foo( +- ...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[] +-); ++declare function foo(...args: any[], ) ++declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], ) +``` + +# Output + +```js +declare function foo(...args: any[], ) +declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], ) +``` + + +# Errors +``` +function-rest-trailing-comma.ts:1:22 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × rest elements may not have trailing commas + + > 1 │ declare function foo(...args: any[], ) + │ ^^^^^^^^^^^^^^ + 2 │ declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], ) + 3 │ + +function-rest-trailing-comma.ts:2:22 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × rest elements may not have trailing commas + + 1 │ declare function foo(...args: any[], ) + > 2 │ declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], ) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 3 │ + + +``` + +# Lines exceeding max width of 80 characters +``` + 2: declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], ) +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/angular.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/angular.ts.snap index d6616a5eb41..4b0ea975fdb 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/angular.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/angular.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/decorators-ts/angular.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap index da62fc56464..7d916a4e88b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/decorators-ts/typeorm.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators-comments.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators-comments.ts.snap index 50ad05e6e27..f8a1b8eb277 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators-comments.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators-comments.ts.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "typescript\\decorators\\decorators-comments.ts" + test_file: typescript/decorators/decorators-comments.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/end-of-line/multiline.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/end-of-line/multiline.ts new file mode 100644 index 00000000000..b5186657980 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/end-of-line/multiline.ts @@ -0,0 +1,23 @@ +type IAmIncredibleLongParameterType = {}; +const IAmAnotherFunctionName = (_0: IAmIncredibleLongParameterType) => {}; +export const IAmIncredibleLongFunctionName = IAmAnotherFunctionName( + (_0: IAmIncredibleLongParameterType) => { + setTimeout(() => { + /* + Multiline comment + Multiline comment + Multiline comment + */ + console.log( + 'Multiline string\ + Multiline string\ + Multiline string' + ); + console.log( + `Multiline \n string\ + Multiline string\ + Multiline string` + ); + }); + } +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/end-of-line/multiline.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/end-of-line/multiline.ts.prettier-snap new file mode 100644 index 00000000000..f39472c27b7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/end-of-line/multiline.ts.prettier-snap @@ -0,0 +1,23 @@ +type IAmIncredibleLongParameterType = {}; +const IAmAnotherFunctionName = (_0: IAmIncredibleLongParameterType) => {}; +export const IAmIncredibleLongFunctionName = IAmAnotherFunctionName( + (_0: IAmIncredibleLongParameterType) => { + setTimeout(() => { + /* + Multiline comment + Multiline comment + Multiline comment + */ + console.log( + "Multiline string\ + Multiline string\ + Multiline string", + ); + console.log( + `Multiline \n string\ + Multiline string\ + Multiline string`, + ); + }); + }, +); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.prettier-snap index 7ba227a2b2c..ba48c56ec74 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.prettier-snap @@ -1,13 +1,13 @@ enum A { - i++, + [i++], } const bar = "bar"; enum B { - bar = 2, + [bar] = 2, } const foo = () => "foo"; enum C { - foo() = 2, + [foo()] = 2, } diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.snap deleted file mode 100644 index d94559fca9e..00000000000 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/enum/computed-members.ts.snap +++ /dev/null @@ -1,69 +0,0 @@ ---- -source: crates/rome_js_formatter/tests/prettier_tests.rs -info: - test_file: typescript/enum/computed-members.ts ---- - -# Input - -```js -enum A { - [i++], -} - -const bar = "bar" -enum B { - [bar] = 2, -} - -const foo = () => "foo"; -enum C { - [foo()] = 2, -} -``` - - -# Prettier differences - -```diff ---- Prettier -+++ Rome -@@ -1,13 +1,13 @@ - enum A { -- i++, -+ [i++], - } - - const bar = "bar"; - enum B { -- bar = 2, -+ [bar] = 2, - } - - const foo = () => "foo"; - enum C { -- foo() = 2, -+ [foo()] = 2, - } -``` - -# Output - -```js -enum A { - [i++], -} - -const bar = "bar"; -enum B { - [bar] = 2, -} - -const foo = () => "foo"; -enum C { - [foo()] = 2, -} -``` - - - diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.prettier-snap index fd8cf153040..7751d7a4192 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.prettier-snap @@ -1,8 +1,8 @@ let a: *; function b(x: ?) {} let c: ?string; -let d: ?string; +let d: string?; let e: ?(string | number); let f: !string; -let g: !string; +let g: string!; let h: !(string | number); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.snap index f3da2e4f2f2..1f5c707c791 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/error-recovery/jsdoc_only_types.ts.snap @@ -29,10 +29,10 @@ let h: !(string | number); +* function b(x: ?) {} -let c: ?string; --let d: ?string; +-let d: string?; -let e: ?(string | number); -let f: !string; --let g: !string; +-let g: string!; -let h: !(string | number); +let c: +?string diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/export-default/function_as.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/export-default/function_as.ts.snap index 8ea53add4b4..0eaf08b2265 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/export-default/function_as.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/export-default/function_as.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/export-default/function_as.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/generic/ungrouped-parameters.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/generic/ungrouped-parameters.ts.snap index 63d617b9f8a..1604fdcb0e5 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/generic/ungrouped-parameters.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/generic/ungrouped-parameters.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/generic/ungrouped-parameters.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/import-export/type-modifier.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/import-export/type-modifier.ts.snap index 8d7ca0b0c41..d8385b1a882 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/import-export/type-modifier.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/import-export/type-modifier.ts.snap @@ -1,7 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs info: - test_file: "typescript\\import-export\\type-modifier.ts" + test_file: typescript/import-export/type-modifier.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/instantiation-expression/binary-expr.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/instantiation-expression/binary-expr.ts.prettier-snap index 1a5bcb63130..ff501026c58 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/instantiation-expression/binary-expr.ts.prettier-snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/instantiation-expression/binary-expr.ts.prettier-snap @@ -1 +1,2 @@ -new A() < B > C; +new A(); +C; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/instantiation-expression/binary-expr.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/instantiation-expression/binary-expr.ts.snap new file mode 100644 index 00000000000..a027a9c0cfb --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/instantiation-expression/binary-expr.ts.snap @@ -0,0 +1,33 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/instantiation-expression/binary-expr.ts +--- + +# Input + +```js +new A < B > +C +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,2 +1 @@ +-new A(); +-C; ++new A() < B > C; +``` + +# Output + +```js +new A() < B > C; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/interface/long-type-parameters/long-type-parameters.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/interface/long-type-parameters/long-type-parameters.ts new file mode 100644 index 00000000000..feedc34865a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/interface/long-type-parameters/long-type-parameters.ts @@ -0,0 +1,14 @@ +// https://github.com/vega/vega-lite/blob/ae13aff7b480cf9c994031eca08a6b1720e01ab3/src/mark.ts#L602 +export interface MarkDef< + M extends string | Mark = Mark, + ES extends ExprRef | SignalRef = ExprRef | SignalRef +> extends GenericMarkDef, + Omit< + MarkConfig & + AreaConfig & + BarConfig & // always extends RectConfig + LineConfig & + TickConfig, + 'startAngle' | 'endAngle' | 'width' | 'height' + >, + MarkDefMixins {} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/interface/long-type-parameters/long-type-parameters.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/interface/long-type-parameters/long-type-parameters.ts.prettier-snap new file mode 100644 index 00000000000..fdd268e1c19 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/interface/long-type-parameters/long-type-parameters.ts.prettier-snap @@ -0,0 +1,14 @@ +// https://github.com/vega/vega-lite/blob/ae13aff7b480cf9c994031eca08a6b1720e01ab3/src/mark.ts#L602 +export interface MarkDef< + M extends string | Mark = Mark, + ES extends ExprRef | SignalRef = ExprRef | SignalRef, +> extends GenericMarkDef, + Omit< + MarkConfig & + AreaConfig & + BarConfig & // always extends RectConfig + LineConfig & + TickConfig, + "startAngle" | "endAngle" | "width" | "height" + >, + MarkDefMixins {} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/multiparser-css/issue-6259.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/multiparser-css/issue-6259.ts.snap index ab54963582e..34074d2b762 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/multiparser-css/issue-6259.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/multiparser-css/issue-6259.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/multiparser-css/issue-6259.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/non-null/braces.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/non-null/braces.ts.snap index d5549a38952..e04be1e5765 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/non-null/braces.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/non-null/braces.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/non-null/braces.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/non-null/optional-chain.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/non-null/optional-chain.ts.snap index 7bde7ecddb7..427d1b7f224 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/non-null/optional-chain.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/non-null/optional-chain.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/non-null/optional-chain.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/index-signature.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/index-signature.ts new file mode 100644 index 00000000000..ebe06818b74 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/index-signature.ts @@ -0,0 +1,4 @@ +class LocalStorage implements Storage { + [index: number]: string; + [key: string]: any; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/index-signature.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/index-signature.ts.prettier-snap new file mode 100644 index 00000000000..ebe06818b74 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/index-signature.ts.prettier-snap @@ -0,0 +1,4 @@ +class LocalStorage implements Storage { + [index: number]: string; + [key: string]: any; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/interface.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/interface.ts new file mode 100644 index 00000000000..41c42a9c624 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/interface.ts @@ -0,0 +1,8 @@ +interface Inline { x: string } + +interface MultiLine { + x: string; + y: string; +} + +interface InlineMultiple { x: string; y: string } diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/interface.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/interface.ts.prettier-snap new file mode 100644 index 00000000000..6e138fd9c28 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/interface.ts.prettier-snap @@ -0,0 +1,13 @@ +interface Inline { + x: string; +} + +interface MultiLine { + x: string; + y: string; +} + +interface InlineMultiple { + x: string; + y: string; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/type.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/type.ts new file mode 100644 index 00000000000..5161f34ed9a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/type.ts @@ -0,0 +1,3 @@ +type A = {disabled?: boolean, error?: string} + +const foo: {aasdf?: string; asdf?: number; foob?: string; zzz?: string; yyy: string} = {} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/type.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/type.ts.prettier-snap new file mode 100644 index 00000000000..b28ec4a9ca4 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/nosemi/type.ts.prettier-snap @@ -0,0 +1,9 @@ +type A = { disabled?: boolean; error?: string }; + +const foo: { + aasdf?: string; + asdf?: number; + foob?: string; + zzz?: string; + yyy: string; +} = {}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/quote-props/types.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/quote-props/types.ts new file mode 100644 index 00000000000..2d37a43df1e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/quote-props/types.ts @@ -0,0 +1,9 @@ +type T = { + 0: string; + 5: number; +} + +type U = { + 0: string; + "5": number; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/quote-props/types.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/quote-props/types.ts.prettier-snap new file mode 100644 index 00000000000..e5b619ef56f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/quote-props/types.ts.prettier-snap @@ -0,0 +1,9 @@ +type T = { + 0: string; + 5: number; +}; + +type U = { + 0: string; + "5": number; +}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/range/export-assignment.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/range/export-assignment.ts.snap index 65ff453c863..a07d153449d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/range/export-assignment.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/range/export-assignment.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/range/export-assignment.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts new file mode 100644 index 00000000000..aef1a1410c1 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts @@ -0,0 +1,19 @@ +const bar1 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, ([] satisfies unknown) satisfies number[]); + +const bar2 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, ([1, 2, 3] satisfies unknown) satisfies number[]); + +const bar3 = [1,2,3].reduce((carry, value) => { + return {...carry, [value]: true}; +}, ({} satisfies unknown) satisfies {[key: number]: boolean}); + +const bar4 = [1,2,3].reduce((carry, value) => { + return {...carry, [value]: true}; +}, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + +const bar5 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, [] satisfies foo); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts.prettier-snap new file mode 100644 index 00000000000..eb86b04ee4c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts.prettier-snap @@ -0,0 +1,25 @@ +const bar1 = [1, 2, 3].reduce((carry, value) => { + return [...carry, value]; +}, [] satisfies unknown satisfies number[]); + +const bar2 = [1, 2, 3].reduce( + (carry, value) => { + return [...carry, value]; + }, + [1, 2, 3] satisfies unknown satisfies number[] +); + +const bar3 = [1, 2, 3].reduce((carry, value) => { + return { ...carry, [value]: true }; +}, {} satisfies unknown satisfies { [key: number]: boolean }); + +const bar4 = [1, 2, 3].reduce( + (carry, value) => { + return { ...carry, [value]: true }; + }, + { 1: true } satisfies unknown satisfies { [key: number]: boolean } +); + +const bar5 = [1, 2, 3].reduce((carry, value) => { + return [...carry, value]; +}, [] satisfies foo); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts.snap new file mode 100644 index 00000000000..09fcea7b100 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/argument-expansion.ts.snap @@ -0,0 +1,735 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/argument-expansion.ts +--- + +# Input + +```js +const bar1 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, ([] satisfies unknown) satisfies number[]); + +const bar2 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, ([1, 2, 3] satisfies unknown) satisfies number[]); + +const bar3 = [1,2,3].reduce((carry, value) => { + return {...carry, [value]: true}; +}, ({} satisfies unknown) satisfies {[key: number]: boolean}); + +const bar4 = [1,2,3].reduce((carry, value) => { + return {...carry, [value]: true}; +}, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + +const bar5 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, [] satisfies foo); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,25 +1,37 @@ +-const bar1 = [1, 2, 3].reduce((carry, value) => { ++const bar1 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +-}, [] satisfies unknown satisfies number[]); ++}, ([] satisfies unknown) ++satisfies; ++number[] ++) + +-const bar2 = [1, 2, 3].reduce( +- (carry, value) => { +- return [...carry, value]; +- }, +- [1, 2, 3] satisfies unknown satisfies number[] +-); ++const bar2 = [1,2,3].reduce((carry, value) => { ++ return [...carry, value]; ++}, ([1, 2, 3] satisfies unknown) ++satisfies; ++number[] ++) + +-const bar3 = [1, 2, 3].reduce((carry, value) => { +- return { ...carry, [value]: true }; +-}, {} satisfies unknown satisfies { [key: number]: boolean }); ++const bar3 = [1,2,3].reduce((carry, value) => { ++ return {...carry, [value]: true}; ++}, ({} satisfies unknown) ++satisfies; ++{ ++ [key: number] ++ : boolean ++} ++) + +-const bar4 = [1, 2, 3].reduce( +- (carry, value) => { +- return { ...carry, [value]: true }; +- }, +- { 1: true } satisfies unknown satisfies { [key: number]: boolean } +-); ++const bar4 = [1,2,3].reduce((carry, value) => { ++ return {...carry, [value]: true}; ++}, ({1: true} satisfies unknown) ++satisfies; ++{ ++ [key: number] ++ : boolean ++} ++) + +-const bar5 = [1, 2, 3].reduce((carry, value) => { ++const bar5 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; + }, [] satisfies foo); +``` + +# Output + +```js +const bar1 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, ([] satisfies unknown) +satisfies; +number[] +) + +const bar2 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, ([1, 2, 3] satisfies unknown) +satisfies; +number[] +) + +const bar3 = [1,2,3].reduce((carry, value) => { + return {...carry, [value]: true}; +}, ({} satisfies unknown) +satisfies; +{ + [key: number] + : boolean +} +) + +const bar4 = [1,2,3].reduce((carry, value) => { + return {...carry, [value]: true}; +}, ({1: true} satisfies unknown) +satisfies; +{ + [key: number] + : boolean +} +) + +const bar5 = [1,2,3].reduce((carry, value) => { + return [...carry, value]; +}, [] satisfies foo); +``` + + +# Errors +``` +argument-expansion.ts:3:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i Remove satisfies + +argument-expansion.ts:3:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `unknown` + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i Remove unknown + +argument-expansion.ts:3:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + > 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:3:37 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^^^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:3:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected an expression but instead found ']' + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i Expected an expression here + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:3:45 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 1 │ const bar1 = [1,2,3].reduce((carry, value) => { + 2 │ return [...carry, value]; + > 3 │ }, ([] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^ + 4 │ + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:7:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i Remove satisfies + +argument-expansion.ts:7:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `unknown` + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i Remove unknown + +argument-expansion.ts:7:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 3 │ }, ([] satisfies unknown) satisfies number[]); + 4 │ + > 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:7:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^^^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:7:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected an expression but instead found ']' + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i Expected an expression here + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:7:52 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 5 │ const bar2 = [1,2,3].reduce((carry, value) => { + 6 │ return [...carry, value]; + > 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + │ ^^^^^^^^^ + 8 │ + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:11:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i Remove satisfies + +argument-expansion.ts:11:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `unknown` + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i Remove unknown + +argument-expansion.ts:11:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 7 │ }, ([1, 2, 3] satisfies unknown) satisfies number[]); + 8 │ + > 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:11:37 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^^^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:11:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `:` + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i Remove : + +argument-expansion.ts:11:51 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^^^^^^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:11:61 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found ')' + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + + i Expected a statement here + + 9 │ const bar3 = [1,2,3].reduce((carry, value) => { + 10 │ return {...carry, [value]: true}; + > 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 12 │ + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:15:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i Remove satisfies + +argument-expansion.ts:15:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `unknown` + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i Remove unknown + +argument-expansion.ts:15:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 11 │ }, ({} satisfies unknown) satisfies {[key: number]: boolean}); + 12 │ + > 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:15:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^^^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:15:49 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `:` + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i Remove : + +argument-expansion.ts:15:58 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i An explicit or implicit semicolon is expected here... + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i ...Which is required to end this statement + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^^^^^^^^^^^^^^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:15:68 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found ')' + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + + i Expected a statement here + + 13 │ const bar4 = [1,2,3].reduce((carry, value) => { + 14 │ return {...carry, [value]: true}; + > 15 │ }, ({1: true} satisfies unknown) satisfies {[key: number]: boolean}); + │ ^ + 16 │ + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + +argument-expansion.ts:19:7 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `satisfies` + + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + 18 │ return [...carry, value]; + > 19 │ }, [] satisfies foo); + │ ^^^^^^^^^ + 20 │ + + i Remove satisfies + +argument-expansion.ts:19:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `foo` + + 17 │ const bar5 = [1,2,3].reduce((carry, value) => { + 18 │ return [...carry, value]; + > 19 │ }, [] satisfies foo); + │ ^^^ + 20 │ + + i Remove foo + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts new file mode 100644 index 00000000000..9b7139253bc --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts @@ -0,0 +1,21 @@ +const extraRendererAttrs = ((attrs.rendererAttrs && + this.utils.safeParseJsonString(attrs.rendererAttrs)) || + Object.create(null)) satisfies FieldService.RendererAttributes; + +const annotate = (angular.injector satisfies any).$$annotate satisfies ( + fn: Function +) => string[]; + +const originalPrototype = originalConstructor.prototype satisfies TComponent & InjectionTarget, + propertyToServiceName = originalPrototype._inject; + +this.previewPlayerHandle = (setInterval(async () => { + if (this.previewIsPlaying) { + await this.fetchNextPreviews(); + this.currentPreviewIndex++; + } +}, this.refreshDelay) satisfies unknown) satisfies number; + +this.intervalID = (setInterval(() => { + self.step(); +}, 30) satisfies unknown) satisfies number; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts.prettier-snap new file mode 100644 index 00000000000..35177c96b8a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts.prettier-snap @@ -0,0 +1,22 @@ +const extraRendererAttrs = ((attrs.rendererAttrs && + this.utils.safeParseJsonString(attrs.rendererAttrs)) || + Object.create(null)) satisfies FieldService.RendererAttributes; + +const annotate = (angular.injector satisfies any).$$annotate satisfies ( + fn: Function +) => string[]; + +const originalPrototype = originalConstructor.prototype satisfies TComponent & + InjectionTarget, + propertyToServiceName = originalPrototype._inject; + +this.previewPlayerHandle = setInterval(async () => { + if (this.previewIsPlaying) { + await this.fetchNextPreviews(); + this.currentPreviewIndex++; + } +}, this.refreshDelay) satisfies unknown satisfies number; + +this.intervalID = setInterval(() => { + self.step(); +}, 30) satisfies unknown satisfies number; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts.snap new file mode 100644 index 00000000000..320be414362 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/assignment.ts.snap @@ -0,0 +1,458 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/assignment.ts +--- + +# Input + +```js +const extraRendererAttrs = ((attrs.rendererAttrs && + this.utils.safeParseJsonString(attrs.rendererAttrs)) || + Object.create(null)) satisfies FieldService.RendererAttributes; + +const annotate = (angular.injector satisfies any).$$annotate satisfies ( + fn: Function +) => string[]; + +const originalPrototype = originalConstructor.prototype satisfies TComponent & InjectionTarget, + propertyToServiceName = originalPrototype._inject; + +this.previewPlayerHandle = (setInterval(async () => { + if (this.previewIsPlaying) { + await this.fetchNextPreviews(); + this.currentPreviewIndex++; + } +}, this.refreshDelay) satisfies unknown) satisfies number; + +this.intervalID = (setInterval(() => { + self.step(); +}, 30) satisfies unknown) satisfies number; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,22 +1,35 @@ +-const extraRendererAttrs = ((attrs.rendererAttrs && +- this.utils.safeParseJsonString(attrs.rendererAttrs)) || +- Object.create(null)) satisfies FieldService.RendererAttributes; ++const extraRendererAttrs = ++ (attrs.rendererAttrs && ++ this.utils.safeParseJsonString(attrs.rendererAttrs)) || ++ Object.create(null); ++satisfies; ++FieldService.RendererAttributes; + +-const annotate = (angular.injector satisfies any).$$annotate satisfies ( ++const annotate = (angular.injector ++satisfies; ++any; ++).$$annotate satisfies ( + fn: Function +-) => string[]; ++) => string[] + +-const originalPrototype = originalConstructor.prototype satisfies TComponent & +- InjectionTarget, +- propertyToServiceName = originalPrototype._inject; ++const originalPrototype = originalConstructor.prototype; ++satisfies; ++TComponent & InjectionTarget, ++ (propertyToServiceName = originalPrototype._inject); + +-this.previewPlayerHandle = setInterval(async () => { ++this.previewPlayerHandle = (setInterval(async () => { + if (this.previewIsPlaying) { + await this.fetchNextPreviews(); + this.currentPreviewIndex++; + } +-}, this.refreshDelay) satisfies unknown satisfies number; ++}, this.refreshDelay) ++satisfies; ++unknown; ++) satisfies number + +-this.intervalID = setInterval(() => { ++this.intervalID = (setInterval(() => { + self.step(); +-}, 30) satisfies unknown satisfies number; ++}, 30) ++satisfies; ++unknown; ++) satisfies number +``` + +# Output + +```js +const extraRendererAttrs = + (attrs.rendererAttrs && + this.utils.safeParseJsonString(attrs.rendererAttrs)) || + Object.create(null); +satisfies; +FieldService.RendererAttributes; + +const annotate = (angular.injector +satisfies; +any; +).$$annotate satisfies ( + fn: Function +) => string[] + +const originalPrototype = originalConstructor.prototype; +satisfies; +TComponent & InjectionTarget, + (propertyToServiceName = originalPrototype._inject); + +this.previewPlayerHandle = (setInterval(async () => { + if (this.previewIsPlaying) { + await this.fetchNextPreviews(); + this.currentPreviewIndex++; + } +}, this.refreshDelay) +satisfies; +unknown; +) satisfies number + +this.intervalID = (setInterval(() => { + self.step(); +}, 30) +satisfies; +unknown; +) satisfies number +``` + + +# Errors +``` +assignment.ts:3:24 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const extraRendererAttrs = ((attrs.rendererAttrs && + 2 │ this.utils.safeParseJsonString(attrs.rendererAttrs)) || + > 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + │ ^^^^^^^^^ + 4 │ + 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + + i An explicit or implicit semicolon is expected here... + + 1 │ const extraRendererAttrs = ((attrs.rendererAttrs && + 2 │ this.utils.safeParseJsonString(attrs.rendererAttrs)) || + > 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + │ ^^^^^^^^^ + 4 │ + 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + + i ...Which is required to end this statement + + > 1 │ const extraRendererAttrs = ((attrs.rendererAttrs && + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 2 │ this.utils.safeParseJsonString(attrs.rendererAttrs)) || + > 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + │ ^^^^^^^^^^^^^^^^^^^^^ + 4 │ + 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + +assignment.ts:3:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const extraRendererAttrs = ((attrs.rendererAttrs && + 2 │ this.utils.safeParseJsonString(attrs.rendererAttrs)) || + > 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + │ ^^^^^^^^^^^^ + 4 │ + 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + + i An explicit or implicit semicolon is expected here... + + 1 │ const extraRendererAttrs = ((attrs.rendererAttrs && + 2 │ this.utils.safeParseJsonString(attrs.rendererAttrs)) || + > 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + │ ^^^^^^^^^^^^ + 4 │ + 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + + i ...Which is required to end this statement + + 1 │ const extraRendererAttrs = ((attrs.rendererAttrs && + 2 │ this.utils.safeParseJsonString(attrs.rendererAttrs)) || + > 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + │ ^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + +assignment.ts:5:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + 4 │ + > 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + │ ^^^^^^^^^ + 6 │ fn: Function + 7 │ ) => string[]; + + i Remove satisfies + +assignment.ts:5:46 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + 4 │ + > 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + │ ^^^ + 6 │ fn: Function + 7 │ ) => string[]; + + i An explicit or implicit semicolon is expected here... + + 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + 4 │ + > 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + │ ^^^ + 6 │ fn: Function + 7 │ ) => string[]; + + i ...Which is required to end this statement + + 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + 4 │ + > 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + │ ^^^^^^^^^^^^^ + 6 │ fn: Function + 7 │ ) => string[]; + +assignment.ts:5:49 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + 4 │ + > 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + │ ^ + 6 │ fn: Function + 7 │ ) => string[]; + + i An explicit or implicit semicolon is expected here... + + 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + 4 │ + > 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + │ ^ + 6 │ fn: Function + 7 │ ) => string[]; + + i ...Which is required to end this statement + + 3 │ Object.create(null)) satisfies FieldService.RendererAttributes; + 4 │ + > 5 │ const annotate = (angular.injector satisfies any).$$annotate satisfies ( + │ ^^^^ + 6 │ fn: Function + 7 │ ) => string[]; + +assignment.ts:9:57 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 7 │ ) => string[]; + 8 │ + > 9 │ const originalPrototype = originalConstructor.prototype satisfies TComponent & InjectionTarget, + │ ^^^^^^^^^ + 10 │ propertyToServiceName = originalPrototype._inject; + 11 │ + + i An explicit or implicit semicolon is expected here... + + 7 │ ) => string[]; + 8 │ + > 9 │ const originalPrototype = originalConstructor.prototype satisfies TComponent & InjectionTarget, + │ ^^^^^^^^^ + 10 │ propertyToServiceName = originalPrototype._inject; + 11 │ + + i ...Which is required to end this statement + + 7 │ ) => string[]; + 8 │ + > 9 │ const originalPrototype = originalConstructor.prototype satisfies TComponent & InjectionTarget, + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 10 │ propertyToServiceName = originalPrototype._inject; + 11 │ + +assignment.ts:9:67 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 7 │ ) => string[]; + 8 │ + > 9 │ const originalPrototype = originalConstructor.prototype satisfies TComponent & InjectionTarget, + │ ^^^^^^^^^^ + 10 │ propertyToServiceName = originalPrototype._inject; + 11 │ + + i An explicit or implicit semicolon is expected here... + + 7 │ ) => string[]; + 8 │ + > 9 │ const originalPrototype = originalConstructor.prototype satisfies TComponent & InjectionTarget, + │ ^^^^^^^^^^ + 10 │ propertyToServiceName = originalPrototype._inject; + 11 │ + + i ...Which is required to end this statement + + 7 │ ) => string[]; + 8 │ + > 9 │ const originalPrototype = originalConstructor.prototype satisfies TComponent & InjectionTarget, + │ ^^^^^^^^^^^^^^^^^^^^ + 10 │ propertyToServiceName = originalPrototype._inject; + 11 │ + +assignment.ts:17:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 15 │ this.currentPreviewIndex++; + 16 │ } + > 17 │ }, this.refreshDelay) satisfies unknown) satisfies number; + │ ^^^^^^^^^ + 18 │ + 19 │ this.intervalID = (setInterval(() => { + + i Remove satisfies + +assignment.ts:17:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 15 │ this.currentPreviewIndex++; + 16 │ } + > 17 │ }, this.refreshDelay) satisfies unknown) satisfies number; + │ ^^^^^^^ + 18 │ + 19 │ this.intervalID = (setInterval(() => { + + i An explicit or implicit semicolon is expected here... + + 15 │ this.currentPreviewIndex++; + 16 │ } + > 17 │ }, this.refreshDelay) satisfies unknown) satisfies number; + │ ^^^^^^^ + 18 │ + 19 │ this.intervalID = (setInterval(() => { + + i ...Which is required to end this statement + + 15 │ this.currentPreviewIndex++; + 16 │ } + > 17 │ }, this.refreshDelay) satisfies unknown) satisfies number; + │ ^^^^^^^^^^^^^^^^^ + 18 │ + 19 │ this.intervalID = (setInterval(() => { + +assignment.ts:17:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 15 │ this.currentPreviewIndex++; + 16 │ } + > 17 │ }, this.refreshDelay) satisfies unknown) satisfies number; + │ ^ + 18 │ + 19 │ this.intervalID = (setInterval(() => { + + i An explicit or implicit semicolon is expected here... + + 15 │ this.currentPreviewIndex++; + 16 │ } + > 17 │ }, this.refreshDelay) satisfies unknown) satisfies number; + │ ^ + 18 │ + 19 │ this.intervalID = (setInterval(() => { + + i ...Which is required to end this statement + + 15 │ this.currentPreviewIndex++; + 16 │ } + > 17 │ }, this.refreshDelay) satisfies unknown) satisfies number; + │ ^^^^^^^^ + 18 │ + 19 │ this.intervalID = (setInterval(() => { + +assignment.ts:21:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 19 │ this.intervalID = (setInterval(() => { + 20 │ self.step(); + > 21 │ }, 30) satisfies unknown) satisfies number; + │ ^^^^^^^^^ + 22 │ + + i Remove satisfies + +assignment.ts:21:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 19 │ this.intervalID = (setInterval(() => { + 20 │ self.step(); + > 21 │ }, 30) satisfies unknown) satisfies number; + │ ^^^^^^^ + 22 │ + + i An explicit or implicit semicolon is expected here... + + 19 │ this.intervalID = (setInterval(() => { + 20 │ self.step(); + > 21 │ }, 30) satisfies unknown) satisfies number; + │ ^^^^^^^ + 22 │ + + i ...Which is required to end this statement + + 19 │ this.intervalID = (setInterval(() => { + 20 │ self.step(); + > 21 │ }, 30) satisfies unknown) satisfies number; + │ ^^^^^^^^^^^^^^^^^ + 22 │ + +assignment.ts:21:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 19 │ this.intervalID = (setInterval(() => { + 20 │ self.step(); + > 21 │ }, 30) satisfies unknown) satisfies number; + │ ^ + 22 │ + + i An explicit or implicit semicolon is expected here... + + 19 │ this.intervalID = (setInterval(() => { + 20 │ self.step(); + > 21 │ }, 30) satisfies unknown) satisfies number; + │ ^ + 22 │ + + i ...Which is required to end this statement + + 19 │ this.intervalID = (setInterval(() => { + 20 │ self.step(); + > 21 │ }, 30) satisfies unknown) satisfies number; + │ ^^^^^^^^ + 22 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts new file mode 100644 index 00000000000..3eff7182b43 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts @@ -0,0 +1,30 @@ +const t1 = { a: 1 } satisfies I1; +const t2 = { a: 1, b: 1 } satisfies I1; +const t3 = { } satisfies I1; +const t4: T1 = { a: "a" } satisfies T1; +const t5 = (m => m.substring(0)) satisfies T2; +const t6 = [1, 2] satisfies [number, number]; +let t7 = { a: 'test' } satisfies A; +let t8 = { a: 'test', b: 'test' } satisfies A; + +const p = { + isEven: n => n % 2 === 0, + isOdd: n => n % 2 === 1 +} satisfies Predicates; + +let obj: { f(s: string): void } & Record = { + f(s) { }, + g(s) { } +} satisfies { g(s: string): void } & Record; + +({ f(x) { } }) satisfies { f(s: string): void }; + +const car = { + start() { }, + move(d) { + // d should be number + }, + stop() { } +} satisfies Movable & Record; + +var v = undefined satisfies 1; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts.prettier-snap new file mode 100644 index 00000000000..7a2f29b67d0 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts.prettier-snap @@ -0,0 +1,30 @@ +const t1 = { a: 1 } satisfies I1; +const t2 = { a: 1, b: 1 } satisfies I1; +const t3 = {} satisfies I1; +const t4: T1 = { a: "a" } satisfies T1; +const t5 = ((m) => m.substring(0)) satisfies T2; +const t6 = [1, 2] satisfies [number, number]; +let t7 = { a: "test" } satisfies A; +let t8 = { a: "test", b: "test" } satisfies A; + +const p = { + isEven: (n) => n % 2 === 0, + isOdd: (n) => n % 2 === 1, +} satisfies Predicates; + +let obj: { f(s: string): void } & Record = { + f(s) {}, + g(s) {}, +} satisfies { g(s: string): void } & Record; + +({ f(x) {} } satisfies { f(s: string): void }); + +const car = { + start() {}, + move(d) { + // d should be number + }, + stop() {}, +} satisfies Movable & Record; + +var v = undefined satisfies 1; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts.snap new file mode 100644 index 00000000000..94737bae44f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/basic.ts.snap @@ -0,0 +1,1017 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/basic.ts +--- + +# Input + +```js +const t1 = { a: 1 } satisfies I1; +const t2 = { a: 1, b: 1 } satisfies I1; +const t3 = { } satisfies I1; +const t4: T1 = { a: "a" } satisfies T1; +const t5 = (m => m.substring(0)) satisfies T2; +const t6 = [1, 2] satisfies [number, number]; +let t7 = { a: 'test' } satisfies A; +let t8 = { a: 'test', b: 'test' } satisfies A; + +const p = { + isEven: n => n % 2 === 0, + isOdd: n => n % 2 === 1 +} satisfies Predicates; + +let obj: { f(s: string): void } & Record = { + f(s) { }, + g(s) { } +} satisfies { g(s: string): void } & Record; + +({ f(x) { } }) satisfies { f(s: string): void }; + +const car = { + start() { }, + move(d) { + // d should be number + }, + stop() { } +} satisfies Movable & Record; + +var v = undefined satisfies 1; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,23 +1,51 @@ +-const t1 = { a: 1 } satisfies I1; +-const t2 = { a: 1, b: 1 } satisfies I1; +-const t3 = {} satisfies I1; +-const t4: T1 = { a: "a" } satisfies T1; +-const t5 = ((m) => m.substring(0)) satisfies T2; +-const t6 = [1, 2] satisfies [number, number]; +-let t7 = { a: "test" } satisfies A; +-let t8 = { a: "test", b: "test" } satisfies A; ++const t1 = { a: 1 }; ++satisfies; ++I1; ++const t2 = { a: 1, b: 1 }; ++satisfies; ++I1; ++const t3 = {}; ++satisfies; ++I1; ++const t4: T1 = { a: "a" }; ++satisfies; ++T1; ++const t5 = (m) => m.substring(0); ++satisfies; ++T2; ++const t6 = [1, 2]; ++satisfies[(number, number)]; ++let t7 = { a: "test" }; ++satisfies; ++A; ++let t8 = { a: "test", b: "test" }; ++satisfies; ++A; + + const p = { + isEven: (n) => n % 2 === 0, + isOdd: (n) => n % 2 === 1, +-} satisfies Predicates; ++}; ++satisfies; ++Predicates; + + let obj: { f(s: string): void } & Record = { + f(s) {}, + g(s) {}, +-} satisfies { g(s: string): void } & Record; ++}; ++satisfies; ++{ ++ g(s: string) ++ : void ++} ++& Record + +-({ f(x) {} } satisfies { f(s: string): void }); ++({ f(x) {} }); ++satisfies; ++{ ++ f(s: string) ++ : void ++} + + const car = { + start() {}, +@@ -25,6 +53,10 @@ + // d should be number + }, + stop() {}, +-} satisfies Movable & Record; ++}; ++satisfies; ++Movable & Record; + +-var v = undefined satisfies 1; ++var v = undefined; ++satisfies; ++1; +``` + +# Output + +```js +const t1 = { a: 1 }; +satisfies; +I1; +const t2 = { a: 1, b: 1 }; +satisfies; +I1; +const t3 = {}; +satisfies; +I1; +const t4: T1 = { a: "a" }; +satisfies; +T1; +const t5 = (m) => m.substring(0); +satisfies; +T2; +const t6 = [1, 2]; +satisfies[(number, number)]; +let t7 = { a: "test" }; +satisfies; +A; +let t8 = { a: "test", b: "test" }; +satisfies; +A; + +const p = { + isEven: (n) => n % 2 === 0, + isOdd: (n) => n % 2 === 1, +}; +satisfies; +Predicates; + +let obj: { f(s: string): void } & Record = { + f(s) {}, + g(s) {}, +}; +satisfies; +{ + g(s: string) + : void +} +& Record + +({ f(x) {} }); +satisfies; +{ + f(s: string) + : void +} + +const car = { + start() {}, + move(d) { + // d should be number + }, + stop() {}, +}; +satisfies; +Movable & Record; + +var v = undefined; +satisfies; +1; +``` + + +# Errors +``` +basic.ts:1:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ const t1 = { a: 1 } satisfies I1; + │ ^^^^^^^^^ + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + + i An explicit or implicit semicolon is expected here... + + > 1 │ const t1 = { a: 1 } satisfies I1; + │ ^^^^^^^^^ + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + + i ...Which is required to end this statement + + > 1 │ const t1 = { a: 1 } satisfies I1; + │ ^^^^^^^^^^^^^^^^^^^^ + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + +basic.ts:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ const t1 = { a: 1 } satisfies I1; + │ ^^ + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + + i An explicit or implicit semicolon is expected here... + + > 1 │ const t1 = { a: 1 } satisfies I1; + │ ^^ + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + + i ...Which is required to end this statement + + > 1 │ const t1 = { a: 1 } satisfies I1; + │ ^^^^^^^^^^^^ + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + +basic.ts:2:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const t1 = { a: 1 } satisfies I1; + > 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + │ ^^^^^^^^^ + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + + i An explicit or implicit semicolon is expected here... + + 1 │ const t1 = { a: 1 } satisfies I1; + > 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + │ ^^^^^^^^^ + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + + i ...Which is required to end this statement + + 1 │ const t1 = { a: 1 } satisfies I1; + > 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + +basic.ts:2:37 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const t1 = { a: 1 } satisfies I1; + > 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + │ ^^ + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + + i An explicit or implicit semicolon is expected here... + + 1 │ const t1 = { a: 1 } satisfies I1; + > 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + │ ^^ + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + + i ...Which is required to end this statement + + 1 │ const t1 = { a: 1 } satisfies I1; + > 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + │ ^^^^^^^^^^^^ + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + +basic.ts:3:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const t1 = { a: 1 } satisfies I1; + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + > 3 │ const t3 = { } satisfies I1; + │ ^^^^^^^^^ + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + + i An explicit or implicit semicolon is expected here... + + 1 │ const t1 = { a: 1 } satisfies I1; + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + > 3 │ const t3 = { } satisfies I1; + │ ^^^^^^^^^ + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + + i ...Which is required to end this statement + + 1 │ const t1 = { a: 1 } satisfies I1; + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + > 3 │ const t3 = { } satisfies I1; + │ ^^^^^^^^^^^^^^^ + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + +basic.ts:3:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const t1 = { a: 1 } satisfies I1; + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + > 3 │ const t3 = { } satisfies I1; + │ ^^ + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + + i An explicit or implicit semicolon is expected here... + + 1 │ const t1 = { a: 1 } satisfies I1; + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + > 3 │ const t3 = { } satisfies I1; + │ ^^ + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + + i ...Which is required to end this statement + + 1 │ const t1 = { a: 1 } satisfies I1; + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + > 3 │ const t3 = { } satisfies I1; + │ ^^^^^^^^^^^^ + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + +basic.ts:4:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + > 4 │ const t4: T1 = { a: "a" } satisfies T1; + │ ^^^^^^^^^ + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + + i An explicit or implicit semicolon is expected here... + + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + > 4 │ const t4: T1 = { a: "a" } satisfies T1; + │ ^^^^^^^^^ + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + + i ...Which is required to end this statement + + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + > 4 │ const t4: T1 = { a: "a" } satisfies T1; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + +basic.ts:4:37 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + > 4 │ const t4: T1 = { a: "a" } satisfies T1; + │ ^^ + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + + i An explicit or implicit semicolon is expected here... + + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + > 4 │ const t4: T1 = { a: "a" } satisfies T1; + │ ^^ + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + + i ...Which is required to end this statement + + 2 │ const t2 = { a: 1, b: 1 } satisfies I1; + 3 │ const t3 = { } satisfies I1; + > 4 │ const t4: T1 = { a: "a" } satisfies T1; + │ ^^^^^^^^^^^^ + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + +basic.ts:5:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + > 5 │ const t5 = (m => m.substring(0)) satisfies T2; + │ ^^^^^^^^^ + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + + i An explicit or implicit semicolon is expected here... + + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + > 5 │ const t5 = (m => m.substring(0)) satisfies T2; + │ ^^^^^^^^^ + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + + i ...Which is required to end this statement + + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + > 5 │ const t5 = (m => m.substring(0)) satisfies T2; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + +basic.ts:5:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + > 5 │ const t5 = (m => m.substring(0)) satisfies T2; + │ ^^ + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + + i An explicit or implicit semicolon is expected here... + + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + > 5 │ const t5 = (m => m.substring(0)) satisfies T2; + │ ^^ + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + + i ...Which is required to end this statement + + 3 │ const t3 = { } satisfies I1; + 4 │ const t4: T1 = { a: "a" } satisfies T1; + > 5 │ const t5 = (m => m.substring(0)) satisfies T2; + │ ^^^^^^^^^^^^ + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + +basic.ts:6:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + > 6 │ const t6 = [1, 2] satisfies [number, number]; + │ ^^^^^^^^^ + 7 │ let t7 = { a: 'test' } satisfies A; + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + + i An explicit or implicit semicolon is expected here... + + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + > 6 │ const t6 = [1, 2] satisfies [number, number]; + │ ^^^^^^^^^ + 7 │ let t7 = { a: 'test' } satisfies A; + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + + i ...Which is required to end this statement + + 4 │ const t4: T1 = { a: "a" } satisfies T1; + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + > 6 │ const t6 = [1, 2] satisfies [number, number]; + │ ^^^^^^^^^^^^^^^^^^ + 7 │ let t7 = { a: 'test' } satisfies A; + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + +basic.ts:7:24 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + > 7 │ let t7 = { a: 'test' } satisfies A; + │ ^^^^^^^^^ + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + 9 │ + + i An explicit or implicit semicolon is expected here... + + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + > 7 │ let t7 = { a: 'test' } satisfies A; + │ ^^^^^^^^^ + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + 9 │ + + i ...Which is required to end this statement + + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + > 7 │ let t7 = { a: 'test' } satisfies A; + │ ^^^^^^^^^^^^^^^^^^^^^^^ + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + 9 │ + +basic.ts:7:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + > 7 │ let t7 = { a: 'test' } satisfies A; + │ ^ + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + 9 │ + + i An explicit or implicit semicolon is expected here... + + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + > 7 │ let t7 = { a: 'test' } satisfies A; + │ ^ + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + 9 │ + + i ...Which is required to end this statement + + 5 │ const t5 = (m => m.substring(0)) satisfies T2; + 6 │ const t6 = [1, 2] satisfies [number, number]; + > 7 │ let t7 = { a: 'test' } satisfies A; + │ ^^^^^^^^^^^ + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + 9 │ + +basic.ts:8:35 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + > 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + │ ^^^^^^^^^ + 9 │ + 10 │ const p = { + + i An explicit or implicit semicolon is expected here... + + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + > 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + │ ^^^^^^^^^ + 9 │ + 10 │ const p = { + + i ...Which is required to end this statement + + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + > 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 9 │ + 10 │ const p = { + +basic.ts:8:45 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + > 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + │ ^ + 9 │ + 10 │ const p = { + + i An explicit or implicit semicolon is expected here... + + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + > 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + │ ^ + 9 │ + 10 │ const p = { + + i ...Which is required to end this statement + + 6 │ const t6 = [1, 2] satisfies [number, number]; + 7 │ let t7 = { a: 'test' } satisfies A; + > 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + │ ^^^^^^^^^^^ + 9 │ + 10 │ const p = { + +basic.ts:13:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 11 │ isEven: n => n % 2 === 0, + 12 │ isOdd: n => n % 2 === 1 + > 13 │ } satisfies Predicates; + │ ^^^^^^^^^ + 14 │ + 15 │ let obj: { f(s: string): void } & Record = { + + i An explicit or implicit semicolon is expected here... + + 11 │ isEven: n => n % 2 === 0, + 12 │ isOdd: n => n % 2 === 1 + > 13 │ } satisfies Predicates; + │ ^^^^^^^^^ + 14 │ + 15 │ let obj: { f(s: string): void } & Record = { + + i ...Which is required to end this statement + + 8 │ let t8 = { a: 'test', b: 'test' } satisfies A; + 9 │ + > 10 │ const p = { + │ ^^^^^^^^^^^ + > 11 │ isEven: n => n % 2 === 0, + > 12 │ isOdd: n => n % 2 === 1 + > 13 │ } satisfies Predicates; + │ ^^ + 14 │ + 15 │ let obj: { f(s: string): void } & Record = { + +basic.ts:13:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 11 │ isEven: n => n % 2 === 0, + 12 │ isOdd: n => n % 2 === 1 + > 13 │ } satisfies Predicates; + │ ^^^^^^^^^^ + 14 │ + 15 │ let obj: { f(s: string): void } & Record = { + + i An explicit or implicit semicolon is expected here... + + 11 │ isEven: n => n % 2 === 0, + 12 │ isOdd: n => n % 2 === 1 + > 13 │ } satisfies Predicates; + │ ^^^^^^^^^^ + 14 │ + 15 │ let obj: { f(s: string): void } & Record = { + + i ...Which is required to end this statement + + 11 │ isEven: n => n % 2 === 0, + 12 │ isOdd: n => n % 2 === 1 + > 13 │ } satisfies Predicates; + │ ^^^^^^^^^^^^^^^^^^^^ + 14 │ + 15 │ let obj: { f(s: string): void } & Record = { + +basic.ts:18:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^^^^^^^^^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + + i An explicit or implicit semicolon is expected here... + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^^^^^^^^^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + + i ...Which is required to end this statement + + 13 │ } satisfies Predicates; + 14 │ + > 15 │ let obj: { f(s: string): void } & Record = { + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 16 │ f(s) { }, + > 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + +basic.ts:18:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + + i An explicit or implicit semicolon is expected here... + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + + i ...Which is required to end this statement + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^^^^^^^^^^^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + +basic.ts:18:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `:` + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + + i Remove : + +basic.ts:18:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + + i An explicit or implicit semicolon is expected here... + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + + i ...Which is required to end this statement + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^^^^^^^^^^^^^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + +basic.ts:18:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found '& Record' + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + + i Expected a statement here + + 16 │ f(s) { }, + 17 │ g(s) { } + > 18 │ } satisfies { g(s: string): void } & Record; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + 19 │ + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + +basic.ts:20:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^^^^^^^^^ + 21 │ + 22 │ const car = { + + i An explicit or implicit semicolon is expected here... + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^^^^^^^^^ + 21 │ + 22 │ const car = { + + i ...Which is required to end this statement + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + 21 │ + 22 │ const car = { + +basic.ts:20:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^ + 21 │ + 22 │ const car = { + + i An explicit or implicit semicolon is expected here... + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^ + 21 │ + 22 │ const car = { + + i ...Which is required to end this statement + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^^^^^^^^^^^ + 21 │ + 22 │ const car = { + +basic.ts:20:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `:` + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^ + 21 │ + 22 │ const car = { + + i Remove : + +basic.ts:20:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^ + 21 │ + 22 │ const car = { + + i An explicit or implicit semicolon is expected here... + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^ + 21 │ + 22 │ const car = { + + i ...Which is required to end this statement + + 18 │ } satisfies { g(s: string): void } & Record; + 19 │ + > 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + │ ^^^^^^^^^^^^^ + 21 │ + 22 │ const car = { + +basic.ts:28:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 26 │ }, + 27 │ stop() { } + > 28 │ } satisfies Movable & Record; + │ ^^^^^^^^^ + 29 │ + 30 │ var v = undefined satisfies 1; + + i An explicit or implicit semicolon is expected here... + + 26 │ }, + 27 │ stop() { } + > 28 │ } satisfies Movable & Record; + │ ^^^^^^^^^ + 29 │ + 30 │ var v = undefined satisfies 1; + + i ...Which is required to end this statement + + 20 │ ({ f(x) { } }) satisfies { f(s: string): void }; + 21 │ + > 22 │ const car = { + │ ^^^^^^^^^^^^^ + > 23 │ start() { }, + ... + > 27 │ stop() { } + > 28 │ } satisfies Movable & Record; + │ ^^ + 29 │ + 30 │ var v = undefined satisfies 1; + +basic.ts:28:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 26 │ }, + 27 │ stop() { } + > 28 │ } satisfies Movable & Record; + │ ^^^^^^^ + 29 │ + 30 │ var v = undefined satisfies 1; + + i An explicit or implicit semicolon is expected here... + + 26 │ }, + 27 │ stop() { } + > 28 │ } satisfies Movable & Record; + │ ^^^^^^^ + 29 │ + 30 │ var v = undefined satisfies 1; + + i ...Which is required to end this statement + + 26 │ }, + 27 │ stop() { } + > 28 │ } satisfies Movable & Record; + │ ^^^^^^^^^^^^^^^^^ + 29 │ + 30 │ var v = undefined satisfies 1; + +basic.ts:30:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 28 │ } satisfies Movable & Record; + 29 │ + > 30 │ var v = undefined satisfies 1; + │ ^^^^^^^^^ + 31 │ + + i An explicit or implicit semicolon is expected here... + + 28 │ } satisfies Movable & Record; + 29 │ + > 30 │ var v = undefined satisfies 1; + │ ^^^^^^^^^ + 31 │ + + i ...Which is required to end this statement + + 28 │ } satisfies Movable & Record; + 29 │ + > 30 │ var v = undefined satisfies 1; + │ ^^^^^^^^^^^^^^^^^^ + 31 │ + +basic.ts:30:29 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 28 │ } satisfies Movable & Record; + 29 │ + > 30 │ var v = undefined satisfies 1; + │ ^ + 31 │ + + i An explicit or implicit semicolon is expected here... + + 28 │ } satisfies Movable & Record; + 29 │ + > 30 │ var v = undefined satisfies 1; + │ ^ + 31 │ + + i ...Which is required to end this statement + + 28 │ } satisfies Movable & Record; + 29 │ + > 30 │ var v = undefined satisfies 1; + │ ^^^^^^^^^^^ + 31 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts new file mode 100644 index 00000000000..0f658aa5460 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts @@ -0,0 +1,7 @@ +const t1 = { + prop1: 1, + prop2: 2, + prop3: 3 +} satisfies +// Comment +Record; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts.prettier-snap new file mode 100644 index 00000000000..28cd18570ad --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts.prettier-snap @@ -0,0 +1,6 @@ +const t1 = { + prop1: 1, + prop2: 2, + prop3: 3, +} satisfies // Comment +Record; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts.snap new file mode 100644 index 00000000000..a7eefe262a2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments-unstable.ts.snap @@ -0,0 +1,87 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/comments-unstable.ts +--- + +# Input + +```js +const t1 = { + prop1: 1, + prop2: 2, + prop3: 3 +} satisfies +// Comment +Record; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -2,5 +2,7 @@ + prop1: 1, + prop2: 2, + prop3: 3, +-} satisfies // Comment ++}; ++satisfies; ++// Comment + Record; +``` + +# Output + +```js +const t1 = { + prop1: 1, + prop2: 2, + prop3: 3, +}; +satisfies; +// Comment +Record; +``` + + +# Errors +``` +comments-unstable.ts:5:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ prop2: 2, + 4 │ prop3: 3 + > 5 │ } satisfies + │ ^^^^^^^^^ + 6 │ // Comment + 7 │ Record; + + i An explicit or implicit semicolon is expected here... + + 3 │ prop2: 2, + 4 │ prop3: 3 + > 5 │ } satisfies + │ ^^^^^^^^^ + 6 │ // Comment + 7 │ Record; + + i ...Which is required to end this statement + + > 1 │ const t1 = { + │ ^^^^^^^^^^^^ + > 2 │ prop1: 1, + > 3 │ prop2: 2, + > 4 │ prop3: 3 + > 5 │ } satisfies + │ ^^ + 6 │ // Comment + 7 │ Record; + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts new file mode 100644 index 00000000000..9ab0ae58c20 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts @@ -0,0 +1,3 @@ +const t2 = {} /* comment */ satisfies {}; +const t3 = {} satisfies /* comment */ {}; +const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts.prettier-snap new file mode 100644 index 00000000000..9ab0ae58c20 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts.prettier-snap @@ -0,0 +1,3 @@ +const t2 = {} /* comment */ satisfies {}; +const t3 = {} satisfies /* comment */ {}; +const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts.snap new file mode 100644 index 00000000000..8ed67f232ab --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/comments.ts.snap @@ -0,0 +1,212 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/comments.ts +--- + +# Input + +```js +const t2 = {} /* comment */ satisfies {}; +const t3 = {} satisfies /* comment */ {}; +const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,3 +1,12 @@ +-const t2 = {} /* comment */ satisfies {}; +-const t3 = {} satisfies /* comment */ {}; +-const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; ++const t2 = {}; /* comment */ ++satisfies; ++{ ++} ++const t3 = {}; ++satisfies; /* comment */ ++{ ++} ++const t4 = {}; /* comment1 */ ++satisfies; /* comment2 */ ++{ ++} +``` + +# Output + +```js +const t2 = {}; /* comment */ +satisfies; +{ +} +const t3 = {}; +satisfies; /* comment */ +{ +} +const t4 = {}; /* comment1 */ +satisfies; /* comment2 */ +{ +} +``` + + +# Errors +``` +comments.ts:1:29 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ const t2 = {} /* comment */ satisfies {}; + │ ^^^^^^^^^ + 2 │ const t3 = {} satisfies /* comment */ {}; + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + + i An explicit or implicit semicolon is expected here... + + > 1 │ const t2 = {} /* comment */ satisfies {}; + │ ^^^^^^^^^ + 2 │ const t3 = {} satisfies /* comment */ {}; + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + + i ...Which is required to end this statement + + > 1 │ const t2 = {} /* comment */ satisfies {}; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ const t3 = {} satisfies /* comment */ {}; + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + +comments.ts:1:39 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ const t2 = {} /* comment */ satisfies {}; + │ ^ + 2 │ const t3 = {} satisfies /* comment */ {}; + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + + i An explicit or implicit semicolon is expected here... + + > 1 │ const t2 = {} /* comment */ satisfies {}; + │ ^ + 2 │ const t3 = {} satisfies /* comment */ {}; + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + + i ...Which is required to end this statement + + > 1 │ const t2 = {} /* comment */ satisfies {}; + │ ^^^^^^^^^^^ + 2 │ const t3 = {} satisfies /* comment */ {}; + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + +comments.ts:2:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const t2 = {} /* comment */ satisfies {}; + > 2 │ const t3 = {} satisfies /* comment */ {}; + │ ^^^^^^^^^ + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ const t2 = {} /* comment */ satisfies {}; + > 2 │ const t3 = {} satisfies /* comment */ {}; + │ ^^^^^^^^^ + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + 4 │ + + i ...Which is required to end this statement + + 1 │ const t2 = {} /* comment */ satisfies {}; + > 2 │ const t3 = {} satisfies /* comment */ {}; + │ ^^^^^^^^^^^^^^ + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + 4 │ + +comments.ts:2:39 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const t2 = {} /* comment */ satisfies {}; + > 2 │ const t3 = {} satisfies /* comment */ {}; + │ ^ + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ const t2 = {} /* comment */ satisfies {}; + > 2 │ const t3 = {} satisfies /* comment */ {}; + │ ^ + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + 4 │ + + i ...Which is required to end this statement + + 1 │ const t2 = {} /* comment */ satisfies {}; + > 2 │ const t3 = {} satisfies /* comment */ {}; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + 4 │ + +comments.ts:3:30 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const t2 = {} /* comment */ satisfies {}; + 2 │ const t3 = {} satisfies /* comment */ {}; + > 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + │ ^^^^^^^^^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ const t2 = {} /* comment */ satisfies {}; + 2 │ const t3 = {} satisfies /* comment */ {}; + > 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + │ ^^^^^^^^^ + 4 │ + + i ...Which is required to end this statement + + 1 │ const t2 = {} /* comment */ satisfies {}; + 2 │ const t3 = {} satisfies /* comment */ {}; + > 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + +comments.ts:3:55 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ const t2 = {} /* comment */ satisfies {}; + 2 │ const t3 = {} satisfies /* comment */ {}; + > 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + │ ^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ const t2 = {} /* comment */ satisfies {}; + 2 │ const t3 = {} satisfies /* comment */ {}; + > 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + │ ^ + 4 │ + + i ...Which is required to end this statement + + 1 │ const t2 = {} /* comment */ satisfies {}; + 2 │ const t3 = {} satisfies /* comment */ {}; + > 3 │ const t4 = {} /* comment1 */ satisfies /* comment2 */ {}; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts new file mode 100644 index 00000000000..6d6905150d8 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts @@ -0,0 +1 @@ +export default (function log() {} satisfies typeof console.log) diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts.prettier-snap new file mode 100644 index 00000000000..f3d0c69aa33 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts.prettier-snap @@ -0,0 +1 @@ +export default (function log() {} satisfies typeof console.log); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts.snap new file mode 100644 index 00000000000..55ec11a1784 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/export-default-as.ts.snap @@ -0,0 +1,92 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/export-default-as.ts +--- + +# Input + +```js +export default (function log() {} satisfies typeof console.log) +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1 +1,4 @@ +-export default (function log() {} satisfies typeof console.log); ++export default (function log() {} ++satisfies; ++typeof console.log; ++) +``` + +# Output + +```js +export default (function log() {} +satisfies; +typeof console.log; +) +``` + + +# Errors +``` +export-default-as.ts:1:35 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + > 1 │ export default (function log() {} satisfies typeof console.log) + │ ^^^^^^^^^ + 2 │ + + i Remove satisfies + +export-default-as.ts:1:45 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export default (function log() {} satisfies typeof console.log) + │ ^^^^^^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export default (function log() {} satisfies typeof console.log) + │ ^^^^^^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ export default (function log() {} satisfies typeof console.log) + │ ^^^^^^^^^^^^^^^^ + 2 │ + +export-default-as.ts:1:63 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ export default (function log() {} satisfies typeof console.log) + │ ^ + 2 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ export default (function log() {} satisfies typeof console.log) + │ ^ + 2 │ + + i ...Which is required to end this statement + + > 1 │ export default (function log() {} satisfies typeof console.log) + │ ^^^^^^^^^^^^^^^^^^^ + 2 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts new file mode 100644 index 00000000000..bdc95deefbe --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts @@ -0,0 +1,2 @@ +x satisfies boolean <= y; // (x satisfies boolean) <= y; +x satisfies boolean ?? y; // (x satisfies boolean) ?? y; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts.prettier-snap new file mode 100644 index 00000000000..5be64b36aa6 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts.prettier-snap @@ -0,0 +1,2 @@ +(x satisfies boolean) <= y; // (x satisfies boolean) <= y; +(x satisfies boolean) ?? y; // (x satisfies boolean) ?? y; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts.snap new file mode 100644 index 00000000000..636d4d02f49 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/gt-lt.ts.snap @@ -0,0 +1,140 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/gt-lt.ts +--- + +# Input + +```js +x satisfies boolean <= y; // (x satisfies boolean) <= y; +x satisfies boolean ?? y; // (x satisfies boolean) ?? y; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,2 +1,6 @@ +-(x satisfies boolean) <= y; // (x satisfies boolean) <= y; +-(x satisfies boolean) ?? y; // (x satisfies boolean) ?? y; ++x; ++satisfies; ++boolean <= y; // (x satisfies boolean) <= y; ++x; ++satisfies; ++boolean ?? y; // (x satisfies boolean) ?? y; +``` + +# Output + +```js +x; +satisfies; +boolean <= y; // (x satisfies boolean) <= y; +x; +satisfies; +boolean ?? y; // (x satisfies boolean) ?? y; +``` + + +# Errors +``` +gt-lt.ts:1:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + │ ^^^^^^^^^ + 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + 3 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + │ ^^^^^^^^^ + 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + 3 │ + + i ...Which is required to end this statement + + > 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + │ ^^^^^^^^^^^ + 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + 3 │ + +gt-lt.ts:1:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + │ ^^^^^^^ + 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + 3 │ + + i An explicit or implicit semicolon is expected here... + + > 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + │ ^^^^^^^ + 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + 3 │ + + i ...Which is required to end this statement + + > 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + │ ^^^^^^^^^^^^^^^^^ + 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + 3 │ + +gt-lt.ts:2:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + > 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + │ ^^^^^^^^^ + 3 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + > 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + │ ^^^^^^^^^ + 3 │ + + i ...Which is required to end this statement + + 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + > 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + │ ^^^^^^^^^^^ + 3 │ + +gt-lt.ts:2:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + > 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + │ ^^^^^^^ + 3 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + > 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + │ ^^^^^^^ + 3 │ + + i ...Which is required to end this statement + + 1 │ x satisfies boolean <= y; // (x satisfies boolean) <= y; + > 2 │ x satisfies boolean ?? y; // (x satisfies boolean) ?? y; + │ ^^^^^^^^^^^^^^^^^ + 3 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts new file mode 100644 index 00000000000..c35cf66fb52 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts @@ -0,0 +1,6 @@ +window.postMessage( + { + context: item.context, + topic: item.topic + } satisfies IActionMessage + ); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts.prettier-snap new file mode 100644 index 00000000000..247aefd7cd4 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts.prettier-snap @@ -0,0 +1,4 @@ +window.postMessage({ + context: item.context, + topic: item.topic, +} satisfies IActionMessage); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts.snap new file mode 100644 index 00000000000..8fc4cbc083a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/hug-args.ts.snap @@ -0,0 +1,80 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/hug-args.ts +--- + +# Input + +```js +window.postMessage( + { + context: item.context, + topic: item.topic + } satisfies IActionMessage + ); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,4 +1,6 @@ +-window.postMessage({ +- context: item.context, +- topic: item.topic, +-} satisfies IActionMessage); ++window.postMessage( ++ { ++ context: item.context, ++ topic: item.topic ++ } satisfies IActionMessage ++ ); +``` + +# Output + +```js +window.postMessage( + { + context: item.context, + topic: item.topic + } satisfies IActionMessage + ); +``` + + +# Errors +``` +hug-args.ts:5:7 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `satisfies` + + 3 │ context: item.context, + 4 │ topic: item.topic + > 5 │ } satisfies IActionMessage + │ ^^^^^^^^^ + 6 │ ); + 7 │ + + i Remove satisfies + +hug-args.ts:5:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `IActionMessage` + + 3 │ context: item.context, + 4 │ topic: item.topic + > 5 │ } satisfies IActionMessage + │ ^^^^^^^^^^^^^^ + 6 │ ); + 7 │ + + i Remove IActionMessage + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts new file mode 100644 index 00000000000..fbdbe1c9106 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts @@ -0,0 +1,5 @@ +(a satisfies number) = 42; +({ a: (b satisfies any) = 2000 } = x); +(this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; +(this.configuration satisfies any) = (this.editor satisfies any) = (this + .editorBody satisfies any) = undefined; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts.prettier-snap new file mode 100644 index 00000000000..5a8548001f6 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts.prettier-snap @@ -0,0 +1,10 @@ +(a satisfies number) = 42; +({ a: (b satisfies any) = 2000 } = x); +(this.selectorElem satisfies any) = + this.multiselectWidget = + this.initialValues = + undefined; +(this.configuration satisfies any) = + (this.editor satisfies any) = + (this.editorBody satisfies any) = + undefined; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts.snap new file mode 100644 index 00000000000..0efa5d3cfc7 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/lhs.ts.snap @@ -0,0 +1,342 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/lhs.ts +--- + +# Input + +```js +(a satisfies number) = 42; +({ a: (b satisfies any) = 2000 } = x); +(this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; +(this.configuration satisfies any) = (this.editor satisfies any) = (this + .editorBody satisfies any) = undefined; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,10 +1,15 @@ +-(a satisfies number) = 42; +-({ a: (b satisfies any) = 2000 } = x); +-(this.selectorElem satisfies any) = +- this.multiselectWidget = +- this.initialValues = +- undefined; +-(this.configuration satisfies any) = +- (this.editor satisfies any) = +- (this.editorBody satisfies any) = +- undefined; ++(a ++satisfies; ++number; ++) = 42 ++({ a: (b satisfies any) = 2000; ++} = x) ++(this.selectorElem ++satisfies; ++any; ++) = this.multiselectWidget = this.initialValues = undefined ++(this.configuration ++satisfies; ++any; ++) = (this.editor satisfies any) = (this ++ .editorBody satisfies any) = undefined +``` + +# Output + +```js +(a +satisfies; +number; +) = 42 +({ a: (b satisfies any) = 2000; +} = x) +(this.selectorElem +satisfies; +any; +) = this.multiselectWidget = this.initialValues = undefined +(this.configuration +satisfies; +any; +) = (this.editor satisfies any) = (this + .editorBody satisfies any) = undefined +``` + + +# Errors +``` +lhs.ts:1:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + > 1 │ (a satisfies number) = 42; + │ ^^^^^^^^^ + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + + i Remove satisfies + +lhs.ts:1:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ (a satisfies number) = 42; + │ ^^^^^^ + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + + i An explicit or implicit semicolon is expected here... + + > 1 │ (a satisfies number) = 42; + │ ^^^^^^ + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + + i ...Which is required to end this statement + + > 1 │ (a satisfies number) = 42; + │ ^^^^^^^^^^^^^^^^ + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + +lhs.ts:1:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ (a satisfies number) = 42; + │ ^ + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + + i An explicit or implicit semicolon is expected here... + + > 1 │ (a satisfies number) = 42; + │ ^ + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + + i ...Which is required to end this statement + + > 1 │ (a satisfies number) = 42; + │ ^^^^^^^ + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + +lhs.ts:2:10 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 1 │ (a satisfies number) = 42; + > 2 │ ({ a: (b satisfies any) = 2000 } = x); + │ ^^^^^^^^^ + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + + i Remove satisfies + +lhs.ts:2:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `any` + + 1 │ (a satisfies number) = 42; + > 2 │ ({ a: (b satisfies any) = 2000 } = x); + │ ^^^ + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + + i Remove any + +lhs.ts:2:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `)` + + 1 │ (a satisfies number) = 42; + > 2 │ ({ a: (b satisfies any) = 2000 } = x); + │ ^ + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + + i Remove ) + +lhs.ts:2:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Invalid assignment to `{ a: (b satisfies any` + + 1 │ (a satisfies number) = 42; + > 2 │ ({ a: (b satisfies any) = 2000 } = x); + │ ^^^^^^^^^^^^^^^^^^^^^ + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + + i This expression cannot be assigned to + +lhs.ts:2:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found '} = x)' + + 1 │ (a satisfies number) = 42; + > 2 │ ({ a: (b satisfies any) = 2000 } = x); + │ ^^^^^^ + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + + i Expected a statement here + + 1 │ (a satisfies number) = 42; + > 2 │ ({ a: (b satisfies any) = 2000 } = x); + │ ^^^^^^ + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + +lhs.ts:3:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 1 │ (a satisfies number) = 42; + 2 │ ({ a: (b satisfies any) = 2000 } = x); + > 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + │ ^^^^^^^^^ + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + 5 │ .editorBody satisfies any) = undefined; + + i Remove satisfies + +lhs.ts:3:30 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ (a satisfies number) = 42; + 2 │ ({ a: (b satisfies any) = 2000 } = x); + > 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + │ ^^^ + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + 5 │ .editorBody satisfies any) = undefined; + + i An explicit or implicit semicolon is expected here... + + 1 │ (a satisfies number) = 42; + 2 │ ({ a: (b satisfies any) = 2000 } = x); + > 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + │ ^^^ + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + 5 │ .editorBody satisfies any) = undefined; + + i ...Which is required to end this statement + + 1 │ (a satisfies number) = 42; + 2 │ ({ a: (b satisfies any) = 2000 } = x); + > 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + │ ^^^^^^^^^^^^^ + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + 5 │ .editorBody satisfies any) = undefined; + +lhs.ts:3:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ (a satisfies number) = 42; + 2 │ ({ a: (b satisfies any) = 2000 } = x); + > 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + │ ^ + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + 5 │ .editorBody satisfies any) = undefined; + + i An explicit or implicit semicolon is expected here... + + 1 │ (a satisfies number) = 42; + 2 │ ({ a: (b satisfies any) = 2000 } = x); + > 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + │ ^ + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + 5 │ .editorBody satisfies any) = undefined; + + i ...Which is required to end this statement + + 1 │ (a satisfies number) = 42; + 2 │ ({ a: (b satisfies any) = 2000 } = x); + > 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + │ ^^^^ + 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + 5 │ .editorBody satisfies any) = undefined; + +lhs.ts:4:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + > 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + │ ^^^^^^^^^ + 5 │ .editorBody satisfies any) = undefined; + 6 │ + + i Remove satisfies + +lhs.ts:4:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + > 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + │ ^^^ + 5 │ .editorBody satisfies any) = undefined; + 6 │ + + i An explicit or implicit semicolon is expected here... + + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + > 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + │ ^^^ + 5 │ .editorBody satisfies any) = undefined; + 6 │ + + i ...Which is required to end this statement + + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + > 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + │ ^^^^^^^^^^^^^ + 5 │ .editorBody satisfies any) = undefined; + 6 │ + +lhs.ts:4:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + > 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + │ ^ + 5 │ .editorBody satisfies any) = undefined; + 6 │ + + i An explicit or implicit semicolon is expected here... + + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + > 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + │ ^ + 5 │ .editorBody satisfies any) = undefined; + 6 │ + + i ...Which is required to end this statement + + 2 │ ({ a: (b satisfies any) = 2000 } = x); + 3 │ (this.selectorElem satisfies any) = this.multiselectWidget = this.initialValues = undefined; + > 4 │ (this.configuration satisfies any) = (this.editor satisfies any) = (this + │ ^^^^ + 5 │ .editorBody satisfies any) = undefined; + 6 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts new file mode 100644 index 00000000000..d9c2b4a600b --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts @@ -0,0 +1,7 @@ +const getAccountCount = async () => + (await + ((await ( + await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + ).findItem("My bookmarks")) satisfies TreeItem + ).getChildren() + ).length diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts.prettier-snap new file mode 100644 index 00000000000..bb76358e68e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts.prettier-snap @@ -0,0 +1,8 @@ +const getAccountCount = async () => + ( + await ( + (await ( + await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + ).findItem("My bookmarks")) satisfies TreeItem + ).getChildren() + ).length; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts.snap new file mode 100644 index 00000000000..254488ee31e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/nested-await-and-satisfies.ts.snap @@ -0,0 +1,129 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/nested-await-and-satisfies.ts +--- + +# Input + +```js +const getAccountCount = async () => + (await + ((await ( + await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + ).findItem("My bookmarks")) satisfies TreeItem + ).getChildren() + ).length +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,8 +1,9 @@ + const getAccountCount = async () => +- ( +- await ( +- (await ( +- await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) +- ).findItem("My bookmarks")) satisfies TreeItem +- ).getChildren() +- ).length; ++ (await ++ ((await ( ++ await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) ++ ).findItem("My bookmarks")) ++satisfies; ++TreeItem; ++).getChildren() ++ ).length +``` + +# Output + +```js +const getAccountCount = async () => + (await + ((await ( + await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + ).findItem("My bookmarks")) +satisfies; +TreeItem; +).getChildren() + ).length +``` + + +# Errors +``` +nested-await-and-satisfies.ts:5:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 3 │ ((await ( + 4 │ await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + > 5 │ ).findItem("My bookmarks")) satisfies TreeItem + │ ^^^^^^^^^ + 6 │ ).getChildren() + 7 │ ).length + + i Remove satisfies + +nested-await-and-satisfies.ts:5:43 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ ((await ( + 4 │ await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + > 5 │ ).findItem("My bookmarks")) satisfies TreeItem + │ ^^^^^^^^ + 6 │ ).getChildren() + 7 │ ).length + + i An explicit or implicit semicolon is expected here... + + 3 │ ((await ( + 4 │ await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + > 5 │ ).findItem("My bookmarks")) satisfies TreeItem + │ ^^^^^^^^ + 6 │ ).getChildren() + 7 │ ).length + + i ...Which is required to end this statement + + 3 │ ((await ( + 4 │ await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + > 5 │ ).findItem("My bookmarks")) satisfies TreeItem + │ ^^^^^^^^^^^^^^^^^^ + 6 │ ).getChildren() + 7 │ ).length + +nested-await-and-satisfies.ts:6:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected a statement but instead found ').getChildren() + ).length' + + 4 │ await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + 5 │ ).findItem("My bookmarks")) satisfies TreeItem + > 6 │ ).getChildren() + │ ^^^^^^^^^^^^^^^ + > 7 │ ).length + │ ^^^^^^^^ + 8 │ + + i Expected a statement here + + 4 │ await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME) + 5 │ ).findItem("My bookmarks")) satisfies TreeItem + > 6 │ ).getChildren() + │ ^^^^^^^^^^^^^^^ + > 7 │ ).length + │ ^^^^^^^^ + 8 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts new file mode 100644 index 00000000000..9e1e0b3ac0b --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts @@ -0,0 +1,3 @@ +// the 2nd line needs ASI protection +const el = ReactDOM.findDOMNode(ref) +;(el satisfies HTMLElement)!.style.cursor = 'pointer' diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts.prettier-snap new file mode 100644 index 00000000000..407e7d89a99 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts.prettier-snap @@ -0,0 +1,3 @@ +// the 2nd line needs ASI protection +const el = ReactDOM.findDOMNode(ref); +(el satisfies HTMLElement)!.style.cursor = "pointer"; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts.snap new file mode 100644 index 00000000000..85dad114211 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/non-null.ts.snap @@ -0,0 +1,112 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/non-null.ts +--- + +# Input + +```js +// the 2nd line needs ASI protection +const el = ReactDOM.findDOMNode(ref) +;(el satisfies HTMLElement)!.style.cursor = 'pointer' +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,3 +1,6 @@ + // the 2nd line needs ASI protection + const el = ReactDOM.findDOMNode(ref); +-(el satisfies HTMLElement)!.style.cursor = "pointer"; ++(el ++satisfies; ++HTMLElement; ++)!.style.cursor = 'pointer' +``` + +# Output + +```js +// the 2nd line needs ASI protection +const el = ReactDOM.findDOMNode(ref); +(el +satisfies; +HTMLElement; +)!.style.cursor = 'pointer' +``` + + +# Errors +``` +non-null.ts:3:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 1 │ // the 2nd line needs ASI protection + 2 │ const el = ReactDOM.findDOMNode(ref) + > 3 │ ;(el satisfies HTMLElement)!.style.cursor = 'pointer' + │ ^^^^^^^^^ + 4 │ + + i Remove satisfies + +non-null.ts:3:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ // the 2nd line needs ASI protection + 2 │ const el = ReactDOM.findDOMNode(ref) + > 3 │ ;(el satisfies HTMLElement)!.style.cursor = 'pointer' + │ ^^^^^^^^^^^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ // the 2nd line needs ASI protection + 2 │ const el = ReactDOM.findDOMNode(ref) + > 3 │ ;(el satisfies HTMLElement)!.style.cursor = 'pointer' + │ ^^^^^^^^^^^ + 4 │ + + i ...Which is required to end this statement + + 1 │ // the 2nd line needs ASI protection + 2 │ const el = ReactDOM.findDOMNode(ref) + > 3 │ ;(el satisfies HTMLElement)!.style.cursor = 'pointer' + │ ^^^^^^^^^^^^^^^^^^^^^ + 4 │ + +non-null.ts:3:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ // the 2nd line needs ASI protection + 2 │ const el = ReactDOM.findDOMNode(ref) + > 3 │ ;(el satisfies HTMLElement)!.style.cursor = 'pointer' + │ ^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ // the 2nd line needs ASI protection + 2 │ const el = ReactDOM.findDOMNode(ref) + > 3 │ ;(el satisfies HTMLElement)!.style.cursor = 'pointer' + │ ^ + 4 │ + + i ...Which is required to end this statement + + 1 │ // the 2nd line needs ASI protection + 2 │ const el = ReactDOM.findDOMNode(ref) + > 3 │ ;(el satisfies HTMLElement)!.style.cursor = 'pointer' + │ ^^^^^^^^^^^^ + 4 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts new file mode 100644 index 00000000000..f9b3f6f2acb --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts @@ -0,0 +1,22 @@ +({}) satisfies {}; +({}) satisfies X; +() => ({}) satisfies X; +this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + +'current' in (props.pagination satisfies Object); +('current' in props.pagination) satisfies Object; +start + (yearSelectTotal satisfies number); +(start + yearSelectTotal) satisfies number; +scrollTop > (visibilityHeight satisfies number); +(scrollTop > visibilityHeight) satisfies number; +(bValue satisfies boolean) ? 0 : -1; + +async function g1() { + const test = (await 'foo') satisfies number; +} + +var x = (v => v) satisfies (x: number) => string; + +foo satisfies unknown satisfies Bar; +foo satisfies unknown as Bar; +foo as unknown satisfies Bar; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts.prettier-snap new file mode 100644 index 00000000000..7a3ffd4944f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts.prettier-snap @@ -0,0 +1,22 @@ +({} satisfies {}); +({} satisfies X); +() => ({} satisfies X); +this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + +"current" in (props.pagination satisfies Object); +("current" in props.pagination) satisfies Object; +start + (yearSelectTotal satisfies number); +(start + yearSelectTotal) satisfies number; +scrollTop > (visibilityHeight satisfies number); +(scrollTop > visibilityHeight) satisfies number; +(bValue satisfies boolean) ? 0 : -1; + +async function g1() { + const test = (await "foo") satisfies number; +} + +var x = ((v) => v) satisfies (x: number) => string; + +foo satisfies unknown satisfies Bar; +foo satisfies unknown as Bar; +foo as unknown satisfies Bar; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts.snap new file mode 100644 index 00000000000..f253e9c85c1 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/satisfies.ts.snap @@ -0,0 +1,1164 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/satisfies.ts +--- + +# Input + +```js +({}) satisfies {}; +({}) satisfies X; +() => ({}) satisfies X; +this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + +'current' in (props.pagination satisfies Object); +('current' in props.pagination) satisfies Object; +start + (yearSelectTotal satisfies number); +(start + yearSelectTotal) satisfies number; +scrollTop > (visibilityHeight satisfies number); +(scrollTop > visibilityHeight) satisfies number; +(bValue satisfies boolean) ? 0 : -1; + +async function g1() { + const test = (await 'foo') satisfies number; +} + +var x = (v => v) satisfies (x: number) => string; + +foo satisfies unknown satisfies Bar; +foo satisfies unknown as Bar; +foo as unknown satisfies Bar; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,22 +1,59 @@ +-({} satisfies {}); +-({} satisfies X); +-() => ({} satisfies X); ++({}); ++satisfies; ++{ ++} ++({}); ++satisfies; ++X; ++() => ({}); ++satisfies; ++X; + this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + +-"current" in (props.pagination satisfies Object); +-("current" in props.pagination) satisfies Object; +-start + (yearSelectTotal satisfies number); +-(start + yearSelectTotal) satisfies number; +-scrollTop > (visibilityHeight satisfies number); +-(scrollTop > visibilityHeight) satisfies number; +-(bValue satisfies boolean) ? 0 : -1; ++'current' in (props.pagination ++satisfies; ++Object; ++) ++"current" in props.pagination; ++satisfies; ++Object; ++start + (yearSelectTotal ++satisfies; ++number; ++) ++start + yearSelectTotal; ++satisfies; ++number; ++scrollTop > (visibilityHeight ++satisfies; ++number; ++) ++scrollTop > visibilityHeight; ++satisfies; ++number; ++(bValue ++satisfies; ++boolean; ++) ? 0 : -1 + + async function g1() { +- const test = (await "foo") satisfies number; ++ const test = await "foo"; ++ satisfies; ++ number; + } + +-var x = ((v) => v) satisfies (x: number) => string; ++var x = (v) => v; ++satisfies (x: number) ++=> string + +-foo satisfies unknown satisfies Bar; +-foo satisfies unknown as Bar; +-foo as unknown satisfies Bar; ++foo; ++satisfies; ++unknown; ++satisfies; ++Bar; ++foo; ++satisfies; ++unknown as Bar; ++foo as unknown; ++satisfies; ++Bar; +``` + +# Output + +```js +({}); +satisfies; +{ +} +({}); +satisfies; +X; +() => ({}); +satisfies; +X; +this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + +'current' in (props.pagination +satisfies; +Object; +) +"current" in props.pagination; +satisfies; +Object; +start + (yearSelectTotal +satisfies; +number; +) +start + yearSelectTotal; +satisfies; +number; +scrollTop > (visibilityHeight +satisfies; +number; +) +scrollTop > visibilityHeight; +satisfies; +number; +(bValue +satisfies; +boolean; +) ? 0 : -1 + +async function g1() { + const test = await "foo"; + satisfies; + number; +} + +var x = (v) => v; +satisfies (x: number) +=> string + +foo; +satisfies; +unknown; +satisfies; +Bar; +foo; +satisfies; +unknown as Bar; +foo as unknown; +satisfies; +Bar; +``` + + +# Errors +``` +satisfies.ts:1:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ ({}) satisfies {}; + │ ^^^^^^^^^ + 2 │ ({}) satisfies X; + 3 │ () => ({}) satisfies X; + + i An explicit or implicit semicolon is expected here... + + > 1 │ ({}) satisfies {}; + │ ^^^^^^^^^ + 2 │ ({}) satisfies X; + 3 │ () => ({}) satisfies X; + + i ...Which is required to end this statement + + > 1 │ ({}) satisfies {}; + │ ^^^^^^^^^^^^^^ + 2 │ ({}) satisfies X; + 3 │ () => ({}) satisfies X; + +satisfies.ts:1:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + > 1 │ ({}) satisfies {}; + │ ^ + 2 │ ({}) satisfies X; + 3 │ () => ({}) satisfies X; + + i An explicit or implicit semicolon is expected here... + + > 1 │ ({}) satisfies {}; + │ ^ + 2 │ ({}) satisfies X; + 3 │ () => ({}) satisfies X; + + i ...Which is required to end this statement + + > 1 │ ({}) satisfies {}; + │ ^^^^^^^^^^^ + 2 │ ({}) satisfies X; + 3 │ () => ({}) satisfies X; + +satisfies.ts:2:6 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ ({}) satisfies {}; + > 2 │ ({}) satisfies X; + │ ^^^^^^^^^ + 3 │ () => ({}) satisfies X; + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + + i An explicit or implicit semicolon is expected here... + + 1 │ ({}) satisfies {}; + > 2 │ ({}) satisfies X; + │ ^^^^^^^^^ + 3 │ () => ({}) satisfies X; + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + + i ...Which is required to end this statement + + 1 │ ({}) satisfies {}; + > 2 │ ({}) satisfies X; + │ ^^^^^^^^^^^^^^ + 3 │ () => ({}) satisfies X; + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + +satisfies.ts:2:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ ({}) satisfies {}; + > 2 │ ({}) satisfies X; + │ ^ + 3 │ () => ({}) satisfies X; + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + + i An explicit or implicit semicolon is expected here... + + 1 │ ({}) satisfies {}; + > 2 │ ({}) satisfies X; + │ ^ + 3 │ () => ({}) satisfies X; + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + + i ...Which is required to end this statement + + 1 │ ({}) satisfies {}; + > 2 │ ({}) satisfies X; + │ ^^^^^^^^^^^ + 3 │ () => ({}) satisfies X; + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + +satisfies.ts:3:12 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ ({}) satisfies {}; + 2 │ ({}) satisfies X; + > 3 │ () => ({}) satisfies X; + │ ^^^^^^^^^ + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ ({}) satisfies {}; + 2 │ ({}) satisfies X; + > 3 │ () => ({}) satisfies X; + │ ^^^^^^^^^ + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + + i ...Which is required to end this statement + + 1 │ ({}) satisfies {}; + 2 │ ({}) satisfies X; + > 3 │ () => ({}) satisfies X; + │ ^^^^^^^^^^^^^^^^^^^^ + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + +satisfies.ts:3:22 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ ({}) satisfies {}; + 2 │ ({}) satisfies X; + > 3 │ () => ({}) satisfies X; + │ ^ + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ ({}) satisfies {}; + 2 │ ({}) satisfies X; + > 3 │ () => ({}) satisfies X; + │ ^ + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + + i ...Which is required to end this statement + + 1 │ ({}) satisfies {}; + 2 │ ({}) satisfies X; + > 3 │ () => ({}) satisfies X; + │ ^^^^^^^^^^^ + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + +satisfies.ts:4:48 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `satisfies` + + 2 │ ({}) satisfies X; + 3 │ () => ({}) satisfies X; + > 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + │ ^^^^^^^^^ + 5 │ + 6 │ 'current' in (props.pagination satisfies Object); + + i Remove satisfies + +satisfies.ts:4:58 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `HTMLElement` + + 2 │ ({}) satisfies X; + 3 │ () => ({}) satisfies X; + > 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + │ ^^^^^^^^^^^ + 5 │ + 6 │ 'current' in (props.pagination satisfies Object); + + i Remove HTMLElement + +satisfies.ts:6:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + > 6 │ 'current' in (props.pagination satisfies Object); + │ ^^^^^^^^^ + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + + i Remove satisfies + +satisfies.ts:6:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + > 6 │ 'current' in (props.pagination satisfies Object); + │ ^^^^^^ + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + + i An explicit or implicit semicolon is expected here... + + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + > 6 │ 'current' in (props.pagination satisfies Object); + │ ^^^^^^ + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + + i ...Which is required to end this statement + + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + > 6 │ 'current' in (props.pagination satisfies Object); + │ ^^^^^^^^^^^^^^^^ + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + +satisfies.ts:6:48 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + > 6 │ 'current' in (props.pagination satisfies Object); + │ ^ + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + + i An explicit or implicit semicolon is expected here... + + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + > 6 │ 'current' in (props.pagination satisfies Object); + │ ^ + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + + i ...Which is required to end this statement + + 4 │ this.isTabActionBar((e.target || e.srcElement) satisfies HTMLElement); + 5 │ + > 6 │ 'current' in (props.pagination satisfies Object); + │ ^^^^^^^ + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + +satisfies.ts:7:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ 'current' in (props.pagination satisfies Object); + > 7 │ ('current' in props.pagination) satisfies Object; + │ ^^^^^^^^^ + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + + i An explicit or implicit semicolon is expected here... + + 6 │ 'current' in (props.pagination satisfies Object); + > 7 │ ('current' in props.pagination) satisfies Object; + │ ^^^^^^^^^ + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + + i ...Which is required to end this statement + + 6 │ 'current' in (props.pagination satisfies Object); + > 7 │ ('current' in props.pagination) satisfies Object; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + +satisfies.ts:7:43 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ 'current' in (props.pagination satisfies Object); + > 7 │ ('current' in props.pagination) satisfies Object; + │ ^^^^^^ + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + + i An explicit or implicit semicolon is expected here... + + 6 │ 'current' in (props.pagination satisfies Object); + > 7 │ ('current' in props.pagination) satisfies Object; + │ ^^^^^^ + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + + i ...Which is required to end this statement + + 6 │ 'current' in (props.pagination satisfies Object); + > 7 │ ('current' in props.pagination) satisfies Object; + │ ^^^^^^^^^^^^^^^^ + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + +satisfies.ts:8:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 6 │ 'current' in (props.pagination satisfies Object); + 7 │ ('current' in props.pagination) satisfies Object; + > 8 │ start + (yearSelectTotal satisfies number); + │ ^^^^^^^^^ + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + + i Remove satisfies + +satisfies.ts:8:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ 'current' in (props.pagination satisfies Object); + 7 │ ('current' in props.pagination) satisfies Object; + > 8 │ start + (yearSelectTotal satisfies number); + │ ^^^^^^ + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + + i An explicit or implicit semicolon is expected here... + + 6 │ 'current' in (props.pagination satisfies Object); + 7 │ ('current' in props.pagination) satisfies Object; + > 8 │ start + (yearSelectTotal satisfies number); + │ ^^^^^^ + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + + i ...Which is required to end this statement + + 6 │ 'current' in (props.pagination satisfies Object); + 7 │ ('current' in props.pagination) satisfies Object; + > 8 │ start + (yearSelectTotal satisfies number); + │ ^^^^^^^^^^^^^^^^ + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + +satisfies.ts:8:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 6 │ 'current' in (props.pagination satisfies Object); + 7 │ ('current' in props.pagination) satisfies Object; + > 8 │ start + (yearSelectTotal satisfies number); + │ ^ + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + + i An explicit or implicit semicolon is expected here... + + 6 │ 'current' in (props.pagination satisfies Object); + 7 │ ('current' in props.pagination) satisfies Object; + > 8 │ start + (yearSelectTotal satisfies number); + │ ^ + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + + i ...Which is required to end this statement + + 6 │ 'current' in (props.pagination satisfies Object); + 7 │ ('current' in props.pagination) satisfies Object; + > 8 │ start + (yearSelectTotal satisfies number); + │ ^^^^^^^ + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + +satisfies.ts:9:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + > 9 │ (start + yearSelectTotal) satisfies number; + │ ^^^^^^^^^ + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + + i An explicit or implicit semicolon is expected here... + + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + > 9 │ (start + yearSelectTotal) satisfies number; + │ ^^^^^^^^^ + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + + i ...Which is required to end this statement + + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + > 9 │ (start + yearSelectTotal) satisfies number; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + +satisfies.ts:9:37 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + > 9 │ (start + yearSelectTotal) satisfies number; + │ ^^^^^^ + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + + i An explicit or implicit semicolon is expected here... + + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + > 9 │ (start + yearSelectTotal) satisfies number; + │ ^^^^^^ + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + + i ...Which is required to end this statement + + 7 │ ('current' in props.pagination) satisfies Object; + 8 │ start + (yearSelectTotal satisfies number); + > 9 │ (start + yearSelectTotal) satisfies number; + │ ^^^^^^^^^^^^^^^^ + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + +satisfies.ts:10:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + > 10 │ scrollTop > (visibilityHeight satisfies number); + │ ^^^^^^^^^ + 11 │ (scrollTop > visibilityHeight) satisfies number; + 12 │ (bValue satisfies boolean) ? 0 : -1; + + i Remove satisfies + +satisfies.ts:10:41 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + > 10 │ scrollTop > (visibilityHeight satisfies number); + │ ^^^^^^ + 11 │ (scrollTop > visibilityHeight) satisfies number; + 12 │ (bValue satisfies boolean) ? 0 : -1; + + i An explicit or implicit semicolon is expected here... + + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + > 10 │ scrollTop > (visibilityHeight satisfies number); + │ ^^^^^^ + 11 │ (scrollTop > visibilityHeight) satisfies number; + 12 │ (bValue satisfies boolean) ? 0 : -1; + + i ...Which is required to end this statement + + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + > 10 │ scrollTop > (visibilityHeight satisfies number); + │ ^^^^^^^^^^^^^^^^ + 11 │ (scrollTop > visibilityHeight) satisfies number; + 12 │ (bValue satisfies boolean) ? 0 : -1; + +satisfies.ts:10:47 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + > 10 │ scrollTop > (visibilityHeight satisfies number); + │ ^ + 11 │ (scrollTop > visibilityHeight) satisfies number; + 12 │ (bValue satisfies boolean) ? 0 : -1; + + i An explicit or implicit semicolon is expected here... + + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + > 10 │ scrollTop > (visibilityHeight satisfies number); + │ ^ + 11 │ (scrollTop > visibilityHeight) satisfies number; + 12 │ (bValue satisfies boolean) ? 0 : -1; + + i ...Which is required to end this statement + + 8 │ start + (yearSelectTotal satisfies number); + 9 │ (start + yearSelectTotal) satisfies number; + > 10 │ scrollTop > (visibilityHeight satisfies number); + │ ^^^^^^^ + 11 │ (scrollTop > visibilityHeight) satisfies number; + 12 │ (bValue satisfies boolean) ? 0 : -1; + +satisfies.ts:11:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + > 11 │ (scrollTop > visibilityHeight) satisfies number; + │ ^^^^^^^^^ + 12 │ (bValue satisfies boolean) ? 0 : -1; + 13 │ + + i An explicit or implicit semicolon is expected here... + + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + > 11 │ (scrollTop > visibilityHeight) satisfies number; + │ ^^^^^^^^^ + 12 │ (bValue satisfies boolean) ? 0 : -1; + 13 │ + + i ...Which is required to end this statement + + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + > 11 │ (scrollTop > visibilityHeight) satisfies number; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 12 │ (bValue satisfies boolean) ? 0 : -1; + 13 │ + +satisfies.ts:11:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + > 11 │ (scrollTop > visibilityHeight) satisfies number; + │ ^^^^^^ + 12 │ (bValue satisfies boolean) ? 0 : -1; + 13 │ + + i An explicit or implicit semicolon is expected here... + + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + > 11 │ (scrollTop > visibilityHeight) satisfies number; + │ ^^^^^^ + 12 │ (bValue satisfies boolean) ? 0 : -1; + 13 │ + + i ...Which is required to end this statement + + 9 │ (start + yearSelectTotal) satisfies number; + 10 │ scrollTop > (visibilityHeight satisfies number); + > 11 │ (scrollTop > visibilityHeight) satisfies number; + │ ^^^^^^^^^^^^^^^^ + 12 │ (bValue satisfies boolean) ? 0 : -1; + 13 │ + +satisfies.ts:12:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + > 12 │ (bValue satisfies boolean) ? 0 : -1; + │ ^^^^^^^^^ + 13 │ + 14 │ async function g1() { + + i Remove satisfies + +satisfies.ts:12:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + > 12 │ (bValue satisfies boolean) ? 0 : -1; + │ ^^^^^^^ + 13 │ + 14 │ async function g1() { + + i An explicit or implicit semicolon is expected here... + + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + > 12 │ (bValue satisfies boolean) ? 0 : -1; + │ ^^^^^^^ + 13 │ + 14 │ async function g1() { + + i ...Which is required to end this statement + + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + > 12 │ (bValue satisfies boolean) ? 0 : -1; + │ ^^^^^^^^^^^^^^^^^ + 13 │ + 14 │ async function g1() { + +satisfies.ts:12:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + > 12 │ (bValue satisfies boolean) ? 0 : -1; + │ ^ + 13 │ + 14 │ async function g1() { + + i An explicit or implicit semicolon is expected here... + + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + > 12 │ (bValue satisfies boolean) ? 0 : -1; + │ ^ + 13 │ + 14 │ async function g1() { + + i ...Which is required to end this statement + + 10 │ scrollTop > (visibilityHeight satisfies number); + 11 │ (scrollTop > visibilityHeight) satisfies number; + > 12 │ (bValue satisfies boolean) ? 0 : -1; + │ ^^^^^^^^ + 13 │ + 14 │ async function g1() { + +satisfies.ts:15:30 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 14 │ async function g1() { + > 15 │ const test = (await 'foo') satisfies number; + │ ^^^^^^^^^ + 16 │ } + 17 │ + + i An explicit or implicit semicolon is expected here... + + 14 │ async function g1() { + > 15 │ const test = (await 'foo') satisfies number; + │ ^^^^^^^^^ + 16 │ } + 17 │ + + i ...Which is required to end this statement + + 14 │ async function g1() { + > 15 │ const test = (await 'foo') satisfies number; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 16 │ } + 17 │ + +satisfies.ts:15:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 14 │ async function g1() { + > 15 │ const test = (await 'foo') satisfies number; + │ ^^^^^^ + 16 │ } + 17 │ + + i An explicit or implicit semicolon is expected here... + + 14 │ async function g1() { + > 15 │ const test = (await 'foo') satisfies number; + │ ^^^^^^ + 16 │ } + 17 │ + + i ...Which is required to end this statement + + 14 │ async function g1() { + > 15 │ const test = (await 'foo') satisfies number; + │ ^^^^^^^^^^^^^^^^ + 16 │ } + 17 │ + +satisfies.ts:18:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 16 │ } + 17 │ + > 18 │ var x = (v => v) satisfies (x: number) => string; + │ ^^^^^^^^^ + 19 │ + 20 │ foo satisfies unknown satisfies Bar; + + i An explicit or implicit semicolon is expected here... + + 16 │ } + 17 │ + > 18 │ var x = (v => v) satisfies (x: number) => string; + │ ^^^^^^^^^ + 19 │ + 20 │ foo satisfies unknown satisfies Bar; + + i ...Which is required to end this statement + + 16 │ } + 17 │ + > 18 │ var x = (v => v) satisfies (x: number) => string; + │ ^^^^^^^^^^^^^^^^^ + 19 │ + 20 │ foo satisfies unknown satisfies Bar; + +satisfies.ts:18:30 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `,` but instead found `:` + + 16 │ } + 17 │ + > 18 │ var x = (v => v) satisfies (x: number) => string; + │ ^ + 19 │ + 20 │ foo satisfies unknown satisfies Bar; + + i Remove : + +satisfies.ts:18:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 16 │ } + 17 │ + > 18 │ var x = (v => v) satisfies (x: number) => string; + │ ^^ + 19 │ + 20 │ foo satisfies unknown satisfies Bar; + + i An explicit or implicit semicolon is expected here... + + 16 │ } + 17 │ + > 18 │ var x = (v => v) satisfies (x: number) => string; + │ ^^ + 19 │ + 20 │ foo satisfies unknown satisfies Bar; + + i ...Which is required to end this statement + + 16 │ } + 17 │ + > 18 │ var x = (v => v) satisfies (x: number) => string; + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + 19 │ + 20 │ foo satisfies unknown satisfies Bar; + +satisfies.ts:20:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + + i An explicit or implicit semicolon is expected here... + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + + i ...Which is required to end this statement + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + +satisfies.ts:20:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + + i An explicit or implicit semicolon is expected here... + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + + i ...Which is required to end this statement + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^^^^^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + +satisfies.ts:20:23 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + + i An explicit or implicit semicolon is expected here... + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + + i ...Which is required to end this statement + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^^^^^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + +satisfies.ts:20:33 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + + i An explicit or implicit semicolon is expected here... + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + + i ...Which is required to end this statement + + 18 │ var x = (v => v) satisfies (x: number) => string; + 19 │ + > 20 │ foo satisfies unknown satisfies Bar; + │ ^^^^^^^^^^^^^ + 21 │ foo satisfies unknown as Bar; + 22 │ foo as unknown satisfies Bar; + +satisfies.ts:21:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 20 │ foo satisfies unknown satisfies Bar; + > 21 │ foo satisfies unknown as Bar; + │ ^^^^^^^^^ + 22 │ foo as unknown satisfies Bar; + 23 │ + + i An explicit or implicit semicolon is expected here... + + 20 │ foo satisfies unknown satisfies Bar; + > 21 │ foo satisfies unknown as Bar; + │ ^^^^^^^^^ + 22 │ foo as unknown satisfies Bar; + 23 │ + + i ...Which is required to end this statement + + 20 │ foo satisfies unknown satisfies Bar; + > 21 │ foo satisfies unknown as Bar; + │ ^^^^^^^^^^^^^ + 22 │ foo as unknown satisfies Bar; + 23 │ + +satisfies.ts:21:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 20 │ foo satisfies unknown satisfies Bar; + > 21 │ foo satisfies unknown as Bar; + │ ^^^^^^^ + 22 │ foo as unknown satisfies Bar; + 23 │ + + i An explicit or implicit semicolon is expected here... + + 20 │ foo satisfies unknown satisfies Bar; + > 21 │ foo satisfies unknown as Bar; + │ ^^^^^^^ + 22 │ foo as unknown satisfies Bar; + 23 │ + + i ...Which is required to end this statement + + 20 │ foo satisfies unknown satisfies Bar; + > 21 │ foo satisfies unknown as Bar; + │ ^^^^^^^^^^^^^^^^^ + 22 │ foo as unknown satisfies Bar; + 23 │ + +satisfies.ts:22:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 20 │ foo satisfies unknown satisfies Bar; + 21 │ foo satisfies unknown as Bar; + > 22 │ foo as unknown satisfies Bar; + │ ^^^^^^^^^ + 23 │ + + i An explicit or implicit semicolon is expected here... + + 20 │ foo satisfies unknown satisfies Bar; + 21 │ foo satisfies unknown as Bar; + > 22 │ foo as unknown satisfies Bar; + │ ^^^^^^^^^ + 23 │ + + i ...Which is required to end this statement + + 20 │ foo satisfies unknown satisfies Bar; + 21 │ foo satisfies unknown as Bar; + > 22 │ foo as unknown satisfies Bar; + │ ^^^^^^^^^^^^^^^^^^^^^^^^ + 23 │ + +satisfies.ts:22:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 20 │ foo satisfies unknown satisfies Bar; + 21 │ foo satisfies unknown as Bar; + > 22 │ foo as unknown satisfies Bar; + │ ^^^ + 23 │ + + i An explicit or implicit semicolon is expected here... + + 20 │ foo satisfies unknown satisfies Bar; + 21 │ foo satisfies unknown as Bar; + > 22 │ foo as unknown satisfies Bar; + │ ^^^ + 23 │ + + i ...Which is required to end this statement + + 20 │ foo satisfies unknown satisfies Bar; + 21 │ foo satisfies unknown as Bar; + > 22 │ foo as unknown satisfies Bar; + │ ^^^^^^^^^^^^^ + 23 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts new file mode 100644 index 00000000000..d4152adc97e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts @@ -0,0 +1,5 @@ +const a = `${(foo + bar) satisfies baz}`; +const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; +const b = `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; +const b = `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; +const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts.prettier-snap new file mode 100644 index 00000000000..accae0b472d --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts.prettier-snap @@ -0,0 +1,14 @@ +const a = `${(foo + bar) satisfies baz}`; +const b = `${ + (veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz +}`; +const b = `${ + (foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz +}`; +const b = `${ + (foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz +}`; +const b = `${ + (veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz +}`; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts.snap new file mode 100644 index 00000000000..9330cbfa803 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/template-literal.ts.snap @@ -0,0 +1,136 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/template-literal.ts +--- + +# Input + +```js +const a = `${(foo + bar) satisfies baz}`; +const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; +const b = `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; +const b = `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; +const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,14 +1,9 @@ + const a = `${(foo + bar) satisfies baz}`; +-const b = `${ +- (veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz +-}`; +-const b = `${ +- (foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz +-}`; +-const b = `${ +- (foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz +-}`; +-const b = `${ +- (veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + +- veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz +-}`; ++const b = ++ `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; ++const b = ++ `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; ++const b = ++ `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; ++const b = ++ `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; +``` + +# Output + +```js +const a = `${(foo + bar) satisfies baz}`; +const b = + `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; +const b = + `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; +const b = + `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; +const b = + `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; +``` + + +# Errors +``` +template-literal.ts:1:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `}` but instead found `satisfies` + + > 1 │ const a = `${(foo + bar) satisfies baz}`; + │ ^^^^^^^^^ + 2 │ const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; + 3 │ const b = `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; + + i Remove satisfies + +template-literal.ts:2:78 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `}` but instead found `satisfies` + + 1 │ const a = `${(foo + bar) satisfies baz}`; + > 2 │ const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; + │ ^^^^^^^^^ + 3 │ const b = `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; + 4 │ const b = `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; + + i Remove satisfies + +template-literal.ts:3:78 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `}` but instead found `satisfies` + + 1 │ const a = `${(foo + bar) satisfies baz}`; + 2 │ const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; + > 3 │ const b = `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; + │ ^^^^^^^^^ + 4 │ const b = `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; + 5 │ const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; + + i Remove satisfies + +template-literal.ts:4:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `}` but instead found `satisfies` + + 2 │ const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; + 3 │ const b = `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; + > 4 │ const b = `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; + │ ^^^^^^^^^ + 5 │ const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; + 6 │ + + i Remove satisfies + +template-literal.ts:5:130 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `}` but instead found `satisfies` + + 3 │ const b = `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; + 4 │ const b = `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; + > 5 │ const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; + │ ^^^^^^^^^ + 6 │ + + i Remove satisfies + + +``` + +# Lines exceeding max width of 80 characters +``` + 3: `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + bar) satisfies baz}`; + 5: `${(foo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies baz}`; + 7: `${(foo + bar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; + 9: `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar) satisfies veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBaz}`; +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts new file mode 100644 index 00000000000..0baab89c6c3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts @@ -0,0 +1,40 @@ +foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + +foo = (condition ? firstValue : secondValue) satisfies SomeType; + +const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + +function foo() { + return (coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; +} + +function foo() { + throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; +} + +function foo() { + void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); +} + +bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 + ? averredBathersBoxroomBuggyNurl + : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + +bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 && + kochabCooieGameOnOboleUnweave === Math.PI + ? averredBathersBoxroomBuggyNurl + : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts.prettier-snap new file mode 100644 index 00000000000..a70eea1eb1c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts.prettier-snap @@ -0,0 +1,50 @@ +foo = ( + coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz +) satisfies Fooooooooooo; + +foo = (condition ? firstValue : secondValue) satisfies SomeType; + +const foo = ( + coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz +) satisfies Fooooooooooo; + +function foo() { + return ( + coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz + ) satisfies Fooooooooooo; +} + +function foo() { + throw ( + coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz + ) satisfies Fooooooooooo; +} + +function foo() { + void (( + coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz + ) satisfies Fooooooooooo); +} + +bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 + ? averredBathersBoxroomBuggyNurl + : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + +bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 && + kochabCooieGameOnOboleUnweave === Math.PI + ? averredBathersBoxroomBuggyNurl + : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts.snap new file mode 100644 index 00000000000..7e738f372f2 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/ternary.ts.snap @@ -0,0 +1,722 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/ternary.ts +--- + +# Input + +```js +foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + +foo = (condition ? firstValue : secondValue) satisfies SomeType; + +const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + +function foo() { + return (coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; +} + +function foo() { + throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; +} + +function foo() { + void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); +} + +bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 + ? averredBathersBoxroomBuggyNurl + : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + +bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 && + kochabCooieGameOnOboleUnweave === Math.PI + ? averredBathersBoxroomBuggyNurl + : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,50 +1,59 @@ +-foo = ( +- coooooooooooooooooooooooooooooooooooooooooooooooooooond +- ? baaaaaaaaaaaaaaaaaaaaar +- : baaaaaaaaaaaaaaaaaaaaaz +-) satisfies Fooooooooooo; ++foo = coooooooooooooooooooooooooooooooooooooooooooooooooooond ++ ? baaaaaaaaaaaaaaaaaaaaar ++ : baaaaaaaaaaaaaaaaaaaaaz; ++satisfies; ++Fooooooooooo; + +-foo = (condition ? firstValue : secondValue) satisfies SomeType; ++foo = condition ? firstValue : secondValue; ++satisfies; ++SomeType; + +-const foo = ( +- coooooooooooooooooooooooooooooooooooooooooooooooooooond +- ? baaaaaaaaaaaaaaaaaaaaar +- : baaaaaaaaaaaaaaaaaaaaaz +-) satisfies Fooooooooooo; ++const foo = coooooooooooooooooooooooooooooooooooooooooooooooooooond ++ ? baaaaaaaaaaaaaaaaaaaaar ++ : baaaaaaaaaaaaaaaaaaaaaz; ++satisfies; ++Fooooooooooo; + + function foo() { +- return ( +- coooooooooooooooooooooooooooooooooooooooooooooooooooond +- ? baaaaaaaaaaaaaaaaaaaaar +- : baaaaaaaaaaaaaaaaaaaaaz +- ) satisfies Fooooooooooo; ++ return coooooooooooooooooooooooooooooooooooooooooooooooooooond ++ ? baaaaaaaaaaaaaaaaaaaaar ++ : baaaaaaaaaaaaaaaaaaaaaz; ++ satisfies; ++ Fooooooooooo; + } + + function foo() { +- throw ( +- coooooooooooooooooooooooooooooooooooooooooooooooooooond +- ? baaaaaaaaaaaaaaaaaaaaar +- : baaaaaaaaaaaaaaaaaaaaaz +- ) satisfies Fooooooooooo; ++ throw coooooooooooooooooooooooooooooooooooooooooooooooooooond ++ ? baaaaaaaaaaaaaaaaaaaaar ++ : baaaaaaaaaaaaaaaaaaaaaz; ++ satisfies; ++ Fooooooooooo; + } + + function foo() { +- void (( +- coooooooooooooooooooooooooooooooooooooooooooooooooooond +- ? baaaaaaaaaaaaaaaaaaaaar +- : baaaaaaaaaaaaaaaaaaaaaz +- ) satisfies Fooooooooooo); ++ void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond ++ ? baaaaaaaaaaaaaaaaaaaaar ++ : baaaaaaaaaaaaaaaaaaaaaz) ++ satisfies; ++ Fooooooooooo; ++ ) + } + + bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 + ? averredBathersBoxroomBuggyNurl +- : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); ++ : anodyneCondosMalateOverateRetinol) ++satisfies; ++AnnularCooeedSplicesWalksWayWay; ++) + + bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 && + kochabCooieGameOnOboleUnweave === Math.PI + ? averredBathersBoxroomBuggyNurl +- : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); ++ : anodyneCondosMalateOverateRetinol) ++satisfies; ++AnnularCooeedSplicesWalksWayWay; ++) +``` + +# Output + +```js +foo = coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz; +satisfies; +Fooooooooooo; + +foo = condition ? firstValue : secondValue; +satisfies; +SomeType; + +const foo = coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz; +satisfies; +Fooooooooooo; + +function foo() { + return coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz; + satisfies; + Fooooooooooo; +} + +function foo() { + throw coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz; + satisfies; + Fooooooooooo; +} + +function foo() { + void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + ? baaaaaaaaaaaaaaaaaaaaar + : baaaaaaaaaaaaaaaaaaaaaz) + satisfies; + Fooooooooooo; + ) +} + +bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 + ? averredBathersBoxroomBuggyNurl + : anodyneCondosMalateOverateRetinol) +satisfies; +AnnularCooeedSplicesWalksWayWay; +) + +bifornCringerMoshedPerplexSawder = + askTrovenaBeenaDependsRowans + + ((glimseGlyphsHazardNoopsTieTie === 0 && + kochabCooieGameOnOboleUnweave === Math.PI + ? averredBathersBoxroomBuggyNurl + : anodyneCondosMalateOverateRetinol) +satisfies; +AnnularCooeedSplicesWalksWayWay; +) +``` + + +# Errors +``` +ternary.ts:3:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 2 │ ? baaaaaaaaaaaaaaaaaaaaar + > 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^ + 4 │ + 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + + i An explicit or implicit semicolon is expected here... + + 1 │ foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 2 │ ? baaaaaaaaaaaaaaaaaaaaar + > 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^ + 4 │ + 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + + i ...Which is required to end this statement + + > 1 │ foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 2 │ ? baaaaaaaaaaaaaaaaaaaaar + > 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + +ternary.ts:3:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 2 │ ? baaaaaaaaaaaaaaaaaaaaar + > 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^ + 4 │ + 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + + i An explicit or implicit semicolon is expected here... + + 1 │ foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 2 │ ? baaaaaaaaaaaaaaaaaaaaar + > 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^ + 4 │ + 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + + i ...Which is required to end this statement + + 1 │ foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 2 │ ? baaaaaaaaaaaaaaaaaaaaar + > 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^^^^^^^^^^^ + 4 │ + 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + +ternary.ts:5:46 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + 4 │ + > 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + │ ^^^^^^^^^ + 6 │ + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + + i An explicit or implicit semicolon is expected here... + + 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + 4 │ + > 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + │ ^^^^^^^^^ + 6 │ + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + + i ...Which is required to end this statement + + 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + 4 │ + > 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 6 │ + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + +ternary.ts:5:56 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + 4 │ + > 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + │ ^^^^^^^^ + 6 │ + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + + i An explicit or implicit semicolon is expected here... + + 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + 4 │ + > 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + │ ^^^^^^^^ + 6 │ + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + + i ...Which is required to end this statement + + 3 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + 4 │ + > 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + │ ^^^^^^^^^^^^^^^^^^ + 6 │ + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + +ternary.ts:9:30 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 8 │ ? baaaaaaaaaaaaaaaaaaaaar + > 9 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^ + 10 │ + 11 │ function foo() { + + i An explicit or implicit semicolon is expected here... + + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 8 │ ? baaaaaaaaaaaaaaaaaaaaar + > 9 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^ + 10 │ + 11 │ function foo() { + + i ...Which is required to end this statement + + 5 │ foo = (condition ? firstValue : secondValue) satisfies SomeType; + 6 │ + > 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 8 │ ? baaaaaaaaaaaaaaaaaaaaar + > 9 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 10 │ + 11 │ function foo() { + +ternary.ts:9:40 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 8 │ ? baaaaaaaaaaaaaaaaaaaaar + > 9 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^ + 10 │ + 11 │ function foo() { + + i An explicit or implicit semicolon is expected here... + + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 8 │ ? baaaaaaaaaaaaaaaaaaaaar + > 9 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^ + 10 │ + 11 │ function foo() { + + i ...Which is required to end this statement + + 7 │ const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 8 │ ? baaaaaaaaaaaaaaaaaaaaar + > 9 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^^^^^^^^^^^ + 10 │ + 11 │ function foo() { + +ternary.ts:14:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 12 │ return (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 13 │ ? baaaaaaaaaaaaaaaaaaaaar + > 14 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^ + 15 │ } + 16 │ + + i An explicit or implicit semicolon is expected here... + + 12 │ return (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 13 │ ? baaaaaaaaaaaaaaaaaaaaar + > 14 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^ + 15 │ } + 16 │ + + i ...Which is required to end this statement + + 11 │ function foo() { + > 12 │ return (coooooooooooooooooooooooooooooooooooooooooooooooooooond + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 13 │ ? baaaaaaaaaaaaaaaaaaaaar + > 14 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 15 │ } + 16 │ + +ternary.ts:14:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 12 │ return (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 13 │ ? baaaaaaaaaaaaaaaaaaaaar + > 14 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^ + 15 │ } + 16 │ + + i An explicit or implicit semicolon is expected here... + + 12 │ return (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 13 │ ? baaaaaaaaaaaaaaaaaaaaar + > 14 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^ + 15 │ } + 16 │ + + i ...Which is required to end this statement + + 12 │ return (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 13 │ ? baaaaaaaaaaaaaaaaaaaaar + > 14 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^^^^^^^^^^^ + 15 │ } + 16 │ + +ternary.ts:20:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 19 │ ? baaaaaaaaaaaaaaaaaaaaar + > 20 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^ + 21 │ } + 22 │ + + i An explicit or implicit semicolon is expected here... + + 18 │ throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 19 │ ? baaaaaaaaaaaaaaaaaaaaar + > 20 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^ + 21 │ } + 22 │ + + i ...Which is required to end this statement + + 17 │ function foo() { + > 18 │ throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + > 19 │ ? baaaaaaaaaaaaaaaaaaaaar + > 20 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 21 │ } + 22 │ + +ternary.ts:20:44 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 18 │ throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 19 │ ? baaaaaaaaaaaaaaaaaaaaar + > 20 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^ + 21 │ } + 22 │ + + i An explicit or implicit semicolon is expected here... + + 18 │ throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 19 │ ? baaaaaaaaaaaaaaaaaaaaar + > 20 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^ + 21 │ } + 22 │ + + i ...Which is required to end this statement + + 18 │ throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond + 19 │ ? baaaaaaaaaaaaaaaaaaaaar + > 20 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo; + │ ^^^^^^^^^^^^^^^^^^^^^^ + 21 │ } + 22 │ + +ternary.ts:26:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 24 │ void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + 25 │ ? baaaaaaaaaaaaaaaaaaaaar + > 26 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); + │ ^^^^^^^^^ + 27 │ } + 28 │ + + i Remove satisfies + +ternary.ts:26:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 24 │ void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + 25 │ ? baaaaaaaaaaaaaaaaaaaaar + > 26 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); + │ ^^^^^^^^^^^^ + 27 │ } + 28 │ + + i An explicit or implicit semicolon is expected here... + + 24 │ void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + 25 │ ? baaaaaaaaaaaaaaaaaaaaar + > 26 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); + │ ^^^^^^^^^^^^ + 27 │ } + 28 │ + + i ...Which is required to end this statement + + 24 │ void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + 25 │ ? baaaaaaaaaaaaaaaaaaaaar + > 26 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); + │ ^^^^^^^^^^^^^^^^^^^^^^ + 27 │ } + 28 │ + +ternary.ts:26:54 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 24 │ void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + 25 │ ? baaaaaaaaaaaaaaaaaaaaar + > 26 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); + │ ^ + 27 │ } + 28 │ + + i An explicit or implicit semicolon is expected here... + + 24 │ void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + 25 │ ? baaaaaaaaaaaaaaaaaaaaar + > 26 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); + │ ^ + 27 │ } + 28 │ + + i ...Which is required to end this statement + + 24 │ void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond + 25 │ ? baaaaaaaaaaaaaaaaaaaaar + > 26 │ : baaaaaaaaaaaaaaaaaaaaaz) satisfies Fooooooooooo); + │ ^^^^^^^^^^^^^ + 27 │ } + 28 │ + +ternary.ts:33:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 31 │ ((glimseGlyphsHazardNoopsTieTie === 0 + 32 │ ? averredBathersBoxroomBuggyNurl + > 33 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^ + 34 │ + 35 │ bifornCringerMoshedPerplexSawder = + + i Remove satisfies + +ternary.ts:33:52 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 31 │ ((glimseGlyphsHazardNoopsTieTie === 0 + 32 │ ? averredBathersBoxroomBuggyNurl + > 33 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 34 │ + 35 │ bifornCringerMoshedPerplexSawder = + + i An explicit or implicit semicolon is expected here... + + 31 │ ((glimseGlyphsHazardNoopsTieTie === 0 + 32 │ ? averredBathersBoxroomBuggyNurl + > 33 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 34 │ + 35 │ bifornCringerMoshedPerplexSawder = + + i ...Which is required to end this statement + + 31 │ ((glimseGlyphsHazardNoopsTieTie === 0 + 32 │ ? averredBathersBoxroomBuggyNurl + > 33 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 34 │ + 35 │ bifornCringerMoshedPerplexSawder = + +ternary.ts:33:83 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 31 │ ((glimseGlyphsHazardNoopsTieTie === 0 + 32 │ ? averredBathersBoxroomBuggyNurl + > 33 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^ + 34 │ + 35 │ bifornCringerMoshedPerplexSawder = + + i An explicit or implicit semicolon is expected here... + + 31 │ ((glimseGlyphsHazardNoopsTieTie === 0 + 32 │ ? averredBathersBoxroomBuggyNurl + > 33 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^ + 34 │ + 35 │ bifornCringerMoshedPerplexSawder = + + i ...Which is required to end this statement + + 31 │ ((glimseGlyphsHazardNoopsTieTie === 0 + 32 │ ? averredBathersBoxroomBuggyNurl + > 33 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 34 │ + 35 │ bifornCringerMoshedPerplexSawder = + +ternary.ts:40:42 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `)` but instead found `satisfies` + + 38 │ kochabCooieGameOnOboleUnweave === Math.PI + 39 │ ? averredBathersBoxroomBuggyNurl + > 40 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^ + 41 │ + + i Remove satisfies + +ternary.ts:40:52 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 38 │ kochabCooieGameOnOboleUnweave === Math.PI + 39 │ ? averredBathersBoxroomBuggyNurl + > 40 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 41 │ + + i An explicit or implicit semicolon is expected here... + + 38 │ kochabCooieGameOnOboleUnweave === Math.PI + 39 │ ? averredBathersBoxroomBuggyNurl + > 40 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 41 │ + + i ...Which is required to end this statement + + 38 │ kochabCooieGameOnOboleUnweave === Math.PI + 39 │ ? averredBathersBoxroomBuggyNurl + > 40 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 41 │ + +ternary.ts:40:83 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 38 │ kochabCooieGameOnOboleUnweave === Math.PI + 39 │ ? averredBathersBoxroomBuggyNurl + > 40 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^ + 41 │ + + i An explicit or implicit semicolon is expected here... + + 38 │ kochabCooieGameOnOboleUnweave === Math.PI + 39 │ ? averredBathersBoxroomBuggyNurl + > 40 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^ + 41 │ + + i ...Which is required to end this statement + + 38 │ kochabCooieGameOnOboleUnweave === Math.PI + 39 │ ? averredBathersBoxroomBuggyNurl + > 40 │ : anodyneCondosMalateOverateRetinol) satisfies AnnularCooeedSplicesWalksWayWay); + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 41 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts new file mode 100644 index 00000000000..8ef9413c2a3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts @@ -0,0 +1,3 @@ +(() => { + // swallow error and fallback to using directory as path +}) satisfies string[]; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts.prettier-snap new file mode 100644 index 00000000000..8ef9413c2a3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts.prettier-snap @@ -0,0 +1,3 @@ +(() => { + // swallow error and fallback to using directory as path +}) satisfies string[]; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts.snap new file mode 100644 index 00000000000..8786b597f14 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/satisfies-operators/types-comments.ts.snap @@ -0,0 +1,118 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/satisfies-operators/types-comments.ts +--- + +# Input + +```js +(() => { + // swallow error and fallback to using directory as path +}) satisfies string[]; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,3 +1,5 @@ +-(() => { ++() => { + // swallow error and fallback to using directory as path +-}) satisfies string[]; ++}; ++satisfies; ++string[]; +``` + +# Output + +```js +() => { + // swallow error and fallback to using directory as path +}; +satisfies; +string[]; +``` + + +# Errors +``` +types-comments.ts:3:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ (() => { + 2 │ // swallow error and fallback to using directory as path + > 3 │ }) satisfies string[]; + │ ^^^^^^^^^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ (() => { + 2 │ // swallow error and fallback to using directory as path + > 3 │ }) satisfies string[]; + │ ^^^^^^^^^ + 4 │ + + i ...Which is required to end this statement + + > 1 │ (() => { + │ ^^^^^^^^ + > 2 │ // swallow error and fallback to using directory as path + > 3 │ }) satisfies string[]; + │ ^^^^^^^^^^^^ + 4 │ + +types-comments.ts:3:14 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 1 │ (() => { + 2 │ // swallow error and fallback to using directory as path + > 3 │ }) satisfies string[]; + │ ^^^^^^ + 4 │ + + i An explicit or implicit semicolon is expected here... + + 1 │ (() => { + 2 │ // swallow error and fallback to using directory as path + > 3 │ }) satisfies string[]; + │ ^^^^^^ + 4 │ + + i ...Which is required to end this statement + + 1 │ (() => { + 2 │ // swallow error and fallback to using directory as path + > 3 │ }) satisfies string[]; + │ ^^^^^^^^^^^^^^^^ + 4 │ + +types-comments.ts:3:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected an expression but instead found ']' + + 1 │ (() => { + 2 │ // swallow error and fallback to using directory as path + > 3 │ }) satisfies string[]; + │ ^ + 4 │ + + i Expected an expression here + + 1 │ (() => { + 2 │ // swallow error and fallback to using directory as path + > 3 │ }) satisfies string[]; + │ ^ + 4 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/semi/no-semi.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/semi/no-semi.ts new file mode 100644 index 00000000000..8a32ed4904f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/semi/no-semi.ts @@ -0,0 +1,9 @@ +export class Mutation { + private set: NQuad[]; + private delete: NQuad[]; +} + +class Foo { + prop1 = 0; + [key: string]: any; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/semi/no-semi.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/semi/no-semi.ts.prettier-snap new file mode 100644 index 00000000000..8a32ed4904f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/semi/no-semi.ts.prettier-snap @@ -0,0 +1,9 @@ +export class Mutation { + private set: NQuad[]; + private delete: NQuad[]; +} + +class Foo { + prop1 = 0; + [key: string]: any; +} diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/test-declarations/test_declarations.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/test-declarations/test_declarations.ts.snap index 538f3508e36..eea3e1e27b3 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/test-declarations/test_declarations.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/test-declarations/test_declarations.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/test-declarations/test_declarations.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx new file mode 100644 index 00000000000..a1555939a25 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx @@ -0,0 +1,4 @@ +const f1 = () => 1; +const f2 = < + Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt, +>() => 1; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx.prettier-snap new file mode 100644 index 00000000000..a35bfe5a7c3 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx.prettier-snap @@ -0,0 +1,4 @@ +const f1 = () => 1; +const f2 = < + Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt, +>() => 1; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx.snap new file mode 100644 index 00000000000..1642ebd5f37 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/arrow-functions.tsx.snap @@ -0,0 +1,40 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/trailing-comma/arrow-functions.tsx +--- + +# Input + +```js +const f1 = () => 1; +const f2 = < + Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt, +>() => 1; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -1,4 +1,4 @@ +-const f1 = () => 1; ++const f1 = () => 1; + const f2 = < + Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt, + >() => 1; +``` + +# Output + +```js +const f1 = () => 1; +const f2 = < + Tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt, +>() => 1; +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts new file mode 100644 index 00000000000..11c7202b52e --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts @@ -0,0 +1,16 @@ +export class BaseSingleLevelProfileTargeting< + T extends ValidSingleLevelProfileNode, +> { +} + +enum Enum { + x = 1, + y = 2, +} + +const { + longKeySoThisWillGoOnMultipleLines, + longKeySoThisWillGoOnMultipleLines2, + longKeySoThisWillGoOnMultipleLines3, + ...rest, +} = something; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts.prettier-snap new file mode 100644 index 00000000000..e9bf08d5a19 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts.prettier-snap @@ -0,0 +1,15 @@ +export class BaseSingleLevelProfileTargeting< + T extends ValidSingleLevelProfileNode, +> {} + +enum Enum { + x = 1, + y = 2, +} + +const { + longKeySoThisWillGoOnMultipleLines, + longKeySoThisWillGoOnMultipleLines2, + longKeySoThisWillGoOnMultipleLines3, + ...rest +} = something; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts.snap new file mode 100644 index 00000000000..9bf800a9ced --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/trailing.ts.snap @@ -0,0 +1,98 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/trailing-comma/trailing.ts +--- + +# Input + +```js +export class BaseSingleLevelProfileTargeting< + T extends ValidSingleLevelProfileNode, +> { +} + +enum Enum { + x = 1, + y = 2, +} + +const { + longKeySoThisWillGoOnMultipleLines, + longKeySoThisWillGoOnMultipleLines2, + longKeySoThisWillGoOnMultipleLines3, + ...rest, +} = something; +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -11,5 +11,5 @@ + longKeySoThisWillGoOnMultipleLines, + longKeySoThisWillGoOnMultipleLines2, + longKeySoThisWillGoOnMultipleLines3, +- ...rest ++ ...rest, + } = something; +``` + +# Output + +```js +export class BaseSingleLevelProfileTargeting< + T extends ValidSingleLevelProfileNode, +> {} + +enum Enum { + x = 1, + y = 2, +} + +const { + longKeySoThisWillGoOnMultipleLines, + longKeySoThisWillGoOnMultipleLines2, + longKeySoThisWillGoOnMultipleLines3, + ...rest, +} = something; +``` + + +# Errors +``` +trailing.ts:15:10 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × rest element may not have a trailing comma + + 13 │ longKeySoThisWillGoOnMultipleLines2, + 14 │ longKeySoThisWillGoOnMultipleLines3, + > 15 │ ...rest, + │ ^ + 16 │ } = something; + 17 │ + + i Remove the trailing comma here + + 13 │ longKeySoThisWillGoOnMultipleLines2, + 14 │ longKeySoThisWillGoOnMultipleLines3, + > 15 │ ...rest, + │ ^ + 16 │ } = something; + 17 │ + + i Rest element + + 13 │ longKeySoThisWillGoOnMultipleLines2, + 14 │ longKeySoThisWillGoOnMultipleLines3, + > 15 │ ...rest, + │ ^^^^^^^ + 16 │ } = something; + 17 │ + + +``` + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-arguments.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-arguments.ts new file mode 100644 index 00000000000..84a9e915d31 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-arguments.ts @@ -0,0 +1,15 @@ +var bar: Bar< + AAAAAAA, + BBBBBBB, + CCCCCCC, + DDDDDDD, + EEEEEEE, + FFFFFFF, + GGGGGGG, + HHHHHHH +>; + +const baz = new Array< + FooFooFooFooFooFooFooFooFooFooFooFooFooFooFoo, + BarBarBarBarBarBarBarBarBarBarBarBarBarBarBar +>(); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-arguments.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-arguments.ts.prettier-snap new file mode 100644 index 00000000000..84a9e915d31 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-arguments.ts.prettier-snap @@ -0,0 +1,15 @@ +var bar: Bar< + AAAAAAA, + BBBBBBB, + CCCCCCC, + DDDDDDD, + EEEEEEE, + FFFFFFF, + GGGGGGG, + HHHHHHH +>; + +const baz = new Array< + FooFooFooFooFooFooFooFooFooFooFooFooFooFooFoo, + BarBarBarBarBarBarBarBarBarBarBarBarBarBarBar +>(); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts new file mode 100644 index 00000000000..8d5ac46d62c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts @@ -0,0 +1,15 @@ +class FooClass< + A, + B, + C, +> { + a: A; + b: B; + c: C; +} + +const instance = new FooClass< + boolean, + number, + string, // [ts] Trailing comma not allowed. + >(); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts.prettier-snap new file mode 100644 index 00000000000..c03ae76b74f --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts.prettier-snap @@ -0,0 +1,11 @@ +class FooClass { + a: A; + b: B; + c: C; +} + +const instance = new FooClass< + boolean, + number, + string // [ts] Trailing comma not allowed. +>(); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts.snap new file mode 100644 index 00000000000..8dde83a7e6b --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/trailing-comma/type-parameters-vs-arguments.ts.snap @@ -0,0 +1,64 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/trailing-comma/type-parameters-vs-arguments.ts +--- + +# Input + +```js +class FooClass< + A, + B, + C, +> { + a: A; + b: B; + c: C; +} + +const instance = new FooClass< + boolean, + number, + string, // [ts] Trailing comma not allowed. + >(); +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -5,7 +5,7 @@ + } + + const instance = new FooClass< +- boolean, +- number, +- string // [ts] Trailing comma not allowed. +->(); ++ boolean, ++ number, ++ string, // [ts] Trailing comma not allowed. ++ >(); +``` + +# Output + +```js +class FooClass { + a: A; + b: B; + c: C; +} + +const instance = new FooClass< + boolean, + number, + string, // [ts] Trailing comma not allowed. + >(); +``` + + + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/tsx/type-parameters.tsx.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/tsx/type-parameters.tsx.snap index fa1583b750c..11b340b0688 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/tsx/type-parameters.tsx.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/tsx/type-parameters.tsx.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/tsx/type-parameters.tsx --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/type-arguments-bit-shift-left-like/1.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/type-arguments-bit-shift-left-like/1.ts.snap index 6d63a3a07df..189c78ffadd 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/type-arguments-bit-shift-left-like/1.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/type-arguments-bit-shift-left-like/1.ts.snap @@ -1,5 +1,7 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/type-arguments-bit-shift-left-like/1.ts --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts new file mode 100644 index 00000000000..b340165235c --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts @@ -0,0 +1,19 @@ +export const Foo = forwardRef((props: FooProps, ref: Ref): JSX.Element => { + return
; +}); + +export const Bar = forwardRef((props: BarProps, ref: Ref): JSX.Element | null => { + return
; +}); + +users.map((user: User): User => { + return user; +}) + +users.map((user: User): User => { + ; // comment +}) + +users.map((user: User): User => { + // comment +}) diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts.prettier-snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts.prettier-snap new file mode 100644 index 00000000000..11340dee601 --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts.prettier-snap @@ -0,0 +1,23 @@ +export const Foo = forwardRef( + (props: FooProps, ref: Ref): JSX.Element => { + return
; + }, +); + +export const Bar = forwardRef( + (props: BarProps, ref: Ref): JSX.Element | null => { + return
; + }, +); + +users.map((user: User): User => { + return user; +}); + +users.map((user: User): User => { + // comment +}); + +users.map((user: User): User => { + // comment +}); diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts.snap new file mode 100644 index 00000000000..6f667ab676a --- /dev/null +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/typeparams/print-width-120/issue-7542.ts.snap @@ -0,0 +1,166 @@ +--- +source: crates/rome_js_formatter/tests/prettier_tests.rs +info: + test_file: typescript/typeparams/print-width-120/issue-7542.ts +--- + +# Input + +```js +export const Foo = forwardRef((props: FooProps, ref: Ref): JSX.Element => { + return
; +}); + +export const Bar = forwardRef((props: BarProps, ref: Ref): JSX.Element | null => { + return
; +}); + +users.map((user: User): User => { + return user; +}) + +users.map((user: User): User => { + ; // comment +}) + +users.map((user: User): User => { + // comment +}) +``` + + +# Prettier differences + +```diff +--- Prettier ++++ Rome +@@ -14,9 +14,11 @@ + return user; + }); + +-users.map((user: User): User => { +- // comment +-}); ++users.map( ++ (user: User): User => { ++ // comment ++ }, ++); + + users.map((user: User): User => { + // comment +``` + +# Output + +```js +export const Foo = forwardRef( + (props: FooProps, ref: Ref): JSX.Element => { + return
; + }, +); + +export const Bar = forwardRef( + (props: BarProps, ref: Ref): JSX.Element | null => { + return
; + }, +); + +users.map((user: User): User => { + return user; +}); + +users.map( + (user: User): User => { + // comment + }, +); + +users.map((user: User): User => { + // comment +}); +``` + + +# Errors +``` +issue-7542.ts:2:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `>` but instead found `/` + + 1 │ export const Foo = forwardRef((props: FooProps, ref: Ref): JSX.Element => { + > 2 │ return
; + │ ^ + 3 │ }); + 4 │ + + i Remove / + +issue-7542.ts:6:15 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × expected `>` but instead found `/` + + 5 │ export const Bar = forwardRef((props: BarProps, ref: Ref): JSX.Element | null => { + > 6 │ return
; + │ ^ + 7 │ }); + 8 │ + + i Remove / + +issue-7542.ts:2:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × unterminated regex literal + + 1 │ export const Foo = forwardRef((props: FooProps, ref: Ref): JSX.Element => { + > 2 │ return
; + │ + 3 │ }); + 4 │ + + i ...but the line ends here + + 1 │ export const Foo = forwardRef((props: FooProps, ref: Ref): JSX.Element => { + > 2 │ return
; + │ + 3 │ }); + 4 │ + + i a regex literal starts there... + + 1 │ export const Foo = forwardRef((props: FooProps, ref: Ref): JSX.Element => { + > 2 │ return
; + │ ^ + 3 │ }); + 4 │ + +issue-7542.ts:6:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × unterminated regex literal + + 5 │ export const Bar = forwardRef((props: BarProps, ref: Ref): JSX.Element | null => { + > 6 │ return
; + │ + 7 │ }); + 8 │ + + i ...but the line ends here + + 5 │ export const Bar = forwardRef((props: BarProps, ref: Ref): JSX.Element | null => { + > 6 │ return
; + │ + 7 │ }); + 8 │ + + i a regex literal starts there... + + 5 │ export const Bar = forwardRef((props: BarProps, ref: Ref): JSX.Element | null => { + > 6 │ return
; + │ ^ + 7 │ }); + 8 │ + + +``` + +