From 03cc0d59b634a347ce7963afb0be7aa6f15ea16e Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 13 May 2022 15:38:32 +0200 Subject: [PATCH 1/4] fix(formatter): Stable member printing This PR simplifies the member printing logic to make sure its output is stable. This results in a small regression ``` Before: **File Based Average Prettier Similarity**: 69.29% **Line Based Average Prettier Similarity**: 64.28% After: **File Based Average Prettier Similarity**: 69.13% **Line Based Average Prettier Similarity**: 64.06% ``` But unblocks my work on refactoring the printer behaviour (which seems to trigger this now a lot), and #2458 --- .../src/utils/member_chain/flatten_item.rs | 19 --- .../src/utils/member_chain/groups.rs | 128 ++---------------- .../src/utils/member_chain/mod.rs | 21 +-- .../member-chain/complex_arguments.js.snap | 5 +- .../expression/member-chain/computed.js.snap | 12 +- .../member-chain/inline-merge.js.snap | 16 +-- .../prettier/js/arrays/holes-in-args.js.snap | 5 +- .../prettier/js/async/inline-await.js.snap | 11 +- .../js/binary-expressions/arrow.js.snap | 2 - .../js/comments/dangling_array.js.snap | 9 +- .../specs/prettier/js/comments/issues.js.snap | 7 +- .../function_expression.js.snap | 39 +++--- .../pipe-function-calls-with-comments.js.snap | 5 +- .../pipe-function-calls.js.snap | 5 +- .../js/last-argument-expansion/arrow.js.snap | 22 +-- .../specs/prettier/js/member/expand.js.snap | 15 +- .../prettier/js/method-chain/comment.js.snap | 78 +++++------ .../js/method-chain/complex-args.js.snap | 4 +- .../js/method-chain/computed-merge.js.snap | 10 +- .../prettier/js/method-chain/computed.js.snap | 11 +- .../specs/prettier/js/method-chain/d3.js.snap | 23 ++-- .../js/method-chain/first_long.js.snap | 25 ++-- .../js/method-chain/inline_merge.js.snap | 15 +- .../js/method-chain/issue-3594.js.snap | 4 +- .../js/method-chain/issue-4125.js.snap | 102 +++++--------- .../js/method-chain/multiple-members.js.snap | 28 ++-- .../js/method-chain/object-literal.js.snap | 8 +- .../prettier/js/method-chain/pr-7889.js.snap | 26 ++-- .../js/method-chain/short-names.js.snap | 7 +- .../prettier/js/method-chain/square_0.js.snap | 4 +- .../js/optional-chaining/comments.js.snap | 32 ++--- .../prettier/js/performance/nested.js.snap | 74 +++------- .../js/preserve-line/member-chain.js.snap | 24 ++-- .../js/template-literals/expressions.js.snap | 13 +- .../js/test-declarations/jest-each.js.snap | 48 +++---- .../js/trailing-comma/function-calls.js.snap | 2 - .../typescript/as/assignment2.ts.snap | 28 ++-- .../custom/typeParameters/variables.ts.snap | 29 ++-- .../pipe-function-calls-with-comments.ts.snap | 5 +- .../pipe-function-calls.ts.snap | 5 +- .../typescript/method-chain/comment.ts.snap | 23 ++-- 41 files changed, 337 insertions(+), 612 deletions(-) diff --git a/crates/rome_js_formatter/src/utils/member_chain/flatten_item.rs b/crates/rome_js_formatter/src/utils/member_chain/flatten_item.rs index 896aab8a289..fb8efa8ef13 100644 --- a/crates/rome_js_formatter/src/utils/member_chain/flatten_item.rs +++ b/crates/rome_js_formatter/src/utils/member_chain/flatten_item.rs @@ -6,7 +6,6 @@ use rome_js_syntax::{ }; use rome_rowan::{AstNode, SyntaxResult}; use std::fmt::Debug; -use std::slice; #[derive(Clone)] /// Data structure that holds the node with its formatted version @@ -35,15 +34,6 @@ impl FlattenItem { } } - pub(crate) fn as_format_elements(&self) -> &[FormatElement] { - match self { - FlattenItem::StaticMember(_, elements) => elements, - FlattenItem::CallExpression(_, elements) => elements, - FlattenItem::ComputedExpression(_, elements) => elements, - FlattenItem::Node(_, element) => slice::from_ref(element), - } - } - pub(crate) fn as_syntax(&self) -> &JsSyntaxNode { match self { FlattenItem::StaticMember(node, _) => node.syntax(), @@ -53,15 +43,6 @@ impl FlattenItem { } } - pub(crate) fn has_leading_comments(&self) -> bool { - match self { - FlattenItem::StaticMember(node, _) => node.syntax().has_leading_comments(), - FlattenItem::CallExpression(node, _) => node.syntax().has_leading_comments(), - FlattenItem::ComputedExpression(node, _) => node.syntax().has_leading_comments(), - FlattenItem::Node(node, _) => node.has_leading_comments(), - } - } - pub(crate) fn has_trailing_comments(&self) -> bool { match self { FlattenItem::StaticMember(node, _) => node.syntax().has_trailing_comments(), diff --git a/crates/rome_js_formatter/src/utils/member_chain/groups.rs b/crates/rome_js_formatter/src/utils/member_chain/groups.rs index a0a5e2686ad..9fc6a3dd0d5 100644 --- a/crates/rome_js_formatter/src/utils/member_chain/groups.rs +++ b/crates/rome_js_formatter/src/utils/member_chain/groups.rs @@ -2,7 +2,7 @@ use crate::prelude::*; use crate::utils::member_chain::flatten_item::FlattenItem; use crate::utils::member_chain::simple_argument::SimpleArgument; -use rome_js_syntax::{JsAnyCallArgument, JsAnyExpression, JsCallExpression}; +use rome_js_syntax::JsCallExpression; use rome_rowan::{AstSeparatedList, SyntaxResult}; use std::mem; @@ -78,48 +78,19 @@ impl<'f> Groups<'f> { } /// It tells if the groups should be break on multiple lines - pub fn groups_should_break( - &self, - calls_count: usize, - head_group: &HeadGroup, - ) -> SyntaxResult { + pub fn groups_should_break(&self, calls_count: usize) -> SyntaxResult { // Do not allow the group to break if it only contains a single call expression if calls_count <= 1 { return Ok(false); } - let node_has_comments = self.has_comments() || head_group.has_comments(); // we want to check the simplicity of the call expressions only if we have at least // two of them // Check prettier: https://github.com/prettier/prettier/blob/main/src/language-js/print/member-chain.js#L389 - let call_expressions_are_not_simple = if calls_count > 2 { - self.call_expressions_are_not_simple()? - } else { - false - }; - let last_group_will_break_and_other_calls_have_function_arguments = - self.last_group_will_break_and_other_calls_have_function_arguments()?; - - // This emulates a simplified version of the similar logic found in the - // printer to force groups to break if they contain any "hard line - // break" (these not only include hard_line_break elements but also - // empty_line or tokens containing the "\n" character): The idea is - // that since any of these will force the group to break when it gets - // printed, the formatter needs to emit a group element for the call - // chain in the first place or it will not be printed correctly - let has_line_breaks = self - .groups - .iter() - .flat_map(|group| group.iter()) - .flat_map(|item| item.as_format_elements()) - .any(|element| element.will_break()); - - let should_break = has_line_breaks - || node_has_comments - || call_expressions_are_not_simple - || last_group_will_break_and_other_calls_have_function_arguments; + let call_expressions_are_not_simple = + calls_count > 2 && self.call_expressions_are_not_simple()?; - Ok(should_break) + Ok(call_expressions_are_not_simple) } fn into_formatted_groups(self) -> Vec { @@ -132,53 +103,16 @@ impl<'f> Groups<'f> { /// Format groups on multiple lines pub fn into_joined_hard_line_groups(self) -> FormatElement { let formatted_groups = self.into_formatted_groups(); - join_elements(hard_line_break(), formatted_groups) + concat_elements(formatted_groups) } /// Creates two different versions of the formatted groups, one that goes in one line /// and the other one that goes on multiple lines. /// /// It's up to the printer to decide which one to use. - pub fn into_format_elements(self) -> (FormatElement, FormatElement) { + pub fn into_format_elements(self) -> FormatElement { let formatted_groups = self.into_formatted_groups(); - ( - concat_elements(formatted_groups.clone()), - join_elements(soft_line_break(), formatted_groups), - ) - } - - /// Checks if the groups contain comments. - pub fn has_comments(&self) -> bool { - let has_leading_comments = if self.groups.len() > 1 { - // SAFETY: access guarded by the previous check - self.groups - .iter() - .flat_map(|item| item.iter()) - .skip(1) - .any(|item| item.has_leading_comments()) - } else { - false - }; - let has_trailing_comments = self - .groups - .iter() - .flat_map(|item| item.iter()) - .any(|item| item.has_trailing_comments()); - - // This check might not be needed... trying to understand why Prettier has it - let cutoff_has_leading_comments = if self.groups.len() >= self.cutoff as usize { - self.groups - .get(self.cutoff as usize) - .map_or(false, |group| { - group - .first() - .map_or(false, |group| group.has_leading_comments()) - }) - } else { - false - }; - - has_leading_comments || has_trailing_comments || cutoff_has_leading_comments + concat_elements(formatted_groups.clone()) } /// Filters the stack of [FlattenItem] and return only the ones that @@ -210,48 +144,6 @@ impl<'f> Groups<'f> { })) } - /// Checks if the last group will break - by emulating the behaviour of the printer, - /// or if there's a call expression that contain a function/arrow function as argument - pub fn last_group_will_break_and_other_calls_have_function_arguments( - &self, - ) -> SyntaxResult { - let last_group = self.groups.iter().flat_map(|group| group.iter()).last(); - - if let Some(last_group) = last_group { - let element = last_group.as_format_elements().last(); - let group_will_break = element.map_or(false, |element| element.will_break()); - - let is_call_expression = last_group.is_loose_call_expression(); - - Ok(group_will_break - && is_call_expression - && self.call_expressions_have_function_or_arrow_func_as_argument()?) - } else { - Ok(false) - } - } - - /// Checks if any of the call expressions contains arguments that are functions or arrow - /// functions. - pub fn call_expressions_have_function_or_arrow_func_as_argument(&self) -> SyntaxResult { - for call_expression in self.get_call_expressions() { - let arguments = call_expression.arguments()?; - for argument in arguments.args() { - if matches!( - argument?, - JsAnyCallArgument::JsAnyExpression(JsAnyExpression::JsFunctionExpression(_)) - | JsAnyCallArgument::JsAnyExpression( - JsAnyExpression::JsArrowFunctionExpression(_) - ) - ) { - return Ok(true); - } - } - } - - Ok(false) - } - /// This is an heuristic needed to check when the first element of the group /// Should be part of the "head" or the "tail". fn should_not_wrap(&self, first_group: &HeadGroup) -> SyntaxResult { @@ -332,8 +224,4 @@ impl HeadGroup { pub fn expand_group(&mut self, group: Vec) { self.items.extend(group) } - - fn has_comments(&self) -> bool { - self.items.iter().any(|item| item.has_trailing_comments()) - } } diff --git a/crates/rome_js_formatter/src/utils/member_chain/mod.rs b/crates/rome_js_formatter/src/utils/member_chain/mod.rs index efa2cab3845..fd5dfc15992 100644 --- a/crates/rome_js_formatter/src/utils/member_chain/mod.rs +++ b/crates/rome_js_formatter/src/utils/member_chain/mod.rs @@ -289,7 +289,8 @@ fn format_groups( head_group: HeadGroup, groups: Groups, ) -> FormatResult { - if groups.groups_should_break(calls_count, &head_group)? { + // TODO use Alternatives once available + if groups.groups_should_break(calls_count)? { Ok(format_elements![ head_group.into_format_element(), group_elements(indent(format_elements![ @@ -298,13 +299,17 @@ fn format_groups( ]),) ]) } else { - let head_formatted = head_group.into_format_element(); - let (one_line, _) = groups.into_format_elements(); - - // TODO: this is not the definitive solution, as there are few restrictions due to how the printer works: - // - groups that contains other groups with hard lines break all the groups - // - conditionally print one single line is subject to how the printer works (by default, multiline) - Ok(format_elements![head_formatted, one_line]) + Ok(format_elements![ + head_group.into_format_element(), + groups.into_format_elements() + ]) + // Ok(format_elements![ + // head_group.into_format_element(), + // group_elements(indent(format_elements![ + // soft_line_break(), + // groups.into_format_elements() + // ])) + // ]) } } diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap index 30362b72a9e..020073719c7 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/spec_test.rs -assertion_line: 242 expression: complex_arguments.js - --- # Input client.execute( @@ -21,7 +19,6 @@ Quote style: Double Quotes ----- client.execute( Post.selectAll() - .where(Post.id.eq(42)) - .where(Post.published.eq(true)), + .where(Post.id.eq(42)).where(Post.published.eq(true)), ); diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap index 2fd938c1979..d0e5ec5ca63 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/spec_test.rs -assertion_line: 242 expression: computed.js --- # Input @@ -19,6 +18,13 @@ Line width: 80 Quote style: Double Quotes ----- nock(/test/) - .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo") - .reply(200, { foo: "bar" }); + .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( + 200, + { foo: "bar" }, + ); + + +## Lines exceeding width of 80 characters + + 2: .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/inline-merge.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/inline-merge.js.snap index 81a71e12494..2122afb5898 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/inline-merge.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/inline-merge.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/spec_test.rs -assertion_line: 242 expression: inline-merge.js - --- # Input _.flatMap(this.visibilityHandlers, fn => fn()) @@ -27,13 +25,11 @@ Line width: 80 Quote style: Double Quotes ----- _.flatMap(this.visibilityHandlers, (fn) => fn()) - .concat(this.record.resolved_legacy_visrules) - .filter(Boolean); + .concat(this.record.resolved_legacy_visrules).filter(Boolean); -Object.keys(availableLocales({ test: true })) - .forEach( - (locale) => { - // ... - }, - ); +Object.keys(availableLocales({ test: true })).forEach( + (locale) => { + // ... + }, +); 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 e5fb4d0297f..c2a2c41c64b 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,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: holes-in-args.js --- # Input @@ -15,9 +14,7 @@ new Test() # Output ```js new Test() - .test() - .test([, 0]) - .test(); + .test().test([, 0]).test(); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap index fd6b29217af..28c75953554 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: inline-await.js - --- # Input ```js @@ -18,10 +16,11 @@ async function f() { const admins = ( await ( db - .select("*") - .from("admins") - .leftJoin("bla") - .where("id", "in", [1, 2, 3, 4]) + .select("*").from("admins").leftJoin("bla").where( + "id", + "in", + [1, 2, 3, 4], + ) ) ).map(({ id, name }) => ({ id, name })); } diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap index b99738cd6ac..940d4071bdd 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: arrow.js - --- # Input ```js diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/comments/dangling_array.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/comments/dangling_array.js.snap index 1657309d6a3..1c1b80126f0 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/comments/dangling_array.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/comments/dangling_array.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: dangling_array.js - --- # Input ```js @@ -16,10 +14,9 @@ expect(() => {}).toTriggerReadyStateChanges([ # Output ```js -expect(() => {}) - .toTriggerReadyStateChanges([ - // Nothing. - ]); +expect(() => {}).toTriggerReadyStateChanges([ + // Nothing. +]); [1 /* first comment */ , 2 /* second comment */ , 3]; diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap index 85f0eeef83e..9565ba49c87 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: issues.js --- # Input @@ -121,8 +120,9 @@ Observable.of(process) // Don't complete until we say so! .merge(Observable.never()) // Get the errors. - .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors) - .takeUntil(exit); + .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors).takeUntil( + exit, + ); // Comments disappear inside of JSX
@@ -160,5 +160,6 @@ foo( # Lines exceeding max width of 80 characters ``` 34: import path from "path"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri + 41: .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors).takeUntil( ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/function-first-param/function_expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/function-first-param/function_expression.js.snap index e9259c68d8c..6ad920c652f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/function-first-param/function_expression.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/function-first-param/function_expression.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: function_expression.js --- # Input @@ -35,29 +34,25 @@ db.collection('indexOptionDefault').createIndex({ a: 1 }, { # Output ```js //https://github.com/prettier/prettier/issues/3002 -beep - .boop() - .baz( - "foo", - { some: { thing: { nested: true } } }, - { another: { thing: true } }, - () => {}, - ); +beep.boop().baz( + "foo", + { some: { thing: { nested: true } } }, + { another: { thing: true } }, + () => {}, +); //https://github.com/prettier/prettier/issues/2984 -db - .collection("indexOptionDefault") - .createIndex( - { a: 1 }, - { indexOptionDefaults: true, w: 2, wtimeout: 1000 }, - function (err) { - test.equal(null, err); - test.deepEqual({ w: 2, wtimeout: 1000 }, commandResult.writeConcern); - - client.close(); - done(); - }, - ); +db.collection("indexOptionDefault").createIndex( + { a: 1 }, + { indexOptionDefaults: true, w: 2, wtimeout: 1000 }, + function (err) { + test.equal(null, err); + test.deepEqual({ w: 2, wtimeout: 1000 }, commandResult.writeConcern); + + client.close(); + done(); + }, +); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap index 2810d31e39d..9b8410a60eb 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: pipe-function-calls-with-comments.js - --- # Input ```js @@ -82,8 +80,7 @@ expression: pipe-function-calls-with-comments.js ), ), )() - .then(messageResponse(logger, msg)) - .catch((err) => { + .then(messageResponse(logger, msg)).catch((err) => { logger.error( pipe( // add a descriptive comment here diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap index b980f7f1080..2a6142f1a8d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: pipe-function-calls.js - --- # Input ```js @@ -59,8 +57,7 @@ expression: pipe-function-calls.js serviceEventFromMessage(msg), TE.chain(flow(publishServiceEvent(analytics), TE.mapLeft(nackFromError))), )() - .then(messageResponse(logger, msg)) - .catch((err) => { + .then(messageResponse(logger, msg)).catch((err) => { logger.error( pipe(O.fromNullable(err.stack), O.getOrElse(constant(err.message))), ); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap index f79b43465fa..d9419294cc1 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: arrow.js --- # Input @@ -27,22 +26,20 @@ export default function searchUsers(action$) { ```js export default function searchUsers(action$) { return action$ - .ofType(ActionTypes.SEARCHED_USERS) - .map((action) => action.payload.query) - .filter((q) => !!q) - .switchMap( + .ofType(ActionTypes.SEARCHED_USERS).map((action) => action.payload.query).filter( + (q) => !!q, + ).switchMap( (q) => Observable.timer(800) // debounce - .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)) - .mergeMap( + .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)).mergeMap( () => Observable.merge( Observable.of(replace(`?q=${q}`)), ajax - .getJSON(`https://api.github.com/search/users?q=${q}`) - .map((res) => res.items) - .map(receiveUsers), + .getJSON(`https://api.github.com/search/users?q=${q}`).map( + (res) => res.items, + ).map(receiveUsers), ), ), ); @@ -50,4 +47,9 @@ export default function searchUsers(action$) { ``` +# Lines exceeding max width of 80 characters +``` + 3: .ofType(ActionTypes.SEARCHED_USERS).map((action) => action.payload.query).filter( + 9: .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)).mergeMap( +``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap index 52e624be039..5d28ccd4875 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: expand.js --- # Input @@ -52,9 +51,7 @@ const small = doc.expandedStates[doc.expandedStates.length - 1]; const promises = [ promise - .resolve() - .then(console.log) - .catch( + .resolve().then(console.log).catch( (err) => { console.log(err); return null; @@ -66,11 +63,7 @@ const promises = [ const promises2 = [ promise - .resolve() - .veryLongFunctionCall() - .veryLongFunctionCall() - .then(console.log) - .catch( + .resolve().veryLongFunctionCall().veryLongFunctionCall().then(console.log).catch( (err) => { console.log(err); return null; @@ -97,4 +90,8 @@ window.FooClient.something.setVars({ ``` +# Lines exceeding max width of 80 characters +``` + 20: .resolve().veryLongFunctionCall().veryLongFunctionCall().then(console.log).catch( +``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/comment.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/comment.js.snap index 62234c37495..5b85bcccc2e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/comment.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/comment.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: comment.js --- # Input @@ -65,75 +64,66 @@ angular.module('AngularAppModule') ```js function f() { return observableFromSubscribeFunction() - // Debounce manually rather than using editor.onDidStopChanging so that the debounce time is - // configurable. - .debounceTime(debounceInterval); + // Debounce manually rather than using editor.onDidStopChanging so that the debounce time is + // configurable. + .debounceTime(debounceInterval); } _.a(a) - /* very very very very very very very long such that it is longer than 80 columns */ - .a(); +/* very very very very very very very long such that it is longer than 80 columns */ +.a(); -_.a(a) - /* very very very very very very very long such that it is longer than 80 columns */ - .a(); +_.a(a).a(); /* very very very very very very very long such that it is longer than 80 columns */ -_.a(a) - /* very very very very very very very long such that it is longer than 80 columns */ - .a(); +_.a(a).a(); /* very very very very very very very long such that it is longer than 80 columns */ Something // $FlowFixMe(>=0.41.0) .getInstance(this.props.dao).getters(); // Warm-up first -measure() - .then(() => { - SomethingLong(); - }); +measure().then(() => { + SomethingLong(); +}); -measure() +measure().then(() => { // Warm-up first - .then(() => { - SomethingLong(); - }); + SomethingLong(); +}); -const configModel = this.baseConfigurationService - .getCache() - .consolidated // global/default values (do NOT modify) - .merge(this.cachedWorkspaceConfig); +const configModel = this.baseConfigurationService.getCache().consolidated.merge( + // global/default values (do NOT modify) + this.cachedWorkspaceConfig, +); -this.doWriteConfiguration(target, value, options) +this.doWriteConfiguration(target, value, options).then( // queue up writes to prevent race conditions - .then( - () => null, - (error) => { - return options.donotNotifyError ? TPromise.wrapError(error) : this.onError( - error, - target, - value, - ); - }, - ); + () => null, + (error) => { + return options.donotNotifyError ? TPromise.wrapError(error) : this.onError( + error, + target, + value, + ); + }, +); ret = __DEV__ ? // $FlowFixMe: this type differs according to the env vm.runInContext(source, ctx) : a; -angular - .module("AngularAppModule") - // Hello, I am comment. - .constant("API_URL", "http://localhost:8080/api"); +angular.module("AngularAppModule") +// Hello, I am comment. +.constant("API_URL", "http://localhost:8080/api"); ``` # Lines exceeding max width of 80 characters ``` - 3: // Debounce manually rather than using editor.onDidStopChanging so that the debounce time is - 9: /* very very very very very very very long such that it is longer than 80 columns */ - 13: /* very very very very very very very long such that it is longer than 80 columns */ - 17: /* very very very very very very very long such that it is longer than 80 columns */ - 46: return options.donotNotifyError ? TPromise.wrapError(error) : this.onError( + 3: // Debounce manually rather than using editor.onDidStopChanging so that the debounce time is + 9: /* very very very very very very very long such that it is longer than 80 columns */ + 12: _.a(a).a(); /* very very very very very very very long such that it is longer than 80 columns */ + 14: _.a(a).a(); /* very very very very very very very long such that it is longer than 80 columns */ ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap index d19825df947..58ef7ae7345 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: complex-args.js --- # Input @@ -17,8 +16,7 @@ client.execute( ```js client.execute( Post.selectAll() - .where(Post.id.eq(42)) - .where(Post.published.eq(true)), + .where(Post.id.eq(42)).where(Post.published.eq(true)), ); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap index 59d204d4e0d..bd67cfa7a71 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: computed-merge.js --- # Input @@ -29,22 +28,19 @@ window.Data[key]("foo") [].forEach( (key) => { data[key]("foo") - .then(() => console.log("bar")) - .catch(() => console.log("baz")); + .then(() => console.log("bar")).catch(() => console.log("baz")); }, ); [].forEach( (key) => { data("foo")[key]("bar") - .then(() => console.log("bar")) - .catch(() => console.log("baz")); + .then(() => console.log("bar")).catch(() => console.log("baz")); }, ); window.Data[key]("foo") - .then(() => a) - .catch(() => b); + .then(() => a).catch(() => b); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap index 8d45c1dd655..b1afabedf9b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: computed.js --- # Input @@ -17,9 +16,15 @@ nock(/test/) # Output ```js nock(/test/) - .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo") - .reply(200, { foo: "bar" }); + .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( + 200, + { foo: "bar" }, + ); ``` +# Lines exceeding max width of 80 characters +``` + 2: .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( +``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap index 15265fbc9a4..d30d2184fcc 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: d3.js --- # Input @@ -28,26 +27,20 @@ not.d3.scaleLinear() # Output ```js d3 - .select("body") - .append("circle") - .at({ width: 30, fill: "#f0f" }) - .st({ fontWeight: 600 }); + .select("body").append("circle").at({ width: 30, fill: "#f0f" }).st({ + fontWeight: 600, + }); const myScale = d3 - .scaleLinear() - .domain([1950, 1980]) - .range([0, width]); + .scaleLinear().domain([1950, 1980]).range([0, width]); not.d3 - .select("body") - .append("circle") - .at({ width: 30, fill: "#f0f" }) - .st({ fontWeight: 600 }); + .select("body").append("circle").at({ width: 30, fill: "#f0f" }).st({ + fontWeight: 600, + }); not.d3 - .scaleLinear() - .domain([1950, 1980]) - .range([0, width]); + .scaleLinear().domain([1950, 1980]).range([0, width]); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/first_long.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/first_long.js.snap index 5625bf415cf..1f795ead7bb 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/first_long.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/first_long.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: first_long.js --- # Input @@ -45,19 +44,17 @@ function f() { # Output ```js export default function theFunction(action$, store) { - return action$ - .ofType(THE_ACTION) - .switchMap( - (action) => - Observable.webSocket({ - url: THE_URL, - more: stuff(), - evenMore: stuff({ value1: true, value2: false, value3: false }), - }) - .filter((data) => theFilter(data)) - .map(({ theType, ...data }) => theMap(theType, data)) - .retryWhen((errors) => errors), - ); + return action$.ofType(THE_ACTION).switchMap( + (action) => + Observable.webSocket({ + url: THE_URL, + more: stuff(), + evenMore: stuff({ value1: true, value2: false, value3: false }), + }) + .filter((data) => theFilter(data)).map( + ({ theType, ...data }) => theMap(theType, data), + ).retryWhen((errors) => errors), + ); } function f() { diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/inline_merge.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/inline_merge.js.snap index 23ad1228f2f..de56418e0c0 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/inline_merge.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/inline_merge.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: inline_merge.js --- # Input @@ -28,18 +27,16 @@ var jqxhr = $.ajax("example.php") # Output ```js -Object.keys(availableLocales({ test: true })) - .forEach( - (locale) => { - // ... - }, - ); +Object.keys(availableLocales({ test: true })).forEach( + (locale) => { + // ... + }, +); this.layoutPartsToHide = this.utils.hashset( _.flatMap(this.visibilityHandlers, (fn) => fn()) - .concat(this.record.resolved_legacy_visrules) - .filter(Boolean), + .concat(this.record.resolved_legacy_visrules).filter(Boolean), ); var jqxhr = $.ajax("example.php").done(doneFn).fail(failFn); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap index b9e214d0de5..588cd2a2019 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: issue-3594.js --- # Input @@ -24,8 +23,7 @@ fetched.then((response) => response.json()).then( ); let column = new Column(null, conn) - .table(data.table) - .json(data.column); + .table(data.table).json(data.column); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-4125.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-4125.js.snap index 918380246ec..9641ca86d05 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-4125.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-4125.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: issue-4125.js --- # Input @@ -174,17 +173,11 @@ const z = obj.foo(-1).foo(import("2")).foo(!x).check(/[A-Z]/); // better on multiple lines: somePromise - .then(format) - .then((val) => doSomething(val)) - .catch((err) => handleError(err)); + .then(format).then((val) => doSomething(val)).catch((err) => handleError(err)); // you can still force multi-line chaining with a comment: const sha256_2 = (data) => - crypto - // breakme - .createHash("sha256") - .update(data) - .digest("hex"); + crypto.createHash("sha256").update(data).digest("hex"); // breakme // examples from https://github.com/prettier/prettier/pull/4765 @@ -207,15 +200,10 @@ function palindrome(a, b) { // examples from https://github.com/prettier/prettier/issues/1565 d3 - .select("body") - .selectAll("p") - .data([1, 2, 3]) - .enter() - .style("color", "white"); + .select("body").selectAll("p").data([1, 2, 3]).enter().style("color", "white"); Object.keys(props) - .filter((key) => (key in own) === false) - .reduce( + .filter((key) => (key in own) === false).reduce( (a, key) => { a[key] = props[key]; return a; @@ -228,15 +216,12 @@ point().x(4).y(3).z(6).plot(); assert.equal(this.$().text().trim(), "1000"); something() - .then(() => doSomethingElse()) - .then((result) => dontForgetThisAsWell(result)); + .then(() => doSomethingElse()).then((result) => dontForgetThisAsWell(result)); db.branch( db.table("users").filter({ email }).count(), db - .table("users") - .filter({ email: "a@b.com" }) - .count(), + .table("users").filter({ email: "a@b.com" }).count(), db.table("users").insert({ email }), db.table("users").filter({ email }), ); @@ -247,10 +232,7 @@ const date = moment.utc(userInput).hour(0).minute(0).second(0); fetchUser(id).then(fetchAccountForUser).catch(handleFetchError); -fetchUser(id) - // - .then(fetchAccountForUser) - .catch(handleFetchError); +fetchUser(id).then(fetchAccountForUser).catch(handleFetchError); // // examples from https://github.com/prettier/prettier/issues/3107 @@ -260,37 +242,33 @@ function HelloWorld() { authorizationToken: data.token, }).initVerify("foo_container"); - fejax - .ajax({ url: "/verification/", dataType: "json" }) - .then( - (data) => { - this.setState({ isLoading: false }); - this.initWidget(data); - }, - (data) => { - this.logImpression("foo_fetch_error", data); - Flash.error(I18n.t("offline_identity.foo_issue")); - }, - ); + fejax.ajax({ url: "/verification/", dataType: "json" }).then( + (data) => { + this.setState({ isLoading: false }); + this.initWidget(data); + }, + (data) => { + this.logImpression("foo_fetch_error", data); + Flash.error(I18n.t("offline_identity.foo_issue")); + }, + ); } action$ - .ofType(ActionTypes.SEARCHED_USERS) - .map((action) => action.payload.query) - .filter((q) => !!q) - .switchMap( + .ofType(ActionTypes.SEARCHED_USERS).map((action) => action.payload.query).filter( + (q) => !!q, + ).switchMap( (q) => Observable.timer(800) // debounce - .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)) - .mergeMap( + .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)).mergeMap( () => Observable.merge( Observable.of(replace(`?q=${q}`)), ajax - .getJSON(`https://api.github.com/search/users?q=${q}`) - .map((res) => res.items) - .map(receiveUsers), + .getJSON(`https://api.github.com/search/users?q=${q}`).map( + (res) => res.items, + ).map(receiveUsers), ), ), ); @@ -312,41 +290,33 @@ const a1 = x.a(true).b(null).c(123); const a2 = x.d("").e(``).f(g); const a3 = x.d("").e(`${123}`).f(g); const a4 = x - .h(i.j) - .k(l()) - .m([n, o]); + .h(i.j).k(l()).m([n, o]); class X { y() { const j = x - .a(this) - .b(super.cde()) - .f(/g/) - .h(new i()) - .j(); + .a(this).b(super.cde()).f(/g/).h(new i()).j(); } } // should break when call expressions get complex x - .a() - .b([c, [d, [e]]]) - .f(); + .a().b([c, [d, [e]]]).f(); x - .a() - .b(c(d(e()))) - .f(); + .a().b(c(d(e()))).f(); x - .a() - .b(`${c(d())}`) - .f(); + .a().b(`${c(d())}`).f(); xyz - .a() - .b() - .c(a(a(b(c(d().p).p).p).p)); + .a().b().c(a(a(b(c(d().p).p).p).p)); var l = base.replace(/^\w*:\/\//, "").replace(/\/$/, "").split("/").length; ``` +# Lines exceeding max width of 80 characters +``` + 16: .then(format).then((val) => doSomething(val)).catch((err) => handleError(err)); + 43: .select("body").selectAll("p").data([1, 2, 3]).enter().style("color", "white"); + 98: .ofType(ActionTypes.SEARCHED_USERS).map((action) => action.payload.query).filter( +``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/multiple-members.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/multiple-members.js.snap index 034bcbb8dd4..21bc23aba08 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/multiple-members.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/multiple-members.js.snap @@ -51,8 +51,7 @@ if (testConfig.ENABLE_ONLINE_TESTS === "true") { function () { function assert(pet) { expect(pet).to.have - .property("OwnerAddress") - .that.deep.equals({ + .property("OwnerAddress").that.deep.equals({ AddressLine1: "Alexanderstrasse", AddressLine2: "", PostalCode: "10999", @@ -68,39 +67,36 @@ if (testConfig.ENABLE_ONLINE_TESTS === "true") { } wrapper - .find("SomewhatLongNodeName") - .prop("longPropFunctionName")() - .then(function () { + .find("SomewhatLongNodeName").prop("longPropFunctionName")().then(function () { doSomething(); }); wrapper - .find("SomewhatLongNodeName") - .prop("longPropFunctionName")("argument") - .then(function () { + .find("SomewhatLongNodeName").prop("longPropFunctionName")("argument").then(function () { doSomething(); }); wrapper - .find("SomewhatLongNodeName") - .prop( + .find("SomewhatLongNodeName").prop( "longPropFunctionName", "second argument that pushes this group past 80 characters", - )("argument") - .then(function () { + )("argument").then(function () { doSomething(); }); wrapper - .find("SomewhatLongNodeName") - .prop("longPropFunctionName")( + .find("SomewhatLongNodeName").prop("longPropFunctionName")( "argument", "second argument that pushes this group past 80 characters", - ) - .then(function () { + ).then(function () { doSomething(); }); ``` +# Lines exceeding max width of 80 characters +``` + 26: .find("SomewhatLongNodeName").prop("longPropFunctionName")().then(function () { + 31: .find("SomewhatLongNodeName").prop("longPropFunctionName")("argument").then(function () { +``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap index 3eaaa949dc5..6fdc5e113b8 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: object-literal.js - --- # Input ```js @@ -27,16 +25,14 @@ of("test") # Output ```js of("test") - .pipe(throwIfEmpty()) - .subscribe({ + .pipe(throwIfEmpty()).subscribe({ error(err) { thrown = err; }, }); of("test") - .pipe(throwIfEmpty()) - .subscribe({ + .pipe(throwIfEmpty()).subscribe({ get foo() { bar(); }, diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/pr-7889.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/pr-7889.js.snap index a900f541656..e92ca33466d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/pr-7889.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/pr-7889.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 149 expression: pr-7889.js - --- # Input ```js @@ -22,25 +20,21 @@ const Profile2 = view.with({ name }).as((props) => ( # Output ```js -const Profile = view - .with({ name: (state) => state.name }) - .as( - (props) => ( -
+const Profile = view.with({ name: (state) => state.name }).as( + (props) => ( +

Hello, {props.name}

- ), - ); + ), +); -const Profile2 = view - .with({ name }) - .as( - (props) => ( -
+const Profile2 = view.with({ name }).as( + (props) => ( +

Hello, {props.name}

- ), - ); + ), +); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap index 814c1742099..23ea3b20f12 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: short-names.js --- # Input @@ -15,9 +14,9 @@ const svgJsFiles = fs # Output ```js const svgJsFiles = fs - .readdirSync(svgDir) - .filter((f) => svgJsFileExtRegex.test(f)) - .map((f) => path.join(svgDir, f)); + .readdirSync(svgDir).filter((f) => svgJsFileExtRegex.test(f)).map( + (f) => path.join(svgDir, f), + ); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap index aa88a1e4bcf..34d6435ecff 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: square_0.js --- # Input @@ -22,8 +21,7 @@ const component = find('.org-lclp-edit-copy-url-banner__link')[0] const version = someLongString.split("jest version =").pop().split(EOL)[0].trim(); const component = find(".org-lclp-edit-copy-url-banner__link")[0] - .getAttribute("href") - .indexOf(this.landingPageLink); + .getAttribute("href").indexOf(this.landingPageLink); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/comments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/comments.js.snap index 4edf457e54f..fd64e9c398e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/comments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/comments.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: comments.js - --- # Input ```js @@ -58,40 +56,36 @@ foo.bar.baz # Output ```js function foo() { - return a - .b() - .c() - // Comment - ?.d(); + return a.b().c() + // Comment + ?.d(); } fooBar - .doSomething("Hello World") - .doAnotherThing("Foo", { foo: bar }) + .doSomething("Hello World").doAnotherThing("Foo", { foo: bar }) // App configuration. - .doOneMoreThing(config) - ?.run(() => console.log("Bar")); + .doOneMoreThing(config)?.run(() => console.log("Bar")); bigDeal .doSomething("Hello World") // Hello world ?.doAnotherThing("Foo", { foo: bar }) // App configuration. - .doOneMoreThing(config) - ?.run(() => console.log("Bar")); + .doOneMoreThing(config)?.run(() => console.log("Bar")); foo.bar.baz ?.doSomething("Hello World") // Hello world - .foo.bar.doAnotherThing("Foo", { foo: bar }) - .doOneMoreThing(config) - ?.bar.run(() => console.log("Bar")); + .foo.bar.doAnotherThing("Foo", { foo: bar }).doOneMoreThing(config)?.bar.run( + () => console.log("Bar"), + ); (somethingGood ? thisIsIt : maybeNot) // Hello world - .doSomething("Hello World") - ?.doAnotherThing("Foo", { foo: bar }) // Run this - .run(() => console.log("Bar")); // Do this + .doSomething("Hello World")?.doAnotherThing("Foo", { foo: bar }).run( + // Run this + () => console.log("Bar"), + ); // Do this ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/performance/nested.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/performance/nested.js.snap index 2ad3c13d4ea..4d3d3cd62ea 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/performance/nested.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/performance/nested.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: nested.js - --- # Input ```js @@ -40,63 +38,35 @@ someObject.someFunction().then(function() { # Output ```js -someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - return someObject - .someFunction() - .then(function () { - anotherFunction(); - }); - }); - }); - }); - }); - }); - }); +someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + return someObject.someFunction().then(function () { + anotherFunction(); }); + }); }); + }); }); + }); }); + }); }); + }); }); + }); }); +}); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/preserve-line/member-chain.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/preserve-line/member-chain.js.snap index 350c8890a25..e9daab7f2a7 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/preserve-line/member-chain.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/preserve-line/member-chain.js.snap @@ -69,32 +69,30 @@ const sel = this.connections # Output ```js fooBar - .doSomething("Hello World") - .doAnotherThing("Foo", { foo: bar }) + .doSomething("Hello World").doAnotherThing("Foo", { foo: bar }) // App configuration. - .doOneMoreThing(config) - .run(() => console.log("Bar")); + .doOneMoreThing(config).run(() => console.log("Bar")); bigDeal .doSomething("Hello World") // Hello world .doAnotherThing("Foo", { foo: bar }) // App configuration. - .doOneMoreThing(config) - .run(() => console.log("Bar")); + .doOneMoreThing(config).run(() => console.log("Bar")); foo.bar.baz .doSomething("Hello World") // Hello world - .foo.bar.doAnotherThing("Foo", { foo: bar }) - .doOneMoreThing(config) - .bar.run(() => console.log("Bar")); + .foo.bar.doAnotherThing("Foo", { foo: bar }).doOneMoreThing(config).bar.run( + () => console.log("Bar"), + ); (somethingGood ? thisIsIt : maybeNot) // Hello world - .doSomething("Hello World") - .doAnotherThing("Foo", { foo: bar }) // Run this - .run(() => console.log("Bar")); // Do this + .doSomething("Hello World").doAnotherThing("Foo", { foo: bar }).run( + // Run this + () => console.log("Bar"), + ); // Do this helloWorld.text().then((t) => t); @@ -114,6 +112,6 @@ const sel = this.connections.concat(this.activities.concat(this.operators)).filt # Lines exceeding max width of 80 characters ``` - 39: const sel = this.connections.concat(this.activities.concat(this.operators)).filter( + 37: const sel = this.connections.concat(this.activities.concat(this.operators)).filter( ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap index e16141f9998..5e617d77378 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: expressions.js --- # Input @@ -92,8 +91,9 @@ function testing() { return `${process.env.OPENID_URL}/something/something/something?${Object.keys( p, ) - .map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(p[k])}`) - .join("&")}`; + .map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(p[k])}`).join( + "&", + )}`; } } } @@ -137,8 +137,9 @@ throw new Error( 14: const shouldNotWrap = `simple expressions should not break ${this} ${variable} ${a.b.c} ${this.b.c} ${a[ 20: `Covered Lines below threshold: ${coverageSettings.lines}%. Actual: ${coverageSummary.total.lines.pct}%`, 34: return `${process.env.OPENID_URL}/something/something/something?${Object.keys( - 44: `Trying update appcast for ${app.name} (${app.cask.appcast}) -> (${app.cask.appcastGenerated})`, - 52: `\nApparently jetbrains changed the release artifact for ${app.name}@${app.jetbrains.version}.\n`, - 66: `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`, + 37: .map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(p[k])}`).join( + 45: `Trying update appcast for ${app.name} (${app.cask.appcast}) -> (${app.cask.appcastGenerated})`, + 53: `\nApparently jetbrains changed the release artifact for ${app.name}@${app.jetbrains.version}.\n`, + 67: `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`, ``` 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 1ad1c5b6f4d..25e5e03d293 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,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: jest-each.js --- # Input @@ -125,35 +124,30 @@ ${2} | ${1} | ${3}`; // an example to demo multiline quasi describe.each`a | b | expected ${11111111111} | ${a() - .b((x) => x) - .c() - .d()} | ${2} + .b((x) => x).c().d()} | ${2} ${1} | ${2} | ${3} ${2} | ${1} | ${3}`; -describe - .each([1, 2, 3])( - "test", - (a) => { - expect(a).toBe(a); - }, - ); - -test.only - .each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( - ".add(%i, %i)", - (a, b, expected) => { - expect(a + b).toBe(expected); - }, - ); - -test - .each([{ a: "1", b: 1 }, { a: "2", b: 2 }, { a: "3", b: 3 }])( - "test", - ({ a, b }) => { - expect(Number(a)).toBe(b); - }, - ); +describe.each([1, 2, 3])( + "test", + (a) => { + expect(a).toBe(a); + }, +); + +test.only.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])( + ".add(%i, %i)", + (a, b, expected) => { + expect(a + b).toBe(expected); + }, +); + +test.each([{ a: "1", b: 1 }, { a: "2", b: 2 }, { a: "3", b: 3 }])( + "test", + ({ a, b }) => { + expect(Number(a)).toBe(b); + }, +); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/trailing-comma/function-calls.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/trailing-comma/function-calls.js.snap index 88ae8688468..d3865e7080f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/trailing-comma/function-calls.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/trailing-comma/function-calls.js.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 57 expression: function-calls.js - --- # Input ```js diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/as/assignment2.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/as/assignment2.ts.snap index 5a15dd448c5..919b719fbcc 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/as/assignment2.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/as/assignment2.ts.snap @@ -42,19 +42,17 @@ const defaultMaskGetter = $parse(attrs[directiveName]) as (scope: ng.IScope) => (this.configuration as any) = (this.editor as any) = (this.editorBody as any) = undefined; -angular - .module("foo") - .directive( - "formIsolator", - () => { - return { - name: "form", - controller: class FormIsolatorController { - $addControl = angular.noop; - } as ng.IControllerConstructor, - }; - }, - ); +angular.module("foo").directive( + "formIsolator", + () => { + return { + name: "form", + controller: class FormIsolatorController { + $addControl = angular.noop; + } as ng.IControllerConstructor, + }; + }, +); (this.selectorElem as any) = this.multiselectWidget = this.initialValues = undefined; @@ -77,7 +75,7 @@ const originalPrototype = originalConstructor.prototype as # Lines exceeding max width of 80 characters ``` 1: const defaultMaskGetter = $parse(attrs[directiveName]) as (scope: ng.IScope) => Mask; - 24: (attrs.rendererAttrs && this.utils.safeParseJsonString(attrs.rendererAttrs)) || Object.create( - 29: const annotate = (angular.injector as any).$$annotate as (fn: Function) => string[]; + 22: (attrs.rendererAttrs && this.utils.safeParseJsonString(attrs.rendererAttrs)) || Object.create( + 27: const annotate = (angular.injector as any).$$annotate as (fn: Function) => string[]; ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/custom/typeParameters/variables.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/custom/typeParameters/variables.ts.snap index 17c0ce277ee..c59a36fb514 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/custom/typeParameters/variables.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/custom/typeParameters/variables.ts.snap @@ -44,15 +44,13 @@ const baaaaaaaaaaaaaaar: SomeThing< } > = looooooooooooooooooooooooooooooongNameFunc(); const baaaaaaaaaaaaaaaar: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); -const isAnySuccessfulAttempt$: Observable = this._quizService - .isAnySuccessfulAttempt$() - .pipe( - tap( - (isAnySuccessfulAttempt: boolean) => { - this.isAnySuccessfulAttempt = isAnySuccessfulAttempt; - }, - ), - ); +const isAnySuccessfulAttempt$: Observable = this._quizService.isAnySuccessfulAttempt$().pipe( + tap( + (isAnySuccessfulAttempt: boolean) => { + this.isAnySuccessfulAttempt = isAnySuccessfulAttempt; + }, + ), +); const isAnySuccessfulAttempt2$: Observable = this._someMethodWithLongName(); const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); @@ -67,11 +65,12 @@ const fooooooooooooooo: SomeThing = looooooooooooooooooooooooo 9: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); 10: const baaaaaaaaaaaaaaaaaaaaar: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); 16: const baaaaaaaaaaaaaaaar: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); - 26: const isAnySuccessfulAttempt2$: Observable = this._someMethodWithLongName(); - 27: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); - 28: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); - 29: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); - 30: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); - 31: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); + 17: const isAnySuccessfulAttempt$: Observable = this._quizService.isAnySuccessfulAttempt$().pipe( + 24: const isAnySuccessfulAttempt2$: Observable = this._someMethodWithLongName(); + 25: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); + 26: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); + 27: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); + 28: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); + 29: const fooooooooooooooo: SomeThing = looooooooooooooooooooooooooooooongNameFunc(); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap index b419ca6f9fc..c373f16a603 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: pipe-function-calls-with-comments.ts - --- # Input ```js @@ -82,8 +80,7 @@ expression: pipe-function-calls-with-comments.ts ), ), )() - .then(messageResponse(logger, msg)) - .catch( + .then(messageResponse(logger, msg)).catch( (err: Error) => { logger.error( pipe( diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap index bc9ab598b9d..ca465e654fe 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap @@ -1,8 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 125 expression: pipe-function-calls.ts - --- # Input ```js @@ -38,8 +36,7 @@ expression: pipe-function-calls.ts serviceEventFromMessage(msg), TE.chain(flow(publishServiceEvent(analytics), TE.mapLeft(nackFromError))), )() - .then(messageResponse(logger, msg)) - .catch( + .then(messageResponse(logger, msg)).catch( (err: Error) => { logger.error( pipe(O.fromNullable(err.stack), O.getOrElse(constant(err.message))), diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/method-chain/comment.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/method-chain/comment.ts.snap index f33a3f8c0ba..c8f5a0ecd6b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/method-chain/comment.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/method-chain/comment.ts.snap @@ -18,22 +18,21 @@ this.firebase.object(`/shops/${shopLocation.shop}`) # Output ```js -this.firebase - .object(`/shops/${shopLocation.shop}`) - // keep distance info - .first( - (shop: ShopQueryResult, index: number, source: Observable): any => { - // add distance to result - const s = shop; - s.distance = shopLocation.distance; - return s; - }, - ); +this.firebase.object(`/shops/${shopLocation.shop}`) +// keep distance info +.first( + (shop: ShopQueryResult, index: number, source: Observable): any => { + // add distance to result + const s = shop; + s.distance = shopLocation.distance; + return s; + }, +); ``` # Lines exceeding max width of 80 characters ``` - 5: (shop: ShopQueryResult, index: number, source: Observable): any => { + 4: (shop: ShopQueryResult, index: number, source: Observable): any => { ``` From 1daa97f165f61fa0c6b45d54041c7fb526700277 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 13 May 2022 16:05:26 +0200 Subject: [PATCH 2/4] Undo change in `into_joined_hard_line_groups` --- .../src/utils/member_chain/groups.rs | 4 +- .../src/utils/member_chain/mod.rs | 7 -- .../member-chain/complex_arguments.js.snap | 3 +- .../expression/member-chain/computed.js.snap | 11 +-- .../member-chain/inline-merge.js.snap | 3 +- .../prettier/js/arrays/holes-in-args.js.snap | 4 +- .../prettier/js/async/inline-await.js.snap | 9 ++- .../specs/prettier/js/comments/issues.js.snap | 6 +- .../pipe-function-calls-with-comments.js.snap | 3 +- .../pipe-function-calls.js.snap | 3 +- .../js/last-argument-expansion/arrow.js.snap | 21 +++--- .../specs/prettier/js/member/expand.js.snap | 14 ++-- .../js/method-chain/complex-args.js.snap | 3 +- .../js/method-chain/computed-merge.js.snap | 9 ++- .../prettier/js/method-chain/computed.js.snap | 10 +-- .../specs/prettier/js/method-chain/d3.js.snap | 22 +++--- .../js/method-chain/first_long.js.snap | 6 +- .../js/method-chain/inline_merge.js.snap | 3 +- .../js/method-chain/issue-3594.js.snap | 3 +- .../js/method-chain/issue-4125.js.snap | 68 ++++++++++++------- .../js/method-chain/multiple-members.js.snap | 29 ++++---- .../js/method-chain/object-literal.js.snap | 6 +- .../js/method-chain/short-names.js.snap | 6 +- .../prettier/js/method-chain/square_0.js.snap | 3 +- .../js/optional-chaining/comments.js.snap | 22 +++--- .../js/preserve-line/member-chain.js.snap | 24 ++++--- .../js/template-literals/expressions.js.snap | 12 ++-- .../js/test-declarations/jest-each.js.snap | 4 +- .../pipe-function-calls-with-comments.ts.snap | 3 +- .../pipe-function-calls.ts.snap | 3 +- 30 files changed, 175 insertions(+), 149 deletions(-) diff --git a/crates/rome_js_formatter/src/utils/member_chain/groups.rs b/crates/rome_js_formatter/src/utils/member_chain/groups.rs index 9fc6a3dd0d5..56ddae3e817 100644 --- a/crates/rome_js_formatter/src/utils/member_chain/groups.rs +++ b/crates/rome_js_formatter/src/utils/member_chain/groups.rs @@ -103,7 +103,7 @@ impl<'f> Groups<'f> { /// Format groups on multiple lines pub fn into_joined_hard_line_groups(self) -> FormatElement { let formatted_groups = self.into_formatted_groups(); - concat_elements(formatted_groups) + join_elements(hard_line_break(), formatted_groups) } /// Creates two different versions of the formatted groups, one that goes in one line @@ -112,7 +112,7 @@ impl<'f> Groups<'f> { /// It's up to the printer to decide which one to use. pub fn into_format_elements(self) -> FormatElement { let formatted_groups = self.into_formatted_groups(); - concat_elements(formatted_groups.clone()) + concat_elements(formatted_groups) } /// Filters the stack of [FlattenItem] and return only the ones that diff --git a/crates/rome_js_formatter/src/utils/member_chain/mod.rs b/crates/rome_js_formatter/src/utils/member_chain/mod.rs index fd5dfc15992..84f10bd49b3 100644 --- a/crates/rome_js_formatter/src/utils/member_chain/mod.rs +++ b/crates/rome_js_formatter/src/utils/member_chain/mod.rs @@ -303,13 +303,6 @@ fn format_groups( head_group.into_format_element(), groups.into_format_elements() ]) - // Ok(format_elements![ - // head_group.into_format_element(), - // group_elements(indent(format_elements![ - // soft_line_break(), - // groups.into_format_elements() - // ])) - // ]) } } diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap index 020073719c7..9e5610ee66e 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap @@ -19,6 +19,7 @@ Quote style: Double Quotes ----- client.execute( Post.selectAll() - .where(Post.id.eq(42)).where(Post.published.eq(true)), + .where(Post.id.eq(42)) + .where(Post.published.eq(true)), ); diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap index d0e5ec5ca63..b1648a2e2bc 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap @@ -18,13 +18,6 @@ Line width: 80 Quote style: Double Quotes ----- nock(/test/) - .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( - 200, - { foo: "bar" }, - ); - - -## Lines exceeding width of 80 characters - - 2: .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( + .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo") + .reply(200, { foo: "bar" }); diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/inline-merge.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/inline-merge.js.snap index 2122afb5898..24de06a8681 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/inline-merge.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/inline-merge.js.snap @@ -25,7 +25,8 @@ Line width: 80 Quote style: Double Quotes ----- _.flatMap(this.visibilityHandlers, (fn) => fn()) - .concat(this.record.resolved_legacy_visrules).filter(Boolean); + .concat(this.record.resolved_legacy_visrules) + .filter(Boolean); Object.keys(availableLocales({ test: true })).forEach( (locale) => { 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 c2a2c41c64b..5fda75dab0f 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 @@ -14,7 +14,9 @@ new Test() # Output ```js new Test() - .test().test([, 0]).test(); + .test() + .test([, 0]) + .test(); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap index 28c75953554..561707fef16 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap @@ -16,11 +16,10 @@ async function f() { const admins = ( await ( db - .select("*").from("admins").leftJoin("bla").where( - "id", - "in", - [1, 2, 3, 4], - ) + .select("*") + .from("admins") + .leftJoin("bla") + .where("id", "in", [1, 2, 3, 4]) ) ).map(({ id, name }) => ({ id, name })); } diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap index 9565ba49c87..15256c5bb8e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap @@ -120,9 +120,8 @@ Observable.of(process) // Don't complete until we say so! .merge(Observable.never()) // Get the errors. - .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors).takeUntil( - exit, - ); + .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors) + .takeUntil(exit); // Comments disappear inside of JSX
@@ -160,6 +159,5 @@ foo( # Lines exceeding max width of 80 characters ``` 34: import path from "path"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri - 41: .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors).takeUntil( ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap index 9b8410a60eb..a7add45fe11 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap @@ -80,7 +80,8 @@ expression: pipe-function-calls-with-comments.js ), ), )() - .then(messageResponse(logger, msg)).catch((err) => { + .then(messageResponse(logger, msg)) + .catch((err) => { logger.error( pipe( // add a descriptive comment here diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap index 2a6142f1a8d..b2c13328458 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap @@ -57,7 +57,8 @@ expression: pipe-function-calls.js serviceEventFromMessage(msg), TE.chain(flow(publishServiceEvent(analytics), TE.mapLeft(nackFromError))), )() - .then(messageResponse(logger, msg)).catch((err) => { + .then(messageResponse(logger, msg)) + .catch((err) => { logger.error( pipe(O.fromNullable(err.stack), O.getOrElse(constant(err.message))), ); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap index d9419294cc1..091b3535b14 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap @@ -26,20 +26,22 @@ export default function searchUsers(action$) { ```js export default function searchUsers(action$) { return action$ - .ofType(ActionTypes.SEARCHED_USERS).map((action) => action.payload.query).filter( - (q) => !!q, - ).switchMap( + .ofType(ActionTypes.SEARCHED_USERS) + .map((action) => action.payload.query) + .filter((q) => !!q) + .switchMap( (q) => Observable.timer(800) // debounce - .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)).mergeMap( + .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)) + .mergeMap( () => Observable.merge( Observable.of(replace(`?q=${q}`)), ajax - .getJSON(`https://api.github.com/search/users?q=${q}`).map( - (res) => res.items, - ).map(receiveUsers), + .getJSON(`https://api.github.com/search/users?q=${q}`) + .map((res) => res.items) + .map(receiveUsers), ), ), ); @@ -47,9 +49,4 @@ export default function searchUsers(action$) { ``` -# Lines exceeding max width of 80 characters -``` - 3: .ofType(ActionTypes.SEARCHED_USERS).map((action) => action.payload.query).filter( - 9: .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)).mergeMap( -``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap index 5d28ccd4875..1499fbe1eae 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap @@ -51,7 +51,9 @@ const small = doc.expandedStates[doc.expandedStates.length - 1]; const promises = [ promise - .resolve().then(console.log).catch( + .resolve() + .then(console.log) + .catch( (err) => { console.log(err); return null; @@ -63,7 +65,11 @@ const promises = [ const promises2 = [ promise - .resolve().veryLongFunctionCall().veryLongFunctionCall().then(console.log).catch( + .resolve() + .veryLongFunctionCall() + .veryLongFunctionCall() + .then(console.log) + .catch( (err) => { console.log(err); return null; @@ -90,8 +96,4 @@ window.FooClient.something.setVars({ ``` -# Lines exceeding max width of 80 characters -``` - 20: .resolve().veryLongFunctionCall().veryLongFunctionCall().then(console.log).catch( -``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap index 58ef7ae7345..00498e0b85f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap @@ -16,7 +16,8 @@ client.execute( ```js client.execute( Post.selectAll() - .where(Post.id.eq(42)).where(Post.published.eq(true)), + .where(Post.id.eq(42)) + .where(Post.published.eq(true)), ); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap index bd67cfa7a71..9963ed27bc0 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap @@ -28,19 +28,22 @@ window.Data[key]("foo") [].forEach( (key) => { data[key]("foo") - .then(() => console.log("bar")).catch(() => console.log("baz")); + .then(() => console.log("bar")) + .catch(() => console.log("baz")); }, ); [].forEach( (key) => { data("foo")[key]("bar") - .then(() => console.log("bar")).catch(() => console.log("baz")); + .then(() => console.log("bar")) + .catch(() => console.log("baz")); }, ); window.Data[key]("foo") - .then(() => a).catch(() => b); + .then(() => a) + .catch(() => b); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap index b1afabedf9b..cf650a9360a 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap @@ -16,15 +16,9 @@ nock(/test/) # Output ```js nock(/test/) - .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( - 200, - { foo: "bar" }, - ); + .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo") + .reply(200, { foo: "bar" }); ``` -# Lines exceeding max width of 80 characters -``` - 2: .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( -``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap index d30d2184fcc..d17614b6f2a 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap @@ -27,20 +27,26 @@ not.d3.scaleLinear() # Output ```js d3 - .select("body").append("circle").at({ width: 30, fill: "#f0f" }).st({ - fontWeight: 600, - }); + .select("body") + .append("circle") + .at({ width: 30, fill: "#f0f" }) + .st({ fontWeight: 600 }); const myScale = d3 - .scaleLinear().domain([1950, 1980]).range([0, width]); + .scaleLinear() + .domain([1950, 1980]) + .range([0, width]); not.d3 - .select("body").append("circle").at({ width: 30, fill: "#f0f" }).st({ - fontWeight: 600, - }); + .select("body") + .append("circle") + .at({ width: 30, fill: "#f0f" }) + .st({ fontWeight: 600 }); not.d3 - .scaleLinear().domain([1950, 1980]).range([0, width]); + .scaleLinear() + .domain([1950, 1980]) + .range([0, width]); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/first_long.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/first_long.js.snap index 1f795ead7bb..c09055525d5 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/first_long.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/first_long.js.snap @@ -51,9 +51,9 @@ export default function theFunction(action$, store) { more: stuff(), evenMore: stuff({ value1: true, value2: false, value3: false }), }) - .filter((data) => theFilter(data)).map( - ({ theType, ...data }) => theMap(theType, data), - ).retryWhen((errors) => errors), + .filter((data) => theFilter(data)) + .map(({ theType, ...data }) => theMap(theType, data)) + .retryWhen((errors) => errors), ); } diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/inline_merge.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/inline_merge.js.snap index de56418e0c0..86668e688c5 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/inline_merge.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/inline_merge.js.snap @@ -36,7 +36,8 @@ Object.keys(availableLocales({ test: true })).forEach( this.layoutPartsToHide = this.utils.hashset( _.flatMap(this.visibilityHandlers, (fn) => fn()) - .concat(this.record.resolved_legacy_visrules).filter(Boolean), + .concat(this.record.resolved_legacy_visrules) + .filter(Boolean), ); var jqxhr = $.ajax("example.php").done(doneFn).fail(failFn); diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap index 588cd2a2019..279647fffb4 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap @@ -23,7 +23,8 @@ fetched.then((response) => response.json()).then( ); let column = new Column(null, conn) - .table(data.table).json(data.column); + .table(data.table) + .json(data.column); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-4125.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-4125.js.snap index 9641ca86d05..afc24bb79fc 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-4125.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-4125.js.snap @@ -173,7 +173,9 @@ const z = obj.foo(-1).foo(import("2")).foo(!x).check(/[A-Z]/); // better on multiple lines: somePromise - .then(format).then((val) => doSomething(val)).catch((err) => handleError(err)); + .then(format) + .then((val) => doSomething(val)) + .catch((err) => handleError(err)); // you can still force multi-line chaining with a comment: const sha256_2 = (data) => @@ -200,10 +202,15 @@ function palindrome(a, b) { // examples from https://github.com/prettier/prettier/issues/1565 d3 - .select("body").selectAll("p").data([1, 2, 3]).enter().style("color", "white"); + .select("body") + .selectAll("p") + .data([1, 2, 3]) + .enter() + .style("color", "white"); Object.keys(props) - .filter((key) => (key in own) === false).reduce( + .filter((key) => (key in own) === false) + .reduce( (a, key) => { a[key] = props[key]; return a; @@ -216,12 +223,15 @@ point().x(4).y(3).z(6).plot(); assert.equal(this.$().text().trim(), "1000"); something() - .then(() => doSomethingElse()).then((result) => dontForgetThisAsWell(result)); + .then(() => doSomethingElse()) + .then((result) => dontForgetThisAsWell(result)); db.branch( db.table("users").filter({ email }).count(), db - .table("users").filter({ email: "a@b.com" }).count(), + .table("users") + .filter({ email: "a@b.com" }) + .count(), db.table("users").insert({ email }), db.table("users").filter({ email }), ); @@ -255,20 +265,22 @@ function HelloWorld() { } action$ - .ofType(ActionTypes.SEARCHED_USERS).map((action) => action.payload.query).filter( - (q) => !!q, - ).switchMap( + .ofType(ActionTypes.SEARCHED_USERS) + .map((action) => action.payload.query) + .filter((q) => !!q) + .switchMap( (q) => Observable.timer(800) // debounce - .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)).mergeMap( + .takeUntil(action$.ofType(ActionTypes.CLEARED_SEARCH_RESULTS)) + .mergeMap( () => Observable.merge( Observable.of(replace(`?q=${q}`)), ajax - .getJSON(`https://api.github.com/search/users?q=${q}`).map( - (res) => res.items, - ).map(receiveUsers), + .getJSON(`https://api.github.com/search/users?q=${q}`) + .map((res) => res.items) + .map(receiveUsers), ), ), ); @@ -290,33 +302,41 @@ const a1 = x.a(true).b(null).c(123); const a2 = x.d("").e(``).f(g); const a3 = x.d("").e(`${123}`).f(g); const a4 = x - .h(i.j).k(l()).m([n, o]); + .h(i.j) + .k(l()) + .m([n, o]); class X { y() { const j = x - .a(this).b(super.cde()).f(/g/).h(new i()).j(); + .a(this) + .b(super.cde()) + .f(/g/) + .h(new i()) + .j(); } } // should break when call expressions get complex x - .a().b([c, [d, [e]]]).f(); + .a() + .b([c, [d, [e]]]) + .f(); x - .a().b(c(d(e()))).f(); + .a() + .b(c(d(e()))) + .f(); x - .a().b(`${c(d())}`).f(); + .a() + .b(`${c(d())}`) + .f(); xyz - .a().b().c(a(a(b(c(d().p).p).p).p)); + .a() + .b() + .c(a(a(b(c(d().p).p).p).p)); var l = base.replace(/^\w*:\/\//, "").replace(/\/$/, "").split("/").length; ``` -# Lines exceeding max width of 80 characters -``` - 16: .then(format).then((val) => doSomething(val)).catch((err) => handleError(err)); - 43: .select("body").selectAll("p").data([1, 2, 3]).enter().style("color", "white"); - 98: .ofType(ActionTypes.SEARCHED_USERS).map((action) => action.payload.query).filter( -``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/multiple-members.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/multiple-members.js.snap index 21bc23aba08..ce6de777774 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/multiple-members.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/multiple-members.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs -assertion_line: 175 expression: multiple-members.js --- # Input @@ -51,7 +50,8 @@ if (testConfig.ENABLE_ONLINE_TESTS === "true") { function () { function assert(pet) { expect(pet).to.have - .property("OwnerAddress").that.deep.equals({ + .property("OwnerAddress") + .that.deep.equals({ AddressLine1: "Alexanderstrasse", AddressLine2: "", PostalCode: "10999", @@ -67,36 +67,39 @@ if (testConfig.ENABLE_ONLINE_TESTS === "true") { } wrapper - .find("SomewhatLongNodeName").prop("longPropFunctionName")().then(function () { + .find("SomewhatLongNodeName") + .prop("longPropFunctionName")() + .then(function () { doSomething(); }); wrapper - .find("SomewhatLongNodeName").prop("longPropFunctionName")("argument").then(function () { + .find("SomewhatLongNodeName") + .prop("longPropFunctionName")("argument") + .then(function () { doSomething(); }); wrapper - .find("SomewhatLongNodeName").prop( + .find("SomewhatLongNodeName") + .prop( "longPropFunctionName", "second argument that pushes this group past 80 characters", - )("argument").then(function () { + )("argument") + .then(function () { doSomething(); }); wrapper - .find("SomewhatLongNodeName").prop("longPropFunctionName")( + .find("SomewhatLongNodeName") + .prop("longPropFunctionName")( "argument", "second argument that pushes this group past 80 characters", - ).then(function () { + ) + .then(function () { doSomething(); }); ``` -# Lines exceeding max width of 80 characters -``` - 26: .find("SomewhatLongNodeName").prop("longPropFunctionName")().then(function () { - 31: .find("SomewhatLongNodeName").prop("longPropFunctionName")("argument").then(function () { -``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap index 6fdc5e113b8..ec0e7d09549 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap @@ -25,14 +25,16 @@ of("test") # Output ```js of("test") - .pipe(throwIfEmpty()).subscribe({ + .pipe(throwIfEmpty()) + .subscribe({ error(err) { thrown = err; }, }); of("test") - .pipe(throwIfEmpty()).subscribe({ + .pipe(throwIfEmpty()) + .subscribe({ get foo() { bar(); }, diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap index 23ea3b20f12..f889f2435b5 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap @@ -14,9 +14,9 @@ const svgJsFiles = fs # Output ```js const svgJsFiles = fs - .readdirSync(svgDir).filter((f) => svgJsFileExtRegex.test(f)).map( - (f) => path.join(svgDir, f), - ); + .readdirSync(svgDir) + .filter((f) => svgJsFileExtRegex.test(f)) + .map((f) => path.join(svgDir, f)); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap index 34d6435ecff..e8d5cbaecaf 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap @@ -21,7 +21,8 @@ const component = find('.org-lclp-edit-copy-url-banner__link')[0] const version = someLongString.split("jest version =").pop().split(EOL)[0].trim(); const component = find(".org-lclp-edit-copy-url-banner__link")[0] - .getAttribute("href").indexOf(this.landingPageLink); + .getAttribute("href") + .indexOf(this.landingPageLink); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/comments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/comments.js.snap index fd64e9c398e..b537e2bc223 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/comments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/optional-chaining/comments.js.snap @@ -62,30 +62,32 @@ function foo() { } fooBar - .doSomething("Hello World").doAnotherThing("Foo", { foo: bar }) + .doSomething("Hello World") + .doAnotherThing("Foo", { foo: bar }) // App configuration. - .doOneMoreThing(config)?.run(() => console.log("Bar")); + .doOneMoreThing(config) + ?.run(() => console.log("Bar")); bigDeal .doSomething("Hello World") // Hello world ?.doAnotherThing("Foo", { foo: bar }) // App configuration. - .doOneMoreThing(config)?.run(() => console.log("Bar")); + .doOneMoreThing(config) + ?.run(() => console.log("Bar")); foo.bar.baz ?.doSomething("Hello World") // Hello world - .foo.bar.doAnotherThing("Foo", { foo: bar }).doOneMoreThing(config)?.bar.run( - () => console.log("Bar"), - ); + .foo.bar.doAnotherThing("Foo", { foo: bar }) + .doOneMoreThing(config) + ?.bar.run(() => console.log("Bar")); (somethingGood ? thisIsIt : maybeNot) // Hello world - .doSomething("Hello World")?.doAnotherThing("Foo", { foo: bar }).run( - // Run this - () => console.log("Bar"), - ); // Do this + .doSomething("Hello World") + ?.doAnotherThing("Foo", { foo: bar }) // Run this + .run(() => console.log("Bar")); // Do this ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/preserve-line/member-chain.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/preserve-line/member-chain.js.snap index e9daab7f2a7..350c8890a25 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/preserve-line/member-chain.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/preserve-line/member-chain.js.snap @@ -69,30 +69,32 @@ const sel = this.connections # Output ```js fooBar - .doSomething("Hello World").doAnotherThing("Foo", { foo: bar }) + .doSomething("Hello World") + .doAnotherThing("Foo", { foo: bar }) // App configuration. - .doOneMoreThing(config).run(() => console.log("Bar")); + .doOneMoreThing(config) + .run(() => console.log("Bar")); bigDeal .doSomething("Hello World") // Hello world .doAnotherThing("Foo", { foo: bar }) // App configuration. - .doOneMoreThing(config).run(() => console.log("Bar")); + .doOneMoreThing(config) + .run(() => console.log("Bar")); foo.bar.baz .doSomething("Hello World") // Hello world - .foo.bar.doAnotherThing("Foo", { foo: bar }).doOneMoreThing(config).bar.run( - () => console.log("Bar"), - ); + .foo.bar.doAnotherThing("Foo", { foo: bar }) + .doOneMoreThing(config) + .bar.run(() => console.log("Bar")); (somethingGood ? thisIsIt : maybeNot) // Hello world - .doSomething("Hello World").doAnotherThing("Foo", { foo: bar }).run( - // Run this - () => console.log("Bar"), - ); // Do this + .doSomething("Hello World") + .doAnotherThing("Foo", { foo: bar }) // Run this + .run(() => console.log("Bar")); // Do this helloWorld.text().then((t) => t); @@ -112,6 +114,6 @@ const sel = this.connections.concat(this.activities.concat(this.operators)).filt # Lines exceeding max width of 80 characters ``` - 37: const sel = this.connections.concat(this.activities.concat(this.operators)).filter( + 39: const sel = this.connections.concat(this.activities.concat(this.operators)).filter( ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap index 5e617d77378..1d950924844 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap @@ -91,9 +91,8 @@ function testing() { return `${process.env.OPENID_URL}/something/something/something?${Object.keys( p, ) - .map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(p[k])}`).join( - "&", - )}`; + .map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(p[k])}`) + .join("&")}`; } } } @@ -137,9 +136,8 @@ throw new Error( 14: const shouldNotWrap = `simple expressions should not break ${this} ${variable} ${a.b.c} ${this.b.c} ${a[ 20: `Covered Lines below threshold: ${coverageSettings.lines}%. Actual: ${coverageSummary.total.lines.pct}%`, 34: return `${process.env.OPENID_URL}/something/something/something?${Object.keys( - 37: .map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(p[k])}`).join( - 45: `Trying update appcast for ${app.name} (${app.cask.appcast}) -> (${app.cask.appcastGenerated})`, - 53: `\nApparently jetbrains changed the release artifact for ${app.name}@${app.jetbrains.version}.\n`, - 67: `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`, + 44: `Trying update appcast for ${app.name} (${app.cask.appcast}) -> (${app.cask.appcastGenerated})`, + 52: `\nApparently jetbrains changed the release artifact for ${app.name}@${app.jetbrains.version}.\n`, + 66: `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`, ``` 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 25e5e03d293..23cd5435328 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 @@ -124,7 +124,9 @@ ${2} | ${1} | ${3}`; // an example to demo multiline quasi describe.each`a | b | expected ${11111111111} | ${a() - .b((x) => x).c().d()} | ${2} + .b((x) => x) + .c() + .d()} | ${2} ${1} | ${2} | ${3} ${2} | ${1} | ${3}`; diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap index c373f16a603..14bfbe6882e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap @@ -80,7 +80,8 @@ expression: pipe-function-calls-with-comments.ts ), ), )() - .then(messageResponse(logger, msg)).catch( + .then(messageResponse(logger, msg)) + .catch( (err: Error) => { logger.error( pipe( diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap index ca465e654fe..53ce5dc5f8b 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap @@ -36,7 +36,8 @@ expression: pipe-function-calls.ts serviceEventFromMessage(msg), TE.chain(flow(publishServiceEvent(analytics), TE.mapLeft(nackFromError))), )() - .then(messageResponse(logger, msg)).catch( + .then(messageResponse(logger, msg)) + .catch( (err: Error) => { logger.error( pipe(O.fromNullable(err.stack), O.getOrElse(constant(err.message))), From f3fb11abef23efdf3d4f1b36f0fd95b126e34002 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 13 May 2022 16:13:27 +0200 Subject: [PATCH 3/4] Revert "unchanged" snapshot tests --- .../expression/member-chain/complex_arguments.js.snap | 3 +-- .../module/expression/member-chain/computed.js.snap | 11 +++++++++-- .../specs/prettier/js/arrays/holes-in-args.js.snap | 4 +--- .../specs/prettier/js/async/inline-await.js.snap | 9 +++++---- .../prettier/js/binary-expressions/arrow.js.snap | 2 ++ .../tests/specs/prettier/js/comments/issues.js.snap | 1 + .../pipe-function-calls-with-comments.js.snap | 2 ++ .../pipe-function-calls.js.snap | 2 ++ .../prettier/js/last-argument-expansion/arrow.js.snap | 1 + .../tests/specs/prettier/js/member/expand.js.snap | 1 + .../prettier/js/method-chain/complex-args.js.snap | 1 + .../prettier/js/method-chain/computed-merge.js.snap | 1 + .../specs/prettier/js/method-chain/computed.js.snap | 1 + .../tests/specs/prettier/js/method-chain/d3.js.snap | 1 + .../specs/prettier/js/method-chain/issue-3594.js.snap | 1 + .../prettier/js/method-chain/object-literal.js.snap | 2 ++ .../prettier/js/method-chain/short-names.js.snap | 1 + .../specs/prettier/js/method-chain/square_0.js.snap | 1 + .../prettier/js/template-literals/expressions.js.snap | 1 + .../prettier/js/trailing-comma/function-calls.js.snap | 2 ++ .../pipe-function-calls-with-comments.ts.snap | 2 ++ .../pipe-function-calls.ts.snap | 2 ++ 22 files changed, 41 insertions(+), 11 deletions(-) diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap index 9e5610ee66e..020073719c7 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap @@ -19,7 +19,6 @@ Quote style: Double Quotes ----- client.execute( Post.selectAll() - .where(Post.id.eq(42)) - .where(Post.published.eq(true)), + .where(Post.id.eq(42)).where(Post.published.eq(true)), ); diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap index b1648a2e2bc..d0e5ec5ca63 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap @@ -18,6 +18,13 @@ Line width: 80 Quote style: Double Quotes ----- nock(/test/) - .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo") - .reply(200, { foo: "bar" }); + .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( + 200, + { foo: "bar" }, + ); + + +## Lines exceeding width of 80 characters + + 2: .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( 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 5fda75dab0f..c2a2c41c64b 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 @@ -14,9 +14,7 @@ new Test() # Output ```js new Test() - .test() - .test([, 0]) - .test(); + .test().test([, 0]).test(); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap index 561707fef16..28c75953554 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap @@ -16,10 +16,11 @@ async function f() { const admins = ( await ( db - .select("*") - .from("admins") - .leftJoin("bla") - .where("id", "in", [1, 2, 3, 4]) + .select("*").from("admins").leftJoin("bla").where( + "id", + "in", + [1, 2, 3, 4], + ) ) ).map(({ id, name }) => ({ id, name })); } diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap index 940d4071bdd..b99738cd6ac 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/binary-expressions/arrow.js.snap @@ -1,6 +1,8 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 125 expression: arrow.js + --- # Input ```js diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap index 15256c5bb8e..85f0eeef83e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/comments/issues.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: issues.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap index a7add45fe11..2810d31e39d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls-with-comments.js.snap @@ -1,6 +1,8 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 125 expression: pipe-function-calls-with-comments.js + --- # Input ```js diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap index b2c13328458..b980f7f1080 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/functional-composition/pipe-function-calls.js.snap @@ -1,6 +1,8 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 125 expression: pipe-function-calls.js + --- # Input ```js diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap index 091b3535b14..f79b43465fa 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/last-argument-expansion/arrow.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: arrow.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap index 1499fbe1eae..52e624be039 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/member/expand.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: expand.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap index 00498e0b85f..d19825df947 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/complex-args.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: complex-args.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap index 9963ed27bc0..59d204d4e0d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed-merge.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: computed-merge.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap index cf650a9360a..8d45c1dd655 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/computed.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: computed.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap index d17614b6f2a..15265fbc9a4 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/d3.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: d3.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap index 279647fffb4..b9e214d0de5 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/issue-3594.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: issue-3594.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap index ec0e7d09549..3eaaa949dc5 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/object-literal.js.snap @@ -1,6 +1,8 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 125 expression: object-literal.js + --- # Input ```js diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap index f889f2435b5..814c1742099 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/short-names.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: short-names.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap index e8d5cbaecaf..aa88a1e4bcf 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/method-chain/square_0.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: square_0.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap index 1d950924844..e16141f9998 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/template-literals/expressions.js.snap @@ -1,5 +1,6 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 175 expression: expressions.js --- # Input diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/trailing-comma/function-calls.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/trailing-comma/function-calls.js.snap index d3865e7080f..88ae8688468 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/trailing-comma/function-calls.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/trailing-comma/function-calls.js.snap @@ -1,6 +1,8 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 57 expression: function-calls.js + --- # Input ```js diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap index 14bfbe6882e..b419ca6f9fc 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls-with-comments.ts.snap @@ -1,6 +1,8 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 125 expression: pipe-function-calls-with-comments.ts + --- # Input ```js diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap index 53ce5dc5f8b..bc9ab598b9d 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/functional-composition/pipe-function-calls.ts.snap @@ -1,6 +1,8 @@ --- source: crates/rome_js_formatter/tests/prettier_tests.rs +assertion_line: 125 expression: pipe-function-calls.ts + --- # Input ```js From 5e8b0a2aa07c7be0b651bf0bfd296929b5b5dd67 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Fri, 13 May 2022 16:18:21 +0200 Subject: [PATCH 4/4] More snapshot updates --- .../expression/member-chain/complex_arguments.js.snap | 3 ++- .../module/expression/member-chain/computed.js.snap | 11 ++--------- .../specs/prettier/js/arrays/holes-in-args.js.snap | 4 +++- .../specs/prettier/js/async/inline-await.js.snap | 9 ++++----- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap index 020073719c7..9e5610ee66e 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/complex_arguments.js.snap @@ -19,6 +19,7 @@ Quote style: Double Quotes ----- client.execute( Post.selectAll() - .where(Post.id.eq(42)).where(Post.published.eq(true)), + .where(Post.id.eq(42)) + .where(Post.published.eq(true)), ); diff --git a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap index d0e5ec5ca63..b1648a2e2bc 100644 --- a/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap +++ b/crates/rome_js_formatter/tests/specs/js/module/expression/member-chain/computed.js.snap @@ -18,13 +18,6 @@ Line width: 80 Quote style: Double Quotes ----- nock(/test/) - .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( - 200, - { foo: "bar" }, - ); - - -## Lines exceeding width of 80 characters - - 2: .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo").reply( + .matchHeader("Accept", "application/json")[httpMethodNock(method)]("/foo") + .reply(200, { foo: "bar" }); 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 c2a2c41c64b..5fda75dab0f 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 @@ -14,7 +14,9 @@ new Test() # Output ```js new Test() - .test().test([, 0]).test(); + .test() + .test([, 0]) + .test(); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap index 28c75953554..561707fef16 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/async/inline-await.js.snap @@ -16,11 +16,10 @@ async function f() { const admins = ( await ( db - .select("*").from("admins").leftJoin("bla").where( - "id", - "in", - [1, 2, 3, 4], - ) + .select("*") + .from("admins") + .leftJoin("bla") + .where("id", "in", [1, 2, 3, 4]) ) ).map(({ id, name }) => ({ id, name })); }