From 44de60ee336c2ae8ba36c2e121cd8bb2700e3cac Mon Sep 17 00:00:00 2001 From: magic-akari Date: Mon, 28 Aug 2023 20:53:02 +0800 Subject: [PATCH] Initial commit --- .editorconfig | 11 + .gitattributes | 4 + .github/workflows/publish.yml | 91 ++++ .github/workflows/test.yml | 78 +++ .gitignore | 2 + .node-version | 1 + .rustfmt.toml | 16 + .taplo.toml | 5 + .vscode/settings.json | 6 + Cargo.toml | 36 ++ LICENSE | 21 + crates/rome_fmt/Cargo.toml | 27 ++ crates/rome_fmt/extra/.npmignore | 2 + crates/rome_fmt/extra/rome_fmt.d.ts | 32 ++ crates/rome_fmt/extra/vite.js | 8 + crates/rome_fmt/patch/rome_fmt.patch | 33 ++ crates/rome_fmt/scripts/build.sh | 17 + crates/rome_fmt/scripts/gen_patch.sh | 29 ++ crates/rome_fmt/scripts/package.mjs | 30 ++ crates/rome_fmt/src/config.rs | 132 +++++ crates/rome_fmt/src/lib.rs | 58 +++ crates/rome_fmt/test_data/specs/.DS_Store | Bin 0 -> 6148 bytes .../specs/js/module/array/array_nested.js | 41 ++ .../js/module/array/array_nested.js.snap | 57 +++ .../specs/js/module/array/binding_pattern.js | 3 + .../js/module/array/binding_pattern.js.snap | 7 + .../specs/js/module/array/empty_lines.js | 12 + .../specs/js/module/array/empty_lines.js.snap | 7 + .../test_data/specs/js/module/array/spaces.js | 5 + .../specs/js/module/array/spaces.js.snap | 5 + .../test_data/specs/js/module/array/spread.js | 5 + .../specs/js/module/array/spread.js.snap | 8 + .../trailing-comma/array_trailing_comma.js | 10 + .../array_trailing_comma.js.snap | 12 + .../specs/js/module/arrow/arrow-comments.js | 21 + .../js/module/arrow/arrow-comments.js.snap | 20 + .../js/module/arrow/arrow_chain_comments.js | 9 + .../module/arrow/arrow_chain_comments.js.snap | 16 + .../specs/js/module/arrow/arrow_function.js | 7 + .../js/module/arrow/arrow_function.js.snap | 10 + .../specs/js/module/arrow/arrow_nested.js | 27 ++ .../js/module/arrow/arrow_nested.js.snap | 26 + .../js/module/arrow/arrow_test_callback.js | 4 + .../module/arrow/arrow_test_callback.js.snap | 4 + .../test_data/specs/js/module/arrow/call.js | 44 ++ .../specs/js/module/arrow/call.js.snap | 53 ++ .../specs/js/module/arrow/currying.js | 17 + .../specs/js/module/arrow/currying.js.snap | 17 + .../test_data/specs/js/module/arrow/params.js | 321 +++++++++++++ .../specs/js/module/arrow/params.js.snap | 301 ++++++++++++ .../assignment/array-assignment-holes.js | 2 + .../assignment/array-assignment-holes.js.snap | 2 + .../specs/js/module/assignment/assignment.js | 154 ++++++ .../js/module/assignment/assignment.js.snap | 224 +++++++++ .../js/module/assignment/assignment_ignore.js | 4 + .../assignment/assignment_ignore.js.snap | 4 + .../js/module/binding/array-binding-holes.js | 2 + .../binding/array-binding-holes.js.snap | 1 + .../specs/js/module/binding/array_binding.js | 3 + .../js/module/binding/array_binding.js.snap | 6 + .../js/module/binding/identifier_binding.js | 3 + .../module/binding/identifier_binding.js.snap | 4 + .../specs/js/module/binding/object_binding.js | 4 + .../js/module/binding/object_binding.js.snap | 9 + .../specs/js/module/call_expression.js | 48 ++ .../specs/js/module/call_expression.js.snap | 49 ++ .../test_data/specs/js/module/class/class.js | 71 +++ .../specs/js/module/class/class.js.snap | 61 +++ .../specs/js/module/class/class_comments.js | 7 + .../js/module/class/class_comments.js.snap | 8 + .../specs/js/module/class/private_method.js | 16 + .../js/module/class/private_method.js.snap | 20 + .../test_data/specs/js/module/comments.js | 78 +++ .../specs/js/module/comments.js.snap | 85 ++++ .../declarations/variable_declaration.js | 265 ++++++++++ .../declarations/variable_declaration.js.snap | 454 ++++++++++++++++++ .../class_members_call_decorator.js | 92 ++++ .../class_members_call_decorator.js.snap | 91 ++++ .../module/decorators/class_members_mixed.js | 92 ++++ .../decorators/class_members_mixed.js.snap | 91 ++++ .../module/decorators/class_members_simple.js | 92 ++++ .../decorators/class_members_simple.js.snap | 91 ++++ .../js/module/decorators/class_simple.js | 48 ++ .../js/module/decorators/class_simple.js.snap | 56 +++ .../decorators/class_simple_call_decorator.js | 48 ++ .../class_simple_call_decorator.js.snap | 56 +++ .../js/module/decorators/export_default_1.js | 1 + .../decorators/export_default_1.js.snap | 1 + .../js/module/decorators/export_default_2.js | 1 + .../decorators/export_default_2.js.snap | 2 + .../js/module/decorators/export_default_3.js | 1 + .../decorators/export_default_3.js.snap | 2 + .../js/module/decorators/export_default_4.js | 1 + .../decorators/export_default_4.js.snap | 2 + .../specs/js/module/decorators/expression.js | 21 + .../js/module/decorators/expression.js.snap | 43 ++ .../specs/js/module/decorators/multiline.js | 16 + .../js/module/decorators/multiline.js.snap | 16 + .../test_data/specs/js/module/each/each.js | 66 +++ .../specs/js/module/each/each.js.snap | 70 +++ .../specs/js/module/export/class_clause.js | 9 + .../js/module/export/class_clause.js.snap | 7 + .../js/module/export/expression_clause.js | 1 + .../module/export/expression_clause.js.snap | 1 + .../specs/js/module/export/from_clause.js | 5 + .../js/module/export/from_clause.js.snap | 8 + .../specs/js/module/export/function_clause.js | 9 + .../js/module/export/function_clause.js.snap | 3 + .../specs/js/module/export/named_clause.js | 7 + .../js/module/export/named_clause.js.snap | 6 + .../js/module/export/named_from_clause.js | 20 + .../module/export/named_from_clause.js.snap | 22 + .../trailing-comma/export_trailing_comma.js | 5 + .../export_trailing_comma.js.snap | 5 + .../js/module/export/variable_declaration.js | 3 + .../export/variable_declaration.js.snap | 5 + .../js/module/expression/binary_expression.js | 34 ++ .../expression/binary_expression.js.snap | 34 ++ .../module/expression/binaryish_expression.js | 1 + .../expression/binaryish_expression.js.snap | 2 + .../expression/computed-member-expression.js | 1 + .../computed-member-expression.js.snap | 1 + .../expression/conditional_expression.js | 10 + .../expression/conditional_expression.js.snap | 18 + .../import_meta_expression.js | 3 + .../import_meta_expression.js.snap | 5 + .../module/expression/literal_expression.js | 7 + .../expression/literal_expression.js.snap | 7 + .../module/expression/logical_expression.js | 112 +++++ .../expression/logical_expression.js.snap | 182 +++++++ .../member-chain/complex_arguments.js | 5 + .../member-chain/complex_arguments.js.snap | 3 + .../expression/member-chain/computed.js | 6 + .../expression/member-chain/computed.js.snap | 6 + .../expression/member-chain/inline-merge.js | 13 + .../member-chain/inline-merge.js.snap | 11 + .../js/module/expression/new_expression.js | 3 + .../module/expression/new_expression.js.snap | 7 + .../expression/post_update_expression.js | 4 + .../expression/post_update_expression.js.snap | 4 + .../expression/pre_update_expression.js | 4 + .../expression/pre_update_expression.js.snap | 4 + .../module/expression/sequence_expression.js | 33 ++ .../expression/sequence_expression.js.snap | 54 +++ .../expression/static_member_expression.js | 20 + .../static_member_expression.js.snap | 31 ++ .../js/module/expression/this_expression.js | 1 + .../module/expression/this_expression.js.snap | 1 + .../js/module/expression/unary_expression.js | 14 + .../expression/unary_expression.js.snap | 18 + .../unary_expression_verbatim_argument.js | 8 + ...unary_expression_verbatim_argument.js.snap | 6 + .../specs/js/module/function/function.js | 32 ++ .../specs/js/module/function/function.js.snap | 30 ++ .../specs/js/module/function/function_args.js | 3 + .../js/module/function/function_args.js.snap | 11 + .../js/module/function/function_comments.js | 17 + .../module/function/function_comments.js.snap | 17 + .../test_data/specs/js/module/ident.js | 1 + .../test_data/specs/js/module/ident.js.snap | 1 + .../specs/js/module/import/bare_import.js | 23 + .../js/module/import/bare_import.js.snap | 21 + .../specs/js/module/import/default_import.js | 11 + .../js/module/import/default_import.js.snap | 12 + .../specs/js/module/import/import_call.js | 3 + .../js/module/import/import_call.js.snap | 6 + .../js/module/import/import_specifiers.js | 32 ++ .../module/import/import_specifiers.js.snap | 42 ++ .../js/module/import/namespace_import.js | 1 + .../js/module/import/namespace_import.js.snap | 1 + .../trailing-comma/import_trailing_comma.js | 30 ++ .../import_trailing_comma.js.snap | 35 ++ .../test_data/specs/js/module/interpreter.js | 4 + .../specs/js/module/interpreter.js.snap | 4 + .../js/module/interpreter_with_empty_line.js | 4 + .../interpreter_with_empty_line.js.snap | 3 + .../specs/js/module/invalid/block_stmt_err.js | 10 + .../js/module/invalid/block_stmt_err.js.snap | 10 + .../specs/js/module/invalid/if_stmt_err.js | 16 + .../js/module/invalid/if_stmt_err.js.snap | 12 + .../test_data/specs/js/module/newlines.js | 78 +++ .../specs/js/module/newlines.js.snap | 59 +++ .../specs/js/module/no-semi/class.js | 118 +++++ .../specs/js/module/no-semi/class.js.snap | 116 +++++ .../specs/js/module/no-semi/issue2006.js | 8 + .../specs/js/module/no-semi/issue2006.js.snap | 8 + .../specs/js/module/no-semi/no-semi.js | 80 +++ .../specs/js/module/no-semi/no-semi.js.snap | 91 ++++ .../specs/js/module/no-semi/private-field.js | 4 + .../js/module/no-semi/private-field.js.snap | 4 + .../specs/js/module/no-semi/semicolons-asi.js | 1 + .../js/module/no-semi/semicolons-asi.js.snap | 1 + .../specs/js/module/number/number.js | 2 + .../specs/js/module/number/number.js.snap | 2 + .../js/module/number/number_with_space.js | 6 + .../module/number/number_with_space.js.snap | 4 + .../specs/js/module/object/computed_member.js | 19 + .../js/module/object/computed_member.js.snap | 26 + .../specs/js/module/object/getter_setter.js | 6 + .../js/module/object/getter_setter.js.snap | 6 + .../specs/js/module/object/object.js | 32 ++ .../specs/js/module/object/object.js.snap | 29 ++ .../specs/js/module/object/object_comments.js | 4 + .../js/module/object/object_comments.js.snap | 5 + .../js/module/object/octal_literals_key.js | 6 + .../module/object/octal_literals_key.js.snap | 6 + .../specs/js/module/object/property_key.js | 8 + .../js/module/object/property_key.js.snap | 8 + .../module/object/property_object_member.js | 88 ++++ .../object/property_object_member.js.snap | 155 ++++++ .../trailing-comma/object_trailing_comma.js | 9 + .../object_trailing_comma.js.snap | 11 + .../js/module/parentheses/parentheses.js | 24 + .../js/module/parentheses/parentheses.js.snap | 24 + .../fill-array-comments.js | 8 + .../fill-array-comments.js.snap | 8 + .../test_data/specs/js/module/script.js | 4 + .../test_data/specs/js/module/script.js.snap | 4 + .../js/module/statement/block_statement.js | 9 + .../module/statement/block_statement.js.snap | 7 + .../specs/js/module/statement/do_while.js | 15 + .../js/module/statement/do_while.js.snap | 11 + .../specs/js/module/statement/empty_blocks.js | 30 ++ .../js/module/statement/empty_blocks.js.snap | 36 ++ .../specs/js/module/statement/for_in.js | 7 + .../specs/js/module/statement/for_in.js.snap | 9 + .../specs/js/module/statement/for_loop.js | 17 + .../js/module/statement/for_loop.js.snap | 20 + .../specs/js/module/statement/for_of.js | 8 + .../specs/js/module/statement/for_of.js.snap | 11 + .../specs/js/module/statement/if_chain.js | 3 + .../js/module/statement/if_chain.js.snap | 7 + .../specs/js/module/statement/if_else.js | 69 +++ .../specs/js/module/statement/if_else.js.snap | 63 +++ .../specs/js/module/statement/return.js | 7 + .../specs/js/module/statement/return.js.snap | 7 + .../statement/return_verbatim_argument.js | 25 + .../return_verbatim_argument.js.snap | 25 + .../specs/js/module/statement/statement.js | 2 + .../js/module/statement/statement.js.snap | 1 + .../specs/js/module/statement/switch.js | 19 + .../specs/js/module/statement/switch.js.snap | 18 + .../specs/js/module/statement/throw.js | 3 + .../specs/js/module/statement/throw.js.snap | 3 + .../js/module/statement/try_catch_finally.js | 26 + .../statement/try_catch_finally.js.snap | 25 + .../specs/js/module/statement/while_loop.js | 26 + .../js/module/statement/while_loop.js.snap | 24 + .../specs/js/module/string/directives.js | 4 + .../specs/js/module/string/directives.js.snap | 4 + .../js/module/string/parentheses_token.js | 1 + .../module/string/parentheses_token.js.snap | 1 + .../js/module/string/properties_quotes.js | 43 ++ .../module/string/properties_quotes.js.snap | 44 ++ .../specs/js/module/string/string.js | 58 +++ .../specs/js/module/string/string.js.snap | 63 +++ .../test_data/specs/js/module/suppression.js | 29 ++ .../specs/js/module/suppression.js.snap | 29 ++ .../specs/js/module/template/template.js | 47 ++ .../specs/js/module/template/template.js.snap | 79 +++ .../test_data/specs/js/module/with.js | 5 + .../test_data/specs/js/module/with.js.snap | 5 + .../test_data/specs/js/script/script.js | 4 + .../test_data/specs/js/script/script.js.snap | 4 + .../test_data/specs/js/script/with.js | 7 + .../test_data/specs/js/script/with.js.snap | 7 + .../test_data/specs/jsx/arrow_function.jsx | 29 ++ .../specs/jsx/arrow_function.jsx.snap | 31 ++ .../test_data/specs/jsx/attributes.jsx | 76 +++ .../test_data/specs/jsx/attributes.jsx.snap | 88 ++++ .../rome_fmt/test_data/specs/jsx/comments.jsx | 5 + .../test_data/specs/jsx/comments.jsx.snap | 7 + .../test_data/specs/jsx/conditional.jsx | 49 ++ .../test_data/specs/jsx/conditional.jsx.snap | 53 ++ .../rome_fmt/test_data/specs/jsx/element.jsx | 330 +++++++++++++ .../test_data/specs/jsx/element.jsx.snap | 397 +++++++++++++++ .../rome_fmt/test_data/specs/jsx/fragment.jsx | 2 + .../test_data/specs/jsx/fragment.jsx.snap | 3 + .../test_data/specs/jsx/new-lines.jsx | 50 ++ .../test_data/specs/jsx/new-lines.jsx.snap | 45 ++ .../specs/jsx/quote_style/quote_style.jsx | 8 + .../jsx/quote_style/quote_style.jsx.snap | 3 + .../test_data/specs/jsx/self_closing.jsx | 15 + .../test_data/specs/jsx/self_closing.jsx.snap | 9 + crates/rome_fmt/test_data/specs/jsx/smoke.jsx | 1 + .../test_data/specs/jsx/smoke.jsx.snap | 1 + .../specs/ts/arrow/arrow_parentheses.ts | 13 + .../specs/ts/arrow/arrow_parentheses.ts.snap | 13 + .../test_data/specs/ts/arrow_chain.ts | 11 + .../test_data/specs/ts/arrow_chain.ts.snap | 27 ++ .../specs/ts/assignment/as_assignment.ts | 5 + .../specs/ts/assignment/as_assignment.ts.snap | 6 + .../specs/ts/assignment/assignment.ts | 13 + .../specs/ts/assignment/assignment.ts.snap | 14 + .../ts/assignment/assignment_comments.ts | 21 + .../ts/assignment/assignment_comments.ts.snap | 16 + .../property_assignment_comments.ts | 33 ++ .../property_assignment_comments.ts.snap | 26 + .../assignment/type_assertion_assignment.ts | 14 + .../type_assertion_assignment.ts.snap | 10 + .../specs/ts/binding/definite_variable.ts | 1 + .../ts/binding/definite_variable.ts.snap | 1 + .../test_data/specs/ts/call_expression.ts | 24 + .../specs/ts/call_expression.ts.snap | 23 + .../test_data/specs/ts/class/accessor.ts | 3 + .../test_data/specs/ts/class/accessor.ts.snap | 3 + .../specs/ts/class/assigment_layout.ts | 7 + .../specs/ts/class/assigment_layout.ts.snap | 7 + .../specs/ts/class/constructor_parameter.ts | 36 ++ .../ts/class/constructor_parameter.ts.snap | 26 + .../specs/ts/class/implements_clause.ts | 3 + .../specs/ts/class/implements_clause.ts.snap | 4 + .../ts/class/readonly_ambient_property.ts | 10 + .../class/readonly_ambient_property.ts.snap | 6 + .../trailing_comma/class_trailing_comma.ts | 11 + .../class_trailing_comma.ts.snap | 25 + .../test_data/specs/ts/declaration/class.ts | 60 +++ .../specs/ts/declaration/class.ts.snap | 61 +++ .../specs/ts/declaration/declare_function.ts | 4 + .../ts/declaration/declare_function.ts.snap | 7 + .../ts/declaration/global_declaration.ts | 7 + .../ts/declaration/global_declaration.ts.snap | 5 + .../specs/ts/declaration/interface.ts | 45 ++ .../specs/ts/declaration/interface.ts.snap | 55 +++ .../ts/declaration/variable_declaration.ts | 87 ++++ .../declaration/variable_declaration.ts.snap | 123 +++++ crates/rome_fmt/test_data/specs/ts/declare.ts | 6 + .../test_data/specs/ts/declare.ts.snap | 4 + .../rome_fmt/test_data/specs/ts/decoartors.ts | 258 ++++++++++ .../test_data/specs/ts/decoartors.ts.snap | 258 ++++++++++ .../specs/ts/decorators/class_members.ts | 92 ++++ .../specs/ts/decorators/class_members.ts.snap | 91 ++++ .../specs/ts/enum/enum_trailing_comma.ts | 5 + .../specs/ts/enum/enum_trailing_comma.ts.snap | 5 + .../specs/ts/expression/as_expression.ts | 4 + .../specs/ts/expression/as_expression.ts.snap | 2 + .../ts/expression/non_null_expression.ts | 2 + .../ts/expression/non_null_expression.ts.snap | 2 + .../expression/type_assertion_expression.ts | 7 + .../type_assertion_expression.ts.snap | 3 + .../specs/ts/expression/type_expression.ts | 105 ++++ .../ts/expression/type_expression.ts.snap | 110 +++++ .../specs/ts/expression/type_member.ts | 47 ++ .../specs/ts/expression/type_member.ts.snap | 98 ++++ .../parameters/function_parameters.ts | 33 ++ .../parameters/function_parameters.ts.snap | 35 ++ .../trailing_comma/function_trailing_comma.ts | 37 ++ .../function_trailing_comma.ts.snap | 39 ++ .../specs/ts/module/export_clause.ts | 22 + .../specs/ts/module/export_clause.ts.snap | 22 + .../ts/module/external_module_reference.ts | 3 + .../module/external_module_reference.ts.snap | 3 + .../specs/ts/module/module_declaration.ts | 4 + .../ts/module/module_declaration.ts.snap | 3 + .../specs/ts/module/qualified_module_name.ts | 1 + .../ts/module/qualified_module_name.ts.snap | 1 + .../test_data/specs/ts/no-semi/class.ts | 51 ++ .../test_data/specs/ts/no-semi/class.ts.snap | 51 ++ .../test_data/specs/ts/no-semi/non-null.ts | 3 + .../specs/ts/no-semi/non-null.ts.snap | 3 + .../test_data/specs/ts/no-semi/statements.ts | 14 + .../specs/ts/no-semi/statements.ts.snap | 13 + .../test_data/specs/ts/no-semi/types.ts | 13 + .../test_data/specs/ts/no-semi/types.ts.snap | 17 + .../specs/ts/object/object_trailing_comma.ts | 22 + .../ts/object/object_trailing_comma.ts.snap | 21 + .../specs/ts/parameters/parameters.ts | 3 + .../specs/ts/parameters/parameters.ts.snap | 1 + .../test_data/specs/ts/parenthesis.ts | 3 + .../test_data/specs/ts/parenthesis.ts.snap | 3 + .../specs/ts/statement/empty_block.ts | 2 + .../specs/ts/statement/empty_block.ts.snap | 2 + .../specs/ts/statement/enum_statement.ts | 13 + .../specs/ts/statement/enum_statement.ts.snap | 17 + .../specs/ts/string/parameter_quotes.ts | 36 ++ .../specs/ts/string/parameter_quotes.ts.snap | 35 ++ .../test_data/specs/ts/suppressions.ts | 7 + .../test_data/specs/ts/suppressions.ts.snap | 6 + .../test_data/specs/ts/type/conditional.ts | 17 + .../specs/ts/type/conditional.ts.snap | 29 ++ .../test_data/specs/ts/type/import_type.ts | 6 + .../specs/ts/type/import_type.ts.snap | 5 + .../specs/ts/type/intersection_type.ts | 58 +++ .../specs/ts/type/intersection_type.ts.snap | 111 +++++ .../test_data/specs/ts/type/mapped_type.ts | 1 + .../specs/ts/type/mapped_type.ts.snap | 2 + .../test_data/specs/ts/type/qualified_name.ts | 1 + .../specs/ts/type/qualified_name.ts.snap | 1 + .../test_data/specs/ts/type/template_type.ts | 4 + .../specs/ts/type/template_type.ts.snap | 13 + .../trailing-comma/type_trailing_comma.ts | 12 + .../type_trailing_comma.ts.snap | 11 + .../test_data/specs/ts/type/union_type.ts | 246 ++++++++++ .../specs/ts/type/union_type.ts.snap | 328 +++++++++++++ crates/rome_fmt/test_data/specs/tsx/smoke.tsx | 1 + .../test_data/specs/tsx/smoke.tsx.snap | 1 + crates/rome_fmt/test_deno/deno.test.ts | 31 ++ crates/rome_fmt/test_node/test-node.mjs | 49 ++ rust-toolchain.toml | 3 + 399 files changed, 12148 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 .node-version create mode 100644 .rustfmt.toml create mode 100644 .taplo.toml create mode 100644 .vscode/settings.json create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 crates/rome_fmt/Cargo.toml create mode 100644 crates/rome_fmt/extra/.npmignore create mode 100644 crates/rome_fmt/extra/rome_fmt.d.ts create mode 100644 crates/rome_fmt/extra/vite.js create mode 100644 crates/rome_fmt/patch/rome_fmt.patch create mode 100755 crates/rome_fmt/scripts/build.sh create mode 100755 crates/rome_fmt/scripts/gen_patch.sh create mode 100755 crates/rome_fmt/scripts/package.mjs create mode 100644 crates/rome_fmt/src/config.rs create mode 100644 crates/rome_fmt/src/lib.rs create mode 100644 crates/rome_fmt/test_data/specs/.DS_Store create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/array_nested.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/array_nested.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/binding_pattern.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/binding_pattern.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/empty_lines.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/empty_lines.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/spaces.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/spaces.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/spread.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/spread.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/trailing-comma/array_trailing_comma.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/array/trailing-comma/array_trailing_comma.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow-comments.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow-comments.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow_chain_comments.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow_chain_comments.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow_function.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow_function.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow_nested.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow_nested.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow_test_callback.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/arrow_test_callback.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/call.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/call.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/currying.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/currying.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/params.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/arrow/params.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/assignment/array-assignment-holes.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/assignment/array-assignment-holes.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/assignment/assignment.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/assignment/assignment.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/assignment/assignment_ignore.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/assignment/assignment_ignore.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/binding/array-binding-holes.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/binding/array-binding-holes.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/binding/array_binding.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/binding/array_binding.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/binding/identifier_binding.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/binding/identifier_binding.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/binding/object_binding.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/binding/object_binding.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/call_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/call_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/class/class.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/class/class.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/class/class_comments.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/class/class_comments.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/class/private_method.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/class/private_method.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/comments.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/comments.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/declarations/variable_declaration.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/declarations/variable_declaration.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_members_call_decorator.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_members_call_decorator.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_members_mixed.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_members_mixed.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_members_simple.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_members_simple.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_simple.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_simple.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_simple_call_decorator.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/class_simple_call_decorator.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/export_default_1.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/export_default_1.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/export_default_2.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/export_default_2.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/export_default_3.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/export_default_3.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/export_default_4.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/export_default_4.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/multiline.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/decorators/multiline.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/each/each.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/each/each.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/class_clause.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/class_clause.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/expression_clause.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/expression_clause.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/from_clause.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/from_clause.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/function_clause.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/function_clause.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/named_clause.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/named_clause.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/named_from_clause.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/named_from_clause.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/trailing-comma/export_trailing_comma.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/trailing-comma/export_trailing_comma.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/variable_declaration.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/export/variable_declaration.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/binary_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/binary_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/binaryish_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/binaryish_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/computed-member-expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/computed-member-expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/conditional_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/conditional_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/import_meta_expression/import_meta_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/import_meta_expression/import_meta_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/literal_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/literal_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/logical_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/logical_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/member-chain/complex_arguments.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/member-chain/complex_arguments.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/member-chain/computed.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/member-chain/computed.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/member-chain/inline-merge.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/member-chain/inline-merge.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/new_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/new_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/post_update_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/post_update_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/pre_update_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/pre_update_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/sequence_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/sequence_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/static_member_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/static_member_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/this_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/this_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/unary_expression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/unary_expression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/unary_expression_verbatim_argument.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/expression/unary_expression_verbatim_argument.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/function/function.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/function/function.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/function/function_args.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/function/function_args.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/function/function_comments.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/function/function_comments.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/ident.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/ident.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/bare_import.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/bare_import.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/default_import.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/default_import.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/import_call.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/import_call.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/import_specifiers.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/import_specifiers.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/namespace_import.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/namespace_import.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/trailing-comma/import_trailing_comma.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/import/trailing-comma/import_trailing_comma.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/interpreter.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/interpreter.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/interpreter_with_empty_line.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/interpreter_with_empty_line.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/invalid/block_stmt_err.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/invalid/block_stmt_err.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/invalid/if_stmt_err.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/invalid/if_stmt_err.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/newlines.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/newlines.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/class.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/class.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/issue2006.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/issue2006.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/no-semi.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/no-semi.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/private-field.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/private-field.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/semicolons-asi.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/no-semi/semicolons-asi.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/number/number.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/number/number.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/number/number_with_space.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/number/number_with_space.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/computed_member.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/computed_member.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/getter_setter.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/getter_setter.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/object.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/object.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/object_comments.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/object_comments.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/octal_literals_key.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/octal_literals_key.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/property_key.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/property_key.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/property_object_member.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/property_object_member.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/trailing-comma/object_trailing_comma.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/object/trailing-comma/object_trailing_comma.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/parentheses/parentheses.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/parentheses/parentheses.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/prettier-differences/fill-array-comments.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/prettier-differences/fill-array-comments.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/script.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/script.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/block_statement.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/block_statement.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/do_while.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/do_while.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/empty_blocks.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/empty_blocks.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/for_in.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/for_in.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/for_loop.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/for_loop.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/for_of.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/for_of.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/if_chain.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/if_chain.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/if_else.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/if_else.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/return.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/return.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/return_verbatim_argument.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/return_verbatim_argument.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/statement.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/statement.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/switch.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/switch.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/throw.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/throw.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/try_catch_finally.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/try_catch_finally.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/while_loop.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/statement/while_loop.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/string/directives.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/string/directives.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/string/parentheses_token.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/string/parentheses_token.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/string/properties_quotes.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/string/properties_quotes.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/string/string.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/string/string.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/suppression.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/suppression.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/template/template.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/template/template.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/module/with.js create mode 100644 crates/rome_fmt/test_data/specs/js/module/with.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/script/script.js create mode 100644 crates/rome_fmt/test_data/specs/js/script/script.js.snap create mode 100644 crates/rome_fmt/test_data/specs/js/script/with.js create mode 100644 crates/rome_fmt/test_data/specs/js/script/with.js.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/arrow_function.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/arrow_function.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/attributes.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/attributes.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/comments.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/comments.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/conditional.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/conditional.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/element.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/element.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/fragment.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/fragment.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/new-lines.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/new-lines.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/quote_style/quote_style.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/quote_style/quote_style.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/self_closing.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/self_closing.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/jsx/smoke.jsx create mode 100644 crates/rome_fmt/test_data/specs/jsx/smoke.jsx.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/arrow/arrow_parentheses.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/arrow/arrow_parentheses.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/arrow_chain.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/arrow_chain.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/as_assignment.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/as_assignment.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/assignment.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/assignment.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/assignment_comments.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/assignment_comments.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/property_assignment_comments.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/property_assignment_comments.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/type_assertion_assignment.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/assignment/type_assertion_assignment.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/binding/definite_variable.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/binding/definite_variable.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/call_expression.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/call_expression.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/class/accessor.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/class/accessor.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/class/assigment_layout.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/class/assigment_layout.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/class/constructor_parameter.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/class/constructor_parameter.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/class/implements_clause.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/class/implements_clause.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/class/readonly_ambient_property.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/class/readonly_ambient_property.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/class/trailing_comma/class_trailing_comma.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/class/trailing_comma/class_trailing_comma.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/class.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/class.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/declare_function.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/declare_function.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/global_declaration.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/global_declaration.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/interface.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/interface.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/variable_declaration.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/declaration/variable_declaration.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/declare.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/declare.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/decoartors.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/decoartors.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/decorators/class_members.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/decorators/class_members.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/enum/enum_trailing_comma.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/enum/enum_trailing_comma.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/as_expression.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/as_expression.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/non_null_expression.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/non_null_expression.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/type_assertion_expression.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/type_assertion_expression.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/type_expression.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/type_expression.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/type_member.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/expression/type_member.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/function/parameters/function_parameters.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/function/parameters/function_parameters.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/function/trailing_comma/function_trailing_comma.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/function/trailing_comma/function_trailing_comma.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/module/export_clause.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/module/export_clause.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/module/external_module_reference.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/module/external_module_reference.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/module/module_declaration.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/module/module_declaration.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/module/qualified_module_name.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/module/qualified_module_name.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/no-semi/class.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/no-semi/class.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/no-semi/non-null.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/no-semi/non-null.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/no-semi/statements.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/no-semi/statements.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/no-semi/types.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/no-semi/types.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/object/object_trailing_comma.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/object/object_trailing_comma.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/parameters/parameters.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/parameters/parameters.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/parenthesis.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/parenthesis.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/statement/empty_block.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/statement/empty_block.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/statement/enum_statement.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/statement/enum_statement.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/string/parameter_quotes.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/string/parameter_quotes.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/suppressions.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/suppressions.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/type/conditional.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/type/conditional.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/type/import_type.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/type/import_type.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/type/intersection_type.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/type/intersection_type.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/type/mapped_type.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/type/mapped_type.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/type/qualified_name.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/type/qualified_name.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/type/template_type.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/type/template_type.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/type/trailing-comma/type_trailing_comma.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/type/trailing-comma/type_trailing_comma.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/ts/type/union_type.ts create mode 100644 crates/rome_fmt/test_data/specs/ts/type/union_type.ts.snap create mode 100644 crates/rome_fmt/test_data/specs/tsx/smoke.tsx create mode 100644 crates/rome_fmt/test_data/specs/tsx/smoke.tsx.snap create mode 100644 crates/rome_fmt/test_deno/deno.test.ts create mode 100644 crates/rome_fmt/test_node/test-node.mjs create mode 100644 rust-toolchain.toml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ae9dc7b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +# Check http://editorconfig.org for more information +# This is the main config file for this project: +root = true + +[*] +charset = utf-8 +indent_size = 4 +end_of_line = lf + +[*.{js,ts,mjs}] +indent_style = tab \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9ef9e96 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +# Auto detect text files and perform LF normalization +* text=auto +*.js linguist-detectable=false +*.mjs linguist-detectable=false diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..5913202 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,91 @@ +name: Publish + +on: + create: + tags: + - "v*" + +env: + CARGO_INCREMENTAL: 0 + RUST_LOG: "off" + +jobs: + publish-npm: + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Build wasm + run: ./crates/rome_fmt/scripts/build.sh + + - uses: actions/setup-node@v3 + with: + node-version-file: ".node-version" + registry-url: "https://registry.npmjs.org" + + - run: | + cd crates/rome_fmt/pkg + npm publish --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + publish-github: + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Build wasm + run: ./crates/rome_fmt/scripts/build.sh + + - uses: actions/setup-node@v3 + with: + node-version-file: ".node-version" + registry-url: "https://npm.pkg.github.com" + + - run: | + cd crates/rome_fmt/pkg + npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + publish-github-release: + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + targets: wasm32-unknown-unknown + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Build wasm + run: | + # build for JS API + ./crates/rome_fmt/scripts/build.sh + + - name: Package + run: cd crates/rome_fmt/pkg && npm pack + + - name: Release + uses: softprops/action-gh-release@c9b46fe7aad9f02afd89b12450b780f52dacfb2d + with: + files: | + crates/rome_fmt/pkg/wasm-fmt-rome_fmt-*.tgz diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..882e39b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,78 @@ +name: Test + +on: [push, pull_request] + +env: + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: "always" + DIFF: 0 + RUST_LOG: "off" + +jobs: + cargo-fmt: + name: Cargo fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - run: cargo fmt -- --check + + cargo-clippy: + name: Cargo clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + + - run: cargo clippy + + cargo-test: + name: Cargo test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + + - run: cargo check + - run: cargo test + + wasm-test: + name: Wasm test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Build wasm + run: ./crates/rome_fmt/scripts/build.sh + + - uses: actions/setup-node@v3 + with: + node-version-file: ".node-version" + + - name: Node Test + run: node --test + + - uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Deno Test + run: deno test --allow-read + + - name: Package + run: cd crates/rome_fmt/pkg && npm pack + + - name: Upload + uses: actions/upload-artifact@v3 + with: + name: npm + path: crates/rome_fmt/pkg/wasm-fmt-rome_fmt-*.tgz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4fffb2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +/Cargo.lock diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..860cc50 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +v18.17.1 diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..79d45d8 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,16 @@ +# group_imports = "StdExternalCrate" +# imports_granularity = "Crate" +reorder_imports = true +use_small_heuristics = "Max" + +# normalize_comments = true +# wrap_comments = true + +# condense_wildcard_suffixes = true +# enum_discrim_align_threshold = 20 +# reorder_impl_items = true +use_field_init_shorthand = true + +# format_code_in_doc_comments = true +# format_macro_matchers = true +# format_strings = true diff --git a/.taplo.toml b/.taplo.toml new file mode 100644 index 0000000..6bd021d --- /dev/null +++ b/.taplo.toml @@ -0,0 +1,5 @@ +# https://taplo.tamasfe.dev/configuration/formatter-options.html +[formatting] +align_entries = true +indent_tables = true +reorder_keys = true diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..41744f2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "deno.enable": true, + "deno.enablePaths": [ + "./crates/rome_fmt/test_deno" + ] +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..9b3f2e4 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,36 @@ +[workspace] +members = ["crates/*"] +resolver = "2" + + [workspace.package] + authors = ["magic-akari "] + description = "JavaScript/TypeScript formatter powered by wasm ported from Rome" + edition = "2021" + homepage = "https://github.com/wasm-fmt/rome_fmt" + keywords = [ + "wasm", + "JavaScript", + "TypeScript", + "JSX", + "TSX", + "formatter", + "Rome", + ] + license = "MIT" + readme = "README.md" + repository = "https://github.com/wasm-fmt/rome_fmt" + version = "0.0.0" + + + [workspace.dependencies] + rome_formatter = { version = "0.0.1" } + rome_js_formatter = { version = "0.0.2" } + rome_js_parser = { version = "0.0.1" } + rome_js_syntax = { version = "0.0.1" } + serde = { version = "1.0" } + serde_json = { version = "1.0" } + wasm-bindgen = "0.2.87" + +[profile.release] +lto = true +opt-level = "s" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..132bba0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 wasm-fmt + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/crates/rome_fmt/Cargo.toml b/crates/rome_fmt/Cargo.toml new file mode 100644 index 0000000..2da8619 --- /dev/null +++ b/crates/rome_fmt/Cargo.toml @@ -0,0 +1,27 @@ +[package] +authors.workspace = true +description.workspace = true +edition.workspace = true +homepage.workspace = true +keywords.workspace = true +license.workspace = true +name = "rome_fmt" +publish = true +repository.workspace = true +version.workspace = true + +[dependencies] +rome_formatter = { workspace = true } +rome_js_formatter = { workspace = true } +rome_js_parser = { workspace = true } +rome_js_syntax = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde-wasm-bindgen = "0.5" +serde_json = { workspace = true, features = ["preserve_order"] } +wasm-bindgen = { workspace = true } + +[dev-dependencies] +testing_macros = "0.2.11" + +[lib] +crate-type = ["cdylib", "rlib"] diff --git a/crates/rome_fmt/extra/.npmignore b/crates/rome_fmt/extra/.npmignore new file mode 100644 index 0000000..604248a --- /dev/null +++ b/crates/rome_fmt/extra/.npmignore @@ -0,0 +1,2 @@ +*.bak +*.tgz diff --git a/crates/rome_fmt/extra/rome_fmt.d.ts b/crates/rome_fmt/extra/rome_fmt.d.ts new file mode 100644 index 0000000..3af45cb --- /dev/null +++ b/crates/rome_fmt/extra/rome_fmt.d.ts @@ -0,0 +1,32 @@ +export * from "./_rome_fmt.js"; + +export type Filename = + | "file.js" + | "file.mjs" + | "file.cjs" + | "file.ts" + | "file.mts" + | "file.cts" + | "file.jsx" + | "file.mjsx" + | "file.cjsx" + | "file.tsx" + | "file.mtsx" + | "file.ctsx" + | "file.d.ts" + | "file.d.mts" + | "file.d.cts" + | "file.d.mtsx" + | "file.d.ctsx" + | (string & {}); + +import init, { type Config } from "./_rome_fmt.js"; +export default init; + +/** + * @param {string} src - The content to format. + * @param {string} filename - The filename to use for determining the language. + * @param {Config} config - The Config to use for formatting. + * @returns {string} The formatted content. + */ +export function format(src: string, filename?: Filename, config?: Config): string; diff --git a/crates/rome_fmt/extra/vite.js b/crates/rome_fmt/extra/vite.js new file mode 100644 index 0000000..c77e2c5 --- /dev/null +++ b/crates/rome_fmt/extra/vite.js @@ -0,0 +1,8 @@ +import init from "./rome_fmt.js"; +import wasm from "./rome_fmt_bg.wasm?url"; + +export default function __wbg_init(input = wasm) { + return init(input); +} + +export * from "./rome_fmt.js"; \ No newline at end of file diff --git a/crates/rome_fmt/patch/rome_fmt.patch b/crates/rome_fmt/patch/rome_fmt.patch new file mode 100644 index 0000000..66b1e64 --- /dev/null +++ b/crates/rome_fmt/patch/rome_fmt.patch @@ -0,0 +1,33 @@ +diff --git a/crates/rome_fmt/pkg/rome_fmt.js b/crates/rome_fmt/pkg/rome_fmt.js +index 1d29ee1..71c2a12 100644 +--- a/crates/rome_fmt/pkg/rome_fmt.js ++++ b/crates/rome_fmt/pkg/rome_fmt.js +@@ -211,7 +211,7 @@ function addBorrowedObject(obj) { + * @param {Config} config + * @returns {string} + */ +-export function format(src, filename, config) { ++export function format(src, filename = "file.tsx", config = {}) { + let deferred4_0; + let deferred4_1; + try { +@@ -512,8 +512,17 @@ async function __wbg_init(input) { + } + const imports = __wbg_get_imports(); + +- if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) { +- input = fetch(input); ++ switch (true) { ++ case typeof input === 'string': ++ input = new URL(input, import.meta.url); ++ case input instanceof URL: ++ if (typeof __webpack_require__ !== 'function' && input.protocol === 'file:') { ++ const fs = await import('node:fs/promises'); ++ input = fs.readFile(input); ++ break; ++ } ++ case typeof Request === 'function' && input instanceof Request: ++ input = fetch(input); + } + + __wbg_init_memory(imports); diff --git a/crates/rome_fmt/scripts/build.sh b/crates/rome_fmt/scripts/build.sh new file mode 100755 index 0000000..ae177fd --- /dev/null +++ b/crates/rome_fmt/scripts/build.sh @@ -0,0 +1,17 @@ +cd $(dirname $0)/.. +crates_dir=$(pwd) + +cd ../.. +wasm-pack build --target=web --scope=wasm-fmt crates/rome_fmt +cp README.md LICENSE crates/rome_fmt/pkg/ + +cd $crates_dir +# backup rome_fmt.js +cp ./pkg/rome_fmt.js ./pkg/rome_fmt.js.bak + +git apply ./patch/rome_fmt.patch + +mv ./pkg/rome_fmt.d.ts ./pkg/_rome_fmt.d.ts +cp -R ./extra/. ./pkg/ + +./scripts/package.mjs ./pkg/package.json diff --git a/crates/rome_fmt/scripts/gen_patch.sh b/crates/rome_fmt/scripts/gen_patch.sh new file mode 100755 index 0000000..f51ea60 --- /dev/null +++ b/crates/rome_fmt/scripts/gen_patch.sh @@ -0,0 +1,29 @@ +# assert current dir is crates/rome_fmt +cd $(dirname $0)/.. +crates_dir=$(pwd) + +cd ./pkg +pkg_prefix=$(git rev-parse --show-prefix) + +tmp_dir=$(mktemp -d) + +cd $tmp_dir +git init + +cp $crates_dir/pkg/rome_fmt.js.bak $tmp_dir/rome_fmt.js +git add -f . +git commit -m "init" + +cp $crates_dir/pkg/rome_fmt.js $tmp_dir/rome_fmt.js +git add -f . + +git diff \ + --cached \ + --no-color \ + --ignore-space-at-eol \ + --no-ext-diff \ + --src-prefix=a/$pkg_prefix \ + --dst-prefix=b/$pkg_prefix \ + >$crates_dir/patch/rome_fmt.patch + +rm -rf $tmp_dir diff --git a/crates/rome_fmt/scripts/package.mjs b/crates/rome_fmt/scripts/package.mjs new file mode 100755 index 0000000..ad28000 --- /dev/null +++ b/crates/rome_fmt/scripts/package.mjs @@ -0,0 +1,30 @@ +#!/usr/bin/env node +import process from "node:process"; +import path from "node:path"; +import fs from "node:fs"; + +const pkg_path = path.resolve(process.cwd(), process.argv[2]); +const pkg_text = fs.readFileSync(pkg_path, { encoding: "utf-8" }); +const pkg_json = JSON.parse(pkg_text); + +delete pkg_json.files; + +pkg_json.main = pkg_json.module; +pkg_json.type = "module"; +pkg_json.publishConfig = { + access: "public", +}; +pkg_json.exports = { + ".": { + types: "./rome_fmt.d.ts", + default: "./rome_fmt.js", + }, + "./vite": { + types: "./rome_fmt.d.ts", + default: "./vite.js", + }, + "./package.json": "./package.json", + "./*": "./*", +}; + +fs.writeFileSync(pkg_path, JSON.stringify(pkg_json, null, 4)); diff --git a/crates/rome_fmt/src/config.rs b/crates/rome_fmt/src/config.rs new file mode 100644 index 0000000..15af6a2 --- /dev/null +++ b/crates/rome_fmt/src/config.rs @@ -0,0 +1,132 @@ +use std::borrow::Cow; + +use rome_formatter::{IndentStyle as RomeIndentStyle, LineWidthFromIntError}; +use rome_js_formatter::context::JsFormatOptions; +use rome_js_syntax::SourceType; +use serde::{ + de::{Error, Unexpected}, + Deserialize, Deserializer, +}; +use wasm_bindgen::prelude::wasm_bindgen; + +#[wasm_bindgen(typescript_custom_section)] +const TS_Config: &'static str = r#" +export interface Config { + indent_style?: "tab" | number; + line_width?: number; + quote_style?: "single" | "double"; + quote_properties?: "as-needed" | "preserve"; + trailing_comma?: "es5" | "all" | "none"; + semicolons?: "as-needed" | "always"; +}"#; + +#[derive(Deserialize)] +#[serde(rename_all = "snake_case")] +pub(crate) struct Config { + /// The indent style. + indent_style: Option, + + /// What's the max width of a line. Defaults to 80. + line_width: Option, + + /// The style for quotes. Defaults to double. + quote_style: Option, + + /// When properties in objects are quoted. Defaults to as-needed. + quote_properties: Option, + + /// Print trailing commas wherever possible in multi-line comma-separated syntactic structures. Defaults to "all". + trailing_comma: Option, + + /// Whether the formatter prints semicolons for all statements, class members, and type members or only when necessary because of [ASI](https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#sec-automatic-semicolon-insertion). + semicolons: Option, + + #[serde(skip)] + source_type: Option, +} + +impl Config { + pub fn with_source_type(mut self, source_type: SourceType) -> Self { + self.source_type = Some(source_type); + self + } +} + +impl TryFrom for JsFormatOptions { + type Error = String; + + fn try_from(value: Config) -> Result { + let source_type = value.source_type.expect("source_type is required"); + + let mut option = JsFormatOptions::new(source_type); + + if let Some(indent_style) = value.indent_style { + let indent_style = match indent_style { + IndentStyle::Tab => RomeIndentStyle::Tab, + IndentStyle::Space(size) => RomeIndentStyle::Space(size), + }; + + option = option.with_indent_style(indent_style); + }; + + if let Some(line_width) = value.line_width { + let line_width = + line_width.try_into().map_err(|e: LineWidthFromIntError| e.to_string())?; + + option = option.with_line_width(line_width); + }; + + if let Some(quote_style) = value.quote_style { + let quote_style = quote_style.parse()?; + + option = option.with_quote_style(quote_style); + }; + + if let Some(quote_properties) = value.quote_properties { + let quote_properties = quote_properties.parse()?; + + option = option.with_quote_properties(quote_properties); + }; + + if let Some(trailing_comma) = value.trailing_comma { + let trailing_comma = trailing_comma.parse()?; + + option = option.with_trailing_comma(trailing_comma); + }; + + if let Some(semicolons) = value.semicolons { + let semicolons = semicolons.parse()?; + + option = option.with_semicolons(semicolons); + }; + + Ok(option) + } +} + +enum IndentStyle { + Tab, + Space(u8), +} + +impl<'de> Deserialize<'de> for IndentStyle { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + #[derive(Deserialize)] + #[serde(untagged)] + enum IndentStyle<'a> { + Tab(Cow<'a, str>), + Space(u8), + } + + match IndentStyle::deserialize(deserializer)? { + IndentStyle::Space(n) => Ok(Self::Space(n)), + IndentStyle::Tab(c) if c == "tab" => Ok(Self::Tab), + IndentStyle::Tab(other) => { + Err(D::Error::invalid_value(Unexpected::Str(&other), &" or `tab`")) + } + } + } +} diff --git a/crates/rome_fmt/src/lib.rs b/crates/rome_fmt/src/lib.rs new file mode 100644 index 0000000..9d60cf1 --- /dev/null +++ b/crates/rome_fmt/src/lib.rs @@ -0,0 +1,58 @@ +mod config; + +use std::path::Path; + +use rome_js_formatter::format_node; +use rome_js_parser::parse; +use rome_js_syntax::{ModuleKind, SourceType}; + +use wasm_bindgen::prelude::*; + +use crate::config::Config as InnerConfig; + +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(typescript_type = "Config")] + pub type Config; +} + +#[wasm_bindgen(skip_typescript)] +pub fn format(src: &str, filename: &str, config: &Config) -> Result { + let config: &JsValue = config.as_ref(); + let config: InnerConfig = + serde_wasm_bindgen::from_value(config.clone()).map_err(|op| op.to_string())?; + + let syntax = source_type_from_filename(filename); + + let tree = parse(src, syntax); + + let option = config.with_source_type(syntax).try_into()?; + + format_node(option, &tree.syntax()) + .map_err(|e| e.to_string())? + .print() + .map(|p| p.into_code()) + .map_err(|e| e.to_string()) +} + +fn source_type_from_filename(filename: &str) -> SourceType { + if filename.ends_with(".d.ts") + || filename.ends_with(".d.mts") + || filename.ends_with(".d.cts") + || filename.ends_with(".d.mtsx") + || filename.ends_with(".d.ctsx") + { + return SourceType::d_ts(); + } + + let Some(ext) = Path::new(filename).extension().and_then(|ext| ext.to_str()) else { + return SourceType::tsx(); + }; + + match ext { + "ts" | "mts" | "cts" => SourceType::ts(), + "js" | "mjs" | "jsx" => SourceType::jsx(), + "cjs" | "cjsx" => SourceType::jsx().with_module_kind(ModuleKind::Script), + _ => SourceType::tsx(), + } +} diff --git a/crates/rome_fmt/test_data/specs/.DS_Store b/crates/rome_fmt/test_data/specs/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..fd1e596d764a6235be22621ca9fb5b3a10958c0e GIT binary patch literal 6148 zcmeHKOG*SW5UtVy8{Ev&jgTuecz~XvJwabU#t{`}=w=xAIg|%*;l>Mi25%s^^3}(N z#t3c{k*Xo}Dyga@{a}(55%KbFT@%fTs6rEDF$yBXMc07`&w#9R?CF-SXt%kpyTU|& zaY*)F(Lg)wdyn6^|I2^7NwYN-?pnwzY^c;+u8He%i|Yu>u<#kH+46zdHUl)v;mdU?3O>21W+td`M`5jbk>{qXSAy0H8dhRbWdkAvwvh zamd0gX|4K1D6ix2jdKZ+OD)iHn4aN@==bTAMMOc^+|?p*Hw zbNpqBMgBA;dci<2@Xr|FS=+Tse3ajE literal 0 HcmV?d00001 diff --git a/crates/rome_fmt/test_data/specs/js/module/array/array_nested.js b/crates/rome_fmt/test_data/specs/js/module/array/array_nested.js new file mode 100644 index 0000000..3b77160 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/array_nested.js @@ -0,0 +1,41 @@ +let a = [[]]; +let b = [[], []]; +let c = [[], [], []]; +let d = [[], [0], []]; +let e = [[], [0], [0]]; +let f = [[], [0, 1], [0]]; +let g = [[], [0, 1], [0, 1]]; +let h = [[0]]; +let i = [[0], []]; +let j = [[0], [], []]; +let k = [[0], [0], []]; +let l = [[0], [0], [0]]; +let m = [[0], [0, 1], [0]]; +let n = [[0], [0, 1], [0, 1]]; +let o = [[0, 1]]; +let p = [[0, 1], []]; +let q = [[0, 1], [], []]; +let r = [[0, 1], [0], []]; +let s = [[0, 1], [0], [0]]; +let t = [[0, 1], [0, 1], [0]]; +let u = [[0, 1], [0, 1], [0, 1]]; +let v = [[], [1, 2, 3]]; +let w = [[1], [1]]; +let x = [[1, 2], [1, 2, 3]]; +let y = [[1, 0], [1, 0]]; +let z = [{}]; +let a1 = [{}, {}]; +let b1 = [{}, {}, {}]; +let c1 = [{}, { a }]; +let d1 = [{}, { a, b }]; +let e1 = [{}, { a, b, c }]; +let f1 = [{ a }]; +let g1 = [{ a }, { a }]; +let h1 = [{ a }, { a }, { a }]; +let i1 = [{ a }, { a, b }]; +let j1 = [{ a }, { a, b, c}]; +let k1 = [{ a, b }]; +let l1 = [{ a, b }, { a }]; +let m1 = [{ a, b }, { a }, { a }]; +let n1 = [{ a, b }, { a, b }]; +let o1 = [{ a, b }, { a, b, c }]; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/array_nested.js.snap b/crates/rome_fmt/test_data/specs/js/module/array/array_nested.js.snap new file mode 100644 index 0000000..27775fe --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/array_nested.js.snap @@ -0,0 +1,57 @@ +let a = [[]]; +let b = [[], []]; +let c = [[], [], []]; +let d = [[], [0], []]; +let e = [[], [0], [0]]; +let f = [[], [0, 1], [0]]; +let g = [[], [0, 1], [0, 1]]; +let h = [[0]]; +let i = [[0], []]; +let j = [[0], [], []]; +let k = [[0], [0], []]; +let l = [[0], [0], [0]]; +let m = [[0], [0, 1], [0]]; +let n = [[0], [0, 1], [0, 1]]; +let o = [[0, 1]]; +let p = [[0, 1], []]; +let q = [[0, 1], [], []]; +let r = [[0, 1], [0], []]; +let s = [[0, 1], [0], [0]]; +let t = [[0, 1], [0, 1], [0]]; +let u = [ + [0, 1], + [0, 1], + [0, 1], +]; +let v = [[], [1, 2, 3]]; +let w = [[1], [1]]; +let x = [ + [1, 2], + [1, 2, 3], +]; +let y = [ + [1, 0], + [1, 0], +]; +let z = [{}]; +let a1 = [{}, {}]; +let b1 = [{}, {}, {}]; +let c1 = [{}, { a }]; +let d1 = [{}, { a, b }]; +let e1 = [{}, { a, b, c }]; +let f1 = [{ a }]; +let g1 = [{ a }, { a }]; +let h1 = [{ a }, { a }, { a }]; +let i1 = [{ a }, { a, b }]; +let j1 = [{ a }, { a, b, c }]; +let k1 = [{ a, b }]; +let l1 = [{ a, b }, { a }]; +let m1 = [{ a, b }, { a }, { a }]; +let n1 = [ + { a, b }, + { a, b }, +]; +let o1 = [ + { a, b }, + { a, b, c }, +]; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/binding_pattern.js b/crates/rome_fmt/test_data/specs/js/module/array/binding_pattern.js new file mode 100644 index 0000000..db91112 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/binding_pattern.js @@ -0,0 +1,3 @@ +let [a,b]=c; +let [d,...e]=c; +let [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,...cccccccccccccccccccccccccccccc]=f; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/binding_pattern.js.snap b/crates/rome_fmt/test_data/specs/js/module/array/binding_pattern.js.snap new file mode 100644 index 0000000..3270fcb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/binding_pattern.js.snap @@ -0,0 +1,7 @@ +let [a, b] = c; +let [d, ...e] = c; +let [ + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + ...cccccccccccccccccccccccccccccc +] = f; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/empty_lines.js b/crates/rome_fmt/test_data/specs/js/module/array/empty_lines.js new file mode 100644 index 0000000..8d3cc1b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/empty_lines.js @@ -0,0 +1,12 @@ +let a = [ + + 1, + 2, + + 3, + + + 4, + + + ]; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/empty_lines.js.snap b/crates/rome_fmt/test_data/specs/js/module/array/empty_lines.js.snap new file mode 100644 index 0000000..ec8b986 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/empty_lines.js.snap @@ -0,0 +1,7 @@ +let a = [ + 1, 2, + + 3, + + 4, +]; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/spaces.js b/crates/rome_fmt/test_data/specs/js/module/array/spaces.js new file mode 100644 index 0000000..1d8d5cb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/spaces.js @@ -0,0 +1,5 @@ +let a = [,]; +let b = [,,]; +let c = [,,1,]; +let d = [,,1,1]; +let e = [2,2,1,3]; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/spaces.js.snap b/crates/rome_fmt/test_data/specs/js/module/array/spaces.js.snap new file mode 100644 index 0000000..04629da --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/spaces.js.snap @@ -0,0 +1,5 @@ +let a = [,]; +let b = [, ,]; +let c = [, , 1]; +let d = [, , 1, 1]; +let e = [2, 2, 1, 3]; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/spread.js b/crates/rome_fmt/test_data/specs/js/module/array/spread.js new file mode 100644 index 0000000..1c2e5ef --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/spread.js @@ -0,0 +1,5 @@ +let a = [...a, ...b,]; +let b = [...a, ...b]; +[...a] +let a = [...baaaaaaaaaaaaaaaaaaaaaaaaaaaaa,...bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,...cccccccccccccccccccccccccccccc] + diff --git a/crates/rome_fmt/test_data/specs/js/module/array/spread.js.snap b/crates/rome_fmt/test_data/specs/js/module/array/spread.js.snap new file mode 100644 index 0000000..9046f32 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/spread.js.snap @@ -0,0 +1,8 @@ +let a = [...a, ...b]; +let b = [...a, ...b]; +[...a]; +let a = [ + ...baaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + ...bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + ...cccccccccccccccccccccccccccccc, +]; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/trailing-comma/array_trailing_comma.js b/crates/rome_fmt/test_data/specs/js/module/array/trailing-comma/array_trailing_comma.js new file mode 100644 index 0000000..ba4b87d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/trailing-comma/array_trailing_comma.js @@ -0,0 +1,10 @@ +const a = [ + longlonglonglongItem1longlonglonglongItem1, + longlonglonglongItem1longlonglonglongItem2, + longlonglonglongItem1longlonglonglongItem3, +]; + +// destructuring +[ adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd,] = [1, 2, 10]; diff --git a/crates/rome_fmt/test_data/specs/js/module/array/trailing-comma/array_trailing_comma.js.snap b/crates/rome_fmt/test_data/specs/js/module/array/trailing-comma/array_trailing_comma.js.snap new file mode 100644 index 0000000..83417f8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/array/trailing-comma/array_trailing_comma.js.snap @@ -0,0 +1,12 @@ +const a = [ + longlonglonglongItem1longlonglonglongItem1, + longlonglonglongItem1longlonglonglongItem2, + longlonglonglongItem1longlonglonglongItem3, +]; + +// destructuring +[ + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +] = [1, 2, 10]; diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow-comments.js b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow-comments.js new file mode 100644 index 0000000..38a3d75 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow-comments.js @@ -0,0 +1,21 @@ +// array +(action) => + // eslint-disable-next-line react/no-array-index-key + [
  • ]; + +// function body +(action) => + // eslint-disable-next-line react/no-array-index-key +{ + return
  • ; +} + +// object expression +(action) => + // eslint-disable-next-line react/no-array-index-key + ({ a: 10 + }); + + (action) => /* comment */ ` +${test} +multiline`; diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow-comments.js.snap b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow-comments.js.snap new file mode 100644 index 0000000..e4f4d20 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow-comments.js.snap @@ -0,0 +1,20 @@ +// array +(action) => + // eslint-disable-next-line react/no-array-index-key + [
  • ]; + +// function body +(action) => + // eslint-disable-next-line react/no-array-index-key + { + return
  • ; + }; + +// object expression +(action) => + // eslint-disable-next-line react/no-array-index-key + ({ a: 10 }); + +(action) => /* comment */ ` +${test} +multiline`; diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_chain_comments.js b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_chain_comments.js new file mode 100644 index 0000000..f1832c2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_chain_comments.js @@ -0,0 +1,9 @@ +x = (bifornCringerMoshedPerplexSawder) => ((askTrovenaBeenaDependsRowans, glimseGlyphsHazardNoopsTieTie) => (f00) => { + averredBathersBoxroomBuggyNurl(); + } // BOOM +) + +x2 = (a) => ((askTrovenaBeenaDependsRowans1, askTrovenaBeenaDependsRowans2, askTrovenaBeenaDependsRowans3) => { + c(); + } /* ! */ // KABOOM +) diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_chain_comments.js.snap b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_chain_comments.js.snap new file mode 100644 index 0000000..3b3359b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_chain_comments.js.snap @@ -0,0 +1,16 @@ +x = + (bifornCringerMoshedPerplexSawder) => + (askTrovenaBeenaDependsRowans, glimseGlyphsHazardNoopsTieTie) => + (f00) => { + averredBathersBoxroomBuggyNurl(); + }; // BOOM + +x2 = + (a) => + ( + askTrovenaBeenaDependsRowans1, + askTrovenaBeenaDependsRowans2, + askTrovenaBeenaDependsRowans3, + ) => { + c(); + } /* ! */; // KABOOM diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_function.js b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_function.js new file mode 100644 index 0000000..4370537 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_function.js @@ -0,0 +1,7 @@ +() => {} +async () => {} +(foo) => {} +(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,ccccccccccccccccccccccccccccc) => {} + + +() => (1,3,4); \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_function.js.snap b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_function.js.snap new file mode 100644 index 0000000..0caf784 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_function.js.snap @@ -0,0 +1,10 @@ +() => {}; +async () => {}; +(foo) => {}; +( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + ccccccccccccccccccccccccccccc, +) => {}; + +() => (1, 3, 4); diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_nested.js b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_nested.js new file mode 100644 index 0000000..08af6bd --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_nested.js @@ -0,0 +1,27 @@ +Seq(typeDef.interface.groups).forEach(group => + Seq(group.members).forEach((member, memberName) => + markdownDoc( + member.doc, + { typePath: typePath.concat(memberName.slice(1)), + signatures: member.signatures } + ) + ) +) + +const promiseFromCallback = fn => + new Promise((resolve, reject) => + fn((err, result) => { + if (err) return reject(err); + return resolve(result); + }) + ); + +runtimeAgent.getProperties( + objectId, + false, // ownProperties + false, // accessorPropertiesOnly + false, // generatePreview + (error, properties, internalProperties) => { + return 1 + }, +); diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_nested.js.snap b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_nested.js.snap new file mode 100644 index 0000000..c0a85d2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_nested.js.snap @@ -0,0 +1,26 @@ +Seq(typeDef.interface.groups).forEach((group) => + Seq(group.members).forEach((member, memberName) => + markdownDoc(member.doc, { + typePath: typePath.concat(memberName.slice(1)), + signatures: member.signatures, + }), + ), +); + +const promiseFromCallback = (fn) => + new Promise((resolve, reject) => + fn((err, result) => { + if (err) return reject(err); + return resolve(result); + }), + ); + +runtimeAgent.getProperties( + objectId, + false, // ownProperties + false, // accessorPropertiesOnly + false, // generatePreview + (error, properties, internalProperties) => { + return 1; + }, +); diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_test_callback.js b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_test_callback.js new file mode 100644 index 0000000..ce3698e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_test_callback.js @@ -0,0 +1,4 @@ +it('should have the default duration when using the onClose arguments', done => { + expect(true); + done(); +}); diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_test_callback.js.snap b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_test_callback.js.snap new file mode 100644 index 0000000..447104f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/arrow_test_callback.js.snap @@ -0,0 +1,4 @@ +it("should have the default duration when using the onClose arguments", (done) => { + expect(true); + done(); +}); diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/call.js b/crates/rome_fmt/test_data/specs/js/module/arrow/call.js new file mode 100644 index 0000000..32ddfba --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/call.js @@ -0,0 +1,44 @@ +const testResults = results.testResults.map(testResult => + formatResult(testResult, formatter, reporter) + ); + +it('mocks regexp instances', () => { + expect( + // () => moduleMocker.generateFromMetadata(moduleMocker.getMetadata(/a/)), + ).not.toThrow(); +}); + +expect(() => asyncRequest({ url: "/test-endpoint" })) + // .toThrowError(/Required parameter/); + +expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-long-url" })) + // .toThrowError(/Required parameter/); + +expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-suuuuuuuuper-long-url" })) + // .toThrowError(/Required parameter/); + +expect(() => asyncRequest({ type: "foo", url: "/test-endpoint" })) + .not.toThrowError(); + +expect(() => asyncRequest({ type: "foo", url: "/test-endpoint-but-with-a-long-url" })) + .not.toThrowError(); + +const a = Observable + .fromPromise(axiosInstance.post('/carts/mine')) + .map((response) => response.data) + +const b = Observable.fromPromise(axiosInstance.get(url)) + .map((response) => response.data) + +func( + veryLoooooooooooooooooooooooongName, + veryLooooooooooooooooooooooooongName => + veryLoooooooooooooooongName.something() +); + +const composition = (ViewComponent, ContainerComponent) => + class extends React.Component { + static propTypes = {}; + }; + +romise.then(result => result.veryLongVariable.veryLongPropertyName > someOtherVariable ? "ok" : "fail"); diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/call.js.snap b/crates/rome_fmt/test_data/specs/js/module/arrow/call.js.snap new file mode 100644 index 0000000..b4f1b17 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/call.js.snap @@ -0,0 +1,53 @@ +const testResults = results.testResults.map((testResult) => + formatResult(testResult, formatter, reporter), +); + +it("mocks regexp instances", () => { + expect( + // () => moduleMocker.generateFromMetadata(moduleMocker.getMetadata(/a/)), + ).not.toThrow(); +}); + +expect(() => asyncRequest({ url: "/test-endpoint" })); +// .toThrowError(/Required parameter/); + +expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-long-url" })); +// .toThrowError(/Required parameter/); + +expect(() => + asyncRequest({ url: "/test-endpoint-but-with-a-suuuuuuuuper-long-url" }), +); +// .toThrowError(/Required parameter/); + +expect(() => + asyncRequest({ type: "foo", url: "/test-endpoint" }), +).not.toThrowError(); + +expect(() => + asyncRequest({ type: "foo", url: "/test-endpoint-but-with-a-long-url" }), +).not.toThrowError(); + +const a = Observable.fromPromise(axiosInstance.post("/carts/mine")).map( + (response) => response.data, +); + +const b = Observable.fromPromise(axiosInstance.get(url)).map( + (response) => response.data, +); + +func( + veryLoooooooooooooooooooooooongName, + (veryLooooooooooooooooooooooooongName) => + veryLoooooooooooooooongName.something(), +); + +const composition = (ViewComponent, ContainerComponent) => + class extends React.Component { + static propTypes = {}; + }; + +romise.then((result) => + result.veryLongVariable.veryLongPropertyName > someOtherVariable + ? "ok" + : "fail", +); diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/currying.js b/crates/rome_fmt/test_data/specs/js/module/arrow/currying.js new file mode 100644 index 0000000..1e3b36d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/currying.js @@ -0,0 +1,17 @@ +const fn = b => c => d => { + return 3; +}; + +const foo = (a, b) => c => d => { + return 3; +}; + +const bar = a => b => c => a + b + c + +const mw = store => next => action => { + return next(action) +} + +const middleware = options => (req, res, next) => { + // ... +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/currying.js.snap b/crates/rome_fmt/test_data/specs/js/module/arrow/currying.js.snap new file mode 100644 index 0000000..69f7eff --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/currying.js.snap @@ -0,0 +1,17 @@ +const fn = (b) => (c) => (d) => { + return 3; +}; + +const foo = (a, b) => (c) => (d) => { + return 3; +}; + +const bar = (a) => (b) => (c) => a + b + c; + +const mw = (store) => (next) => (action) => { + return next(action); +}; + +const middleware = (options) => (req, res, next) => { + // ... +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/params.js b/crates/rome_fmt/test_data/specs/js/module/arrow/params.js new file mode 100644 index 0000000..5d3458d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/params.js @@ -0,0 +1,321 @@ +fooooooooooooooooooooooooooooooooooooooooooooooooooo(action => next => + dispatch(action), +); + +foo( + ({ + a, + + b + }) => {} +); + +foo( + ({ + a, + b + + }) => {} +); + +foo( + ({ + a, + b + }) => {} +); + +foo( + a, + ({ + a, + + b + }) => {} +) + +foo( + ({ + a, + + b + }) => a +); + +foo( + ({ + a, + b + }) => a +); + +foo( + ({ + a, + b + + }) => a +); + +foo( + ({ + a: { + a, + + b + } + }) => {} +); + +foo( + ({ + a: { + b: { + c, + + d + } + } + }) => {} +); + +foo( + ({ + a: { + b: { + c: { + d, + + e + } + } + } + }) => {} +); + +foo( + ({ + a: { + a, + + b + } + }) => a +); + +foo( + ({ + a: { + b: { + c, + + d + } + } + }) => a +); + +foo( + ({ + a: { + b: { + c: { + d, + + e + } + } + } + }) => a +); + +foo( + ([ + { + a: { + b: { + c: { + d, + + e + } + } + } + } + ]) => {} +); + +foo( + ([ + ...{ + a: { + b: { + c: { + d, + + e + } + } + } + } + ]) => {} +); + +foo( + ( + n = { + a: { + b: { + c: { + d, + + e + } + } + } + } + ) => {} +); + +foo( + ({ + x: [ + { + a, + + b + } + ] + }) => {} +); + +foo( + ( + a = [ + { + a, + + b + } + ] + ) => a +); + +foo( + ([ + [ + { + a, + + b + } + ] + ]) => {} +); + +foo( + ([ + [ + [ + [ + { + a, + b: { + c, + d: { + e, + + f + } + } + } + ] + ] + ] + ]) => {} +); + +foo( + ( + ...{ + a, + + b + } + ) => {} +); + +foo( + ( + ...[ + { + a, + + b + } + ] + ) => {} +); + +foo( + ([ + ...[ + { + a, + + b + } + ] + ]) => {} +); + +foo( + ( + a = [{ + a, + + b + }] + ) => {} +); + +foo( + ( + a = (({ + a, + + b + }) => {})() + ) => {} +); + +foo( + ( + a = f({ + a, + + b + }) + ) => {} +); + +foo( + ( + a = ({ + a, + + b + }) => {} + ) => {} +); + +foo( + ( + a = 1 + + f({ + a, + + b + }) + ) => {} +); diff --git a/crates/rome_fmt/test_data/specs/js/module/arrow/params.js.snap b/crates/rome_fmt/test_data/specs/js/module/arrow/params.js.snap new file mode 100644 index 0000000..28df115 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/arrow/params.js.snap @@ -0,0 +1,301 @@ +fooooooooooooooooooooooooooooooooooooooooooooooooooo( + (action) => (next) => dispatch(action), +); + +foo( + ({ + a, + + b, + }) => {}, +); + +foo(({ a, b }) => {}); + +foo(({ a, b }) => {}); + +foo( + a, + ({ + a, + + b, + }) => {}, +); + +foo( + ({ + a, + + b, + }) => a, +); + +foo(({ a, b }) => a); + +foo(({ a, b }) => a); + +foo( + ({ + a: { + a, + + b, + }, + }) => {}, +); + +foo( + ({ + a: { + b: { + c, + + d, + }, + }, + }) => {}, +); + +foo( + ({ + a: { + b: { + c: { + d, + + e, + }, + }, + }, + }) => {}, +); + +foo( + ({ + a: { + a, + + b, + }, + }) => a, +); + +foo( + ({ + a: { + b: { + c, + + d, + }, + }, + }) => a, +); + +foo( + ({ + a: { + b: { + c: { + d, + + e, + }, + }, + }, + }) => a, +); + +foo( + ([ + { + a: { + b: { + c: { + d, + + e, + }, + }, + }, + }, + ]) => {}, +); + +foo( + ([ + ...{ + a: { + b: { + c: { + d, + + e, + }, + }, + }, + } + ]) => {}, +); + +foo( + ( + n = { + a: { + b: { + c: { + d, + + e, + }, + }, + }, + }, + ) => {}, +); + +foo( + ({ + x: [ + { + a, + + b, + }, + ], + }) => {}, +); + +foo( + ( + a = [ + { + a, + + b, + }, + ], + ) => a, +); + +foo( + ([ + [ + { + a, + + b, + }, + ], + ]) => {}, +); + +foo( + ([ + [ + [ + [ + { + a, + b: { + c, + d: { + e, + + f, + }, + }, + }, + ], + ], + ], + ]) => {}, +); + +foo( + ( + ...{ + a, + + b, + } + ) => {}, +); + +foo( + ( + ...[ + { + a, + + b, + }, + ] + ) => {}, +); + +foo( + ([ + ...[ + { + a, + + b, + }, + ] + ]) => {}, +); + +foo( + ( + a = [ + { + a, + + b, + }, + ], + ) => {}, +); + +foo( + ( + a = (({ + a, + + b, + }) => {})(), + ) => {}, +); + +foo( + ( + a = f({ + a, + + b, + }), + ) => {}, +); + +foo( + ( + a = ({ + a, + + b, + }) => {}, + ) => {}, +); + +foo( + ( + a = 1 + + f({ + a, + + b, + }), + ) => {}, +); diff --git a/crates/rome_fmt/test_data/specs/js/module/assignment/array-assignment-holes.js b/crates/rome_fmt/test_data/specs/js/module/assignment/array-assignment-holes.js new file mode 100644 index 0000000..5ba42f8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/assignment/array-assignment-holes.js @@ -0,0 +1,2 @@ +let a, b; +[a,/*empty*/,] = b; diff --git a/crates/rome_fmt/test_data/specs/js/module/assignment/array-assignment-holes.js.snap b/crates/rome_fmt/test_data/specs/js/module/assignment/array-assignment-holes.js.snap new file mode 100644 index 0000000..21d641d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/assignment/array-assignment-holes.js.snap @@ -0,0 +1,2 @@ +let a, b; +[a, /*empty*/ ,] = b; diff --git a/crates/rome_fmt/test_data/specs/js/module/assignment/assignment.js b/crates/rome_fmt/test_data/specs/js/module/assignment/assignment.js new file mode 100644 index 0000000..149e3c5 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/assignment/assignment.js @@ -0,0 +1,154 @@ +a = b +a += b +a -= b +a *= b +a /= b +a %= b +a <<= b +a >>= b +a >>>= b +a &= b +a |= b +a ^= b +a &&= b +a ||= b +a ??= b +a **= b +a.b = c.#d +a[ b ] = c[ d ] +;( a ) = b +;[a, b = "b", ...c] = d +;[fooooooooooooooooooooooooooooooooooooooooooooooooo, barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, bazzzzzzzzzzzzzzzzzzzzzzzzzz] = d +;({a,b=c,d:e,f:g=h,...j} = x) +;({aaaaaaaaaa,bbbbbbbbbb=cccccccccc,dddddddddd:eeeeeeeeee,ffffffffff:gggggggggg=hhhhhhhhhh,...jjjjjjjjjj} = x); + +(s||(s=Object.create(null)))[i]=!0; +(s||(s=Object.create(null))).test=!0; + +//never break after operator object layout +this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_1 = require(); +class_member_with_looooooooooooooooongggggggg_nameeeeeeeeee = class MyLooooonnnngggClassNamee { constructor() { console.log('class object constructor')}}; +this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_boolean_true = true; +this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_boolean_false = false; +number = 1232132132131231232132112321321321312312321321123213213213123123213211232132132131231232132112321321321312312321321; +number_with_dot = 12321321321312312321321123213213213123123213211232132132131231232132112321321321312312321321.12321321321312312321321; +template_string = ` + dsadsadas + 32131ewqewq + `; + +//break after operator layout +x = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +url = "http://example.com/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +a = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +ab = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +abc = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +long_key_for_string = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +古体诗 = 'https://prettier.io/docs/en/rationale.html#what_prettier_is_concerned_about'; +logical_expression_1 = this.state.longLongLongLongLongLongLongLongLongTooLongProp === true; +logical_expression_2 = longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337; +binary_expression_1 = 13321321312312321311332132131231232131232132132132232132132132 + 1332132131231232131232132132132; +binary_expression_2 = 1332132131231232131232132132132 + 13321321312312321312321321321321332132131231232131232132132132; +instanceof_expression = '321321312312ddddddddddddddddddddddd312312312312' instanceof Object; +in_expression = {'long_key': '123123213123213123edwqdqwdasdasdsaewqewqewqdas'} in 'long_key'; +sequence_expression = (33333333333333331, 'dsadsadasdsadas', 3, 'dsadsadasdsadasdsadsadasdsadas', 5); +conditional_expression_1 = this.state.longLongLongLongLongLongLongLongLongTooLongProp === true ? {} : {}; +conditional_expression_2 = longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 ? {} : {}; +conditional_expression_3 = 13321321312312321311332132131231232131232132132132232132132132 + 1332132131231232131232132132132 ? {} : {}; +conditional_expression_4 = '321321312312ddddddddddddddddddddddd312312312312' instanceof Object ? {} : {}; +conditional_expression_5 = {'long_key': '123123213123213123edwqdqwdasdasdsaewqewqewqdas'} in 'long_key'; +a = this.state.longLongLongLongLongLongLongLongLongTooLongProp === true ? {} : {}; +b = longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 ? {} : {}; +c = 13321321312312321311332132131231232131232132132132232132132132 + 1332132131231232131232132132132 ? {} : {}; +d = '321321312312ddddddddddddddddddddddd312312312312' instanceof Object ? {} : {}; +g = {'long_key': '123123213123213123edwqdqwdasdasdsaewqewqewqdas'} in 'long_key'; +blablah = + "aldkfkladfskladklsfkladklfkaldfadfkdaf" + + "adlfasdklfkldsklfakldsfkladsfkadsfladsfa" + + "dflkadfkladsfklkadlfkladlfkadklfjadlfdfdaf"; +fn = +// something + fn() + +loooooooooooooooooooooooooong1 = + void "looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong2 = + !"looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong3 = + +"looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong4 = + void void "looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong5 = + !!"looooooooooooooooooooooooooooooooooooooooooog"; +// rome-ignore format: test +loooooooooooooooooooooooooong6 = + void "looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong7 = + // rome-ignore format: test + ! "looooooooooooooooooooooooooooooooooooooooooog"; + +// fluid layout +bifornCringerMoshedPerplex.bifornCringerMoshedPerplexSawder.arrayOfNumbers = [1, 2, 3, 4, 5]; +bifornCringerMoshedPerplex.bifornCringerMoshedPerplexSawder.arrayOfNumbers = { a: 10 }; +bifornCringerMoshedPerplex.bifornCringerMoshedPerplexSawder = bifornCringerMoshedPerplex.bifornCringerMoshedPerplexSawderArrayNumbes = { a: 10 }; +fn = + + fn() +this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line = orMaybeIAmMisunderstandingAndIHaveSetSomethingWrongInMyConfig(); +dsakdljaskldjaslk = [ + { + message: "test", + messageType: "SMS", + status: "Unknown", + created: "11/01/2017 13:36", + }, + { + message: "test", + messageType: "Email", + status: "Unknown", + created: "11/01/2017 13:36", + }, + { + message: "te", + messageType: "SMS", + status: "Unknown", + created: "09/01/2017 17:25", + }, +]; +render = withGraphQLQuery( + 'node(1234567890){image{uri}}', + function(container, data) { + return 'image'; + } +); + +loadNext = (stateIsOK && hasNext) || { + skipNext: true, +}; + +// chain and chain tail where it breaks +bifornCringerMoshedPerplex = bifornCringerMoshedPerplexSawder = arrayOfNumb = a = "test" + +// chain and chain tail where it doesn't break +loreum = ipsum = arrayOfNumb = a = "test" + +// chain tail arrow function +lorem = fff = ee = () => (fff) => () => (fefef) => () => fff; + +// complex destructuring, break left hand +a = { + a: { t: c = b }, loreum, ipsurm +} = {} + +a = +// rome-ignore format: test +{ + a: { t: c = b }, loreum, ipsurm +} = {} + +a = + { +// rome-ignore format: test + a: { t: c = b }, loreum, ipsurm + } = {} + diff --git a/crates/rome_fmt/test_data/specs/js/module/assignment/assignment.js.snap b/crates/rome_fmt/test_data/specs/js/module/assignment/assignment.js.snap new file mode 100644 index 0000000..dcbd4e5 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/assignment/assignment.js.snap @@ -0,0 +1,224 @@ +a = b; +a += b; +a -= b; +a *= b; +a /= b; +a %= b; +a <<= b; +a >>= b; +a >>>= b; +a &= b; +a |= b; +a ^= b; +a &&= b; +a ||= b; +a ??= b; +a **= b; +a.b = c.#d; +a[b] = c[d]; +a = b; +[a, b = "b", ...c] = d; +[ + fooooooooooooooooooooooooooooooooooooooooooooooooo, + barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr, + bazzzzzzzzzzzzzzzzzzzzzzzzzz, +] = d; +({ a, b = c, d: e, f: g = h, ...j } = x); +({ + aaaaaaaaaa, + bbbbbbbbbb = cccccccccc, + dddddddddd: eeeeeeeeee, + ffffffffff: gggggggggg = hhhhhhhhhh, + ...jjjjjjjjjj +} = x); + +(s || (s = Object.create(null)))[i] = !0; +(s || (s = Object.create(null))).test = !0; + +//never break after operator object layout +this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_1 = require(); +class_member_with_looooooooooooooooongggggggg_nameeeeeeeeee = class MyLooooonnnngggClassNamee { + constructor() { + console.log("class object constructor"); + } +}; +this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_boolean_true = true; +this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line_boolean_false = false; +number = 1232132132131231232132112321321321312312321321123213213213123123213211232132132131231232132112321321321312312321321; +number_with_dot = 12321321321312312321321123213213213123123213211232132132131231232132112321321321312312321321.12321321321312312321321; +template_string = ` + dsadsadas + 32131ewqewq + `; + +//break after operator layout +x = + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +url = + "http://example.com/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +a = + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +ab = + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +abc = + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +long_key_for_string = + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"; +古体诗 = + "https://prettier.io/docs/en/rationale.html#what_prettier_is_concerned_about"; +logical_expression_1 = + this.state.longLongLongLongLongLongLongLongLongTooLongProp === true; +logical_expression_2 = + longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337; +binary_expression_1 = + 13321321312312321311332132131231232131232132132132232132132132 + + 1332132131231232131232132132132; +binary_expression_2 = + 1332132131231232131232132132132 + + 13321321312312321312321321321321332132131231232131232132132132; +instanceof_expression = + "321321312312ddddddddddddddddddddddd312312312312" instanceof Object; +in_expression = + { long_key: "123123213123213123edwqdqwdasdasdsaewqewqewqdas" } in "long_key"; +sequence_expression = + (33333333333333331, + "dsadsadasdsadas", + 3, + "dsadsadasdsadasdsadsadasdsadas", + 5); +conditional_expression_1 = + this.state.longLongLongLongLongLongLongLongLongTooLongProp === true ? {} : {}; +conditional_expression_2 = + longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 + ? {} + : {}; +conditional_expression_3 = + 13321321312312321311332132131231232131232132132132232132132132 + + 1332132131231232131232132132132 + ? {} + : {}; +conditional_expression_4 = + "321321312312ddddddddddddddddddddddd312312312312" instanceof Object ? {} : {}; +conditional_expression_5 = + { long_key: "123123213123213123edwqdqwdasdasdsaewqewqewqdas" } in "long_key"; +a = + this.state.longLongLongLongLongLongLongLongLongTooLongProp === true ? {} : {}; +b = + longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 + ? {} + : {}; +c = + 13321321312312321311332132131231232131232132132132232132132132 + + 1332132131231232131232132132132 + ? {} + : {}; +d = + "321321312312ddddddddddddddddddddddd312312312312" instanceof Object ? {} : {}; +g = + { long_key: "123123213123213123edwqdqwdasdasdsaewqewqewqdas" } in "long_key"; +blablah = + "aldkfkladfskladklsfkladklfkaldfadfkdaf" + + "adlfasdklfkldsklfakldsfkladsfkadsfladsfa" + + "dflkadfkladsfklkadlfkladlfkadklfjadlfdfdaf"; +fn = + // something + fn(); + +loooooooooooooooooooooooooong1 = + void "looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong2 = + !"looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong3 = + +"looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong4 = + void void "looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong5 = + !!"looooooooooooooooooooooooooooooooooooooooooog"; +// rome-ignore format: test +loooooooooooooooooooooooooong6 = + void "looooooooooooooooooooooooooooooooooooooooooog"; +loooooooooooooooooooooooooong7 = + // rome-ignore format: test + ! "looooooooooooooooooooooooooooooooooooooooooog"; + +// fluid layout +bifornCringerMoshedPerplex.bifornCringerMoshedPerplexSawder.arrayOfNumbers = [ + 1, 2, 3, 4, 5, +]; +bifornCringerMoshedPerplex.bifornCringerMoshedPerplexSawder.arrayOfNumbers = { + a: 10, +}; +bifornCringerMoshedPerplex.bifornCringerMoshedPerplexSawder = + bifornCringerMoshedPerplex.bifornCringerMoshedPerplexSawderArrayNumbes = { + a: 10, + }; +fn = fn(); +this_is_a_very_long_key_and_the_assignment_should_be_put_on_the_next_line = + orMaybeIAmMisunderstandingAndIHaveSetSomethingWrongInMyConfig(); +dsakdljaskldjaslk = [ + { + message: "test", + messageType: "SMS", + status: "Unknown", + created: "11/01/2017 13:36", + }, + { + message: "test", + messageType: "Email", + status: "Unknown", + created: "11/01/2017 13:36", + }, + { + message: "te", + messageType: "SMS", + status: "Unknown", + created: "09/01/2017 17:25", + }, +]; +render = withGraphQLQuery( + "node(1234567890){image{uri}}", + function (container, data) { + return "image"; + }, +); + +loadNext = (stateIsOK && hasNext) || { + skipNext: true, +}; + +// chain and chain tail where it breaks +bifornCringerMoshedPerplex = + bifornCringerMoshedPerplexSawder = + arrayOfNumb = + a = + "test"; + +// chain and chain tail where it doesn't break +loreum = ipsum = arrayOfNumb = a = "test"; + +// chain tail arrow function +lorem = + fff = + ee = + () => (fff) => () => (fefef) => () => + fff; + +// complex destructuring, break left hand +a = { + a: { t: c = b }, + loreum, + ipsurm, +} = {}; + +a = + // rome-ignore format: test + { + a: { t: c = b }, loreum, ipsurm +} = {}; + +a = { + // rome-ignore format: test + a: { t: c = b }, + loreum, + ipsurm, +} = {}; diff --git a/crates/rome_fmt/test_data/specs/js/module/assignment/assignment_ignore.js b/crates/rome_fmt/test_data/specs/js/module/assignment/assignment_ignore.js new file mode 100644 index 0000000..bdae718 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/assignment/assignment_ignore.js @@ -0,0 +1,4 @@ +let { + /* rome-ignore format: Test that the property doesn't get formatted */ + someProperty: alias +} = { someProperty: 20 }; diff --git a/crates/rome_fmt/test_data/specs/js/module/assignment/assignment_ignore.js.snap b/crates/rome_fmt/test_data/specs/js/module/assignment/assignment_ignore.js.snap new file mode 100644 index 0000000..52cb3d9 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/assignment/assignment_ignore.js.snap @@ -0,0 +1,4 @@ +let { + /* rome-ignore format: Test that the property doesn't get formatted */ + someProperty: alias, +} = { someProperty: 20 }; diff --git a/crates/rome_fmt/test_data/specs/js/module/binding/array-binding-holes.js b/crates/rome_fmt/test_data/specs/js/module/binding/array-binding-holes.js new file mode 100644 index 0000000..c0bd1cc --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/binding/array-binding-holes.js @@ -0,0 +1,2 @@ +function foo([foo, /* not used */, /* not used */]) { +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/binding/array-binding-holes.js.snap b/crates/rome_fmt/test_data/specs/js/module/binding/array-binding-holes.js.snap new file mode 100644 index 0000000..c927f75 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/binding/array-binding-holes.js.snap @@ -0,0 +1 @@ +function foo([foo, /* not used */ /* not used */ ,]) {} diff --git a/crates/rome_fmt/test_data/specs/js/module/binding/array_binding.js b/crates/rome_fmt/test_data/specs/js/module/binding/array_binding.js new file mode 100644 index 0000000..a523756 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/binding/array_binding.js @@ -0,0 +1,3 @@ +[a="b"]=c +let [a="b"]=c +let [aaaaaaaaaaaaaaaaaaaa=bbbbbbbbbbbbbbbbbbbb,cccccccccccccccccccc=dddddddddddddddddddd]=e diff --git a/crates/rome_fmt/test_data/specs/js/module/binding/array_binding.js.snap b/crates/rome_fmt/test_data/specs/js/module/binding/array_binding.js.snap new file mode 100644 index 0000000..09ee4b7 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/binding/array_binding.js.snap @@ -0,0 +1,6 @@ +[a = "b"] = c; +let [a = "b"] = c; +let [ + aaaaaaaaaaaaaaaaaaaa = bbbbbbbbbbbbbbbbbbbb, + cccccccccccccccccccc = dddddddddddddddddddd, +] = e; diff --git a/crates/rome_fmt/test_data/specs/js/module/binding/identifier_binding.js b/crates/rome_fmt/test_data/specs/js/module/binding/identifier_binding.js new file mode 100644 index 0000000..5798584 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/binding/identifier_binding.js @@ -0,0 +1,3 @@ +let x = y + +let abcde = "very long value that will cause a line break", fghij = "this should end up on the next line" diff --git a/crates/rome_fmt/test_data/specs/js/module/binding/identifier_binding.js.snap b/crates/rome_fmt/test_data/specs/js/module/binding/identifier_binding.js.snap new file mode 100644 index 0000000..423c39c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/binding/identifier_binding.js.snap @@ -0,0 +1,4 @@ +let x = y; + +let abcde = "very long value that will cause a line break", + fghij = "this should end up on the next line"; diff --git a/crates/rome_fmt/test_data/specs/js/module/binding/object_binding.js b/crates/rome_fmt/test_data/specs/js/module/binding/object_binding.js new file mode 100644 index 0000000..ce64d16 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/binding/object_binding.js @@ -0,0 +1,4 @@ +let {a}=b +let {d,b:c}=d +let {x,y=c,z:pp=f,...g}=h +let {aaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbbbbbb=cccccccccccccccccccc,dddddddddddddddddddd:eeeeeeeeeeeeeeeeeeee=ffffffffffffffffffff,...gggggggggggggggggggg}=h diff --git a/crates/rome_fmt/test_data/specs/js/module/binding/object_binding.js.snap b/crates/rome_fmt/test_data/specs/js/module/binding/object_binding.js.snap new file mode 100644 index 0000000..bf59134 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/binding/object_binding.js.snap @@ -0,0 +1,9 @@ +let { a } = b; +let { d, b: c } = d; +let { x, y = c, z: pp = f, ...g } = h; +let { + aaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbb = cccccccccccccccccccc, + dddddddddddddddddddd: eeeeeeeeeeeeeeeeeeee = ffffffffffffffffffff, + ...gggggggggggggggggggg +} = h; diff --git a/crates/rome_fmt/test_data/specs/js/module/call_expression.js b/crates/rome_fmt/test_data/specs/js/module/call_expression.js new file mode 100644 index 0000000..73f1767 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/call_expression.js @@ -0,0 +1,48 @@ + +useEffect(() => { + +}, [a, b]) + +useMemo(() => { + return { + d, e + } +}, [a, b]) + +useMemo(() => { + + } // some comment + , + [a, b] +) + +useEffect(() => { + if (clipboardStatus !== "normal") { + setClipboardStatus("normal"); + } +}, [formatter_ir]); + +test.expect(t => { + t.true(a) +}) + +test.expect(t => { + t.true(a) +}, false) + +test.something(t => { + t.true() +}, context => { + context.flush() +}) + +// trailing separator omitted +test.expect(t => { + t.true(a) +}, false,) + +test.expect(t => { + t.true(a) +}, false, + // comment + ) \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/call_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/call_expression.js.snap new file mode 100644 index 0000000..92ebe8f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/call_expression.js.snap @@ -0,0 +1,49 @@ +useEffect(() => {}, [a, b]); + +useMemo(() => { + return { + d, + e, + }; +}, [a, b]); + +useMemo( + () => {}, // some comment + [a, b], +); + +useEffect(() => { + if (clipboardStatus !== "normal") { + setClipboardStatus("normal"); + } +}, [formatter_ir]); + +test.expect((t) => { + t.true(a); +}); + +test.expect((t) => { + t.true(a); +}, false); + +test.something( + (t) => { + t.true(); + }, + (context) => { + context.flush(); + }, +); + +// trailing separator omitted +test.expect((t) => { + t.true(a); +}, false); + +test.expect( + (t) => { + t.true(a); + }, + false, + // comment +); diff --git a/crates/rome_fmt/test_data/specs/js/module/class/class.js b/crates/rome_fmt/test_data/specs/js/module/class/class.js new file mode 100644 index 0000000..e740cc3 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/class/class.js @@ -0,0 +1,71 @@ +class Foo extends Boar { + static { // some comment + this.a = "test"; + } + constructor(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, c = d) { + super(); + } + + static get sg() { + + } + + get g() { + + } + + set gg(a) { + + } + + method() { + return "ipsum"; + } + + async asyncMethod() {} + + * generatorMethod (){} + + static staticMethod() { + return "bar" + } + + async * asyncGeneratorMethod (){} + + static async staticAsyncMethod (){} + + static * staticGeneratorMethod (){} + + static async *staticAsyncGeneratorMethod() {} + + static foo; + + new_prop = 5 + + #a = b + + double_semicolon = [5,3,4];; +} + +x = class { +} + +x = class foo extends Boar { +} + +x = class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa extends bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb { +} + + +export class Task { + + + constructor( + script, + duration, + threadCount, + ...args + ) { + this.args = args; + } +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/class/class.js.snap b/crates/rome_fmt/test_data/specs/js/module/class/class.js.snap new file mode 100644 index 0000000..ed870c8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/class/class.js.snap @@ -0,0 +1,61 @@ +class Foo extends Boar { + static { + // some comment + this.a = "test"; + } + constructor( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + c = d, + ) { + super(); + } + + static get sg() {} + + get g() {} + + set gg(a) {} + + method() { + return "ipsum"; + } + + async asyncMethod() {} + + *generatorMethod() {} + + static staticMethod() { + return "bar"; + } + + async *asyncGeneratorMethod() {} + + static async staticAsyncMethod() {} + + static *staticGeneratorMethod() {} + + static async *staticAsyncGeneratorMethod() {} + + static foo; + + new_prop = 5; + + #a = b; + + double_semicolon = [5, 3, 4]; +} + +x = class {}; + +x = class foo extends Boar {}; + +x = class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa extends ( + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +) {}; + +export class Task { + constructor(script, duration, threadCount, ...args) { + this.args = args; + } +} diff --git a/crates/rome_fmt/test_data/specs/js/module/class/class_comments.js b/crates/rome_fmt/test_data/specs/js/module/class/class_comments.js new file mode 100644 index 0000000..6a1f7a9 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/class/class_comments.js @@ -0,0 +1,7 @@ +class A extends B { // leading comment + constructor() { + super(); + } + + // trailing comment +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/class/class_comments.js.snap b/crates/rome_fmt/test_data/specs/js/module/class/class_comments.js.snap new file mode 100644 index 0000000..7a06090 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/class/class_comments.js.snap @@ -0,0 +1,8 @@ +class A extends B { + // leading comment + constructor() { + super(); + } + + // trailing comment +} diff --git a/crates/rome_fmt/test_data/specs/js/module/class/private_method.js b/crates/rome_fmt/test_data/specs/js/module/class/private_method.js new file mode 100644 index 0000000..fb2f1fd --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/class/private_method.js @@ -0,0 +1,16 @@ +class Foo { + a = 1; + + *#a() { + yield bar(); + } + + #b = 2; + + get b() { return 9999; } + set #c(x) { return x; } + + static #d() { + return Math.random(); + } +} diff --git a/crates/rome_fmt/test_data/specs/js/module/class/private_method.js.snap b/crates/rome_fmt/test_data/specs/js/module/class/private_method.js.snap new file mode 100644 index 0000000..2ba5e8d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/class/private_method.js.snap @@ -0,0 +1,20 @@ +class Foo { + a = 1; + + *#a() { + yield bar(); + } + + #b = 2; + + get b() { + return 9999; + } + set #c(x) { + return x; + } + + static #d() { + return Math.random(); + } +} diff --git a/crates/rome_fmt/test_data/specs/js/module/comments.js b/crates/rome_fmt/test_data/specs/js/module/comments.js new file mode 100644 index 0000000..c0d6963 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/comments.js @@ -0,0 +1,78 @@ +import { + func, // trailing comma removal +} from 'module'; + + +expression(/* block comment */); + +expression( + /* block comment */ +); + + +expression( // line comment +); + +expression( + // line comment +); + + +expression( "something" // line comment +); + + +expression( "something" /** something **/ ); + +expression(/** something **/ "something" + ); + +expression( + /** something **/ + "something" +); + +const array0 = [/*0*/]; +const array1 = [/*0*/,/*1*/]; +const array2 = [/*0*/,/*1*/,/*2*/]; + +/* block comment */ +statement(); + +statement(); /* block comment */ + +// line comment +statement(); + +statement(); // inline + +// leading +[1, 2, 3]; + +[1, 2, 3] // trailing + +function name() /* comment */ {} + +function name(very, long, list, of_parameters, to, insert, a_break, in_the, parameters, group) /* comment */ {} + +4 + /* plus trailing */3 * 2 /* 2 trailing */ ; + +/* leading of opening */ (/* trailing of opening */ (4 + 3) + + /* leading of closing */) /* trailing of closing */; + + [ + 3 /* trailing num */ , /* trailing sep */ + ]; + +function test /* spacing before parentheses*/ () {} + +a /* before member */.test; +statement /* comment */; + +/* leading */ "test" /*trailing*/ ; + +/* leading */ +"test" /*trailing*/ ; + +/* EOF comment */ diff --git a/crates/rome_fmt/test_data/specs/js/module/comments.js.snap b/crates/rome_fmt/test_data/specs/js/module/comments.js.snap new file mode 100644 index 0000000..7398b85 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/comments.js.snap @@ -0,0 +1,85 @@ +import { + func, // trailing comma removal +} from "module"; + +expression(/* block comment */); + +expression(/* block comment */); + +expression( + // line comment +); + +expression( + // line comment +); + +expression( + "something", // line comment +); + +expression("something" /** something **/); + +expression(/** something **/ "something"); + +expression( + /** something **/ + "something", +); + +const array0 = [ + /*0*/ +]; +const array1 = [/*0*/ /*1*/ ,]; +const array2 = [/*0*/ , /*1*/ /*2*/ ,]; + +/* block comment */ +statement(); + +statement(); /* block comment */ + +// line comment +statement(); + +statement(); // inline + +// leading +[1, 2, 3]; + +[1, 2, 3]; // trailing + +function name() /* comment */ {} + +function name( + very, + long, + list, + of_parameters, + to, + insert, + a_break, + in_the, + parameters, + group, +) /* comment */ {} + +4 + /* plus trailing */ 3 * 2 /* 2 trailing */; + +/* leading of opening */ /* trailing of opening */ 4 + 3; + +/* leading of closing */ +/* trailing of closing */ + +[3 /* trailing num */ /* trailing sep */]; + +function test /* spacing before parentheses*/() {} + +a /* before member */.test; +statement /* comment */; + +/* leading */ ("test") /*trailing*/; + +/* leading */ +("test") /*trailing*/; + +/* EOF comment */ diff --git a/crates/rome_fmt/test_data/specs/js/module/declarations/variable_declaration.js b/crates/rome_fmt/test_data/specs/js/module/declarations/variable_declaration.js new file mode 100644 index 0000000..77425fa --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/declarations/variable_declaration.js @@ -0,0 +1,265 @@ +//break left-hand side layout +{ + const { + id, + static: isStatic, + method: isMethod, + methodId, + getId, + setId, + } = privateNamesMap.get(name); + + // rome-ignore format: test + const { + id, static: isStatic, method: isMethod, + methodId, getId, setId, + } = privateNamesMap.get(name); + + const { id1, method: isMethod1, methodId1 } = privateNamesMap.get(name); + + const { id1, method: isMethod1, methodId1 } = + // rome-ignore format: test + privateNamesMap.get(name); + + const { + id3, + method: isMethod3, + methodId3, + } = anodyneCondosMalateOverateRetinol.get(bifornCringerMoshedPerplexSawder); + + // rome-ignore format: test + const { + id3, method: isMethod3, + methodId3, + } = + // rome-ignore format: test + anodyneCondosMalateOverateRetinol.get( + bifornCringerMoshedPerplexSawder + ); +} + +//break after operator layout +const loooooooooooooooooooooooooong1 = + void "looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong2 = + !"looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong3 = + +"looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong4 = + void void "looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong5 = + !!"looooooooooooooooooooooooooooooooooooooooooog"; +// rome-ignore format: test +const loooooooooooooooooooooooooong6 = + void "looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong7 = + // rome-ignore format: test + ! "looooooooooooooooooooooooooooooooooooooooooog"; + +//poorly breakable member or call chain (break after operator layout) +//JsIdentifierExpression +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect.ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong4 = objdddddddddectobjdddddddddect[dsadsadsadsadsadsadsa + ewqoewqoeiowqieopwqie]; +let loooooooooooooooooooooooooong5 = objdddddddddectobjdddddddddect()[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsThisExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this.ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this[dsadsadsadsadsadsadsa + ewqoewqoeiowqieopwqie]; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong5 = this()[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//lone short argument for JsIdentifierExpression +//JsThisExpression argument +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(this); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect(this).ewqeqewqwdddddddddddddeqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(this)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(this)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsIdentifierExpression argument +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(aaaaaaaaaaaaaaaaaaaa); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect(aaaaaaaaaaaaaaaaaaaa).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(aaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(aaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsUnaryExpression argument +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(+12312312321321312); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect(-12312312321321312).ewqeqewqweqweqweqweqweqweqw; + +//JsStringLiteralExpression argument +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn("111111111111111111"); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect("111111111111111111").ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect("111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect("111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsRegexLiteralExpression argument +var loooooooooooooooooooooooooong1 = objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwww+/gi); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwww+/gi).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsTemplate argument +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(``); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddsadsadddddddect(`111111111111111111`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjddsadsaddddddddect(`111111111111111111`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddsadaddddddddect(`111111111111111111`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +// rest JsAnyLiteralExpression +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(true); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddsadsadasdddect(undefined).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(321321312321312321321)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(9007199254740991n)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + + +//lone short argument for JsThisExpression +//JsThisExpression argument +var looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(this); +let looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(this).ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(this)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this(this)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsIdentifierExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(aaaaaaaaaaaaaaaaaaaa); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(aaaaaaaaaaaaaaaaaaaa).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(aaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this(aaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsUnaryExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(+12312312321321312); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(-12312312321321312).ewqeqewqweqweqweqweqweqweqw; + +//JsStringLiteralExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this("111111111111111111"); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this("111111111111111111").ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this("111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this("111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsRegexLiteralExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(/\wwwwwwwwwwwwwwwwww+/gi); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(/\wwwwwwwwwwwwwwwwww+/gi).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(/\wwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this(/\wwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsTemplate argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(``); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(`111111111111111111`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(`111111111111111111`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this(`111111111111111111`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +// rest JsAnyLiteralExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(true); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(undefined).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(321321312321312321321)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this(9007199254740991n)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//fluid layout +const otherBrandsWithThisAdjacencyCount123 = Object.values(edge.to.edges).length; +let vgChannel = pointPositionDefaultRef({ model, defaultPos, channel })(); +const bifornCringerMoshedPerplexSawderGlyphsHb = someBigFunctionName( + `foo +`, +)("bar"); + +//not poorly breakable member or call chain (fluid layout layout) +//JsIdentifierExpression +var looooooooooooooooooooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(1,2,3,4); +let looooooooooooooooooooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect(1,2).ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(a,b,c)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//exceed the length of JsIdentifierExpression argument +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(aaaaaaaaaaaaaaaaaaaaa); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect(aaaaaaaaaaaaaaaaaaaaa).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(aaaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(aaaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//exceed the length of JsStringLiteralExpression argument +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn("1111111111111111111"); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect("1111111111111111111").ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect("1111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect("1111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//exceed the length of JsRegexLiteralExpression argument +var loooooooooooooooooooooooooong1 = objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwwwwww+/gi); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwwwwww+/gi).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//exceed the length of JsTemplate argument +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(`111111111111111111111111111111111111111111111111111111`); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddsadsadddddddect(`111111111111111111111111111111111111`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjddsadsaddddddddect(`111111111111111111111111111111111111`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +// has expression +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(`123123 ${adsada} dsa`); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddsadsadddddddect(`123123 ${adsada} dsa`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjddsadsaddddddddect(`123123 ${adsada} dsa`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +// has new line +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(`123123 + dsa`); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddsadsadddddddect(`123123 +dsa`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjddsadsaddddddddect(`123123 + dsa`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//JsThisExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(1,2,3); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(a, b).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this()[dsadsadsadsadsadsadsa](g,c,d).ewqoewqoeiowqieopwqie; + +//exceed the length of JsIdentifierExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(aaaaaaaaaaaaaaaaaaaaa); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(aaaaaaaaaaaaaaaaaaaaa).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(aaaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this(aaaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//exceed the length of JsStringLiteralExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this("1111111111111111111"); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this("1111111111111111111").ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this("1111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this("1111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + + +//exceed the length of JsRegexLiteralExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(/\wwwwwwwwwwwwwwwwwwwww+/gi); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(/\wwwwwwwwwwwwwwwwwwwww+/gi).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(/\wwwwwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = this(/\wwwwwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//exceed the length of JsTemplate argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(`111111111111111111111111111111111111111111111111111111`); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(`111111111111111111111111111111111111`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(`111111111111111111111111111111111111`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +// has expression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(`123123 ${adsada} dsa`); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(`123123 ${adsada} dsa`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(`123123 ${adsada} dsa`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +// has new line +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(`123123 + dsa`); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this(`123123 +dsa`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this(`123123 + dsa`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +//lone short argument JsUnaryExpression argument with comment +var loooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(+12312312321321312 /*comment*/); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect( + //comment + -12312312321321312).ewqeqewqweqweqweqweqweqweqw; + +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(+12312312321321312 /*comment*/); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this( + //comment + -12312312321321312).ewqeqewqweqweqweqweqweqweqw; + + +const a + // rome-ignore format: Ignore the initializer + = + + [A, B, C].push( aaa ) diff --git a/crates/rome_fmt/test_data/specs/js/module/declarations/variable_declaration.js.snap b/crates/rome_fmt/test_data/specs/js/module/declarations/variable_declaration.js.snap new file mode 100644 index 0000000..6590905 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/declarations/variable_declaration.js.snap @@ -0,0 +1,454 @@ +//break left-hand side layout +{ + const { + id, + static: isStatic, + method: isMethod, + methodId, + getId, + setId, + } = privateNamesMap.get(name); + + // rome-ignore format: test + const { + id, static: isStatic, method: isMethod, + methodId, getId, setId, + } = privateNamesMap.get(name); + + const { id1, method: isMethod1, methodId1 } = privateNamesMap.get(name); + + const { + id1, + method: isMethod1, + methodId1, + } = // rome-ignore format: test + privateNamesMap.get(name); + + const { + id3, + method: isMethod3, + methodId3, + } = anodyneCondosMalateOverateRetinol.get(bifornCringerMoshedPerplexSawder); + + // rome-ignore format: test + const { + id3, method: isMethod3, + methodId3, + } = + // rome-ignore format: test + anodyneCondosMalateOverateRetinol.get( + bifornCringerMoshedPerplexSawder + ); +} + +//break after operator layout +const loooooooooooooooooooooooooong1 = + void "looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong2 = + !"looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong3 = + +"looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong4 = + void void "looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong5 = + !!"looooooooooooooooooooooooooooooooooooooooooog"; +// rome-ignore format: test +const loooooooooooooooooooooooooong6 = + void "looooooooooooooooooooooooooooooooooooooooooog"; +const loooooooooooooooooooooooooong7 = + // rome-ignore format: test + ! "looooooooooooooooooooooooooooooooooooooooooog"; + +//poorly breakable member or call chain (break after operator layout) +//JsIdentifierExpression +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(); +let loooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect.ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong4 = + objdddddddddectobjdddddddddect[dsadsadsadsadsadsadsa + ewqoewqoeiowqieopwqie]; +let loooooooooooooooooooooooooong5 = + objdddddddddectobjdddddddddect()[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +//JsThisExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this.ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this[dsadsadsadsadsadsadsa + ewqoewqoeiowqieopwqie]; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong5 = + this()[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//lone short argument for JsIdentifierExpression +//JsThisExpression argument +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + this, + ); +let loooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect(this).ewqeqewqwdddddddddddddeqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(this)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(this)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +//JsIdentifierExpression argument +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + aaaaaaaaaaaaaaaaaaaa, + ); +let loooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect( + aaaaaaaaaaaaaaaaaaaa, + ).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(aaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(aaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +//JsUnaryExpression argument +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + +12312312321321312, + ); +let loooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect( + -12312312321321312, + ).ewqeqewqweqweqweqweqweqweqw; + +//JsStringLiteralExpression argument +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + "111111111111111111", + ); +let loooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect( + "111111111111111111", + ).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect("111111111111111111")[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect("111111111111111111")[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +//JsRegexLiteralExpression argument +var loooooooooooooooooooooooooong1 = + objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwww+/gi); +let loooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect( + /\wwwwwwwwwwwwwwwwww+/gi, + ).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwww+/gi)[ + dsadsadsadsadsadsadsa + ]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(/\wwwwwwwwwwwwwwwwww+/gi)[ + dsadsadsadsadsadsadsa + ]().ewqoewqoeiowqieopwqie; + +//JsTemplate argument +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + ``, + ); +let loooooooooooooooooooooooooong2 = + objdddddddddectobjdddsadsadddddddect( + `111111111111111111`, + ).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjddsadsaddddddddect(`111111111111111111`)[ + dsadsadsadsadsadsadsa + ]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddsadaddddddddect(`111111111111111111`)[ + dsadsadsadsadsadsadsa + ]().ewqoewqoeiowqieopwqie; + +// rest JsAnyLiteralExpression +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + true, + ); +let loooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddsadsadasdddect( + undefined, + ).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(321321312321312321321)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(9007199254740991n)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +//lone short argument for JsThisExpression +//JsThisExpression argument +var looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(this); +let looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(this).ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(this)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this(this)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//JsIdentifierExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(aaaaaaaaaaaaaaaaaaaa); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(aaaaaaaaaaaaaaaaaaaa).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(aaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this(aaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//JsUnaryExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(+12312312321321312); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(-12312312321321312).ewqeqewqweqweqweqweqweqweqw; + +//JsStringLiteralExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this("111111111111111111"); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this("111111111111111111").ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this("111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this("111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//JsRegexLiteralExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(/\wwwwwwwwwwwwwwwwww+/gi); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(/\wwwwwwwwwwwwwwwwww+/gi).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(/\wwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this(/\wwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//JsTemplate argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(``); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(`111111111111111111`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(`111111111111111111`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this(`111111111111111111`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +// rest JsAnyLiteralExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(true); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(undefined).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(321321312321312321321)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this(9007199254740991n)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//fluid layout +const otherBrandsWithThisAdjacencyCount123 = Object.values( + edge.to.edges, +).length; +let vgChannel = pointPositionDefaultRef({ model, defaultPos, channel })(); +const bifornCringerMoshedPerplexSawderGlyphsHb = someBigFunctionName( + `foo +`, +)("bar"); + +//not poorly breakable member or call chain (fluid layout layout) +//JsIdentifierExpression +var looooooooooooooooooooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + 1, + 2, + 3, + 4, + ); +let looooooooooooooooooooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect(1, 2).ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect(a, b, c)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +//exceed the length of JsIdentifierExpression argument +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + aaaaaaaaaaaaaaaaaaaaa, + ); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect( + aaaaaaaaaaaaaaaaaaaaa, +).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect( + aaaaaaaaaaaaaaaaaaaaa, +)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect( + aaaaaaaaaaaaaaaaaaaaa, +)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//exceed the length of JsStringLiteralExpression argument +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + "1111111111111111111", + ); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect( + "1111111111111111111", +).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect( + "1111111111111111111", +)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect( + "1111111111111111111", +)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//exceed the length of JsRegexLiteralExpression argument +var loooooooooooooooooooooooooong1 = objdddddddddectobjdddddddddect( + /\wwwwwwwwwwwwwwwwwwwww+/gi, +); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect( + /\wwwwwwwwwwwwwwwwwwwww+/gi, +).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect( + /\wwwwwwwwwwwwwwwwwwwww+/gi, +)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect( + /\wwwwwwwwwwwwwwwwwwwww+/gi, +)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//exceed the length of JsTemplate argument +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + `111111111111111111111111111111111111111111111111111111`, + ); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddsadsadddddddect( + `111111111111111111111111111111111111`, +).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjddsadsaddddddddect( + `111111111111111111111111111111111111`, +)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +// has expression +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + `123123 ${adsada} dsa`, + ); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddsadsadddddddect( + `123123 ${adsada} dsa`, +).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjddsadsaddddddddect( + `123123 ${adsada} dsa`, +)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +// has new line +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(`123123 + dsa`); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddsadsadddddddect(`123123 +dsa`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooong3 = objdddddddddectobjddsadsaddddddddect(`123123 + dsa`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//JsThisExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(1, 2, 3); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(a, b).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this()[dsadsadsadsadsadsadsa](g, c, d).ewqoewqoeiowqieopwqie; + +//exceed the length of JsIdentifierExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(aaaaaaaaaaaaaaaaaaaaa); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(aaaaaaaaaaaaaaaaaaaaa).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(aaaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this(aaaaaaaaaaaaaaaaaaaaa)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//exceed the length of JsStringLiteralExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this("1111111111111111111"); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this("1111111111111111111").ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this("1111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this("1111111111111111111")[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//exceed the length of JsRegexLiteralExpression argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(/\wwwwwwwwwwwwwwwwwwwww+/gi); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(/\wwwwwwwwwwwwwwwwwwwww+/gi).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(/\wwwwwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong4 = + this(/\wwwwwwwwwwwwwwwwwwwww+/gi)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +//exceed the length of JsTemplate argument +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(`111111111111111111111111111111111111111111111111111111`); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(`111111111111111111111111111111111111`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(`111111111111111111111111111111111111`)[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +// has expression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(`123123 ${adsada} dsa`); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(`123123 ${adsada} dsa`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(`123123 ${adsada} dsa`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +// has new line +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(`123123 + dsa`); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this(`123123 +dsa`).ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this(`123123 + dsa`)[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +//lone short argument JsUnaryExpression argument with comment +var loooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn( + +12312312321321312 /*comment*/, + ); +let loooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect( + //comment + -12312312321321312, +).ewqeqewqweqweqweqweqweqweqw; + +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(+12312312321321312 /*comment*/); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this( + //comment + -12312312321321312, + ).ewqeqewqweqweqweqweqweqweqw; + +const a + // rome-ignore format: Ignore the initializer + = + + [A, B, C].push( aaa ); diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_call_decorator.js b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_call_decorator.js new file mode 100644 index 0000000..1c86e37 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_call_decorator.js @@ -0,0 +1,92 @@ +class Foo { + // one decorator without a newline + @decorator.method(value) property; + @decorator.method(value) method() {} + @decorator.method(value) async method() {} + @decorator.method(value) *method() {} + @decorator.method(value) get getter() {} + @decorator.method(value) set setter(val) {} + + // two decorators without a newline + @decorator.method(value) @decorator.method(value) property; + @decorator.method(value) @decorator.method(value) method() {} + @decorator.method(value) @decorator.method(value) async method() {} + @decorator.method(value) @decorator.method(value) *method() {} + @decorator.method(value) @decorator.method(value) get getter() {} + @decorator.method(value) @decorator.method(value) set setter(val) {} + + // one decorator with a newline + @decorator.method(value) + property; + @decorator.method(value) + method() {} + @decorator.method(value) + async method() {} + @decorator.method(value) + *method() {} + @decorator.method(value) + get getter() {} + @decorator.method(value) + set setter(val) {} + + // two decorators without a newline + @decorator.method(value) + @decorator.method(value) property; + @decorator.method(value) + @decorator.method(value) method() {} + @decorator.method(value) + @decorator.method(value) async method() {} + @decorator.method(value) + @decorator.method(value) *method() {} + @decorator.method(value) + @decorator.method(value) get getter() {} + @decorator.method(value) + @decorator.method(value) set setter(val) {} +} + + +class Foo { + // one decorator without a newline + /*before*/ @decorator.method(value) /*after*/ property; + /*before*/ @decorator.method(value) /*after*/ method() {} + /*before*/ @decorator.method(value) /*after*/ async method() {} + /*before*/ @decorator.method(value) /*after*/ *method() {} + /*before*/ @decorator.method(value) /*after*/ get getter() {} + /*before*/ @decorator.method(value) /*after*/ set setter(val) {} + + // two decorators without a newline + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ property; + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ method() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ async method() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ *method() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ get getter() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ set setter(val) {} + + // one decorator with a newline + @decorator.method(value) /*before*/ + /*after*/ property; + @decorator.method(value) /*before*/ + /*after*/ method() {} + @decorator.method(value) /*before*/ + /*after*/ async method() {} + @decorator.method(value) /*before*/ + /*after*/ *method() {} + @decorator.method(value) /*before*/ + /*after*/ get getter() {} + @decorator.method(value) /*before*/ + /*after*/ set setter(val) {} + + // two decorators without a newline + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ property; + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ async method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ *method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ get getter() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ set setter(val) {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_call_decorator.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_call_decorator.js.snap new file mode 100644 index 0000000..576ced4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_call_decorator.js.snap @@ -0,0 +1,91 @@ +class Foo { + // one decorator without a newline + @decorator.method(value) property; + @decorator.method(value) method() {} + @decorator.method(value) async method() {} + @decorator.method(value) *method() {} + @decorator.method(value) get getter() {} + @decorator.method(value) set setter(val) {} + + // two decorators without a newline + @decorator.method(value) @decorator.method(value) property; + @decorator.method(value) @decorator.method(value) method() {} + @decorator.method(value) @decorator.method(value) async method() {} + @decorator.method(value) @decorator.method(value) *method() {} + @decorator.method(value) @decorator.method(value) get getter() {} + @decorator.method(value) @decorator.method(value) set setter(val) {} + + // one decorator with a newline + @decorator.method(value) + property; + @decorator.method(value) + method() {} + @decorator.method(value) + async method() {} + @decorator.method(value) + *method() {} + @decorator.method(value) + get getter() {} + @decorator.method(value) + set setter(val) {} + + // two decorators without a newline + @decorator.method(value) + @decorator.method(value) property; + @decorator.method(value) + @decorator.method(value) method() {} + @decorator.method(value) + @decorator.method(value) async method() {} + @decorator.method(value) + @decorator.method(value) *method() {} + @decorator.method(value) + @decorator.method(value) get getter() {} + @decorator.method(value) + @decorator.method(value) set setter(val) {} +} + +class Foo { + // one decorator without a newline + /*before*/ @decorator.method(value) /*after*/ property; + /*before*/ @decorator.method(value) /*after*/ method() {} + /*before*/ @decorator.method(value) /*after*/ async method() {} + /*before*/ @decorator.method(value) /*after*/ *method() {} + /*before*/ @decorator.method(value) /*after*/ get getter() {} + /*before*/ @decorator.method(value) /*after*/ set setter(val) {} + + // two decorators without a newline + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ property; + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ method() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ async method() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ *method() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ get getter() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ set setter(val) {} + + // one decorator with a newline + @decorator.method(value) /*before*/ + /*after*/ property; + @decorator.method(value) /*before*/ + /*after*/ method() {} + @decorator.method(value) /*before*/ + /*after*/ async method() {} + @decorator.method(value) /*before*/ + /*after*/ *method() {} + @decorator.method(value) /*before*/ + /*after*/ get getter() {} + @decorator.method(value) /*before*/ + /*after*/ set setter(val) {} + + // two decorators without a newline + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ property; + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ async method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ *method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ get getter() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator.method(value) /*after*/ set setter(val) {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_mixed.js b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_mixed.js new file mode 100644 index 0000000..20b8124 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_mixed.js @@ -0,0 +1,92 @@ +class Foo { + // one decorator without a newline + @decorator.method(value) property; + @decorator.method(value) method() {} + @decorator.method(value) async method() {} + @decorator.method(value) *method() {} + @decorator.method(value) get getter() {} + @decorator.method(value) set setter(val) {} + + // two decorators without a newline + @decorator.method(value) @decorator property; + @decorator.method(value) @decorator method() {} + @decorator.method(value) @decorator async method() {} + @decorator @decorator.method(value) *method() {} + @decorator @decorator.method(value) get getter() {} + @decorator @decorator.method(value) set setter(val) {} + + // one decorator with a newline + @decorator.method(value) + property; + @decorator + method() {} + @decorator.method(value) + async method() {} + @decorator + *method() {} + @decorator.method(value) + get getter() {} + @decorator.method(value) + set setter(val) {} + + // two decorators without a newline + @decorator + @decorator.method(value) property; + @decorator.method(value) + @decorator method() {} + @decorator.method(value) + @decorator.method(value) async method() {} + @decorator.method(value) + @decorator *method() {} + @decorator.method(value) + @decorator.method(value) get getter() {} + @decorator + @decorator.method(value) set setter(val) {} +} + + +class Foo { + // one decorator without a newline + /*before*/ @decorator /*after*/ property; + /*before*/ @decorator.method(value) /*after*/ method() {} + /*before*/ @decorator.method(value) /*after*/ async method() {} + /*before*/ @decorator /*after*/ *method() {} + /*before*/ @decorator.method(value) /*after*/ get getter() {} + /*before*/ @decorator /*after*/ set setter(val) {} + + // two decorators without a newline + /*before*/ @decorator /*middle*/ @decorator.method(value) /*after*/ property; + /*before*/ @decorator.method(value) /*middle*/ @decorator /*after*/ method() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ async method() {} + /*before*/ @decorator /*middle*/ @decorator.method(value) /*after*/ *method() {} + /*before*/ @decorator /*middle*/ @decorator.method(value) /*after*/ get getter() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator /*after*/ set setter(val) {} + + // one decorator with a newline + @decorator.method(value) /*before*/ + /*after*/ property; + @decorator /*before*/ + /*after*/ method() {} + @decorator.method(value) /*before*/ + /*after*/ async method() {} + @decorator /*before*/ + /*after*/ *method() {} + @decorator.method(value) /*before*/ + /*after*/ get getter() {} + @decorator /*before*/ + /*after*/ set setter(val) {} + + // two decorators without a newline + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ property; + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ async method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ *method() {} + @decorator /*before*/ + /*middle*/ @decorator.method(value) /*after*/ get getter() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ set setter(val) {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_mixed.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_mixed.js.snap new file mode 100644 index 0000000..7d353cb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_mixed.js.snap @@ -0,0 +1,91 @@ +class Foo { + // one decorator without a newline + @decorator.method(value) property; + @decorator.method(value) method() {} + @decorator.method(value) async method() {} + @decorator.method(value) *method() {} + @decorator.method(value) get getter() {} + @decorator.method(value) set setter(val) {} + + // two decorators without a newline + @decorator.method(value) @decorator property; + @decorator.method(value) @decorator method() {} + @decorator.method(value) @decorator async method() {} + @decorator @decorator.method(value) *method() {} + @decorator @decorator.method(value) get getter() {} + @decorator @decorator.method(value) set setter(val) {} + + // one decorator with a newline + @decorator.method(value) + property; + @decorator + method() {} + @decorator.method(value) + async method() {} + @decorator + *method() {} + @decorator.method(value) + get getter() {} + @decorator.method(value) + set setter(val) {} + + // two decorators without a newline + @decorator + @decorator.method(value) property; + @decorator.method(value) + @decorator method() {} + @decorator.method(value) + @decorator.method(value) async method() {} + @decorator.method(value) + @decorator *method() {} + @decorator.method(value) + @decorator.method(value) get getter() {} + @decorator + @decorator.method(value) set setter(val) {} +} + +class Foo { + // one decorator without a newline + /*before*/ @decorator /*after*/ property; + /*before*/ @decorator.method(value) /*after*/ method() {} + /*before*/ @decorator.method(value) /*after*/ async method() {} + /*before*/ @decorator /*after*/ *method() {} + /*before*/ @decorator.method(value) /*after*/ get getter() {} + /*before*/ @decorator /*after*/ set setter(val) {} + + // two decorators without a newline + /*before*/ @decorator /*middle*/ @decorator.method(value) /*after*/ property; + /*before*/ @decorator.method(value) /*middle*/ @decorator /*after*/ method() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator.method(value) /*after*/ async method() {} + /*before*/ @decorator /*middle*/ @decorator.method(value) /*after*/ *method() {} + /*before*/ @decorator /*middle*/ @decorator.method(value) /*after*/ get getter() {} + /*before*/ @decorator.method(value) /*middle*/ @decorator /*after*/ set setter(val) {} + + // one decorator with a newline + @decorator.method(value) /*before*/ + /*after*/ property; + @decorator /*before*/ + /*after*/ method() {} + @decorator.method(value) /*before*/ + /*after*/ async method() {} + @decorator /*before*/ + /*after*/ *method() {} + @decorator.method(value) /*before*/ + /*after*/ get getter() {} + @decorator /*before*/ + /*after*/ set setter(val) {} + + // two decorators without a newline + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ property; + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ async method() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ *method() {} + @decorator /*before*/ + /*middle*/ @decorator.method(value) /*after*/ get getter() {} + @decorator.method(value) /*before*/ + /*middle*/ @decorator /*after*/ set setter(val) {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_simple.js b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_simple.js new file mode 100644 index 0000000..37d623b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_simple.js @@ -0,0 +1,92 @@ +class Foo { + // one decorator without a newline + @dec property; + @dec method() {} + @dec async method() {} + @dec *method() {} + @dec get getter() {} + @dec set setter(val) {} + + // two decorators without a newline + @dec @dec property; + @dec @dec method() {} + @dec @dec async method() {} + @dec @dec *method() {} + @dec @dec get getter() {} + @dec @dec set setter(val) {} + + // one decorator with a newline + @dec + property; + @dec + method() {} + @dec + async method() {} + @dec + *method() {} + @dec + get getter() {} + @dec + set setter(val) {} + + // two decorators without a newline + @dec + @dec property; + @dec + @dec method() {} + @dec + @dec async method() {} + @dec + @dec *method() {} + @dec + @dec get getter() {} + @dec + @dec set setter(val) {} +} + + +class Foo { + // one decorator without a newline + /*before*/ @dec /*after*/ property; + /*before*/ @dec /*after*/ method() {} + /*before*/ @dec /*after*/ async method() {} + /*before*/ @dec /*after*/ *method() {} + /*before*/ @dec /*after*/ get getter() {} + /*before*/ @dec /*after*/ set setter(val) {} + + // two decorators without a newline + /*before*/ @dec /*middle*/ @dec /*after*/ property; + /*before*/ @dec /*middle*/ @dec /*after*/ method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ async method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ *method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ get getter() {} + /*before*/ @dec /*middle*/ @dec /*after*/ set setter(val) {} + + // one decorator with a newline + @dec /*before*/ + /*after*/ property; + @dec /*before*/ + /*after*/ method() {} + @dec /*before*/ + /*after*/ async method() {} + @dec /*before*/ + /*after*/ *method() {} + @dec /*before*/ + /*after*/ get getter() {} + @dec /*before*/ + /*after*/ set setter(val) {} + + // two decorators without a newline + @dec /*before*/ + /*middle*/ @dec /*after*/ property; + @dec /*before*/ + /*middle*/ @dec /*after*/ method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ async method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ *method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ get getter() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ set setter(val) {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_simple.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_simple.js.snap new file mode 100644 index 0000000..bd854c6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_members_simple.js.snap @@ -0,0 +1,91 @@ +class Foo { + // one decorator without a newline + @dec property; + @dec method() {} + @dec async method() {} + @dec *method() {} + @dec get getter() {} + @dec set setter(val) {} + + // two decorators without a newline + @dec @dec property; + @dec @dec method() {} + @dec @dec async method() {} + @dec @dec *method() {} + @dec @dec get getter() {} + @dec @dec set setter(val) {} + + // one decorator with a newline + @dec + property; + @dec + method() {} + @dec + async method() {} + @dec + *method() {} + @dec + get getter() {} + @dec + set setter(val) {} + + // two decorators without a newline + @dec + @dec property; + @dec + @dec method() {} + @dec + @dec async method() {} + @dec + @dec *method() {} + @dec + @dec get getter() {} + @dec + @dec set setter(val) {} +} + +class Foo { + // one decorator without a newline + /*before*/ @dec /*after*/ property; + /*before*/ @dec /*after*/ method() {} + /*before*/ @dec /*after*/ async method() {} + /*before*/ @dec /*after*/ *method() {} + /*before*/ @dec /*after*/ get getter() {} + /*before*/ @dec /*after*/ set setter(val) {} + + // two decorators without a newline + /*before*/ @dec /*middle*/ @dec /*after*/ property; + /*before*/ @dec /*middle*/ @dec /*after*/ method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ async method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ *method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ get getter() {} + /*before*/ @dec /*middle*/ @dec /*after*/ set setter(val) {} + + // one decorator with a newline + @dec /*before*/ + /*after*/ property; + @dec /*before*/ + /*after*/ method() {} + @dec /*before*/ + /*after*/ async method() {} + @dec /*before*/ + /*after*/ *method() {} + @dec /*before*/ + /*after*/ get getter() {} + @dec /*before*/ + /*after*/ set setter(val) {} + + // two decorators without a newline + @dec /*before*/ + /*middle*/ @dec /*after*/ property; + @dec /*before*/ + /*middle*/ @dec /*after*/ method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ async method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ *method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ get getter() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ set setter(val) {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple.js b/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple.js new file mode 100644 index 0000000..0ef9d9a --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple.js @@ -0,0 +1,48 @@ +@dec1 export class My {} +@dec1 +export class My {} +@dec1 @dec2 export class My {} +@dec1 +@dec2 export class My {} + +@dec1 @dec2 +export class My {} + +export @dec1 class My {} +export @dec1 +class My {} +export +@dec1 class My {} + +export @dec1 @dec2 class My {} +export @dec1 +@dec2 class My {} +export @dec1 +@dec2 class My {} +export +@dec1 @dec2 class My {} + +export +@dec1 +@dec2 class My {} + +export +@dec1 +@dec2 +class My {} + +@dec1 +export @dec2 class My {} + +@dec1 export @dec2 class My {} + +@dec1 export +@dec2 class My {} + +@dec1 +export +@dec2 class My {} + +@dec1 @dec2 export @dec3 @dec4 class My {} +export @dec1 @dec2 @dec3 @dec4 class My {} + diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple.js.snap new file mode 100644 index 0000000..66ffa32 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple.js.snap @@ -0,0 +1,56 @@ +@dec1 export class My {} +@dec1 +export class My {} +@dec1 @dec2 export class My {} +@dec1 +@dec2 export class My {} + +@dec1 @dec2 +export class My {} + +export +@dec1 class My {} +export +@dec1 +class My {} +export +@dec1 class My {} + +export +@dec1 @dec2 class My {} +export +@dec1 +@dec2 class My {} +export +@dec1 +@dec2 class My {} +export +@dec1 @dec2 class My {} + +export +@dec1 +@dec2 class My {} + +export +@dec1 +@dec2 +class My {} + +@dec1 +export +@dec2 class My {} + +@dec1 export +@dec2 class My {} + +@dec1 export +@dec2 class My {} + +@dec1 +export +@dec2 class My {} + +@dec1 @dec2 export +@dec3 @dec4 class My {} +export +@dec1 @dec2 @dec3 @dec4 class My {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple_call_decorator.js b/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple_call_decorator.js new file mode 100644 index 0000000..0b63f92 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple_call_decorator.js @@ -0,0 +1,48 @@ +@decorator.method(value) export class Foo {} +@decorator.method(value) +export class Foo {} +@decorator.method(value) @decorator2.method(value) export class Foo {} +@decorator.method(value) +@decorator2.method(value) export class Foo {} + +@decorator.method(value) @decorator2.method(value) +export class Foo {} + +export @decorator.method(value) class Foo {} +export @decorator.method(value) +class Foo {} +export +@decorator.method(value) class Foo {} + +export @decorator.method(value) @decorator2.method(value) class Foo {} +export @decorator.method(value) +@decorator2.method(value) class Foo {} +export @decorator.method(value) +@decorator2.method(value) class Foo {} +export +@decorator.method(value) @decorator2.method(value) class Foo {} + +export +@decorator.method(value) +@decorator2.method(value) class Foo {} + +export +@decorator.method(value) +@decorator2.method(value) +class Foo {} + +@decorator.method(value) +export @decorator2.method(value) class Foo {} + +@decorator.method(value) export @decorator2.method(value) class Foo {} + +@decorator.method(value) export +@decorator2.method(value) class Foo {} + +@decorator.method(value) +export +@decorator2.method(value) class Foo {} + +@decorator.method(value) @decorator2.method(value) export @decorator3.method(value) @decorator4.method(value) class Foo {} +export @decorator.method(value) @decorator2.method(value) @decorator3.method(value) @decorator4.method(value) class Foo {} + diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple_call_decorator.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple_call_decorator.js.snap new file mode 100644 index 0000000..b2b0330 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/class_simple_call_decorator.js.snap @@ -0,0 +1,56 @@ +@decorator.method(value) export class Foo {} +@decorator.method(value) +export class Foo {} +@decorator.method(value) @decorator2.method(value) export class Foo {} +@decorator.method(value) +@decorator2.method(value) export class Foo {} + +@decorator.method(value) @decorator2.method(value) +export class Foo {} + +export +@decorator.method(value) class Foo {} +export +@decorator.method(value) +class Foo {} +export +@decorator.method(value) class Foo {} + +export +@decorator.method(value) @decorator2.method(value) class Foo {} +export +@decorator.method(value) +@decorator2.method(value) class Foo {} +export +@decorator.method(value) +@decorator2.method(value) class Foo {} +export +@decorator.method(value) @decorator2.method(value) class Foo {} + +export +@decorator.method(value) +@decorator2.method(value) class Foo {} + +export +@decorator.method(value) +@decorator2.method(value) +class Foo {} + +@decorator.method(value) +export +@decorator2.method(value) class Foo {} + +@decorator.method(value) export +@decorator2.method(value) class Foo {} + +@decorator.method(value) export +@decorator2.method(value) class Foo {} + +@decorator.method(value) +export +@decorator2.method(value) class Foo {} + +@decorator.method(value) @decorator2.method(value) export +@decorator3.method(value) @decorator4.method(value) class Foo {} +export +@decorator.method(value) @decorator2.method(value) @decorator3.method(value) @decorator4.method(value) class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_1.js b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_1.js new file mode 100644 index 0000000..fa13a16 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_1.js @@ -0,0 +1 @@ +@dec export default class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_1.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_1.js.snap new file mode 100644 index 0000000..fa13a16 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_1.js.snap @@ -0,0 +1 @@ +@dec export default class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_2.js b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_2.js new file mode 100644 index 0000000..1673ed1 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_2.js @@ -0,0 +1 @@ + export default @dec class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_2.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_2.js.snap new file mode 100644 index 0000000..9c6a85f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_2.js.snap @@ -0,0 +1,2 @@ +export default +@dec class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_3.js b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_3.js new file mode 100644 index 0000000..079f9d8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_3.js @@ -0,0 +1 @@ +@dec1 export default @dec2 class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_3.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_3.js.snap new file mode 100644 index 0000000..fbda1ca --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_3.js.snap @@ -0,0 +1,2 @@ +@dec1 export default +@dec2 class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_4.js b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_4.js new file mode 100644 index 0000000..e59a24c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_4.js @@ -0,0 +1 @@ +@dec1 @dec2 export default @dec3 @dec4 class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_4.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_4.js.snap new file mode 100644 index 0000000..c20e030 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/export_default_4.js.snap @@ -0,0 +1,2 @@ +@dec1 @dec2 export default +@dec3 @dec4 class Foo {} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/expression.js b/crates/rome_fmt/test_data/specs/js/module/decorators/expression.js new file mode 100644 index 0000000..81d0bb4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/expression.js @@ -0,0 +1,21 @@ +console.log(@deco class Foo {}) +console.log(@deco class {}) + +const a1 = (@deco class Foo {}); +const a2 = (@deco class {}); + +(@deco class Foo {}); +(@deco class {}); + +const b1 = [] +;(@deco class Foo {}) + +const b2 = [] +;(@deco class {}) + +(@deco class Foo {}).name; +(@deco class {}).name; + +class Foo extends (@deco class Foo {}){} + +class Foo extends (@deco class {}){} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/expression.js.snap new file mode 100644 index 0000000..5b7d036 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/expression.js.snap @@ -0,0 +1,43 @@ +console.log(@deco class Foo {}); +console.log(@deco class {}); + +const a1 = ( +@deco class Foo {} +) +const a2 = ( +@deco class {} +) + +( +@deco class Foo {} +) +( +@deco class {} +) + +const b1 = []; +( +@deco class Foo {} +) + +const b2 = []; +( +@deco class {} +) + +( +@deco class Foo {} +).name +( +@deco class {} +).name + +class Foo extends (@deco class Foo {} +) +{ +} + +class Foo extends (@deco class {} +) +{ +} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/multiline.js b/crates/rome_fmt/test_data/specs/js/module/decorators/multiline.js new file mode 100644 index 0000000..31b1724 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/multiline.js @@ -0,0 +1,16 @@ +class Foo { + @deco([ + foo, + bar + ]) prop = value; + + @decorator([]) method() {} + + @decorator([ + ]) method() {} + + @decorator({}) method() {} + + @decorator({ + }) method() {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/decorators/multiline.js.snap b/crates/rome_fmt/test_data/specs/js/module/decorators/multiline.js.snap new file mode 100644 index 0000000..31b1724 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/decorators/multiline.js.snap @@ -0,0 +1,16 @@ +class Foo { + @deco([ + foo, + bar + ]) prop = value; + + @decorator([]) method() {} + + @decorator([ + ]) method() {} + + @decorator({}) method() {} + + @decorator({ + }) method() {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/each/each.js b/crates/rome_fmt/test_data/specs/js/module/each/each.js new file mode 100644 index 0000000..d3882b6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/each/each.js @@ -0,0 +1,66 @@ +describe.each` +a|b|expected +${11 } | ${ 1 }|${222} +${1-1}|${2+2}|${ 3333} +${2+1+2}|${1111}|${3} +`('$a + $b', ({a, b, expected}) => { + test(`returns ${expected}`, () => { + expect(a + b).toBe(expected); + }); + + test(`returned value not be greater than ${expected}`, () => { + expect(a + b).not.toBeGreaterThan(expected); + }); + + test(`returned value not be less than ${expected}`, () => { + expect(a + b).not.toBeLessThan(expected); + }); +}); + +describe.only.each` +a|b|expected +${11 } | ${ 1 }|${222}|${'unknown column 1'}|${'unknown column 2'} +${1-1}|${2+2}|${ 3333} +${2+1+2}|${1111}|${3} |${'unknown column xyz'} +` + +describe.only.each` +|| +${11 } | ${ 1 }|${222}|${'unknown column 1'}|${'unknown column 2'} +${1-1}|${2+2}|${ 3333} +${2+1+2}|${1111}|${3} |${'unknown column xyz'} +` + +describe.each`a | b | expected +${1} | ${1} | ${2} +${1} | ${2} | ${3} +${2} | ${1} | ${3}` + +// an example to demo multiline quasi +describe.each`a | b | expected +${11111111111} | ${a().b(x => x).c().d()} | ${2} +${1} | ${2} | ${3} +${2} | ${1} | ${3}` + +test.each` +a | b | c +${1} | ${[{ start: 5, end: 15 }]} | ${[1,2,3,4,5,6,7,8]} +${1}| ${[{ start: 5, end: 15 }]} | ${["test", "string", "for", "prettier"]} +${3} | ${[{ start: 5, end: 15 }]} | ${[]} +${4} | ${[{ start: 1, end: 3 },{ start: 15, end: 20 },]} | ${[]} +`("example test", ({a, b, c}) => {}) + + +test.each` +a | +${[{ a: 1, b: 3 },{ c: 15, d: 20 }]}| +${[{ start: 1, end: 3 },{ start: 15, end: 20 }, { start: 15, end: 20 },]}| +`("example test", ({a, b, c}) => {}) + + +// here poor layout because the first element isn't header +describe.each`${1}a | b | expected +${11111111111} | ${2} | ${2} +${1} | ${2} | ${3} +${2} | ${1} | ${3}` + diff --git a/crates/rome_fmt/test_data/specs/js/module/each/each.js.snap b/crates/rome_fmt/test_data/specs/js/module/each/each.js.snap new file mode 100644 index 0000000..fc40f77 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/each/each.js.snap @@ -0,0 +1,70 @@ +describe.each` + a | b | expected + ${11} | ${1} | ${222} + ${1 - 1} | ${2 + 2} | ${3333} + ${2 + 1 + 2} | ${1111} | ${3} +`("$a + $b", ({ a, b, expected }) => { + test(`returns ${expected}`, () => { + expect(a + b).toBe(expected); + }); + + test(`returned value not be greater than ${expected}`, () => { + expect(a + b).not.toBeGreaterThan(expected); + }); + + test(`returned value not be less than ${expected}`, () => { + expect(a + b).not.toBeLessThan(expected); + }); +}); + +describe.only.each` + a | b | expected + ${11} | ${1} | ${222} | ${"unknown column 1"} | ${"unknown column 2"} + ${1 - 1} | ${2 + 2} | ${3333} + ${2 + 1 + 2} | ${1111} | ${3} | ${"unknown column xyz"} +`; + +describe.only.each` + | | + ${11} | ${1} | ${222} | ${"unknown column 1"} | ${"unknown column 2"} + ${1 - 1} | ${2 + 2} | ${3333} + ${2 + 1 + 2} | ${1111} | ${3} | ${"unknown column xyz"} +`; + +describe.each` + a | b | expected + ${1} | ${1} | ${2} + ${1} | ${2} | ${3} + ${2} | ${1} | ${3} +`; + +// an example to demo multiline quasi +describe.each` + a | b | expected + ${11111111111} | ${a() + .b((x) => x) + .c() + .d()} | ${2} + ${1} | ${2} | ${3} + ${2} | ${1} | ${3} +`; + +test.each` + a | b | c + ${1} | ${[{ start: 5, end: 15 }]} | ${[1, 2, 3, 4, 5, 6, 7, 8]} + ${1} | ${[{ start: 5, end: 15 }]} | ${["test", "string", "for", "prettier"]} + ${3} | ${[{ start: 5, end: 15 }]} | ${[]} + ${4} | ${[{ start: 1, end: 3 }, { start: 15, end: 20 }]} | ${[]} +`("example test", ({ a, b, c }) => {}); + +test.each` + a | + ${[{ a: 1, b: 3 }, { c: 15, d: 20 }]} + ${[{ start: 1, end: 3 }, { start: 15, end: 20 }, { start: 15, end: 20 }]} +`("example test", ({ a, b, c }) => {}); + +// here poor layout because the first element isn't header +describe.each`${1}a | b | expected +${11111111111} | ${2} | ${2} +${1} | ${2} | ${3} +${2} | ${1} | ${3}`; diff --git a/crates/rome_fmt/test_data/specs/js/module/export/class_clause.js b/crates/rome_fmt/test_data/specs/js/module/export/class_clause.js new file mode 100644 index 0000000..1c132d8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/class_clause.js @@ -0,0 +1,9 @@ +// another comment +export class A { // small comment + constructor() { + } +} + + +export default class +B {} diff --git a/crates/rome_fmt/test_data/specs/js/module/export/class_clause.js.snap b/crates/rome_fmt/test_data/specs/js/module/export/class_clause.js.snap new file mode 100644 index 0000000..f153a74 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/class_clause.js.snap @@ -0,0 +1,7 @@ +// another comment +export class A { + // small comment + constructor() {} +} + +export default class B {} diff --git a/crates/rome_fmt/test_data/specs/js/module/export/expression_clause.js b/crates/rome_fmt/test_data/specs/js/module/export/expression_clause.js new file mode 100644 index 0000000..6cda1a4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/expression_clause.js @@ -0,0 +1 @@ +export default (1 - 43); \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/export/expression_clause.js.snap b/crates/rome_fmt/test_data/specs/js/module/export/expression_clause.js.snap new file mode 100644 index 0000000..0ff47cd --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/expression_clause.js.snap @@ -0,0 +1 @@ +export default 1 - 43; diff --git a/crates/rome_fmt/test_data/specs/js/module/export/from_clause.js b/crates/rome_fmt/test_data/specs/js/module/export/from_clause.js new file mode 100644 index 0000000..7235ae9 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/from_clause.js @@ -0,0 +1,5 @@ +export * from "hey" + +export * as something_bad_will_happen from "something_bad_might_not_happen" + +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/export/from_clause.js.snap b/crates/rome_fmt/test_data/specs/js/module/export/from_clause.js.snap new file mode 100644 index 0000000..0c86cbc --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/from_clause.js.snap @@ -0,0 +1,8 @@ +export * from "hey"; + +export * as something_bad_will_happen from "something_bad_might_not_happen"; + +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { + "type": "json", + "type2": "json3", +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/export/function_clause.js b/crates/rome_fmt/test_data/specs/js/module/export/function_clause.js new file mode 100644 index 0000000..d3f42cc --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/function_clause.js @@ -0,0 +1,9 @@ +export function f() { + + +} + + +export default function ff() { + +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/export/function_clause.js.snap b/crates/rome_fmt/test_data/specs/js/module/export/function_clause.js.snap new file mode 100644 index 0000000..71d5ffa --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/function_clause.js.snap @@ -0,0 +1,3 @@ +export function f() {} + +export default function ff() {} diff --git a/crates/rome_fmt/test_data/specs/js/module/export/named_clause.js b/crates/rome_fmt/test_data/specs/js/module/export/named_clause.js new file mode 100644 index 0000000..bfc4318 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/named_clause.js @@ -0,0 +1,7 @@ +export { + // the boo api + boo, + // the buzz api is now bar!! + buzz as bar, + +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/export/named_clause.js.snap b/crates/rome_fmt/test_data/specs/js/module/export/named_clause.js.snap new file mode 100644 index 0000000..3b1c044 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/named_clause.js.snap @@ -0,0 +1,6 @@ +export { + // the boo api + boo, + // the buzz api is now bar!! + buzz as bar, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/export/named_from_clause.js b/crates/rome_fmt/test_data/specs/js/module/export/named_from_clause.js new file mode 100644 index 0000000..a8f3ac2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/named_from_clause.js @@ -0,0 +1,20 @@ +export {a, + b as c +} from "fancy" assert { type: "json"} + + +export { + lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem, + lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_ +} from "fancy" assert { type: "json", "type2": "json", type23: "json", "type24": "json"} + + +export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +export { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +export { +// comment +loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/export/named_from_clause.js.snap b/crates/rome_fmt/test_data/specs/js/module/export/named_from_clause.js.snap new file mode 100644 index 0000000..5771075 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/named_from_clause.js.snap @@ -0,0 +1,22 @@ +export { a, b as c } from "fancy" assert { type: "json" }; + +export { + lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem, + lorem_lorem_lorem_lorem_lorem_ as ipsum_ipsum_ipsum_ipsum_ipsum_ipsum_, +} from "fancy" assert { + type: "json", + "type2": "json", + type23: "json", + "type24": "json", +}; + +export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"; + +export { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"; + +export { + // comment + loooooooooooooooooooooooooooooooooooooooooooooooooong, +} from "loooooooooooooooooooooooooooooooooooooooooooooong"; + +export { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"; diff --git a/crates/rome_fmt/test_data/specs/js/module/export/trailing-comma/export_trailing_comma.js b/crates/rome_fmt/test_data/specs/js/module/export/trailing-comma/export_trailing_comma.js new file mode 100644 index 0000000..913c081 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/trailing-comma/export_trailing_comma.js @@ -0,0 +1,5 @@ +export { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/export/trailing-comma/export_trailing_comma.js.snap b/crates/rome_fmt/test_data/specs/js/module/export/trailing-comma/export_trailing_comma.js.snap new file mode 100644 index 0000000..913c081 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/trailing-comma/export_trailing_comma.js.snap @@ -0,0 +1,5 @@ +export { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/export/variable_declaration.js b/crates/rome_fmt/test_data/specs/js/module/export/variable_declaration.js new file mode 100644 index 0000000..ed7431a --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/variable_declaration.js @@ -0,0 +1,3 @@ +export let a, d, c; + +export const foofoofoofoofoofoofoo = "ahah", barbarbarbarbarbarbar = {}, loremloremloremloremlorem = [] \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/export/variable_declaration.js.snap b/crates/rome_fmt/test_data/specs/js/module/export/variable_declaration.js.snap new file mode 100644 index 0000000..abba3a4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/export/variable_declaration.js.snap @@ -0,0 +1,5 @@ +export let a, d, c; + +export const foofoofoofoofoofoofoo = "ahah", + barbarbarbarbarbarbar = {}, + loremloremloremloremlorem = []; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/binary_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/binary_expression.js new file mode 100644 index 0000000..88c0208 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/binary_expression.js @@ -0,0 +1,34 @@ +a + b +a < b +a > b +a <= b +a >= b +a == b +a === b +a != b +a !== b +a + b +a - b +a * b +a / b +a % b +a ** b +a << b +a >> b +a >>> b +a & b +a | b +a ^ b +a in b +a instanceof b + +a + b * c > 65; +a + b * c > 65 + 5; +2 > 65 << 5 + 3 >> 3; +2 > 4 + 4 * 24 % 3 << 23; + + + +a + b + 4 + +// rome-ignore format: Test formatting ignored binary expressions + - 4_444_444; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/binary_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/binary_expression.js.snap new file mode 100644 index 0000000..d8bb254 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/binary_expression.js.snap @@ -0,0 +1,34 @@ +a + b; +a < b; +a > b; +a <= b; +a >= b; +a == b; +a === b; +a != b; +a !== b; +a + b; +a - b; +a * b; +a / b; +a % b; +a ** b; +a << b; +a >> b; +a >>> b; +a & b; +a | b; +a ^ b; +a in b; +a instanceof b; + +a + b * c > 65; +a + b * c > 65 + 5; +2 > (65 << (5 + 3)) >> 3; +2 > (4 + ((4 * 24) % 3)) << 23; + +a + + b + + 4 + + // rome-ignore format: Test formatting ignored binary expressions + - 4_444_444; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/binaryish_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/binaryish_expression.js new file mode 100644 index 0000000..dc47120 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/binaryish_expression.js @@ -0,0 +1 @@ +2 > 4 + 4 * 24 % 3 << 23 instanceof Number in data || a in status instanceof String + 15 && foo && bar && lorem instanceof String; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/binaryish_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/binaryish_expression.js.snap new file mode 100644 index 0000000..4080426 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/binaryish_expression.js.snap @@ -0,0 +1,2 @@ +2 > (4 + ((4 * 24) % 3)) << 23 instanceof Number in data || + (a in status instanceof String + 15 && foo && bar && lorem instanceof String); diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/computed-member-expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/computed-member-expression.js new file mode 100644 index 0000000..7c4fe76 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/computed-member-expression.js @@ -0,0 +1 @@ +a["test"][5 + 5][call()]; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/computed-member-expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/computed-member-expression.js.snap new file mode 100644 index 0000000..7c4fe76 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/computed-member-expression.js.snap @@ -0,0 +1 @@ +a["test"][5 + 5][call()]; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/conditional_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/conditional_expression.js new file mode 100644 index 0000000..984af42 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/conditional_expression.js @@ -0,0 +1,10 @@ +a ? b : c +d + ? (e + f) + : (g + h) + +somethingThatsAReallyLongPropName ? somethingThatsAReallyLongPropName : somethingThatsAReallyLongPropName + +somethingThatsAReallyLongPropName ? somethingThatsAReallyLongPropName ? somethingThatsAReallyLongPropName : somethingThatsAReallyLongPropName : somethingThatsAReallyLongPropName + +somethingThatsAReallyLongPropName ? somethingThatsAReallyLongPropName : somethingThatsAReallyLongPropName ? somethingThatsAReallyLongPropName : somethingThatsAReallyLongPropName \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/conditional_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/conditional_expression.js.snap new file mode 100644 index 0000000..815acb0 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/conditional_expression.js.snap @@ -0,0 +1,18 @@ +a ? b : c; +d ? e + f : g + h; + +somethingThatsAReallyLongPropName + ? somethingThatsAReallyLongPropName + : somethingThatsAReallyLongPropName; + +somethingThatsAReallyLongPropName + ? somethingThatsAReallyLongPropName + ? somethingThatsAReallyLongPropName + : somethingThatsAReallyLongPropName + : somethingThatsAReallyLongPropName; + +somethingThatsAReallyLongPropName + ? somethingThatsAReallyLongPropName + : somethingThatsAReallyLongPropName + ? somethingThatsAReallyLongPropName + : somethingThatsAReallyLongPropName; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/import_meta_expression/import_meta_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/import_meta_expression/import_meta_expression.js new file mode 100644 index 0000000..8b5c473 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/import_meta_expression/import_meta_expression.js @@ -0,0 +1,3 @@ +console.log(import.meta); +import.meta.field = obj.aReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariable; +import.meta.aReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariable; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/import_meta_expression/import_meta_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/import_meta_expression/import_meta_expression.js.snap new file mode 100644 index 0000000..e903d5a --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/import_meta_expression/import_meta_expression.js.snap @@ -0,0 +1,5 @@ +console.log(import.meta); +import.meta.field = + obj.aReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariableName.andAnotherReallyLongVariable; +import.meta.aReallyLongVariableName.andAnotherReallyLongVariableName + .andAnotherReallyLongVariableName.andAnotherReallyLongVariable; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/literal_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/literal_expression.js new file mode 100644 index 0000000..e458889 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/literal_expression.js @@ -0,0 +1,7 @@ +"a" +1 +45n +true +false +null +;/[/]\/\u0aBc/mgi; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/literal_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/literal_expression.js.snap new file mode 100644 index 0000000..22a2dfa --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/literal_expression.js.snap @@ -0,0 +1,7 @@ +"a"; +1; +45n; +true; +false; +null; +/[/]\/\u0aBc/gim; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/logical_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/logical_expression.js new file mode 100644 index 0000000..3c7084b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/logical_expression.js @@ -0,0 +1,112 @@ +x ?? y; +x || y; +x && y; + + +lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem && lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem && lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem && lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem; + + +if (something && elsewhere && happy && thoughts && something && elsewhere && happy && thoughts && somethingsomethingsomethingsomethin) {} + +do { + +} while (something && elsewhere && happy && thoughts && something && elsewhere && happy && thoughts && somethingsomethingsomethingsomethin) + +switch (something && elsewhere && happy && thoughts && something && elsewhere && happy && thoughts && somethingsomethingsomethingsomethin) { + default: {} +} + +while (something && elsewhere && happy && thoughts && something && elsewhere && happy && thoughts && somethingsomethingsomethingsomethin) {} + +(something && elsewhere && happy && thoughts) + +function a() { + return something && elsewhere && happy && thoughts && somethingsomethingsomethingsomething && thoughts && somethingsomethingsomethingsomething; +} + +const a = () => aa && bb && +something && +somethingsomethingsomethingsomething; + +const a = () => aa && bb && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething && somethingsomethingsomethingsomething && somethingsomethingsomethingsomething; + + +const a = aa && bb && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething; + + +const a = x + y + + +{ something && lsewhere && +happy && +thoughts && dldldlldldldldldldldl && dldldlldldldldldldldl +} + +if ( somethingsomethingsomethingsomethin && somethingsomethingsomethingsomethin || somethingsomethingsomethingsomethin && somethingsomethingsomethingsomethin) {} + + +undefined === function () { + throw undefined; +}; + +const b = `${(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar)}`; + + +const a = + aa && + bb && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething || + aa && + bb && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething; + + +( + lorem && // foo + ipsum +); + +( + lorem && call_function(1, 3) // foo +); + +( + lorem && + // foo + (3 + 6 == 9) +); + + +let a = a || b && c; + +let foo = one && two || three && four || five && six; + +// Implicitly parenthesized && and || requires parens +foo && bar || baz; + + +a instanceof Number instanceof String instanceof Boolean instanceof Number instanceof String instanceof Boolean instanceof Number instanceof String instanceof Boolean; + +a in LongClassName in LongClassName in LongClassName in LongClassName in LongClassName in LongClassName in LongClassName in LongClassName in LongClassName; + + +veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo instanceof String && veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar instanceof Number || veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar instanceof Boolean + diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/logical_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/logical_expression.js.snap new file mode 100644 index 0000000..ff37381 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/logical_expression.js.snap @@ -0,0 +1,182 @@ +x ?? y; +x || y; +x && y; + +lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem && + lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem && + lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem && + lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem_lorem; + +if ( + something && + elsewhere && + happy && + thoughts && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomethin +) { +} + +do {} while ( + something && + elsewhere && + happy && + thoughts && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomethin +); + +switch ( + something && + elsewhere && + happy && + thoughts && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomethin +) { + default: { + } +} + +while ( + something && + elsewhere && + happy && + thoughts && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomethin +) {} + +something && elsewhere && happy && thoughts; + +function a() { + return ( + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething && + thoughts && + somethingsomethingsomethingsomething + ); +} + +const a = () => aa && bb && something && somethingsomethingsomethingsomething; + +const a = () => + aa && + bb && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething && + somethingsomethingsomethingsomething && + somethingsomethingsomethingsomething; + +const a = + aa && + bb && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething; + +const a = x + y; + +{ + something && + lsewhere && + happy && + thoughts && + dldldlldldldldldldldl && + dldldlldldldldldldldl; +} + +if ( + (somethingsomethingsomethingsomethin && + somethingsomethingsomethingsomethin) || + (somethingsomethingsomethingsomethin && somethingsomethingsomethingsomethin) +) { +} + +undefined === + function () { + throw undefined; + }; + +const b = `${ + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo + + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar +}`; + +const a = + (aa && + bb && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething) || + (aa && + bb && + something && + elsewhere && + happy && + thoughts && + somethingsomethingsomethingsomething); + +lorem && // foo + ipsum; + +lorem && call_function(1, 3); // foo + +lorem && + // foo + 3 + 6 == 9; + +let a = a || (b && c); + +let foo = (one && two) || (three && four) || (five && six); + +// Implicitly parenthesized && and || requires parens +(foo && bar) || baz; + +a instanceof + Number instanceof + String instanceof + Boolean instanceof + Number instanceof + String instanceof + Boolean instanceof + Number instanceof + String instanceof + Boolean; + +a in + LongClassName in + LongClassName in + LongClassName in + LongClassName in + LongClassName in + LongClassName in + LongClassName in + LongClassName in + LongClassName; + +(veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongFoo instanceof String && + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar instanceof Number) || + veryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongBar instanceof Boolean; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/complex_arguments.js b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/complex_arguments.js new file mode 100644 index 0000000..59cdd9c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/complex_arguments.js @@ -0,0 +1,5 @@ +client.execute( + Post.selectAll() + .where(Post.id.eq(42)) + .where(Post.published.eq(true)) +); diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/complex_arguments.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/complex_arguments.js.snap new file mode 100644 index 0000000..ac9fb67 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/complex_arguments.js.snap @@ -0,0 +1,3 @@ +client.execute( + Post.selectAll().where(Post.id.eq(42)).where(Post.published.eq(true)), +); diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/computed.js b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/computed.js new file mode 100644 index 0000000..f0d3dd1 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/computed.js @@ -0,0 +1,6 @@ +nock(/test/) + .matchHeader('Accept', 'application/json') + [httpMethodNock(method)]('/foo') + .reply(200, { + foo: 'bar', + }); \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/computed.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/computed.js.snap new file mode 100644 index 0000000..a5fb4ff --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/computed.js.snap @@ -0,0 +1,6 @@ +nock(/test/) + .matchHeader("Accept", "application/json") + [httpMethodNock(method)]("/foo") + .reply(200, { + foo: "bar", + }); diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/inline-merge.js b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/inline-merge.js new file mode 100644 index 0000000..b32f6dc --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/inline-merge.js @@ -0,0 +1,13 @@ +_.flatMap(this.visibilityHandlers, fn => fn()) + .concat(this.record.resolved_legacy_visrules) + .filter(Boolean) + +Object + .keys( + availableLocales({ + test: true + }) +) + .forEach(locale => { + // ... + }); \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/inline-merge.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/inline-merge.js.snap new file mode 100644 index 0000000..a05ca4c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/member-chain/inline-merge.js.snap @@ -0,0 +1,11 @@ +_.flatMap(this.visibilityHandlers, (fn) => fn()) + .concat(this.record.resolved_legacy_visrules) + .filter(Boolean); + +Object.keys( + availableLocales({ + test: true, + }), +).forEach((locale) => { + // ... +}); diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/new_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/new_expression.js new file mode 100644 index 0000000..79d5845 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/new_expression.js @@ -0,0 +1,3 @@ +new a() +new b(x) +new c(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,cccccccccccccccccccccccccccccc) diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/new_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/new_expression.js.snap new file mode 100644 index 0000000..d280bd3 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/new_expression.js.snap @@ -0,0 +1,7 @@ +new a(); +new b(x); +new c( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + cccccccccccccccccccccccccccccc, +); diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/post_update_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/post_update_expression.js new file mode 100644 index 0000000..568776d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/post_update_expression.js @@ -0,0 +1,4 @@ +y++ +y-- +x = y++ +x = y-- diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/post_update_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/post_update_expression.js.snap new file mode 100644 index 0000000..958be25 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/post_update_expression.js.snap @@ -0,0 +1,4 @@ +y++; +y--; +x = y++; +x = y--; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/pre_update_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/pre_update_expression.js new file mode 100644 index 0000000..800ed13 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/pre_update_expression.js @@ -0,0 +1,4 @@ +++y +--y +x = ++y +x = --y diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/pre_update_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/pre_update_expression.js.snap new file mode 100644 index 0000000..01df83d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/pre_update_expression.js.snap @@ -0,0 +1,4 @@ +++y; +--y; +x = ++y; +x = --y; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/sequence_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/sequence_expression.js new file mode 100644 index 0000000..a70c3da --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/sequence_expression.js @@ -0,0 +1,33 @@ +a,b + +const f = () => ( + ____________first, ____________second, ____________third, ____________third, ____________third, ____________third, ____________third + +); + +( + ____________first, ____________second, ____________third, ____________third, ____________third, ____________third, ____________third + +) + +function a() { + return ____________first, ____________second, ____________third, ____________third, ____________third, ____________third, ____________third +} + +const object ={ + something: ( + ____________first, ____________second, ____________third, ____________third, ____________third, ____________third, ____________third + ) + +} + +a, + // rome-ignore format: Test suppression comments + [ + 0, 1, 2 + ], d; + +aLongIdentifierName, + aLongIdentifierName, + aLongIdentifierName, + aLongIdentifierName; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/sequence_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/sequence_expression.js.snap new file mode 100644 index 0000000..67c8451 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/sequence_expression.js.snap @@ -0,0 +1,54 @@ +a, b; + +const f = () => ( + ____________first, + ____________second, + ____________third, + ____________third, + ____________third, + ____________third, + ____________third +); + +____________first, + ____________second, + ____________third, + ____________third, + ____________third, + ____________third, + ____________third; + +function a() { + return ( + ____________first, + ____________second, + ____________third, + ____________third, + ____________third, + ____________third, + ____________third + ); +} + +const object = { + something: + (____________first, + ____________second, + ____________third, + ____________third, + ____________third, + ____________third, + ____________third), +}; + +a, + // rome-ignore format: Test suppression comments + [ + 0, 1, 2 + ], + d; + +aLongIdentifierName, + aLongIdentifierName, + aLongIdentifierName, + aLongIdentifierName; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/static_member_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/static_member_expression.js new file mode 100644 index 0000000..5f2812e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/static_member_expression.js @@ -0,0 +1,20 @@ +a.b +a?.b +a.#b +a?.#b +a?.b.#c +a?.#b.c().d + +lorem.ipsum(); +lorem.ipsum().looooooooooooooooooooooooooong().looooooooooooooooooooooooooong().looooooooooooooooooooooooooong(); +lorem()[0]().ipsum().looooooooooooooooooooooooooong().looooooooooooooooooooooooooong().looooooooooooooooooooooooooong(); + + +something()[1]()[3]().items.item.what_else[3]().something().something().then().catcht().else().what_the_hell(); + + +some.member.with. + // rome-ignore format: Verify that formatting calls into right.format() + rather.hard.to.test.because.name.doesnt.format + + . being.ignored; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/static_member_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/static_member_expression.js.snap new file mode 100644 index 0000000..f01d883 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/static_member_expression.js.snap @@ -0,0 +1,31 @@ +a.b; +a?.b; +a.#b; +a?.#b; +a?.b.#c; +a?.#b.c().d; + +lorem.ipsum(); +lorem + .ipsum() + .looooooooooooooooooooooooooong() + .looooooooooooooooooooooooooong() + .looooooooooooooooooooooooooong(); +lorem()[0]() + .ipsum() + .looooooooooooooooooooooooooong() + .looooooooooooooooooooooooooong() + .looooooooooooooooooooooooooong(); + +something()[1]()[3]() + .items.item.what_else[3]() + .something() + .something() + .then() + .catcht() + .else() + .what_the_hell(); + +some.member.with. + // rome-ignore format: Verify that formatting calls into right.format() + rather.hard.to.test.because.name.doesnt.format.being.ignored; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/this_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/this_expression.js new file mode 100644 index 0000000..9ecf3cf --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/this_expression.js @@ -0,0 +1 @@ +this diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/this_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/this_expression.js.snap new file mode 100644 index 0000000..b251f26 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/this_expression.js.snap @@ -0,0 +1 @@ +this; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression.js b/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression.js new file mode 100644 index 0000000..2c16c7d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression.js @@ -0,0 +1,14 @@ +delete a.a +void b +typeof c +x = +1 +x = -1 +x = ~1 +x = !1 +delete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +typeof aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +x = +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +x = -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +x = ~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +x = !aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression.js.snap new file mode 100644 index 0000000..9e6f44d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression.js.snap @@ -0,0 +1,18 @@ +delete a.a; +void b; +typeof c; +x = +1; +x = -1; +x = ~1; +x = !1; +delete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +typeof aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +x = + +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +x = + -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +x = + ~aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +x = + !aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression_verbatim_argument.js b/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression_verbatim_argument.js new file mode 100644 index 0000000..0172fb4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression_verbatim_argument.js @@ -0,0 +1,8 @@ +// https://github.com/rome/tools/issues/3735 + +!( + // rome-ignore format: Work around https://github.com/rome/tools/issues/3734 + a && b +); + + diff --git a/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression_verbatim_argument.js.snap b/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression_verbatim_argument.js.snap new file mode 100644 index 0000000..e6c62b2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/expression/unary_expression_verbatim_argument.js.snap @@ -0,0 +1,6 @@ +// https://github.com/rome/tools/issues/3735 + +!( + // rome-ignore format: Work around https://github.com/rome/tools/issues/3734 + a && b +); diff --git a/crates/rome_fmt/test_data/specs/js/module/function/function.js b/crates/rome_fmt/test_data/specs/js/module/function/function.js new file mode 100644 index 0000000..9b1e335 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/function/function.js @@ -0,0 +1,32 @@ +function foo() { +} +async function foo(a) { + await x +} +x = function() { +} +x = async function* foo(a) { +} +function Foo() { + if (!new.target) { } +} +function* Foo() { + yield + yield x + yield* x + yield aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + yield* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +} +function foo() { + let [ref, setRef] = useState(); + + useEffect(() => { + setRef() + }); + + return ref; +} + +function directives() { + "use strict"; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/function/function.js.snap b/crates/rome_fmt/test_data/specs/js/module/function/function.js.snap new file mode 100644 index 0000000..a51112d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/function/function.js.snap @@ -0,0 +1,30 @@ +function foo() {} +async function foo(a) { + await x; +} +x = function () {}; +x = async function* foo(a) {}; +function Foo() { + if (!new.target) { + } +} +function* Foo() { + yield; + yield x; + yield* x; + yield aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + yield* aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; +} +function foo() { + let [ref, setRef] = useState(); + + useEffect(() => { + setRef(); + }); + + return ref; +} + +function directives() { + "use strict"; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/function/function_args.js b/crates/rome_fmt/test_data/specs/js/module/function/function_args.js new file mode 100644 index 0000000..110d2e4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/function/function_args.js @@ -0,0 +1,3 @@ +function foo(someotherlongvariableshould1, someotherlongvariableshould2, someotherlongvariableshould3, someotherlongvariableshould4, someotherlongvariableshould5, someotherlongvariableshould6 = foooooooooooo, ...someotherlongvariableshould7) { + return "nothing"; +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/function/function_args.js.snap b/crates/rome_fmt/test_data/specs/js/module/function/function_args.js.snap new file mode 100644 index 0000000..39f94c1 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/function/function_args.js.snap @@ -0,0 +1,11 @@ +function foo( + someotherlongvariableshould1, + someotherlongvariableshould2, + someotherlongvariableshould3, + someotherlongvariableshould4, + someotherlongvariableshould5, + someotherlongvariableshould6 = foooooooooooo, + ...someotherlongvariableshould7 +) { + return "nothing"; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/function/function_comments.js b/crates/rome_fmt/test_data/specs/js/module/function/function_comments.js new file mode 100644 index 0000000..996c1ab --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/function/function_comments.js @@ -0,0 +1,17 @@ +function a() { // trailing comment + let a = 2; + + + /** leading comment **/ } + + +function b() // leading comment +{ // trailing + + +} + + +function c( //some comment + foo, bar, +) {} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/function/function_comments.js.snap b/crates/rome_fmt/test_data/specs/js/module/function/function_comments.js.snap new file mode 100644 index 0000000..d98e94e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/function/function_comments.js.snap @@ -0,0 +1,17 @@ +function a() { + // trailing comment + let a = 2; + + /** leading comment **/ +} + +function b() { + // leading comment + // trailing +} + +function c( + //some comment + foo, + bar, +) {} diff --git a/crates/rome_fmt/test_data/specs/js/module/ident.js b/crates/rome_fmt/test_data/specs/js/module/ident.js new file mode 100644 index 0000000..587be6b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/ident.js @@ -0,0 +1 @@ +x diff --git a/crates/rome_fmt/test_data/specs/js/module/ident.js.snap b/crates/rome_fmt/test_data/specs/js/module/ident.js.snap new file mode 100644 index 0000000..6c650fc --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/ident.js.snap @@ -0,0 +1 @@ +x; diff --git a/crates/rome_fmt/test_data/specs/js/module/import/bare_import.js b/crates/rome_fmt/test_data/specs/js/module/import/bare_import.js new file mode 100644 index 0000000..f424f1f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/bare_import.js @@ -0,0 +1,23 @@ +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_"; +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { type : "json"} +import "short" assert { + + type : "json" +} + +import "very_long_import_very_long_import_very" assert { + // something good is here + "type": /****/ "json" + } + +import "very_long_import_very_long_import_very" assert { + // something good is here + "type": /****/ "json", + "type2" /****/ : "json", + /****/ + "type4" /* dangling 1 */: /* danling 2 */ // line + "json", + /****/ + "typetypetypetypetypetypetypetypetypetypetype": /****/ "typetypetypetypetypetypetypetypetypetypetypetypetypetype", + } + diff --git a/crates/rome_fmt/test_data/specs/js/module/import/bare_import.js.snap b/crates/rome_fmt/test_data/specs/js/module/import/bare_import.js.snap new file mode 100644 index 0000000..0c4d6ea --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/bare_import.js.snap @@ -0,0 +1,21 @@ +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_"; +import "very_long_import_very_long_import_very_long_import_very_long_import_very_long_import_very_long" assert { + type: "json", +}; +import "short" assert { type: "json" }; + +import "very_long_import_very_long_import_very" assert { + // something good is here + "type": /****/ "json", +}; + +import "very_long_import_very_long_import_very" assert { + // something good is here + "type": /****/ "json", + "type2": /****/ "json", + /****/ + /* dangling 1 */ /* danling 2 */ // line + "type4": "json", + /****/ + "typetypetypetypetypetypetypetypetypetypetype": /****/ "typetypetypetypetypetypetypetypetypetypetypetypetypetype", +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/import/default_import.js b/crates/rome_fmt/test_data/specs/js/module/import/default_import.js new file mode 100644 index 0000000..0e99749 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/default_import.js @@ -0,0 +1,11 @@ +import hey from "hey" +import hey from "hey"; +import "x" assert { type: "json" } +import "foo" assert { "type": "json" }; +import foo from "foo.json" assert { type: "json" }; +import foo from "foo.json" assert { + + type: + "json" }; +import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; +import a, * as b from "foo" diff --git a/crates/rome_fmt/test_data/specs/js/module/import/default_import.js.snap b/crates/rome_fmt/test_data/specs/js/module/import/default_import.js.snap new file mode 100644 index 0000000..7997586 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/default_import.js.snap @@ -0,0 +1,12 @@ +import hey from "hey"; +import hey from "hey"; +import "x" assert { type: "json" }; +import "foo" assert { "type": "json" }; +import foo from "foo.json" assert { type: "json" }; +import foo from "foo.json" assert { type: "json" }; +import foo2 from "foo.json" assert { + "type": "json", + type: "html", + "type": "js", +}; +import a, * as b from "foo"; diff --git a/crates/rome_fmt/test_data/specs/js/module/import/import_call.js b/crates/rome_fmt/test_data/specs/js/module/import/import_call.js new file mode 100644 index 0000000..44546bb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/import_call.js @@ -0,0 +1,3 @@ +import(x) +import('x') +import(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, {assert: {type:'json'}}) diff --git a/crates/rome_fmt/test_data/specs/js/module/import/import_call.js.snap b/crates/rome_fmt/test_data/specs/js/module/import/import_call.js.snap new file mode 100644 index 0000000..0c67092 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/import_call.js.snap @@ -0,0 +1,6 @@ +import(x); +import("x"); +import( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + { assert: { type: "json" } } +); diff --git a/crates/rome_fmt/test_data/specs/js/module/import/import_specifiers.js b/crates/rome_fmt/test_data/specs/js/module/import/import_specifiers.js new file mode 100644 index 0000000..d2223d4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/import_specifiers.js @@ -0,0 +1,32 @@ +import { hey } from "hey" +import { hey } from "hey"; +import { + apple, +banana } from "fruits"; +import {test} from "foo.json" assert { for: "for" } +import { // some funky comment + loooooooooooooooooooong as moreeeeeeloooooooooooooooooooong, + loooooooooooooooooooong2 as moreeeeeeloooooooooooooooooooong2, +// some other comment +} from "test"; +import { + loooooooooooooooooooong3 as moreeeeeeloooooooooooooooooooong3 + // some funky comment +} from "test"; + +import {loooooooooooooooooooong3,loooooooooooooooooooong5,loooooooooooooooooooong6 } from "boo" +import { f as x, default as w, "a-b-c" as y } from "b"; + +import loooooooooooooooooooong7, { loooooooooooooooooooong8, loooooooooooooooooooong9, loooooooooooooooooooong10} from "module" + +import { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +import { loooooooooooooooooooooooooooooooooooooooooooooooooong, } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +import { +// comment +loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong" + +import { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong" + +import a, { loooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooooonnoong" diff --git a/crates/rome_fmt/test_data/specs/js/module/import/import_specifiers.js.snap b/crates/rome_fmt/test_data/specs/js/module/import/import_specifiers.js.snap new file mode 100644 index 0000000..9928457 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/import_specifiers.js.snap @@ -0,0 +1,42 @@ +import { hey } from "hey"; +import { hey } from "hey"; +import { apple, banana } from "fruits"; +import { test } from "foo.json" assert { for: "for" }; +import { + // some funky comment + loooooooooooooooooooong as moreeeeeeloooooooooooooooooooong, + loooooooooooooooooooong2 as moreeeeeeloooooooooooooooooooong2, + // some other comment +} from "test"; +import { + loooooooooooooooooooong3 as moreeeeeeloooooooooooooooooooong3, + // some funky comment +} from "test"; + +import { + loooooooooooooooooooong3, + loooooooooooooooooooong5, + loooooooooooooooooooong6, +} from "boo"; +import { f as x, default as w, "a-b-c" as y } from "b"; + +import loooooooooooooooooooong7, { + loooooooooooooooooooong8, + loooooooooooooooooooong9, + loooooooooooooooooooong10, +} from "module"; + +import { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"; + +import { loooooooooooooooooooooooooooooooooooooooooooooooooong } from "loooooooooooooooooooooooooooooooooooooooooooooong"; + +import { + // comment + loooooooooooooooooooooooooooooooooooooooooooooooooong, +} from "loooooooooooooooooooooooooooooooooooooooooooooong"; + +import { a as b } from "loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"; + +import a, { + loooooooooooooooooooooong, +} from "loooooooooooooooooooooooooooooooooooooooooooooooonnoong"; diff --git a/crates/rome_fmt/test_data/specs/js/module/import/namespace_import.js b/crates/rome_fmt/test_data/specs/js/module/import/namespace_import.js new file mode 100644 index 0000000..f254244 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/namespace_import.js @@ -0,0 +1 @@ +import * as all from "all" \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/import/namespace_import.js.snap b/crates/rome_fmt/test_data/specs/js/module/import/namespace_import.js.snap new file mode 100644 index 0000000..15603b1 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/namespace_import.js.snap @@ -0,0 +1 @@ +import * as all from "all"; diff --git a/crates/rome_fmt/test_data/specs/js/module/import/trailing-comma/import_trailing_comma.js b/crates/rome_fmt/test_data/specs/js/module/import/trailing-comma/import_trailing_comma.js new file mode 100644 index 0000000..876513e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/trailing-comma/import_trailing_comma.js @@ -0,0 +1,30 @@ +import { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +} from "D"; + +import { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, } from "W"; + +const StandaloneBackendWASMModule = await import(/* webpackChunkName: "standalone" */'./StandaloneBackendWASM'); + +const StandaloneBackendWASMModule = await import(/* webpackChunkName: "standalone" */'./StandaloneBackendWASM', + /* webpackChunkName: "standalone" */'./StandaloneBackendWASM'); + +import( + 'myreallylongdynamicallyloadedmodulenamemyreallylongdynamicallyloadedmodulename' + ); + +import(/* Hello */ "something"); +import("something" /* Hello */); +import(/* Hello */ "something" /* Hello */); +import("something" /* Hello */ + "else"); +import( + /* Hello */ + "something", + /* Hello */ + ); +wrap(import(/* Hello */ "something")); diff --git a/crates/rome_fmt/test_data/specs/js/module/import/trailing-comma/import_trailing_comma.js.snap b/crates/rome_fmt/test_data/specs/js/module/import/trailing-comma/import_trailing_comma.js.snap new file mode 100644 index 0000000..bcd6b4d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/import/trailing-comma/import_trailing_comma.js.snap @@ -0,0 +1,35 @@ +import { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +} from "D"; + +import { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +} from "W"; + +const StandaloneBackendWASMModule = await import( + /* webpackChunkName: "standalone" */ "./StandaloneBackendWASM" +); + +const StandaloneBackendWASMModule = await import( + /* webpackChunkName: "standalone" */ "./StandaloneBackendWASM", + /* webpackChunkName: "standalone" */ "./StandaloneBackendWASM" +); + +import( + "myreallylongdynamicallyloadedmodulenamemyreallylongdynamicallyloadedmodulename" +); + +import(/* Hello */ "something"); +import("something" /* Hello */); +import(/* Hello */ "something" /* Hello */); +import("something" /* Hello */ + "else"); +import( + /* Hello */ + "something" + /* Hello */ +); +wrap(import(/* Hello */ "something")); diff --git a/crates/rome_fmt/test_data/specs/js/module/interpreter.js b/crates/rome_fmt/test_data/specs/js/module/interpreter.js new file mode 100644 index 0000000..41237ac --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/interpreter.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node +console.log(1) + +console.log(1) \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/interpreter.js.snap b/crates/rome_fmt/test_data/specs/js/module/interpreter.js.snap new file mode 100644 index 0000000..828a60d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/interpreter.js.snap @@ -0,0 +1,4 @@ +#!/usr/bin/env node +console.log(1); + +console.log(1); diff --git a/crates/rome_fmt/test_data/specs/js/module/interpreter_with_empty_line.js b/crates/rome_fmt/test_data/specs/js/module/interpreter_with_empty_line.js new file mode 100644 index 0000000..257a521 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/interpreter_with_empty_line.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node + + +console.log(1) \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/interpreter_with_empty_line.js.snap b/crates/rome_fmt/test_data/specs/js/module/interpreter_with_empty_line.js.snap new file mode 100644 index 0000000..0122b29 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/interpreter_with_empty_line.js.snap @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +console.log(1); diff --git a/crates/rome_fmt/test_data/specs/js/module/invalid/block_stmt_err.js b/crates/rome_fmt/test_data/specs/js/module/invalid/block_stmt_err.js new file mode 100644 index 0000000..cb5fb42 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/invalid/block_stmt_err.js @@ -0,0 +1,10 @@ +{ + let x= 10; + let y = 100; + + if (test) { + let z = 110; + } else +} + +let recovered = "no" diff --git a/crates/rome_fmt/test_data/specs/js/module/invalid/block_stmt_err.js.snap b/crates/rome_fmt/test_data/specs/js/module/invalid/block_stmt_err.js.snap new file mode 100644 index 0000000..afda494 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/invalid/block_stmt_err.js.snap @@ -0,0 +1,10 @@ +{ + let x = 10; + let y = 100; + + if (test) { + let z = 110; + } else +} + +let recovered = "no"; diff --git a/crates/rome_fmt/test_data/specs/js/module/invalid/if_stmt_err.js b/crates/rome_fmt/test_data/specs/js/module/invalid/if_stmt_err.js new file mode 100644 index 0000000..f631e14 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/invalid/if_stmt_err.js @@ -0,0 +1,16 @@ +function test() { + let x = 10; + if test { + return 10; + } + let y = + 100; + + } + if (true) { + } else + + var z = 191; +if (false) { + let x = 99; +} else { diff --git a/crates/rome_fmt/test_data/specs/js/module/invalid/if_stmt_err.js.snap b/crates/rome_fmt/test_data/specs/js/module/invalid/if_stmt_err.js.snap new file mode 100644 index 0000000..d001b74 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/invalid/if_stmt_err.js.snap @@ -0,0 +1,12 @@ +function test() { + let x = 10; + if test { + return 10; + } + let y = 100; +} +if (true) { +} else var z = 191; +if (false) { + let x = 99; +} else { diff --git a/crates/rome_fmt/test_data/specs/js/module/newlines.js b/crates/rome_fmt/test_data/specs/js/module/newlines.js new file mode 100644 index 0000000..2cba5e0 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/newlines.js @@ -0,0 +1,78 @@ +"directive"; +// comment +"directive"; + +"directive"; + + +"directive"; + + +statement(); +// comment +statement(); + +statement(); + + +statement(); + + +; + + + +switch(a) { + case 1: + break; + // comment + case 2: + break; + + case 3: + break; + + + case 3: + break; + +} + + +class Test { + item; + // comment + item2; + + item3; + + + item4; + +} + + +const array = [ + 1, + // comment + 2, + + 3, + + + 4, + +]; + + +const object = { + key1: 1, + // comment + key2: 2, + + key3: 3, + + + key4: 4, + +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/newlines.js.snap b/crates/rome_fmt/test_data/specs/js/module/newlines.js.snap new file mode 100644 index 0000000..abb8524 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/newlines.js.snap @@ -0,0 +1,59 @@ +"directive"; +// comment +"directive"; + +"directive"; + +"directive"; + +statement(); +// comment +statement(); + +statement(); + +statement(); + +switch (a) { + case 1: + break; + // comment + case 2: + break; + + case 3: + break; + + case 3: + break; +} + +class Test { + item; + // comment + item2; + + item3; + + item4; +} + +const array = [ + 1, + // comment + 2, + + 3, + + 4, +]; + +const object = { + key1: 1, + // comment + key2: 2, + + key3: 3, + + key4: 4, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/class.js b/crates/rome_fmt/test_data/specs/js/module/no-semi/class.js new file mode 100644 index 0000000..d724770 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/class.js @@ -0,0 +1,118 @@ +// TODO: upgrade parser +// class A { +// async; // The semicolon is *not* necessary +// x(){} +// } +class B { + static; // The semicolon *is* necessary + x(){} +} + +class C1 { + get; // The semicolon *is* necessary + x(){} +} +class C2 { + get = () => {}; // The semicolon is *not* necessary + x(){} +} +class C3 { + set; // The semicolon *is* necessary + x(){} +} +class C4 { + set = () => {}; // The semicolon is *not* necessary + x(){} +} + + + +class A1 { + a = 0; + [b](){} + + c = 0; + *d(){} + + e = 0; + [f] = 0 + + // none of the semicolons above this comment can be omitted. + // none of the semicolons below this comment are necessary. + + q() {}; + [h](){} + + p() {}; + *i(){} + + a = 1; + get ['y']() {} + + a = 1; + static ['y']() {} + + a = 1; + set ['z'](z) {} + + a = 1; + async ['a']() {} + + a = 1; + async *g() {} + + a = 0; + b = 1; +} + +class A2 { + a = 0; + [b](){} + + c = 0; + *d(){} + + e = 0; + [f] = 0 + + // none of the semicolons above this comment can be omitted. + // none of the semicolons below this comment are necessary. + + q() {}; + [h](){} + + p() {}; + *i(){} + + a = 1; + get ['y']() {} + + a = 1; + static ['y']() {} + + a = 1; + set ['z'](z) {} + + a = 1; + async ['a']() {} + + a = 1; + async *g() {} + + a = 0; + b = 1; +} + +// being first/last shouldn't break things +class G1 { + x = 1 +} +class G2 { + x() {} +} +class G3 { + *x() {} +} +class G4 { + [x] = 1 +} diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/class.js.snap b/crates/rome_fmt/test_data/specs/js/module/no-semi/class.js.snap new file mode 100644 index 0000000..ccdf740 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/class.js.snap @@ -0,0 +1,116 @@ +// TODO: upgrade parser +// class A { +// async; // The semicolon is *not* necessary +// x(){} +// } +class B { + static; // The semicolon *is* necessary + x() {} +} + +class C1 { + get; // The semicolon *is* necessary + x() {} +} +class C2 { + get = () => {}; // The semicolon is *not* necessary + x() {} +} +class C3 { + set; // The semicolon *is* necessary + x() {} +} +class C4 { + set = () => {}; // The semicolon is *not* necessary + x() {} +} + +class A1 { + a = 0; + [b]() {} + + c = 0; + *d() {} + + e = 0; + [f] = 0; + + // none of the semicolons above this comment can be omitted. + // none of the semicolons below this comment are necessary. + + q() {} + [h]() {} + + p() {} + *i() {} + + a = 1; + get ["y"]() {} + + a = 1; + static ["y"]() {} + + a = 1; + set ["z"](z) {} + + a = 1; + async ["a"]() {} + + a = 1; + async *g() {} + + a = 0; + b = 1; +} + +class A2 { + a = 0; + [b]() {} + + c = 0; + *d() {} + + e = 0; + [f] = 0; + + // none of the semicolons above this comment can be omitted. + // none of the semicolons below this comment are necessary. + + q() {} + [h]() {} + + p() {} + *i() {} + + a = 1; + get ["y"]() {} + + a = 1; + static ["y"]() {} + + a = 1; + set ["z"](z) {} + + a = 1; + async ["a"]() {} + + a = 1; + async *g() {} + + a = 0; + b = 1; +} + +// being first/last shouldn't break things +class G1 { + x = 1; +} +class G2 { + x() {} +} +class G3 { + *x() {} +} +class G4 { + [x] = 1; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/issue2006.js b/crates/rome_fmt/test_data/specs/js/module/no-semi/issue2006.js new file mode 100644 index 0000000..bcbd4fb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/issue2006.js @@ -0,0 +1,8 @@ +switch (n) { + case 11: + var c = a.e; + (i.a += Ga(c.e)), F(i, c.i, 0); +} + +var c = a.e; +(i.a += Ga(c.e)), F(i, c.i, 0); diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/issue2006.js.snap b/crates/rome_fmt/test_data/specs/js/module/no-semi/issue2006.js.snap new file mode 100644 index 0000000..0289f23 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/issue2006.js.snap @@ -0,0 +1,8 @@ +switch (n) { + case 11: + var c = a.e; + (i.a += Ga(c.e)), F(i, c.i, 0); +} + +var c = a.e; +(i.a += Ga(c.e)), F(i, c.i, 0); diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/no-semi.js b/crates/rome_fmt/test_data/specs/js/module/no-semi/no-semi.js new file mode 100644 index 0000000..2169fb9 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/no-semi.js @@ -0,0 +1,80 @@ + +// with preexisting semi + +x; [1, 2, 3].forEach(fn) +x; [a, b, ...c] = [1, 2] +x; /r/i.test('r') +x; +1 +x; - 1 +x; ('h' + 'i').repeat(10) +x; (1, 2) +x; (() => {})() +x; ({ a: 1 }).entries() +x; ({ a: 1 }).entries() +x; +x; `string` +x; (x, y) => x + +// doesn't have to be preceded by a semicolon + +class X {} [1, 2, 3].forEach(fn) + + +// don't semicolon if it doesn't start statement + +if (true) (() => {})() + + +// check indentation + +if (true) { + x; (() => {})() +} + +// check statement clauses + +do break; while (false) +if (true) do break; while (false) + +if (true) 1; else 2 +for (;;) ; +for (x of y) ; + +debugger + +// check that it doesn't break non-ASI + +1 +- 1 + +1 ++ 1 + +1 +/ 1 + +arr +[0] + +fn +(x) + +!1 + +1 +< 1 + +tag +`string` + +x; x => x + +x; (a || b).c++ + +x; ++(a || b).c + +while (false) + (function(){}()) + +aReallyLongLine012345678901234567890123456789012345678901234567890123456789 * + (b + c) diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/no-semi.js.snap b/crates/rome_fmt/test_data/specs/js/module/no-semi/no-semi.js.snap new file mode 100644 index 0000000..06c39cf --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/no-semi.js.snap @@ -0,0 +1,91 @@ +// with preexisting semi + +x; +[1, 2, 3].forEach(fn); +x; +[a, b, ...c] = [1, 2]; +x; +/r/i.test("r"); +x; ++1; +x; +-1; +x; +("h" + "i").repeat(10); +x; +1, 2; +x; +(() => {})(); +x; +({ a: 1 }).entries(); +x; +({ a: 1 }).entries(); +x; +; +x; +`string`; +x; +(x, y) => x; + +// doesn't have to be preceded by a semicolon + +class X {} +[1, 2, 3].forEach(fn); + +// don't semicolon if it doesn't start statement + +if (true) (() => {})(); + +// check indentation + +if (true) { + x; + (() => {})(); +} + +// check statement clauses + +do break; +while (false); +if (true) + do break; + while (false); + +if (true) 1; +else 2; +for (;;); +for (x of y); + +debugger; + +// check that it doesn't break non-ASI + +1 - 1; + +1 + 1; + +1 / 1; + +arr[0]; + +fn(x); + +!1; + +1 < 1; + +tag`string`; + +x; +(x) => x; + +x; +(a || b).c++; + +x; +++(a || b).c; + +while (false) (function () {})(); + +aReallyLongLine012345678901234567890123456789012345678901234567890123456789 * + (b + c); diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/private-field.js b/crates/rome_fmt/test_data/specs/js/module/no-semi/private-field.js new file mode 100644 index 0000000..feca225 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/private-field.js @@ -0,0 +1,4 @@ +class C { + #field = 'value'; + ["method"]() {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/private-field.js.snap b/crates/rome_fmt/test_data/specs/js/module/no-semi/private-field.js.snap new file mode 100644 index 0000000..300152d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/private-field.js.snap @@ -0,0 +1,4 @@ +class C { + #field = "value"; + ["method"]() {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/semicolons-asi.js b/crates/rome_fmt/test_data/specs/js/module/no-semi/semicolons-asi.js new file mode 100644 index 0000000..0612741 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/semicolons-asi.js @@ -0,0 +1 @@ +[1, 2]; diff --git a/crates/rome_fmt/test_data/specs/js/module/no-semi/semicolons-asi.js.snap b/crates/rome_fmt/test_data/specs/js/module/no-semi/semicolons-asi.js.snap new file mode 100644 index 0000000..0612741 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/no-semi/semicolons-asi.js.snap @@ -0,0 +1 @@ +[1, 2]; diff --git a/crates/rome_fmt/test_data/specs/js/module/number/number.js b/crates/rome_fmt/test_data/specs/js/module/number/number.js new file mode 100644 index 0000000..d70382d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/number/number.js @@ -0,0 +1,2 @@ +1.23e4 +1000e3 // FIXME handle number with scientific notation #1294 diff --git a/crates/rome_fmt/test_data/specs/js/module/number/number.js.snap b/crates/rome_fmt/test_data/specs/js/module/number/number.js.snap new file mode 100644 index 0000000..a79a41b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/number/number.js.snap @@ -0,0 +1,2 @@ +1.23e4; +1000e3; // FIXME handle number with scientific notation #1294 diff --git a/crates/rome_fmt/test_data/specs/js/module/number/number_with_space.js b/crates/rome_fmt/test_data/specs/js/module/number/number_with_space.js new file mode 100644 index 0000000..48a40f7 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/number/number_with_space.js @@ -0,0 +1,6 @@ +123 .toString +123 +/****/.toString +123/**/.toString +123 +.toString diff --git a/crates/rome_fmt/test_data/specs/js/module/number/number_with_space.js.snap b/crates/rome_fmt/test_data/specs/js/module/number/number_with_space.js.snap new file mode 100644 index 0000000..29638b7 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/number/number_with_space.js.snap @@ -0,0 +1,4 @@ +(123).toString; +/****/ (123).toString; +(123) /**/.toString; +(123).toString; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/computed_member.js b/crates/rome_fmt/test_data/specs/js/module/object/computed_member.js new file mode 100644 index 0000000..c70c423 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/computed_member.js @@ -0,0 +1,19 @@ +const foo = {}; + +foo["bar"] = true; +foo["foo-bar"] = true; +foo.bar["bar"]["lorem_ispsum"].foo["lorem-ipsum"] = true; + +a[ b ] +c?.[ d ] + +x["very"]["long"]["chain"]["of"]["computed"]["members"]["that"]["goes"]["on"]["for"]["ever"]["I"]["mean"]["it"]["for"]["ever"]["and"]["even"]["longer"]["than"]["that"] + +x.very.long.chain.of.static.members.that.goes.on.for.ever.I.mean.it.for.ever["and"].even.longer.than.that.and["rofefefeeffeme"].doesnt.supportit + +x.very.long.chain.of.static.members.that.goes.on.for.ever.I.mean.it.for.ever[and()].even.longer.than.that.and["rofefefeefefme"].doesnt.supportit + +x[b["test"]] + + +a[("test")] diff --git a/crates/rome_fmt/test_data/specs/js/module/object/computed_member.js.snap b/crates/rome_fmt/test_data/specs/js/module/object/computed_member.js.snap new file mode 100644 index 0000000..983d944 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/computed_member.js.snap @@ -0,0 +1,26 @@ +const foo = {}; + +foo["bar"] = true; +foo["foo-bar"] = true; +foo.bar["bar"]["lorem_ispsum"].foo["lorem-ipsum"] = true; + +a[b]; +c?.[d]; + +x["very"]["long"]["chain"]["of"]["computed"]["members"]["that"]["goes"]["on"][ + "for" +]["ever"]["I"]["mean"]["it"]["for"]["ever"]["and"]["even"]["longer"]["than"][ + "that" +]; + +x.very.long.chain.of.static.members.that.goes.on.for.ever.I.mean.it.for.ever[ + "and" +].even.longer.than.that.and["rofefefeeffeme"].doesnt.supportit; + +x.very.long.chain.of.static.members.that.goes.on.for.ever.I.mean.it.for.ever[ + and() +].even.longer.than.that.and["rofefefeefefme"].doesnt.supportit; + +x[b["test"]]; + +a["test"]; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/getter_setter.js b/crates/rome_fmt/test_data/specs/js/module/object/getter_setter.js new file mode 100644 index 0000000..f005de7 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/getter_setter.js @@ -0,0 +1,6 @@ +let a = { + get foo() {} +} +let b = { + set foo(a) {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/object/getter_setter.js.snap b/crates/rome_fmt/test_data/specs/js/module/object/getter_setter.js.snap new file mode 100644 index 0000000..886a5eb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/getter_setter.js.snap @@ -0,0 +1,6 @@ +let a = { + get foo() {}, +}; +let b = { + set foo(a) {}, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/object.js b/crates/rome_fmt/test_data/specs/js/module/object/object.js new file mode 100644 index 0000000..3c4b9f2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/object.js @@ -0,0 +1,32 @@ +let a = { + ...spread, + + foo() { + }, + + *foo() { + }, + + async *foo(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, cccccccccccccccccccccccccccccc) { + }, + + [fooooooooooooooooooooooooooooooooooooooooooooooooo()]: () => { + }, + + [foo()]: { + + }, + + ...spread, +} + +const x = {apple: "banana"}; + +const y = { + apple: "banana", +}; + +({a, b, c} = {a: 'apple', b: 'banana', c: 'coconut'}); + +({ + a, b, c} = {a: 'apple', b: 'banana', c: 'coconut'}); diff --git a/crates/rome_fmt/test_data/specs/js/module/object/object.js.snap b/crates/rome_fmt/test_data/specs/js/module/object/object.js.snap new file mode 100644 index 0000000..4885079 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/object.js.snap @@ -0,0 +1,29 @@ +let a = { + ...spread, + + foo() {}, + + *foo() {}, + + async *foo( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + cccccccccccccccccccccccccccccc, + ) {}, + + [fooooooooooooooooooooooooooooooooooooooooooooooooo()]: () => {}, + + [foo()]: {}, + + ...spread, +}; + +const x = { apple: "banana" }; + +const y = { + apple: "banana", +}; + +({ a, b, c } = { a: "apple", b: "banana", c: "coconut" }); + +({ a, b, c } = { a: "apple", b: "banana", c: "coconut" }); diff --git a/crates/rome_fmt/test_data/specs/js/module/object/object_comments.js b/crates/rome_fmt/test_data/specs/js/module/object/object_comments.js new file mode 100644 index 0000000..e09be50 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/object_comments.js @@ -0,0 +1,4 @@ +let a = { // leading comment + "type": "bar" + // trailing comment +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/object/object_comments.js.snap b/crates/rome_fmt/test_data/specs/js/module/object/object_comments.js.snap new file mode 100644 index 0000000..eabcb3e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/object_comments.js.snap @@ -0,0 +1,5 @@ +let a = { + // leading comment + type: "bar", + // trailing comment +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/octal_literals_key.js b/crates/rome_fmt/test_data/specs/js/module/object/octal_literals_key.js new file mode 100644 index 0000000..2413a06 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/octal_literals_key.js @@ -0,0 +1,6 @@ +const x = { + 8: 'yay', + 01: 'one', + '0': 'zero', + '010': 'oh no', +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/octal_literals_key.js.snap b/crates/rome_fmt/test_data/specs/js/module/object/octal_literals_key.js.snap new file mode 100644 index 0000000..68f6998 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/octal_literals_key.js.snap @@ -0,0 +1,6 @@ +const x = { + 8: "yay", + 01: "one", + 0: "zero", + "010": "oh no", +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/property_key.js b/crates/rome_fmt/test_data/specs/js/module/object/property_key.js new file mode 100644 index 0000000..6508ded --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/property_key.js @@ -0,0 +1,8 @@ +const foo = { + "foo-bar": true, + "bar": { + "lorem_ispsum": { + "lorem-ipsum": true + }, + }, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/property_key.js.snap b/crates/rome_fmt/test_data/specs/js/module/object/property_key.js.snap new file mode 100644 index 0000000..840be55 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/property_key.js.snap @@ -0,0 +1,8 @@ +const foo = { + "foo-bar": true, + bar: { + lorem_ispsum: { + "lorem-ipsum": true, + }, + }, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/property_object_member.js b/crates/rome_fmt/test_data/specs/js/module/object/property_object_member.js new file mode 100644 index 0000000..b4789a3 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/property_object_member.js @@ -0,0 +1,88 @@ +const neverBreakAfterColonObject = { + 'this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-1': require(), + x: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + url: "http://example.com/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + "x": "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + a: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + ab: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + abc: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + '古今': 'https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about', + a̐éö̲: 'https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about', + "class-member": class MyClass { constructor() { console.log('class object constructor')}}, + "this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-boolean-true": true, + "this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-boolean-false": false, + "number": 1232132132131231232132112321321321312312321321123213213213123123213211232132132131231232132112321321321312312321321, + "number-with-dot": 12321321321312312321321123213213213123123213211232132132131231232132112321321321312312321321.12321321321312312321321, + "template-string": ` + dsadsadas + 32131ewqewq + `, +}; + +const breakAfterColonObject = { + 'long-key-for-string': "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + '古体诗': 'https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about', + 'logical-expression-1': this.state.longLongLongLongLongLongLongLongLongTooLongProp === true, + "logical-expression-2": longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337, + "binary-expression-1": 13321321312312321311332132131231232131232132132132232132132132 + 1332132131231232131232132132132, + "binary-expression-2": 1332132131231232131232132132132 - 13321321312312321312321321321321332132131231232131232132132132, + "instanceof-expression": '321321312312ddddddddddddddddddddddd312312312312' instanceof Object, + "in-expression": {'long-key': '123123213123213123edwqdqwdasdasdsaewqewqewqdas'} in 'long-key', + "sequence-expression": (33333333333333331, 'dsadsadasdsadas', 3, 'dsadsadasdsadasdsadsadasdsadas', 5), + 'conditional-expression-1': this.state.longLongLongLongLongLongLongLongLongTooLongProp === true ? {} : {}, + 'conditional-expression-2': longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 ? {} : {}, + 'conditional-expression-3': 13321321312312321311332132131231232131232132132132232132132132 + 1332132131231232131232132132132 ? {} : {}, + 'conditional-expression-4': '321321312312ddddddddddddddddddddddd312312312312' instanceof Object ? {} : {}, + 'conditional-expression-5': {'long-key': '123123213123213123edwqdqwdasdasdsaewqewqewqdas'} in 'long-key', + + 1: this.state.longLongLongLongLongLlongLongLongLongLongLongLongLongLongTooLongPropongLongLongLongTooLongProp === true, + 2: longLongLongLongLongLongLongLongLonlongLongLongLongLongLongLongLongLongTooLongPropgLongLongLongLongTooLongVar || 1337, + 11: 13321321312312321311332132131231232131232132132132232132132132 + 1332132131231232131232132132132, + 22: 1332132131231232131232132132132 - 13321321312312321312321321321321332132131231232131232132132132, + 33: '321321312312ddddddddddddddddddddddd312312312312' instanceof Object, + 44: {'long-key': '123123213123213123edwqdqwdasdasdsaewqewqewqdas'} in 'long-key', + 5: (33333333333333331, 'dsadsadasdsadas', 3, 'dsadsadasdsadasdsadsadasdsadas', 5), + + a: this.state.longLongLongLongLongLongLongLongLongTooLongProp === true ? {} : {}, + b: longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 ? {} : {}, + c: 13321321312312321311332132131231232131232132132132232132132132 + 1332132131231232131232132132132 ? {} : {}, + d: '321321312312ddddddddddddddddddddddd312312312312' instanceof Object ? {} : {}, + g: {'long-key': '123123213123213123edwqdqwdasdasdsaewqewqewqdas'} in 'long-key', + blablah: + "aldkfkladfskladklsfkladklfkaldfadfkdaf" + + "adlfasdklfkldsklfakldsfkladsfkadsfladsfa" + + "dflkadfkladsfklkadlfkladlfkadklfjadlfdfdaf", +}; + +const fluidObject = { + 'this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line': orMaybeIAmMisunderstandingAndIHaveSetSomethingWrongInMyConfig(), + "11/01/2017 13:36": [ + { + message: "test", + messageType: "SMS", + status: "Unknown", + created: "11/01/2017 13:36", + }, + { + message: "test", + messageType: "Email", + status: "Unknown", + created: "11/01/2017 13:36", + }, + { + message: "te", + messageType: "SMS", + status: "Unknown", + created: "09/01/2017 17:25", + }, + ], + render: withGraphQLQuery( + 'node(1234567890){image{uri}}', + function(container, data) { + return 'image'; + } + ), + loadNext: (stateIsOK && hasNext) || { + skipNext: true, + }, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/property_object_member.js.snap b/crates/rome_fmt/test_data/specs/js/module/object/property_object_member.js.snap new file mode 100644 index 0000000..57204fd --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/property_object_member.js.snap @@ -0,0 +1,155 @@ +const neverBreakAfterColonObject = { + "this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-1": require(), + x: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + url: "http://example.com/12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + x: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + a: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + ab: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + abc: "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + 古今: "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about", + a̐éö̲: "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about", + "class-member": class MyClass { + constructor() { + console.log("class object constructor"); + } + }, + "this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-boolean-true": true, + "this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line-boolean-false": false, + number: 1232132132131231232132112321321321312312321321123213213213123123213211232132132131231232132112321321321312312321321, + "number-with-dot": 12321321321312312321321123213213213123123213211232132132131231232132112321321321312312321321.12321321321312312321321, + "template-string": ` + dsadsadas + 32131ewqewq + `, +}; + +const breakAfterColonObject = { + "long-key-for-string": + "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", + 古体诗: + "https://prettier.io/docs/en/rationale.html#what-prettier-is-concerned-about", + "logical-expression-1": + this.state.longLongLongLongLongLongLongLongLongTooLongProp === true, + "logical-expression-2": + longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337, + "binary-expression-1": + 13321321312312321311332132131231232131232132132132232132132132 + + 1332132131231232131232132132132, + "binary-expression-2": + 1332132131231232131232132132132 - + 13321321312312321312321321321321332132131231232131232132132132, + "instanceof-expression": + "321321312312ddddddddddddddddddddddd312312312312" instanceof Object, + "in-expression": + { "long-key": "123123213123213123edwqdqwdasdasdsaewqewqewqdas" } in + "long-key", + "sequence-expression": + (33333333333333331, + "dsadsadasdsadas", + 3, + "dsadsadasdsadasdsadsadasdsadas", + 5), + "conditional-expression-1": + this.state.longLongLongLongLongLongLongLongLongTooLongProp === true + ? {} + : {}, + "conditional-expression-2": + longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 + ? {} + : {}, + "conditional-expression-3": + 13321321312312321311332132131231232131232132132132232132132132 + + 1332132131231232131232132132132 + ? {} + : {}, + "conditional-expression-4": + "321321312312ddddddddddddddddddddddd312312312312" instanceof Object + ? {} + : {}, + "conditional-expression-5": + { "long-key": "123123213123213123edwqdqwdasdasdsaewqewqewqdas" } in + "long-key", + + 1: + this.state + .longLongLongLongLongLlongLongLongLongLongLongLongLongLongTooLongPropongLongLongLongTooLongProp === + true, + 2: + longLongLongLongLongLongLongLongLonlongLongLongLongLongLongLongLongLongTooLongPropgLongLongLongLongTooLongVar || + 1337, + 11: + 13321321312312321311332132131231232131232132132132232132132132 + + 1332132131231232131232132132132, + 22: + 1332132131231232131232132132132 - + 13321321312312321312321321321321332132131231232131232132132132, + 33: "321321312312ddddddddddddddddddddddd312312312312" instanceof Object, + 44: + { "long-key": "123123213123213123edwqdqwdasdasdsaewqewqewqdas" } in + "long-key", + 5: + (33333333333333331, + "dsadsadasdsadas", + 3, + "dsadsadasdsadasdsadsadasdsadas", + 5), + + a: + this.state.longLongLongLongLongLongLongLongLongTooLongProp === true + ? {} + : {}, + b: + longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 + ? {} + : {}, + c: + 13321321312312321311332132131231232131232132132132232132132132 + + 1332132131231232131232132132132 + ? {} + : {}, + d: + "321321312312ddddddddddddddddddddddd312312312312" instanceof Object + ? {} + : {}, + g: + { "long-key": "123123213123213123edwqdqwdasdasdsaewqewqewqdas" } in + "long-key", + blablah: + "aldkfkladfskladklsfkladklfkaldfadfkdaf" + + "adlfasdklfkldsklfakldsfkladsfkadsfladsfa" + + "dflkadfkladsfklkadlfkladlfkadklfjadlfdfdaf", +}; + +const fluidObject = { + "this-is-a-very-long-key-and-the-assignment-should-be-put-on-the-next-line": + orMaybeIAmMisunderstandingAndIHaveSetSomethingWrongInMyConfig(), + "11/01/2017 13:36": [ + { + message: "test", + messageType: "SMS", + status: "Unknown", + created: "11/01/2017 13:36", + }, + { + message: "test", + messageType: "Email", + status: "Unknown", + created: "11/01/2017 13:36", + }, + { + message: "te", + messageType: "SMS", + status: "Unknown", + created: "09/01/2017 17:25", + }, + ], + render: withGraphQLQuery( + "node(1234567890){image{uri}}", + function (container, data) { + return "image"; + }, + ), + loadNext: (stateIsOK && hasNext) || { + skipNext: true, + }, +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/trailing-comma/object_trailing_comma.js b/crates/rome_fmt/test_data/specs/js/module/object/trailing-comma/object_trailing_comma.js new file mode 100644 index 0000000..1030b84 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/trailing-comma/object_trailing_comma.js @@ -0,0 +1,9 @@ +const b = { + longlonglonglongField1, + longlonglonglongField2, + longlonglonglongField3, +}; + +const { adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd,} = o; diff --git a/crates/rome_fmt/test_data/specs/js/module/object/trailing-comma/object_trailing_comma.js.snap b/crates/rome_fmt/test_data/specs/js/module/object/trailing-comma/object_trailing_comma.js.snap new file mode 100644 index 0000000..955c25f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/object/trailing-comma/object_trailing_comma.js.snap @@ -0,0 +1,11 @@ +const b = { + longlonglonglongField1, + longlonglonglongField2, + longlonglonglongField3, +}; + +const { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +} = o; diff --git a/crates/rome_fmt/test_data/specs/js/module/parentheses/parentheses.js b/crates/rome_fmt/test_data/specs/js/module/parentheses/parentheses.js new file mode 100644 index 0000000..6f2f4e6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/parentheses/parentheses.js @@ -0,0 +1,24 @@ +(foo++)?.(); +async () => { + (await foo)?.(); +} +(+foo)?.(); ++(+foo); +class Foo extends (+Bar) {} +class Foo extends (Bar ?? Baz) {} +const foo = class extends (Bar ?? Baz) {} +;(1) +;(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); + +(b + c)``; + +const foo = { ...(a || b) }; + +async function *f() { + await (a || b); + yield (a && b); +} + +const a = () => ({}?.() && a); + +(list || list2)?.[(list || list2)]; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/parentheses/parentheses.js.snap b/crates/rome_fmt/test_data/specs/js/module/parentheses/parentheses.js.snap new file mode 100644 index 0000000..281e415 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/parentheses/parentheses.js.snap @@ -0,0 +1,24 @@ +(foo++)?.(); +async () => { + (await foo)?.(); +}; +(+foo)?.(); ++(+foo); +class Foo extends (+Bar) {} +class Foo extends (Bar ?? Baz) {} +const foo = class extends (Bar ?? Baz) {}; +1; +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + +(b + c)``; + +const foo = { ...(a || b) }; + +async function* f() { + await (a || b); + yield a && b; +} + +const a = () => ({})?.() && a; + +(list || list2)?.[list || list2]; diff --git a/crates/rome_fmt/test_data/specs/js/module/prettier-differences/fill-array-comments.js b/crates/rome_fmt/test_data/specs/js/module/prettier-differences/fill-array-comments.js new file mode 100644 index 0000000..27b71ff --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/prettier-differences/fill-array-comments.js @@ -0,0 +1,8 @@ +[ + // Prettier prints the `-2` element on the same line as the `-3`. + // This is the case because Prettier doesn't add virtual groups around `fill` elements, making it return `true` when it + // encounters the first hard line break. As it happens, this line comment contains a hard line break, making + // Prettier believe that the `-3` with this leading comment all fits on the line, which, obviously, isn't the case. + -3, + -2 +] diff --git a/crates/rome_fmt/test_data/specs/js/module/prettier-differences/fill-array-comments.js.snap b/crates/rome_fmt/test_data/specs/js/module/prettier-differences/fill-array-comments.js.snap new file mode 100644 index 0000000..8a54f05 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/prettier-differences/fill-array-comments.js.snap @@ -0,0 +1,8 @@ +[ + // Prettier prints the `-2` element on the same line as the `-3`. + // This is the case because Prettier doesn't add virtual groups around `fill` elements, making it return `true` when it + // encounters the first hard line break. As it happens, this line comment contains a hard line break, making + // Prettier believe that the `-3` with this leading comment all fits on the line, which, obviously, isn't the case. + -3, + -2, +]; diff --git a/crates/rome_fmt/test_data/specs/js/module/script.js b/crates/rome_fmt/test_data/specs/js/module/script.js new file mode 100644 index 0000000..2e50f36 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/script.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node +"use strict"; +'use asm' +var express = require("express") diff --git a/crates/rome_fmt/test_data/specs/js/module/script.js.snap b/crates/rome_fmt/test_data/specs/js/module/script.js.snap new file mode 100644 index 0000000..779e5a6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/script.js.snap @@ -0,0 +1,4 @@ +#!/usr/bin/env node +"use strict"; +"use asm"; +var express = require("express"); diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/block_statement.js b/crates/rome_fmt/test_data/specs/js/module/statement/block_statement.js new file mode 100644 index 0000000..5a82294 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/block_statement.js @@ -0,0 +1,9 @@ +if (true) { + ; +} + + +if (true) { + // rome-ignore format: Tests that ignored empty statements don't get removed + ; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/block_statement.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/block_statement.js.snap new file mode 100644 index 0000000..a795961 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/block_statement.js.snap @@ -0,0 +1,7 @@ +if (true) { +} + +if (true) { + // rome-ignore format: Tests that ignored empty statements don't get removed + ; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/do_while.js b/crates/rome_fmt/test_data/specs/js/module/statement/do_while.js new file mode 100644 index 0000000..ed3b198 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/do_while.js @@ -0,0 +1,15 @@ +do { +var foo = 4 +} + +while (something) + + +do { // trailing + var foo = 4 +} + +while (something) + + +do; while(true); \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/do_while.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/do_while.js.snap new file mode 100644 index 0000000..b150a57 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/do_while.js.snap @@ -0,0 +1,11 @@ +do { + var foo = 4; +} while (something); + +do { + // trailing + var foo = 4; +} while (something); + +do; +while (true); diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/empty_blocks.js b/crates/rome_fmt/test_data/specs/js/module/statement/empty_blocks.js new file mode 100644 index 0000000..b2f57e4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/empty_blocks.js @@ -0,0 +1,30 @@ +// Line break before closing `}` +if (true) {} +if (true) {} else {} + +for (x in []) {} +for (x of []) {} + + + +switch ("test") {} + +switch ("test") { + case "test": {} +} + +test: {} + +try { +} catch { +} finally { +} + +// No Line breaks +class Test {} + +function test() {} + +for (;;) {} +while (true) {} +do {} while (true); \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/empty_blocks.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/empty_blocks.js.snap new file mode 100644 index 0000000..75fe19f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/empty_blocks.js.snap @@ -0,0 +1,36 @@ +// Line break before closing `}` +if (true) { +} +if (true) { +} else { +} + +for (x in []) { +} +for (x of []) { +} + +switch ("test") { +} + +switch ("test") { + case "test": { + } +} + +test: { +} + +try { +} catch { +} finally { +} + +// No Line breaks +class Test {} + +function test() {} + +for (;;) {} +while (true) {} +do {} while (true); diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/for_in.js b/crates/rome_fmt/test_data/specs/js/module/statement/for_in.js new file mode 100644 index 0000000..f5cd90d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/for_in.js @@ -0,0 +1,7 @@ +for (a in b) {} + +for (aVeryLongVariableNameToEnforceLineBreaksaVeryLongVariableNameToEnforceLineBreaks in aVeryLongVariableNameToEnforceLineBreaksaVeryLongVariableNameToEnforceLineBreaks) { +} + +for (a in b) { // trailing + } \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/for_in.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/for_in.js.snap new file mode 100644 index 0000000..bcae3b1 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/for_in.js.snap @@ -0,0 +1,9 @@ +for (a in b) { +} + +for (aVeryLongVariableNameToEnforceLineBreaksaVeryLongVariableNameToEnforceLineBreaks in aVeryLongVariableNameToEnforceLineBreaksaVeryLongVariableNameToEnforceLineBreaks) { +} + +for (a in b) { + // trailing +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/for_loop.js b/crates/rome_fmt/test_data/specs/js/module/statement/for_loop.js new file mode 100644 index 0000000..7be90f6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/for_loop.js @@ -0,0 +1,17 @@ +for (; ;) { + let x = 10; +} +for (x;;) { + let y = 20 +} +for (;y;) { + let z = 8; +} +for (;;z) { + let a = 3; +} +for(a;b;c) { + let b = 3; +} +for(let aVeryLongVariableNameToEnforceLineBreaks = 0; aVeryLongVariableNameToEnforceLineBreaks; aVeryLongVariableNameToEnforceLineBreaks) { +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/for_loop.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/for_loop.js.snap new file mode 100644 index 0000000..f35f84e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/for_loop.js.snap @@ -0,0 +1,20 @@ +for (;;) { + let x = 10; +} +for (x; ; ) { + let y = 20; +} +for (; y; ) { + let z = 8; +} +for (; ; z) { + let a = 3; +} +for (a; b; c) { + let b = 3; +} +for ( + let aVeryLongVariableNameToEnforceLineBreaks = 0; + aVeryLongVariableNameToEnforceLineBreaks; + aVeryLongVariableNameToEnforceLineBreaks +) {} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/for_of.js b/crates/rome_fmt/test_data/specs/js/module/statement/for_of.js new file mode 100644 index 0000000..66763b4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/for_of.js @@ -0,0 +1,8 @@ +for (a of b) {} + +for (let a of b) {} + +for (const aVeryLongVariableNameToEnforceLineBreaksaVeryLongVariableNameToEnforceLineBreaks of aVeryLongVariableNameToEnforceLineBreaksaVeryLongVariableNameToEnforceLineBreaks) { +} + +for await ( const a of b ) {} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/for_of.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/for_of.js.snap new file mode 100644 index 0000000..76998f7 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/for_of.js.snap @@ -0,0 +1,11 @@ +for (a of b) { +} + +for (let a of b) { +} + +for (const aVeryLongVariableNameToEnforceLineBreaksaVeryLongVariableNameToEnforceLineBreaks of aVeryLongVariableNameToEnforceLineBreaksaVeryLongVariableNameToEnforceLineBreaks) { +} + +for await (const a of b) { +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/if_chain.js b/crates/rome_fmt/test_data/specs/js/module/statement/if_chain.js new file mode 100644 index 0000000..1b821e4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/if_chain.js @@ -0,0 +1,3 @@ +if(1)1;else if(2)2;else 3; + +if(very_long_condition_1) very_long_statement_1(); else if (very_long_condition_2) very_long_statement_2(); else very_long_statement_3(); diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/if_chain.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/if_chain.js.snap new file mode 100644 index 0000000..5bee846 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/if_chain.js.snap @@ -0,0 +1,7 @@ +if (1) 1; +else if (2) 2; +else 3; + +if (very_long_condition_1) very_long_statement_1(); +else if (very_long_condition_2) very_long_statement_2(); +else very_long_statement_3(); diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/if_else.js b/crates/rome_fmt/test_data/specs/js/module/statement/if_else.js new file mode 100644 index 0000000..e5b34d6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/if_else.js @@ -0,0 +1,69 @@ +if(a); +if(a); else ; + +if (Math.random() > 0.5) { + console.log(1) +} else if (Math.random() > 0.5) { + console.log(2) +} else { + console.log(3) +} + +if (Math.random() > 0.5) { + console.log(1) +} +else if (Math.random() > 0.5) { + console.log(2) +} +else { + console.log(3) +} + +if (Math.random() > 0.5) { + console.log(1) +} +// wow +else if (Math.random() > 0.5) { + console.log(2) +} +// so cool +else { + console.log(3) +} + +if ( + true) { + let y = 20; +} else { + let x= 10; +} + +if (aVeryLongVeriableNameSoThatTheConditionBreaksAcrossMultipleLinesAndIDontKnow) { + + + +} else { + + +} + +if (true) { + + +} + +if (true) { + // trailing + +} else { // trailing + +} + +if (true) that(); else; + +if (true) {} +else if ( + // rome-ignore format: Test suppression comments + +true && false +) {} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/if_else.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/if_else.js.snap new file mode 100644 index 0000000..85695ae --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/if_else.js.snap @@ -0,0 +1,63 @@ +if (a); +if (a); +else; + +if (Math.random() > 0.5) { + console.log(1); +} else if (Math.random() > 0.5) { + console.log(2); +} else { + console.log(3); +} + +if (Math.random() > 0.5) { + console.log(1); +} else if (Math.random() > 0.5) { + console.log(2); +} else { + console.log(3); +} + +if (Math.random() > 0.5) { + console.log(1); +} +// wow +else if (Math.random() > 0.5) { + console.log(2); +} +// so cool +else { + console.log(3); +} + +if (true) { + let y = 20; +} else { + let x = 10; +} + +if ( + aVeryLongVeriableNameSoThatTheConditionBreaksAcrossMultipleLinesAndIDontKnow +) { +} else { +} + +if (true) { +} + +if (true) { + // trailing +} else { + // trailing +} + +if (true) that(); +else; + +if (true) { +} else if ( + // rome-ignore format: Test suppression comments + + true && false +) { +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/return.js b/crates/rome_fmt/test_data/specs/js/module/statement/return.js new file mode 100644 index 0000000..58e4b62 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/return.js @@ -0,0 +1,7 @@ +function f1() { + return 1 +} + +function f2() { + return 1,3,4 +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/return.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/return.js.snap new file mode 100644 index 0000000..8aa1c17 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/return.js.snap @@ -0,0 +1,7 @@ +function f1() { + return 1; +} + +function f2() { + return 1, 3, 4; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/return_verbatim_argument.js b/crates/rome_fmt/test_data/specs/js/module/statement/return_verbatim_argument.js new file mode 100644 index 0000000..4aec2c2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/return_verbatim_argument.js @@ -0,0 +1,25 @@ +// https://github.com/rome/tools/issues/3735 + +function supported1(){ + return ( + // rome-ignore format: Work around https://github.com/rome/tools/issues/3734 + // rome-ignore lint/style/useOptionalChain: Optional chaining creates more complicated ES2019 code + a && b + ); +} + +function supported2(){ + return !( + // rome-ignore format: Work around https://github.com/rome/tools/issues/3734 + // rome-ignore lint/style/useOptionalChain: Optional chaining creates more complicated ES2019 code + a && b + ); +} + +function supported3(){ + return ( + // rome-ignore format: + aVeryLongLogicalExpression && + thatBreaksOverMultipleLines + ); +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/return_verbatim_argument.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/return_verbatim_argument.js.snap new file mode 100644 index 0000000..c901a48 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/return_verbatim_argument.js.snap @@ -0,0 +1,25 @@ +// https://github.com/rome/tools/issues/3735 + +function supported1() { + return ( + // rome-ignore format: Work around https://github.com/rome/tools/issues/3734 + // rome-ignore lint/style/useOptionalChain: Optional chaining creates more complicated ES2019 code + a && b + ); +} + +function supported2() { + return !( + // rome-ignore format: Work around https://github.com/rome/tools/issues/3734 + // rome-ignore lint/style/useOptionalChain: Optional chaining creates more complicated ES2019 code + a && b + ); +} + +function supported3() { + return ( + // rome-ignore format: + aVeryLongLogicalExpression && + thatBreaksOverMultipleLines + ); +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/statement.js b/crates/rome_fmt/test_data/specs/js/module/statement/statement.js new file mode 100644 index 0000000..42f7378 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/statement.js @@ -0,0 +1,2 @@ +; +debugger diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/statement.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/statement.js.snap new file mode 100644 index 0000000..eab7469 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/statement.js.snap @@ -0,0 +1 @@ +debugger; diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/switch.js b/crates/rome_fmt/test_data/specs/js/module/statement/switch.js new file mode 100644 index 0000000..ec9f94d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/switch.js @@ -0,0 +1,19 @@ +switch (key) { + case // comment + value: + + case value: + // fallthrough + + case value: + break; + + default: + break; + + +} + +switch ("test") { + case "test": {} +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/switch.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/switch.js.snap new file mode 100644 index 0000000..d1f0ed8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/switch.js.snap @@ -0,0 +1,18 @@ +switch (key) { + case // comment + value: + + case value: + // fallthrough + + case value: + break; + + default: + break; +} + +switch ("test") { + case "test": { + } +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/throw.js b/crates/rome_fmt/test_data/specs/js/module/statement/throw.js new file mode 100644 index 0000000..eb93667 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/throw.js @@ -0,0 +1,3 @@ +throw "Something"; + +throw false diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/throw.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/throw.js.snap new file mode 100644 index 0000000..401d621 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/throw.js.snap @@ -0,0 +1,3 @@ +throw "Something"; + +throw false; diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/try_catch_finally.js b/crates/rome_fmt/test_data/specs/js/module/statement/try_catch_finally.js new file mode 100644 index 0000000..73f999c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/try_catch_finally.js @@ -0,0 +1,26 @@ +try { + var foo = 4 +} catch { + var foo = 4 +} + +try { + var foo = 4 +} catch (e) { + var foo = 4 +} + + +try { + var foo = 4 +} finally { + var foo = 4 +} + +try { + var foo = 4 +} catch { + var foo = 4 +} finally { + var foo = 4 +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/try_catch_finally.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/try_catch_finally.js.snap new file mode 100644 index 0000000..274bc50 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/try_catch_finally.js.snap @@ -0,0 +1,25 @@ +try { + var foo = 4; +} catch { + var foo = 4; +} + +try { + var foo = 4; +} catch (e) { + var foo = 4; +} + +try { + var foo = 4; +} finally { + var foo = 4; +} + +try { + var foo = 4; +} catch { + var foo = 4; +} finally { + var foo = 4; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/while_loop.js b/crates/rome_fmt/test_data/specs/js/module/statement/while_loop.js new file mode 100644 index 0000000..2d82056 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/while_loop.js @@ -0,0 +1,26 @@ +while (true) { var foo = 4 } + +while + + + ( + true + +) { var foo = 4; } +while (true) {} + +while (true) { + continue; +} + +tour: while (true) { + continue tour; +} + +while (true) { + break; +} + +tour: while (true) { + break tour; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/statement/while_loop.js.snap b/crates/rome_fmt/test_data/specs/js/module/statement/while_loop.js.snap new file mode 100644 index 0000000..0115b28 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/statement/while_loop.js.snap @@ -0,0 +1,24 @@ +while (true) { + var foo = 4; +} + +while (true) { + var foo = 4; +} +while (true) {} + +while (true) { + continue; +} + +tour: while (true) { + continue tour; +} + +while (true) { + break; +} + +tour: while (true) { + break tour; +} diff --git a/crates/rome_fmt/test_data/specs/js/module/string/directives.js b/crates/rome_fmt/test_data/specs/js/module/string/directives.js new file mode 100644 index 0000000..f4e8b9a --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/string/directives.js @@ -0,0 +1,4 @@ +'use preferred quote'; +"use preferred quote"; +"keep quotes and escpaes \" "; +'keep quotes and escpaes \' '; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/string/directives.js.snap b/crates/rome_fmt/test_data/specs/js/module/string/directives.js.snap new file mode 100644 index 0000000..4e128b9 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/string/directives.js.snap @@ -0,0 +1,4 @@ +"use preferred quote"; +"use preferred quote"; +"keep quotes and escpaes \" "; +'keep quotes and escpaes \' '; diff --git a/crates/rome_fmt/test_data/specs/js/module/string/parentheses_token.js b/crates/rome_fmt/test_data/specs/js/module/string/parentheses_token.js new file mode 100644 index 0000000..a6b386b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/string/parentheses_token.js @@ -0,0 +1 @@ +("Jan 1, <<>>2018 – Jan 1, 2019<<>>") diff --git a/crates/rome_fmt/test_data/specs/js/module/string/parentheses_token.js.snap b/crates/rome_fmt/test_data/specs/js/module/string/parentheses_token.js.snap new file mode 100644 index 0000000..c312110 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/string/parentheses_token.js.snap @@ -0,0 +1 @@ +("Jan 1, <<>>2018 – Jan 1, 2019<<>>"); diff --git a/crates/rome_fmt/test_data/specs/js/module/string/properties_quotes.js b/crates/rome_fmt/test_data/specs/js/module/string/properties_quotes.js new file mode 100644 index 0000000..68af05a --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/string/properties_quotes.js @@ -0,0 +1,43 @@ +class Y { + "other" = 4; + "method"() {} + "another_method"() {} + "camelMethod"() {} + "stay-like-this"() {} + get "getter"() {} + set "setterr"(value) {} + "constructor"() {} +} + +let value = { "a": "test", "quotes-required": "test" }; + +({ "a": test } = value); + +let { "a": test } = value; + +// you guys stay like this + +({ "$$_": test } = value); + +({ "%{}": test } = value); + +({ "[]": test } = value); + +let { "fff--fff": test } = value; + +let { "with_underscore": test } = value; + +let a = { "": 10, "c_d": 30 } + +let b = { "'": 10, "c_d": 30 } + +let { "_$_ff$_morning_not_quotes": test, "_$_ff$_morning_yes_quotes_@": test } = value; + +let { "_$_$_%": test } = value; + +let { "0197": test, "3n": test, "3p": test, "p9": test } = value; + +const x = { + '¾¾¾¾': 'test1', + '①': 'test2', +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/string/properties_quotes.js.snap b/crates/rome_fmt/test_data/specs/js/module/string/properties_quotes.js.snap new file mode 100644 index 0000000..990b4b0 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/string/properties_quotes.js.snap @@ -0,0 +1,44 @@ +class Y { + other = 4; + method() {} + another_method() {} + camelMethod() {} + "stay-like-this"() {} + get getter() {} + set setterr(value) {} + constructor() {} +} + +let value = { a: "test", "quotes-required": "test" }; + +({ a: test } = value); + +let { a: test } = value; + +// you guys stay like this + +({ $$_: test } = value); + +({ "%{}": test } = value); + +({ "[]": test } = value); + +let { "fff--fff": test } = value; + +let { with_underscore: test } = value; + +let a = { "": 10, c_d: 30 }; + +let b = { "'": 10, c_d: 30 }; + +let { _$_ff$_morning_not_quotes: test, "_$_ff$_morning_yes_quotes_@": test } = + value; + +let { "_$_$_%": test } = value; + +let { "0197": test, "3n": test, "3p": test, p9: test } = value; + +const x = { + "¾¾¾¾": "test1", + "①": "test2", +}; diff --git a/crates/rome_fmt/test_data/specs/js/module/string/string.js b/crates/rome_fmt/test_data/specs/js/module/string/string.js new file mode 100644 index 0000000..ec8d585 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/string/string.js @@ -0,0 +1,58 @@ +import hey from "hey" +import hey from "hey"; +import "x" assert { type: "json" } +import "foo" assert { "type": "json" }; +import foo from "foo.json" assert { type: "json" }; +import foo from "foo.json" assert { + + type: + "json" }; +import foo2 from "foo.json" assert { "type": "json", type: "html", "type": "js" }; +import a, * as b from "foo" + +const foo = {}; + +foo["bar"] = true; +foo["foo-bar"] = true; +foo.bar["bar"]["lorem_ispsum"].foo["lorem-ipsum"] = true; + +a[ b ] +c?.[ d ] + +let a = { // leading comment + "type": "bar" + // trailing comment +} + +class Foo extends Boar { + static { // some comment + this.a = "test"; + } + + method() { + return "ipsum"; + } + + static staticMethod() { + return "bar" + } +} + +export * from "hey" + +export * as something_bad_will_happen from "something_bad_might_not_happen" + +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { "type": "json", "type2": "json3"} + + +// this one should switch to use single quotes +("content '' \"\"\" "); + +// this one should switch to use double quotes +('content \'\' " '); + +// you should keep all the character as they are +("content \\' \\' "); + +// you should remove the escape +("content \'\' ") \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/string/string.js.snap b/crates/rome_fmt/test_data/specs/js/module/string/string.js.snap new file mode 100644 index 0000000..1b57608 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/string/string.js.snap @@ -0,0 +1,63 @@ +import hey from "hey"; +import hey from "hey"; +import "x" assert { type: "json" }; +import "foo" assert { "type": "json" }; +import foo from "foo.json" assert { type: "json" }; +import foo from "foo.json" assert { type: "json" }; +import foo2 from "foo.json" assert { + "type": "json", + type: "html", + "type": "js", +}; +import a, * as b from "foo"; + +const foo = {}; + +foo["bar"] = true; +foo["foo-bar"] = true; +foo.bar["bar"]["lorem_ispsum"].foo["lorem-ipsum"] = true; + +a[b]; +c?.[d]; + +let a = { + // leading comment + type: "bar", + // trailing comment +}; + +class Foo extends Boar { + static { + // some comment + this.a = "test"; + } + + method() { + return "ipsum"; + } + + static staticMethod() { + return "bar"; + } +} + +export * from "hey"; + +export * as something_bad_will_happen from "something_bad_might_not_happen"; + +export * as something_bad_will_happen from "something_bad_might_not_happen" assert { + "type": "json", + "type2": "json3", +}; + +// this one should switch to use single quotes +('content \'\' """ '); + +// this one should switch to use double quotes +("content '' \" "); + +// you should keep all the character as they are +("content \\' \\' "); + +// you should remove the escape +("content '' "); diff --git a/crates/rome_fmt/test_data/specs/js/module/suppression.js b/crates/rome_fmt/test_data/specs/js/module/suppression.js new file mode 100644 index 0000000..0ea9163 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/suppression.js @@ -0,0 +1,29 @@ +// rome-ignore format: the following if should print inline +if(true) statement(); + +/** rome-ignore format: the following if should print inline */ +if (true) statement(); + +/** + * rome-ignore format: the following if should print inline + */ +if (true) statement(); + +const expr = +// rome-ignore format: the array should not be formatted +[ + (2*n)/(r-l), 0, (r+l)/(r-l), 0, + 0, (2*n)/(t-b), (t+b)/(t-b), 0, + 0, 0, -(f+n)/(f-n), -(2*f*n)/(f-n), + 0, 0, -1, 0, +]; + +const expr2 = { + key: + // rome-ignore format: only skip formatting the value + 'single quoted string' +} + +let a = + // rome-ignore format: test +function () {} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/module/suppression.js.snap b/crates/rome_fmt/test_data/specs/js/module/suppression.js.snap new file mode 100644 index 0000000..a6f8cc8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/suppression.js.snap @@ -0,0 +1,29 @@ +// rome-ignore format: the following if should print inline +if(true) statement(); + +/** rome-ignore format: the following if should print inline */ +if (true) statement(); + +/** + * rome-ignore format: the following if should print inline + */ +if (true) statement(); + +const expr = + // rome-ignore format: the array should not be formatted + [ + (2*n)/(r-l), 0, (r+l)/(r-l), 0, + 0, (2*n)/(t-b), (t+b)/(t-b), 0, + 0, 0, -(f+n)/(f-n), -(2*f*n)/(f-n), + 0, 0, -1, 0, +]; + +const expr2 = { + key: + // rome-ignore format: only skip formatting the value + 'single quoted string', +}; + +let a = + // rome-ignore format: test + function () {}; diff --git a/crates/rome_fmt/test_data/specs/js/module/template/template.js b/crates/rome_fmt/test_data/specs/js/module/template/template.js new file mode 100644 index 0000000..7c4d033 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/template/template.js @@ -0,0 +1,47 @@ +`something`; + +tag`something` +`something ${ " hello" }`; + +`something ${ () => { var hey; const looooooooooong_expression = "loooooooooong_expression" }} something else ${ ehy }`; + `something ${ () => { var hey; const looooooooooong_expression = "loooooooooong_expression"; return hey; }} something else ${ ehy }`; + + +`test + abcd ${input} +output +`; + +`test + abcd ${ () => { var hey; const looooooooooong_expression = "loooooooooong_expression"; return hey; }} +output +`; + +// Single Line +const bar =`but where will ${this.fanta} wrap ${baz} ${"hello"} template literal? ${bar.ff.sss} long long long long ${foo[3]} long long long long long long`; + + +// Fit +const foo = `but where will ${a && b && bar || c && d && g} wrap long long long long long long`; + +const foo = `but where will ${lorem && loremlorem && loremlorem || loremc && lorem && loremlorem} wrap long long long long long long`; + +const a = ` +let expression_is_simple = is_plain_expression(&expression)?; +${loooooong || loooooong || loooooong || loooooong || loooooong || loooooong || loooooong || loooooong } +let expression_is_simple = is_plain_expression(&expression)?; +`; + +const foo = `but where will ${ + // with comment + this.fanta} wrap long long long long long long`; + +`
    ${this.set && this.set.artist + /* avoid console errors if `this.set` is undefined */}
    `; + +`
    ${ /* avoid console errors if `this.set` is undefined */ + this.set && this.set.artist}
    `; + +`${// $FlowFixMe found when converting React.createClass to ES6 +ExampleStory.getFragment('story')} +`; diff --git a/crates/rome_fmt/test_data/specs/js/module/template/template.js.snap b/crates/rome_fmt/test_data/specs/js/module/template/template.js.snap new file mode 100644 index 0000000..9111985 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/template/template.js.snap @@ -0,0 +1,79 @@ +`something`; + +tag`something``something ${" hello"}`; + +`something ${() => { + var hey; + const looooooooooong_expression = "loooooooooong_expression"; +}} something else ${ehy}`; +`something ${() => { + var hey; + const looooooooooong_expression = "loooooooooong_expression"; + return hey; +}} something else ${ehy}`; + +`test + abcd ${input} +output +`; + +`test + abcd ${() => { + var hey; + const looooooooooong_expression = "loooooooooong_expression"; + return hey; + }} +output +`; + +// Single Line +const bar = `but where will ${ + this.fanta +} wrap ${baz} ${"hello"} template literal? ${bar.ff.sss} long long long long ${ + foo[3] +} long long long long long long`; + +// Fit +const foo = `but where will ${ + (a && b && bar) || (c && d && g) +} wrap long long long long long long`; + +const foo = `but where will ${ + (lorem && loremlorem && loremlorem) || (loremc && lorem && loremlorem) +} wrap long long long long long long`; + +const a = ` +let expression_is_simple = is_plain_expression(&expression)?; +${ + loooooong || + loooooong || + loooooong || + loooooong || + loooooong || + loooooong || + loooooong || + loooooong +} +let expression_is_simple = is_plain_expression(&expression)?; +`; + +const foo = `but where will ${ + // with comment + this.fanta +} wrap long long long long long long`; + +`
    ${ + this.set && this.set.artist + /* avoid console errors if `this.set` is undefined */ +}
    `; + +`
    ${ + /* avoid console errors if `this.set` is undefined */ + this.set && this.set.artist +}
    `; + +`${ + // $FlowFixMe found when converting React.createClass to ES6 + ExampleStory.getFragment("story") +} +`; diff --git a/crates/rome_fmt/test_data/specs/js/module/with.js b/crates/rome_fmt/test_data/specs/js/module/with.js new file mode 100644 index 0000000..886941f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/with.js @@ -0,0 +1,5 @@ +with ( b) + +{ + 5 +} diff --git a/crates/rome_fmt/test_data/specs/js/module/with.js.snap b/crates/rome_fmt/test_data/specs/js/module/with.js.snap new file mode 100644 index 0000000..886941f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/module/with.js.snap @@ -0,0 +1,5 @@ +with ( b) + +{ + 5 +} diff --git a/crates/rome_fmt/test_data/specs/js/script/script.js b/crates/rome_fmt/test_data/specs/js/script/script.js new file mode 100644 index 0000000..2e50f36 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/script/script.js @@ -0,0 +1,4 @@ +#!/usr/bin/env node +"use strict"; +'use asm' +var express = require("express") diff --git a/crates/rome_fmt/test_data/specs/js/script/script.js.snap b/crates/rome_fmt/test_data/specs/js/script/script.js.snap new file mode 100644 index 0000000..779e5a6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/script/script.js.snap @@ -0,0 +1,4 @@ +#!/usr/bin/env node +"use strict"; +"use asm"; +var express = require("express"); diff --git a/crates/rome_fmt/test_data/specs/js/script/with.js b/crates/rome_fmt/test_data/specs/js/script/with.js new file mode 100644 index 0000000..e801c82 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/script/with.js @@ -0,0 +1,7 @@ +with ( b) + +{ + 5 +} + +with({}) {} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/js/script/with.js.snap b/crates/rome_fmt/test_data/specs/js/script/with.js.snap new file mode 100644 index 0000000..b83355d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/js/script/with.js.snap @@ -0,0 +1,7 @@ +with ( b) + +{ + 5 +} + +with({}) {} diff --git a/crates/rome_fmt/test_data/specs/jsx/arrow_function.jsx b/crates/rome_fmt/test_data/specs/jsx/arrow_function.jsx new file mode 100644 index 0000000..190d8b5 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/arrow_function.jsx @@ -0,0 +1,29 @@ +function BackTopContent(props){ + return ( + + {({ className: motionClassName }) => + cloneElement(className => ({ + className + }))} + + ); +} + +function BackTopContent(props){ + return ( + + {({ className: motionClassName }) => + cloneElement(className => ({ + className + }))/*with comment*/} + + ); +} + +function ArrowBodyIsJsxWithComment({ action }) { + return (action) => + ( + // eslint-disable-next-line react/no-array-index-key +
  • + ); +} diff --git a/crates/rome_fmt/test_data/specs/jsx/arrow_function.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/arrow_function.jsx.snap new file mode 100644 index 0000000..b94cf5c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/arrow_function.jsx.snap @@ -0,0 +1,31 @@ +function BackTopContent(props) { + return ( + + {({ className: motionClassName }) => + cloneElement((className) => ({ + className, + })) + } + + ); +} + +function BackTopContent(props) { + return ( + + { + ({ className: motionClassName }) => + cloneElement((className) => ({ + className, + })) /*with comment*/ + } + + ); +} + +function ArrowBodyIsJsxWithComment({ action }) { + return (action) => ( + // eslint-disable-next-line react/no-array-index-key +
  • + ); +} diff --git a/crates/rome_fmt/test_data/specs/jsx/attributes.jsx b/crates/rome_fmt/test_data/specs/jsx/attributes.jsx new file mode 100644 index 0000000..0cda6ae --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/attributes.jsx @@ -0,0 +1,76 @@ + + ; + + ; + + let a = ; + + ; +
    ; + + +// https://github.com/rome/tools/issues/2944 +
    ; +
    ; + +// Wrapping JSX in attribute +const a = + Are you sure delete this task? let + + ) + } + okText="Yes" + cancelText="No" + mouseEnterDelay={0} + mouseLeaveDelay={0} + onVisibleChange={onVisibleChange} + > + Delete + +; + + diff --git a/crates/rome_fmt/test_data/specs/jsx/attributes.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/attributes.jsx.snap new file mode 100644 index 0000000..4f93c18 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/attributes.jsx.snap @@ -0,0 +1,88 @@ +; + +; + +let a = ( + +); + +; +
    ; + +// https://github.com/rome/tools/issues/2944 +
    ; +
    ; + +// Wrapping JSX in attribute +const a = ( + + Are you sure delete this task? let + + } + okText="Yes" + cancelText="No" + mouseEnterDelay={0} + mouseLeaveDelay={0} + onVisibleChange={onVisibleChange} + > + Delete + +); + +; diff --git a/crates/rome_fmt/test_data/specs/jsx/comments.jsx b/crates/rome_fmt/test_data/specs/jsx/comments.jsx new file mode 100644 index 0000000..7b099b2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/comments.jsx @@ -0,0 +1,5 @@ +; + +; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/jsx/comments.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/comments.jsx.snap new file mode 100644 index 0000000..d610c44 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/comments.jsx.snap @@ -0,0 +1,7 @@ +; + +; diff --git a/crates/rome_fmt/test_data/specs/jsx/conditional.jsx b/crates/rome_fmt/test_data/specs/jsx/conditional.jsx new file mode 100644 index 0000000..41d7601 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/conditional.jsx @@ -0,0 +1,49 @@ +(bifornCringerMoshedPerplexSawder ? ( + askTrovenaBeenaDependsRowans +) : ( + glimseGlyphsHazardNoopsTieTie +)) ? null : ( + + + + + +); + + +(bifornCringerMoshedPerplexSawder ? ( + askTrovenaBeenaDependsRowans +) : ( + glimseGlyphsHazardNoopsTieTie +)) ? undefined : ( + + + + + +); + +(bifornCringerMoshedPerplexSawder ? ( + askTrovenaBeenaDependsRowans +) : ( + glimseGlyphsHazardNoopsTieTie +)) ? x : ( + + + + + +); + + +(bifornCringerMoshedPerplexSawder ? ( + askTrovenaBeenaDependsRowans +) : ( + glimseGlyphsHazardNoopsTieTie +)) ? a ? b : ( + + + + + +) : null; diff --git a/crates/rome_fmt/test_data/specs/jsx/conditional.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/conditional.jsx.snap new file mode 100644 index 0000000..ffc93c7 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/conditional.jsx.snap @@ -0,0 +1,53 @@ +( + bifornCringerMoshedPerplexSawder + ? askTrovenaBeenaDependsRowans + : glimseGlyphsHazardNoopsTieTie +) ? null : ( + + + + + +); + +( + bifornCringerMoshedPerplexSawder + ? askTrovenaBeenaDependsRowans + : glimseGlyphsHazardNoopsTieTie +) ? undefined : ( + + + + + +); + +( + bifornCringerMoshedPerplexSawder + ? askTrovenaBeenaDependsRowans + : glimseGlyphsHazardNoopsTieTie +) ? ( + x +) : ( + + + + + +); + +( + bifornCringerMoshedPerplexSawder + ? askTrovenaBeenaDependsRowans + : glimseGlyphsHazardNoopsTieTie +) ? ( + a ? ( + b + ) : ( + + + + + + ) +) : null; diff --git a/crates/rome_fmt/test_data/specs/jsx/element.jsx b/crates/rome_fmt/test_data/specs/jsx/element.jsx new file mode 100644 index 0000000..a10a12f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/element.jsx @@ -0,0 +1,330 @@ +// Single string attribute +
    ; + +// Not single string because of the new line +a =
    ; + +// Inline +a = ; + +// IndentAttributes +a = ; + +// Empty +a =
    ; +<> + + +; + +// Not empty +a =
    ; + +// Template +a =
    {`A Long Tempalte String That uses ${5 + 4} that will eventually break across multiple lines ${40 / 3 * 45}`}
    ; + +// Meaningful text after self closing element adds a hard line break +a =
    adefg
    ; + +// Meaningful text after a non-self closing element should add a soft line break +b = a =
    a
    abcd
    ; + +// A word right before a self-closing element inserts a hard line break +a =
    ab
    ; + +// A Word not right before a self-closing element inserts a soft line break. +a =
    ab
    text
    ; + +// whitespaces +c =
    a{' '}{' '}{' '}{' '}{' '}{' '}{' '}{' '}b{' '}{' '}{' '}{' '}{' '}{' '}
    ; + +c2 =
    a{' '}{' '}{' '}{' '}{' '}{' '}{' '}{' '}
    content{' '}{' '}{' '}{' '}{' '}{' '}
    ; + +// this group should fit one line jsx whitespaces are hidden +b = +
    + + + {' '} + + + + {' '} + 1 +
    ; + +// this group should break first tag and show only first jsx whitespace +b1 = +
    + + {` +12312 +12312 + `} + + + {' '} + + + + {' '} + 1 +
    ; + +// this group fit one line and hide jsx whitespace +b2 = + <> + 123 + + + {' '} + 1 + ; + +// this group break group and show jsx whitespace +b3 = + <> + {` +123`} + + + {' '} + 1 + ; + +const b4 =
    + Text + some link +{' '} + | some other text,{' '} +
    ; + +b5 = +
    +
    long text long text long text long text long text long text long text long texturl long text long text +
    ; + +; + +const Essay = () =>
    The films of Wong Kar-Wai exemplify the synthesis of French New Wave cinema—specifically the unrelenting + experimental technique and fascination with American/western culture—with more conventional melodramatic, romantic narratives.
    ; + +function Tabs() { + return + + Input + Settings + Formatter Output + CST + AST + Rome IR + Prettier IR + + Errors + + + + { + setPlaygroundState((state) => ({ + ...state, + code: evn.target.value, + })); + }} + style={{ + fontSize: 12, + height: "100vh", + fontFamily: + "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace", + }} + /> + + + + + +

    Rome

    + +

    Prettier

    + +
    + + + + + + + +
    {formatter_ir}
    +
    + +
    {prettierOutput.ir}
    +
    + +
    +						{errors}
    +					
    +
    +
    ; +} + +function LoginForm() { + return
    { + e.preventDefault(); + console.log("Submitted form!")} + }> + setUsername(e.target.value)} /> + setPassword(e.target.value)} /> +
    +} + +function MapoTofuRecipe() { + return
      + Mapo tofu recipe +
    • 2 packets soft or silken tofu
    • +
    • 1 tablespoon minced garlic
    • +
    • 1 tablespoon minced ginger
    • +
    • 2 tablespoons doubanjiang
    • +
    • 1 tablespoon douchi
    • +
    • 1 tablespoon corn or potato starch
    • +
    • 2 scallions or jiu cai
    • +
    • 6 ounces of ground beef or pork
    • +
    +} + +} />; + +let component =
    La Haine dir. Mathieu Kassovitz
    ; + +let component = ( +
    Uncle Boonmee Who Can Recall His Past Lives dir. Apichatpong Weerasethakul
    +); + +(
    Badlands
    ).property; + +let bar =
    + {foo(() =>
    the quick brown fox jumps over the lazy dog and then jumps over the lazy cat and then over the lazy fish.
    )} +
    ; + +; + +// spacing +let a = {' '} +let b = {" "} + +// comments +let a = { /* comment */ " " /* comment */ }; +let a = { " " + /* comment */ }; +let a = { /* comment */ " " }; + +// in array +const breadcrumbItems = [ + ( + + Home + + ), +].concat(extraBreadcrumbItems); + +function Component() { + return ( + + ); +} + +let b = ( +
    +
    + aVeryLongCOntentThat +
    +
    +); + + +let a = ( + + + +); + +function Component() { + return ( +
    + {fn(data)}{' '} + +
    + ); +} + +// jsx whitespace {' '} adds meaningful jsx text +function Component() { + return ( +
    + {fn(datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata)}{' '} + +
    + ); +} + +// not jsx whitespace doesn't add meaningful jsx text +function Component() { + return ( +
    + {fn(datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata)}{' '} + +
    + ); +} diff --git a/crates/rome_fmt/test_data/specs/jsx/element.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/element.jsx.snap new file mode 100644 index 0000000..570a9f8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/element.jsx.snap @@ -0,0 +1,397 @@ +// Single string attribute +
    ; + +// Not single string because of the new line +a = ( +
    +); + +// Inline +a = ( + +); + +// IndentAttributes +a = ( + +); + +// Empty +a =
    ; +<>; + +// Not empty +a =
    ; + +// Template +a = ( +
    {`A Long Tempalte String That uses ${ + 5 + 4 + } that will eventually break across multiple lines ${(40 / 3) * 45}`}
    +); + +// Meaningful text after self closing element adds a hard line break +a = ( +
    +
    +		adefg
    +	
    +); + +// Meaningful text after a non-self closing element should add a soft line break +b = a = ( +
    +
    a
    abcd +
    +); + +// A word right before a self-closing element inserts a hard line break +a = ( +
    + ab +
    +
    +); + +// A Word not right before a self-closing element inserts a soft line break. +a = ( +
    + ab
    text
    +
    +); + +// whitespaces +c =
    a b
    ; + +c2 = ( +
    + a
    content{" "} +
    +); + +// this group should fit one line jsx whitespaces are hidden +b = ( +
    + 1 +
    +); + +// this group should break first tag and show only first jsx whitespace +b1 = ( + +); + +// this group fit one line and hide jsx whitespace +b2 = ( + <> + 123 1 + +); + +// this group break group and show jsx whitespace +b3 = ( + <> + + {` +123`} + {" "} + 1 + +); + +const b4 = ( +
    + Text{" "} + + some link + {" "} + | some other text,{" "} +
    +); + +b5 = ( +
    +
    long text long text long text long text long text long text long text + long texturl long text long text +
    +); + +; + +const Essay = () => ( +
    + The films of Wong Kar-Wai exemplify the synthesis of French New Wave + cinema—specifically the unrelenting experimental technique and fascination + with American/western culture—with more conventional melodramatic, romantic + narratives. +
    +); + +function Tabs() { + return ( + + + Input + Settings + Formatter Output + CST + AST + Rome IR + Prettier IR + + Errors + + + + { + setPlaygroundState((state) => ({ + ...state, + code: evn.target.value, + })); + }} + style={{ + fontSize: 12, + height: "100vh", + fontFamily: + "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace", + }} + /> + + + + + +

    Rome

    + +

    Prettier

    + +
    + + + + + + + +
    {formatter_ir}
    +
    + +
    {prettierOutput.ir}
    +
    + +
    +					{errors}
    +				
    +
    +
    + ); +} + +function LoginForm() { + return ( +
    { + e.preventDefault(); + console.log("Submitted form!"); + }} + > + setUsername(e.target.value)} /> + setPassword(e.target.value)} + /> +
    + ); +} + +function MapoTofuRecipe() { + return ( +
      + Mapo tofu recipe +
    • 2 packets soft or silken tofu
    • +
    • 1 tablespoon minced garlic
    • +
    • 1 tablespoon minced ginger
    • +
    • 2 tablespoons doubanjiang
    • +
    • 1 tablespoon douchi
    • +
    • 1 tablespoon corn or potato starch
    • +
    • 2 scallions or jiu cai
    • +
    • 6 ounces of ground beef or pork
    • +
    + ); +} + +} />; + +let component =
    La Haine dir. Mathieu Kassovitz
    ; + +let component = ( +
    + {" "} + Uncle Boonmee Who Can Recall His Past Lives dir. Apichatpong Weerasethakul{" "} +
    +); + +(
    Badlands
    ).property; + +let bar = ( +
    + {foo(() => ( +
    + {" "} + the quick brown fox jumps over the lazy dog and then jumps over the lazy + cat and then over the lazy fish.{" "} +
    + ))} +
    +); + +; + +// spacing +let a = ; +let b = ; + +// comments +let a = {/* comment */ " " /* comment */}; +let a = ( + + { + " " + /* comment */ + } + +); +let a = {/* comment */ " "}; + +// in array +const breadcrumbItems = [ + + Home + , +].concat(extraBreadcrumbItems); + +function Component() { + return ( + + ); +} + +let b = ( +
    +
    + aVeryLongCOntentThat +
    +
    +); + +let a = ( + + + +); + +function Component() { + return ( +
    + {fn(data)} +
    + ); +} + +// jsx whitespace {' '} adds meaningful jsx text +function Component() { + return ( +
    + {fn(datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata)}{" "} + +
    + ); +} + +// not jsx whitespace doesn't add meaningful jsx text +function Component() { + return ( +
    + {fn(datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata)} + {" "} + +
    + ); +} diff --git a/crates/rome_fmt/test_data/specs/jsx/fragment.jsx b/crates/rome_fmt/test_data/specs/jsx/fragment.jsx new file mode 100644 index 0000000..59a7d1c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/fragment.jsx @@ -0,0 +1,2 @@ +<> +<> diff --git a/crates/rome_fmt/test_data/specs/jsx/fragment.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/fragment.jsx.snap new file mode 100644 index 0000000..f446cb6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/fragment.jsx.snap @@ -0,0 +1,3 @@ +<> +<> + diff --git a/crates/rome_fmt/test_data/specs/jsx/new-lines.jsx b/crates/rome_fmt/test_data/specs/jsx/new-lines.jsx new file mode 100644 index 0000000..adc85ba --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/new-lines.jsx @@ -0,0 +1,50 @@ + + +x = ( +
    +
    First
    ,
    Second
    +
    +); + +x = ( +
    +
    First
    , +
    Second
    +
    +); + +x = ( +
    +
    First
    + ,
    Second
    +
    +); + +function Component() { + return ( + <> + text.
    + + ); +} + +let myDiv1 = ReactTestUtils.renderIntoDocument( + +
    , + +); + + +let myDiv2 = ReactTestUtils.renderIntoDocument( + +
    + , + +); + +let myDiv3 = ReactTestUtils.renderIntoDocument( + +
    , + + +); diff --git a/crates/rome_fmt/test_data/specs/jsx/new-lines.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/new-lines.jsx.snap new file mode 100644 index 0000000..91d54ea --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/new-lines.jsx.snap @@ -0,0 +1,45 @@ +x = ( +
    +
    First
    ,
    Second
    +
    +); + +x = ( +
    +
    First
    ,
    Second
    +
    +); + +x = ( +
    +
    First
    ,
    Second
    +
    +); + +function Component() { + return ( + <> + text.
    + + ); +} + +let myDiv1 = ReactTestUtils.renderIntoDocument( + +
    , + , +); + +let myDiv2 = ReactTestUtils.renderIntoDocument( + +
    + , + , +); + +let myDiv3 = ReactTestUtils.renderIntoDocument( + +
    , + + , +); diff --git a/crates/rome_fmt/test_data/specs/jsx/quote_style/quote_style.jsx b/crates/rome_fmt/test_data/specs/jsx/quote_style/quote_style.jsx new file mode 100644 index 0000000..d702c08 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/quote_style/quote_style.jsx @@ -0,0 +1,8 @@ +( +
    + "123" +
    +) diff --git a/crates/rome_fmt/test_data/specs/jsx/quote_style/quote_style.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/quote_style/quote_style.jsx.snap new file mode 100644 index 0000000..74ef9b3 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/quote_style/quote_style.jsx.snap @@ -0,0 +1,3 @@ +
    + "123" +
    ; diff --git a/crates/rome_fmt/test_data/specs/jsx/self_closing.jsx b/crates/rome_fmt/test_data/specs/jsx/self_closing.jsx new file mode 100644 index 0000000..c4e3bd8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/self_closing.jsx @@ -0,0 +1,15 @@ +; + +; + +; +; +; + + diff --git a/crates/rome_fmt/test_data/specs/jsx/self_closing.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/self_closing.jsx.snap new file mode 100644 index 0000000..13201cc --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/self_closing.jsx.snap @@ -0,0 +1,9 @@ +; + +; + +; +; +; + +; diff --git a/crates/rome_fmt/test_data/specs/jsx/smoke.jsx b/crates/rome_fmt/test_data/specs/jsx/smoke.jsx new file mode 100644 index 0000000..00d7c96 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/smoke.jsx @@ -0,0 +1 @@ +"foo"; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/jsx/smoke.jsx.snap b/crates/rome_fmt/test_data/specs/jsx/smoke.jsx.snap new file mode 100644 index 0000000..310cbfe --- /dev/null +++ b/crates/rome_fmt/test_data/specs/jsx/smoke.jsx.snap @@ -0,0 +1 @@ +"foo"; diff --git a/crates/rome_fmt/test_data/specs/ts/arrow/arrow_parentheses.ts b/crates/rome_fmt/test_data/specs/ts/arrow/arrow_parentheses.ts new file mode 100644 index 0000000..47dd080 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/arrow/arrow_parentheses.ts @@ -0,0 +1,13 @@ +action => {} +(action) => {} +(action?) => {} +(action: string) => {} +(action): void => {} +( + action + // hhhhhhhh +) => {} +({ action }) => {} +([ action ]) => {} +(...action) => {} +(action = 1) => {} diff --git a/crates/rome_fmt/test_data/specs/ts/arrow/arrow_parentheses.ts.snap b/crates/rome_fmt/test_data/specs/ts/arrow/arrow_parentheses.ts.snap new file mode 100644 index 0000000..58efb41 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/arrow/arrow_parentheses.ts.snap @@ -0,0 +1,13 @@ +(action) => {}; +(action) => {}; +(action?) => {}; +(action: string) => {}; +(action): void => {}; +( + action, + // hhhhhhhh +) => {}; +({ action }) => {}; +([action]) => {}; +(...action) => {}; +(action = 1) => {}; diff --git a/crates/rome_fmt/test_data/specs/ts/arrow_chain.ts b/crates/rome_fmt/test_data/specs/ts/arrow_chain.ts new file mode 100644 index 0000000..06f8a82 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/arrow_chain.ts @@ -0,0 +1,11 @@ +// chain is-callee +const x = ((a) => (b) => c)(test); + +// chain should break +const x = ({prop}) => (b) => { c }; +const x = (a): string => b => c => d => e => f; +const x = (a): string => b => ({test}); + + +// break sequence body on new line +const x = a => b => (aLongSequenceExpression, thatContinuesFurtherOnUntilItBreaks, expands); diff --git a/crates/rome_fmt/test_data/specs/ts/arrow_chain.ts.snap b/crates/rome_fmt/test_data/specs/ts/arrow_chain.ts.snap new file mode 100644 index 0000000..28ea663 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/arrow_chain.ts.snap @@ -0,0 +1,27 @@ +// chain is-callee +const x = ( + (a) => (b) => + c +)(test); + +// chain should break +const x = + ({ prop }) => + (b) => { + c; + }; +const x = + (a): string => + (b) => + (c) => + (d) => + (e) => + f; +const x = + (a): string => + (b) => ({ test }); + +// break sequence body on new line +const x = (a) => (b) => ( + aLongSequenceExpression, thatContinuesFurtherOnUntilItBreaks, expands +); diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/as_assignment.ts b/crates/rome_fmt/test_data/specs/ts/assignment/as_assignment.ts new file mode 100644 index 0000000..f1ad2cc --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/as_assignment.ts @@ -0,0 +1,5 @@ +let binding; + +(binding as boolean) = true; + +(binding.very.long.chain.of.static.members as VeryLongTypeName) = veryLongExpression(); diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/as_assignment.ts.snap b/crates/rome_fmt/test_data/specs/ts/assignment/as_assignment.ts.snap new file mode 100644 index 0000000..03be0a1 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/as_assignment.ts.snap @@ -0,0 +1,6 @@ +let binding; + +(binding as boolean) = true; + +(binding.very.long.chain.of.static.members as VeryLongTypeName) = + veryLongExpression(); diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/assignment.ts b/crates/rome_fmt/test_data/specs/ts/assignment/assignment.ts new file mode 100644 index 0000000..a2eb63b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/assignment.ts @@ -0,0 +1,13 @@ +//break after operator layout +loooooooooooooooooooooooooong1 = "looooooooooooooooooooooooooooooooooooooooooog"!; +loooooooooooooooooooooooooong2 = void void "looooooooooooooooooooooooooooooooooooooooooog"!; +// rome-ignore format: test + loooooooooooooooooooooooooong6 = + void "looooooooooooooooooooooooooooooooooooooooooog"!; +loooooooooooooooooooooooooong7 = + // rome-ignore format: test + ! "looooooooooooooooooooooooooooooooooooooooooog"!; + +const gitBaseExtension = extensions.getExtension( + "vscode.git-base", +)!.exports; diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/assignment.ts.snap b/crates/rome_fmt/test_data/specs/ts/assignment/assignment.ts.snap new file mode 100644 index 0000000..cf2395e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/assignment.ts.snap @@ -0,0 +1,14 @@ +//break after operator layout +loooooooooooooooooooooooooong1 = + "looooooooooooooooooooooooooooooooooooooooooog"!; +loooooooooooooooooooooooooong2 = + void void "looooooooooooooooooooooooooooooooooooooooooog"!; +// rome-ignore format: test +loooooooooooooooooooooooooong6 = + void "looooooooooooooooooooooooooooooooooooooooooog"!; +loooooooooooooooooooooooooong7 = + // rome-ignore format: test + ! "looooooooooooooooooooooooooooooooooooooooooog"!; + +const gitBaseExtension = + extensions.getExtension("vscode.git-base")!.exports; diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/assignment_comments.ts b/crates/rome_fmt/test_data/specs/ts/assignment/assignment_comments.ts new file mode 100644 index 0000000..9eb9895 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/assignment_comments.ts @@ -0,0 +1,21 @@ +const a = // test + 1; + +const b = + /* leading */ + 2; + +const c + /* leading */ + = 3; + + +const d: string // 1 + = // 2 + 4; + + +const e: string // 1 + = // 2 + { object: 5 }; + diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/assignment_comments.ts.snap b/crates/rome_fmt/test_data/specs/ts/assignment/assignment_comments.ts.snap new file mode 100644 index 0000000..6956a3c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/assignment_comments.ts.snap @@ -0,0 +1,16 @@ +const a = 1; // test + +const b = + /* leading */ + 2; + +const c = + /* leading */ + 3; + +const d: string = 4; // 1 // 2 + +const e: string = + // 1 + // 2 + { object: 5 }; diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/property_assignment_comments.ts b/crates/rome_fmt/test_data/specs/ts/assignment/property_assignment_comments.ts new file mode 100644 index 0000000..e9c101f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/property_assignment_comments.ts @@ -0,0 +1,33 @@ +class Test { + prop1 = /* leading */ 1; + + prop2 = // test + 2; + + prop3 // test + = 3; + + prop4 // test + = 4; + + prop5 // test + = 5 // a + + prop6 + /* leading */ + = 6 // c + + prop7 = + /* leading */ + 7 // c + + prop8 /* comment */ = 8; + + prop9: string // 1 + = // 2 + 3; + + prop10: any // 1 + = // 2 + { object: 3} +} diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/property_assignment_comments.ts.snap b/crates/rome_fmt/test_data/specs/ts/assignment/property_assignment_comments.ts.snap new file mode 100644 index 0000000..3afea4d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/property_assignment_comments.ts.snap @@ -0,0 +1,26 @@ +class Test { + prop1 = /* leading */ 1; + + prop2 = 2; // test + + prop3 = 3; // test + + prop4 = 4; // test + + prop5 = 5; // test // a + + prop6 = + /* leading */ + 6; // c + + prop7 = + /* leading */ + 7; // c + + prop8 /* comment */ = 8; + + prop9: string = 3; // 1 // 2 + + prop10: any = // 1 // 2 + { object: 3 }; +} diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/type_assertion_assignment.ts b/crates/rome_fmt/test_data/specs/ts/assignment/type_assertion_assignment.ts new file mode 100644 index 0000000..e37ab97 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/type_assertion_assignment.ts @@ -0,0 +1,14 @@ +let x; + +( x) = true; + +(x.very.long.chain.of.static.members.that.goes.on.for.ever.I.mean.it.for.ever as string) = veryLongExpression(); + + +for ( x of []) { + + +} +({ x: + + x } = { x: "test"}) diff --git a/crates/rome_fmt/test_data/specs/ts/assignment/type_assertion_assignment.ts.snap b/crates/rome_fmt/test_data/specs/ts/assignment/type_assertion_assignment.ts.snap new file mode 100644 index 0000000..0a71426 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/assignment/type_assertion_assignment.ts.snap @@ -0,0 +1,10 @@ +let x; + +(x) = true; + +(x.very.long.chain.of.static.members.that.goes.on.for.ever.I.mean.it.for + .ever as string) = veryLongExpression(); + +for (x of []) { +} +({ x: x } = { x: "test" }); diff --git a/crates/rome_fmt/test_data/specs/ts/binding/definite_variable.ts b/crates/rome_fmt/test_data/specs/ts/binding/definite_variable.ts new file mode 100644 index 0000000..57b7642 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/binding/definite_variable.ts @@ -0,0 +1 @@ +let definiteVariable!: TypeName; diff --git a/crates/rome_fmt/test_data/specs/ts/binding/definite_variable.ts.snap b/crates/rome_fmt/test_data/specs/ts/binding/definite_variable.ts.snap new file mode 100644 index 0000000..57b7642 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/binding/definite_variable.ts.snap @@ -0,0 +1 @@ +let definiteVariable!: TypeName; diff --git a/crates/rome_fmt/test_data/specs/ts/call_expression.ts b/crates/rome_fmt/test_data/specs/ts/call_expression.ts new file mode 100644 index 0000000..e79f24b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/call_expression.ts @@ -0,0 +1,24 @@ +app.get("/", (req, res): void => { + res.send("Hello World!"); +}) + + +export class Thing implements OtherThing { + do: (type: Type) => Provider = memoize( + (type: ObjectType): Provider => {} + ); +} + +// Issue https://github.com/rome/tools/issues/2756 +export class Task { + args: any[]; + + constructor( + public script: string, + public duration: number, + public threadCount: number, + ...args: any[] + ) { + this.args = args; + } +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/call_expression.ts.snap b/crates/rome_fmt/test_data/specs/ts/call_expression.ts.snap new file mode 100644 index 0000000..54dece8 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/call_expression.ts.snap @@ -0,0 +1,23 @@ +app.get("/", (req, res): void => { + res.send("Hello World!"); +}); + +export class Thing implements OtherThing { + do: (type: Type) => Provider = memoize( + (type: ObjectType): Provider => {}, + ); +} + +// Issue https://github.com/rome/tools/issues/2756 +export class Task { + args: any[]; + + constructor( + public script: string, + public duration: number, + public threadCount: number, + ...args: any[] + ) { + this.args = args; + } +} diff --git a/crates/rome_fmt/test_data/specs/ts/class/accessor.ts b/crates/rome_fmt/test_data/specs/ts/class/accessor.ts new file mode 100644 index 0000000..e96b3c4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/accessor.ts @@ -0,0 +1,3 @@ +export abstract class C { + protected abstract accessor prop: number +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/class/accessor.ts.snap b/crates/rome_fmt/test_data/specs/ts/class/accessor.ts.snap new file mode 100644 index 0000000..bc695fb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/accessor.ts.snap @@ -0,0 +1,3 @@ +export abstract class C { + protected abstract accessor prop: number; +} diff --git a/crates/rome_fmt/test_data/specs/ts/class/assigment_layout.ts b/crates/rome_fmt/test_data/specs/ts/class/assigment_layout.ts new file mode 100644 index 0000000..7eb4f2e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/assigment_layout.ts @@ -0,0 +1,7 @@ +class SourceRemoveUnused extends SourceAction { + static readonly kind = vscode.CodeActionKind.Source.append( + "removeUnused", + ).append("ts"); + + public static readonly id = "javascript-walkthrough.commands.nodeInstallationFound"; +} diff --git a/crates/rome_fmt/test_data/specs/ts/class/assigment_layout.ts.snap b/crates/rome_fmt/test_data/specs/ts/class/assigment_layout.ts.snap new file mode 100644 index 0000000..9dafb02 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/assigment_layout.ts.snap @@ -0,0 +1,7 @@ +class SourceRemoveUnused extends SourceAction { + static readonly kind = + vscode.CodeActionKind.Source.append("removeUnused").append("ts"); + + public static readonly id = + "javascript-walkthrough.commands.nodeInstallationFound"; +} diff --git a/crates/rome_fmt/test_data/specs/ts/class/constructor_parameter.ts b/crates/rome_fmt/test_data/specs/ts/class/constructor_parameter.ts new file mode 100644 index 0000000..f52945b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/constructor_parameter.ts @@ -0,0 +1,36 @@ +class B { + constructor( + private a: string + ) { + } +} + +class A { + constructor( + private readonly a: string, + readonly b: string, + + ) { + } +} + +class C { + constructor( + private readonly a: string, + readonly b1: string, + readonly b2: string, + readonly b3: string, + readonly b4: string, + readonly b5: string, + readonly b6: string, + readonly b7: string, + readonly b8: string, + readonly b9: string, + readonly b0: string, + readonly b11: string, + readonly b22: string, + readonly b33: string, + + ) { + } +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/class/constructor_parameter.ts.snap b/crates/rome_fmt/test_data/specs/ts/class/constructor_parameter.ts.snap new file mode 100644 index 0000000..cde3e0c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/constructor_parameter.ts.snap @@ -0,0 +1,26 @@ +class B { + constructor(private a: string) {} +} + +class A { + constructor(private readonly a: string, readonly b: string) {} +} + +class C { + constructor( + private readonly a: string, + readonly b1: string, + readonly b2: string, + readonly b3: string, + readonly b4: string, + readonly b5: string, + readonly b6: string, + readonly b7: string, + readonly b8: string, + readonly b9: string, + readonly b0: string, + readonly b11: string, + readonly b22: string, + readonly b33: string, + ) {} +} diff --git a/crates/rome_fmt/test_data/specs/ts/class/implements_clause.ts b/crates/rome_fmt/test_data/specs/ts/class/implements_clause.ts new file mode 100644 index 0000000..c924a49 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/implements_clause.ts @@ -0,0 +1,3 @@ +class ClassName implements Interface { } + +class LongClassName implements Interface1, Interface2, Interface3, Interface4, Interface5 { } \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/class/implements_clause.ts.snap b/crates/rome_fmt/test_data/specs/ts/class/implements_clause.ts.snap new file mode 100644 index 0000000..220b05a --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/implements_clause.ts.snap @@ -0,0 +1,4 @@ +class ClassName implements Interface {} + +class LongClassName + implements Interface1, Interface2, Interface3, Interface4, Interface5 {} diff --git a/crates/rome_fmt/test_data/specs/ts/class/readonly_ambient_property.ts b/crates/rome_fmt/test_data/specs/ts/class/readonly_ambient_property.ts new file mode 100644 index 0000000..342e8be --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/readonly_ambient_property.ts @@ -0,0 +1,10 @@ +declare class A { + readonly prop = "value"; + + +} +export class B { + + declare readonly prop = "value__value__value__value__value__value__value"; + +} diff --git a/crates/rome_fmt/test_data/specs/ts/class/readonly_ambient_property.ts.snap b/crates/rome_fmt/test_data/specs/ts/class/readonly_ambient_property.ts.snap new file mode 100644 index 0000000..8605b10 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/readonly_ambient_property.ts.snap @@ -0,0 +1,6 @@ +declare class A { + readonly prop = "value"; +} +export class B { + declare readonly prop = "value__value__value__value__value__value__value"; +} diff --git a/crates/rome_fmt/test_data/specs/ts/class/trailing_comma/class_trailing_comma.ts b/crates/rome_fmt/test_data/specs/ts/class/trailing_comma/class_trailing_comma.ts new file mode 100644 index 0000000..2d8c9b2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/trailing_comma/class_trailing_comma.ts @@ -0,0 +1,11 @@ +// class method +class C< longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3,> { + one< longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3,>(adsadasdasdasdasdasdasdasdasdasdas1,dsadsadasdasdasdasdasdasdasd2, dsadsadasdasdasdasdasdasdasd) {} + two< longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3,>(adsadasdasdasdasdasdasdasdasdasdas1,dsadsadasdasdasdasdasdasdasd2, dsadsadasdasdasdasdasdasdasd) {} +} diff --git a/crates/rome_fmt/test_data/specs/ts/class/trailing_comma/class_trailing_comma.ts.snap b/crates/rome_fmt/test_data/specs/ts/class/trailing_comma/class_trailing_comma.ts.snap new file mode 100644 index 0000000..3976ebe --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/class/trailing_comma/class_trailing_comma.ts.snap @@ -0,0 +1,25 @@ +// class method +class C< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3, +> { + one< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3, + >( + adsadasdasdasdasdasdasdasdasdasdas1, + dsadsadasdasdasdasdasdasdasd2, + dsadsadasdasdasdasdasdasdasd, + ) {} + two< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3, + >( + adsadasdasdasdasdasdasdasdasdasdas1, + dsadsadasdasdasdasdasdasdasd2, + dsadsadasdasdasdasdasdasdasd, + ) {} +} diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/class.ts b/crates/rome_fmt/test_data/specs/ts/declaration/class.ts new file mode 100644 index 0000000..5794e94 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/class.ts @@ -0,0 +1,60 @@ + +class Test { + name: string; + + constructor( + a: string + ) {} + + declare private readonly test?: string; + readonly test2!: string; + + display2(): void { console.log(this.name); } + my_name(): string { + return this.name + }; + + public get my_name2(): any { return this.name; } + public set my_name2(name) { this.name = name; } + + + +} + +class Test2 { + + static readonly [a: string]: string; +} + + +abstract class A {} +abstract class ConcreteMembers { + name: string; + + + + constructor(name: string) { this.name = name; } + + + + display(): void { console.log(this.name); } + public get my_name() { return this.name; } + public set my_name(name) { this.name = name; } + #private_method() { } +} +abstract class AbstractMembers { + abstract name: string; + abstract display(); + abstract get my_name(); + abstract set my_name(val); +} + + +abstract class Test1 { + private c?: string; + private d?: string; + private readonly e: string; + private readonly f: string; + protected abstract readonly g: string; + protected readonly abstract h: string; +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/class.ts.snap b/crates/rome_fmt/test_data/specs/ts/declaration/class.ts.snap new file mode 100644 index 0000000..64d75d9 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/class.ts.snap @@ -0,0 +1,61 @@ +class Test { + name: string; + + constructor(a: string) {} + + private declare readonly test?: string; + readonly test2!: string; + + display2(): void { + console.log(this.name); + } + my_name(): string { + return this.name; + } + + public get my_name2(): any { + return this.name; + } + public set my_name2(name) { + this.name = name; + } +} + +class Test2 { + static readonly [a: string]: string; +} + +abstract class A {} +abstract class ConcreteMembers { + name: string; + + constructor(name: string) { + this.name = name; + } + + display(): void { + console.log(this.name); + } + public get my_name() { + return this.name; + } + public set my_name(name) { + this.name = name; + } + #private_method() {} +} +abstract class AbstractMembers { + abstract name: string; + abstract display(); + abstract get my_name(); + abstract set my_name(val); +} + +abstract class Test1 { + private c?: string; + private d?: string; + private readonly e: string; + private readonly f: string; + protected abstract readonly g: string; + protected abstract readonly h: string; +} diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/declare_function.ts b/crates/rome_fmt/test_data/specs/ts/declaration/declare_function.ts new file mode 100644 index 0000000..776c10c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/declare_function.ts @@ -0,0 +1,4 @@ +declare function +test(): Promise; + +declare function looooooooooooooooooooooooooooong_naaaaaame(loreum: string, ipsum: number, chilly: symbol, powder: number): string \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/declare_function.ts.snap b/crates/rome_fmt/test_data/specs/ts/declaration/declare_function.ts.snap new file mode 100644 index 0000000..2332674 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/declare_function.ts.snap @@ -0,0 +1,7 @@ +declare function test(): Promise; + +declare function looooooooooooooooooooooooooooong_naaaaaame< + FirstType, + SecondType, + ThirdType, +>(loreum: string, ipsum: number, chilly: symbol, powder: number): string; diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/global_declaration.ts b/crates/rome_fmt/test_data/specs/ts/declaration/global_declaration.ts new file mode 100644 index 0000000..786501f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/global_declaration.ts @@ -0,0 +1,7 @@ +declare module "./test" +{ + global { + let VERSION: string; + } + +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/global_declaration.ts.snap b/crates/rome_fmt/test_data/specs/ts/declaration/global_declaration.ts.snap new file mode 100644 index 0000000..a4ff90c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/global_declaration.ts.snap @@ -0,0 +1,5 @@ +declare module "./test" { + global { + let VERSION: string; + } +} diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/interface.ts b/crates/rome_fmt/test_data/specs/ts/declaration/interface.ts new file mode 100644 index 0000000..6c7953c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/interface.ts @@ -0,0 +1,45 @@ +interface A {} +interface B extends A /** comment **/ { + something: string +} + + +interface C extends B { + something: string +} + +// @ts-ignore +interface D extends B, F, G, H { + something1: string, + something2: string, + something3: string, + something4: string, + something5: string, +} +// @ts-ignore +interface D extends B, F { + +} + +interface Wrong { + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + ppppppp: ppppppp +} + +f(() => { + interface Wrong { + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + ppppppp: ppppppp + } +}); + +x.y(() => { + interface Wrong { + a: { + b: string; + }; + p: { + q: string; + }; + } +}); diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/interface.ts.snap b/crates/rome_fmt/test_data/specs/ts/declaration/interface.ts.snap new file mode 100644 index 0000000..c888c32 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/interface.ts.snap @@ -0,0 +1,55 @@ +interface A {} +interface B extends A /** comment **/ { + something: string; +} + +interface C< + Foo, + Bar, + Loreum, + Ipsum, + ItShouldBeLongEnoughToCoverSomeEdgeCases, + But, + Maybe, + Not, +> extends B { + something: string; +} + +// @ts-ignore +interface D + extends B, + F, + G, + H { + something1: string; + something2: string; + something3: string; + something4: string; + something5: string; +} +// @ts-ignore +interface D extends B, F {} + +interface Wrong { + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + ppppppp: ppppppp; +} + +f(() => { + interface Wrong { + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; + ppppppp: ppppppp; + } +}); + +x.y(() => { + interface Wrong { + a: { + b: string; + }; + p: { + q: string; + }; + } +}); diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/variable_declaration.ts b/crates/rome_fmt/test_data/specs/ts/declaration/variable_declaration.ts new file mode 100644 index 0000000..dae5fc2 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/variable_declaration.ts @@ -0,0 +1,87 @@ +//break left-hand side layout +const map: Map> = + new Map(); + +const map: Map = + new Map(); + +const map: Map> = new Map(); + +//fluid layout + +const map: Map> = + new Map(); + +const map: Map = + new Map(); + +const map: Map> = + new Map(); + +const map: Map = + new Map(); + +const { + id, static: isStatic, method: isMethod, + methodId, getId, setId, +}: + Map> = + anodyneCondosMalateOverateRetinol.get( + bifornCringerMoshedPerplexSawder + ); + +// rome-ignore format: test +const { + id, static: isStatic, method: isMethod, + methodId, getId, setId, +}: + // rome-ignore format: test + Map> = + // rome-ignore format: test + anodyneCondosMalateOverateRetinol.get( + bifornCringerMoshedPerplexSawder + ); + +//break after operator layout +const loooooooooooooooooooooooooong1 = "looooooooooooooooooooooooooooooooooooooooooog"!; +const loooooooooooooooooooooooooong2 = void void "looooooooooooooooooooooooooooooooooooooooooog"!; +// rome-ignore format: test +const loooooooooooooooooooooooooong6 = + void "looooooooooooooooooooooooooooooooooooooooooog"!; +const loooooooooooooooooooooooooong7 = + // rome-ignore format: test + ! "looooooooooooooooooooooooooooooooooooooooooog"!; + +//poorly breakable member or call chain (fluid layout layout) +//JsIdentifierExpression +var looooooooooooooooooooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(); +let looooooooooooooooooooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect<[number, boolean]>().ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect()[dsadsadsadsadsadsadsa]<'key'>().ewqoewqoeiowqieopwqie + +//JsThisExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this<[number, boolean]>().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this()[dsadsadsadsadsadsadsa]<'key'>().ewqoewqoeiowqieopwqie + +//not poorly breakable member or call chain (fluid layout layout) +//JsIdentifierExpression +var looooooooooooooooooooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(); +let looooooooooooooooooooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect().ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect()[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +var looooooooooooooooooooooooooooooooooooooooooong1 = fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(); +let looooooooooooooooooooooooooooooooooooooooooong2 = objdddddddddectobjdddddddddect().ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooong3 = objdddddddddectobjdddddddddect()[dsadsadsadsadsadsadsa]<{ }>().ewqoewqoeiowqieopwqie + +//JsThisExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this()[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie + +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = this(); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = this().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = this()[dsadsadsadsadsadsadsa]<{ }>().ewqoewqoeiowqieopwqie diff --git a/crates/rome_fmt/test_data/specs/ts/declaration/variable_declaration.ts.snap b/crates/rome_fmt/test_data/specs/ts/declaration/variable_declaration.ts.snap new file mode 100644 index 0000000..66b20ca --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declaration/variable_declaration.ts.snap @@ -0,0 +1,123 @@ +//break left-hand side layout +const map: Map< + Function, + Map +> = new Map(); + +const map: Map< + Function, + Condition extends Foo ? FooFooFoo : BarBarBar +> = new Map(); + +const map: Map> = new Map(); + +//fluid layout + +const map: Map> = new Map(); + +const map: Map = + new Map(); + +const map: Map> = new Map(); + +const map: Map = new Map(); + +const { + id, + static: isStatic, + method: isMethod, + methodId, + getId, + setId, +}: Map< + Function, + Map< + string | void, + { + value: UnloadedDescriptor; + } + > +> = anodyneCondosMalateOverateRetinol.get(bifornCringerMoshedPerplexSawder); + +// rome-ignore format: test +const { + id, static: isStatic, method: isMethod, + methodId, getId, setId, +}: + // rome-ignore format: test + Map> = + // rome-ignore format: test + anodyneCondosMalateOverateRetinol.get( + bifornCringerMoshedPerplexSawder + ); + +//break after operator layout +const loooooooooooooooooooooooooong1 = + "looooooooooooooooooooooooooooooooooooooooooog"!; +const loooooooooooooooooooooooooong2 = + void void "looooooooooooooooooooooooooooooooooooooooooog"!; +// rome-ignore format: test +const loooooooooooooooooooooooooong6 = + void "looooooooooooooooooooooooooooooooooooooooooog"!; +const loooooooooooooooooooooooooong7 = + // rome-ignore format: test + ! "looooooooooooooooooooooooooooooooooooooooooog"!; + +//poorly breakable member or call chain (fluid layout layout) +//JsIdentifierExpression +var looooooooooooooooooooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn(); +let looooooooooooooooooooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect<[number, boolean]>() + .ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect()[dsadsadsadsadsadsadsa]<"key">() + .ewqoewqoeiowqieopwqie; + +//JsThisExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this<[number, boolean]>().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this()[dsadsadsadsadsadsadsa]<"key">().ewqoewqoeiowqieopwqie; + +//not poorly breakable member or call chain (fluid layout layout) +//JsIdentifierExpression +var looooooooooooooooooooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn< + A, + B + >(); +let looooooooooooooooooooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect().ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect()[dsadsadsadsadsadsadsa]() + .ewqoewqoeiowqieopwqie; + +var looooooooooooooooooooooooooooooooooooooooooong1 = + fnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfnfn< + A | B + >(); +let looooooooooooooooooooooooooooooooooooooooooong2 = + objdddddddddectobjdddddddddect().ewqeqewqweqweqweqweqweqweqw; +let looooooooooooooooooooooooooooooooooooooooooong3 = + objdddddddddectobjdddddddddect()[dsadsadsadsadsadsadsa]<{}>() + .ewqoewqoeiowqieopwqie; + +//JsThisExpression +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this()[dsadsadsadsadsadsadsa]().ewqoewqoeiowqieopwqie; + +var loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1 = + this(); +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong2 = + this().ewqeqewqweqweqweqweqweqweqw; +let loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong3 = + this()[dsadsadsadsadsadsadsa]<{}>().ewqoewqoeiowqieopwqie; diff --git a/crates/rome_fmt/test_data/specs/ts/declare.ts b/crates/rome_fmt/test_data/specs/ts/declare.ts new file mode 100644 index 0000000..924481d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declare.ts @@ -0,0 +1,6 @@ +declare module 'remark-html' ; +declare module 'other' + +declare module 'remark-html' { + +} diff --git a/crates/rome_fmt/test_data/specs/ts/declare.ts.snap b/crates/rome_fmt/test_data/specs/ts/declare.ts.snap new file mode 100644 index 0000000..3f1fe97 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/declare.ts.snap @@ -0,0 +1,4 @@ +declare module "remark-html"; +declare module "other"; + +declare module "remark-html" {} diff --git a/crates/rome_fmt/test_data/specs/ts/decoartors.ts b/crates/rome_fmt/test_data/specs/ts/decoartors.ts new file mode 100644 index 0000000..00fa44e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/decoartors.ts @@ -0,0 +1,258 @@ +@sealed +class Test { + @readonly + prop: string; + + constructor(@param test, @readonly private other, @aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last) {} + + method(@param a) {} + + get getter() {} + + set setter(@param param) {} +} + +@sealed +export default class {} + +@sealed +export class Test {} + +// Leading comment before decorator +@test // first decorator +// Leading comment before class +class Test2 { + + + + + + /* + * Leading multiline comment + */ + + + + @test /* trailing multiline comment + for decorator */ @anotherDecorator() + + + + + // leading comment + prop: string; + +} + +class Foo { + constructor( + @inject(Bar) + private readonly bar: IBar, + + @inject(MyProcessor) + private readonly myProcessor: IMyProcessor, + + @inject(InjectionTypes.AnotherThing) + + private readonly anotherThing: IAnotherThing | undefined, + ) { } +} + +export class TestTextFileService { + constructor( + @ILifecycleService lifecycleService, + ) { + } +} + +@commonEditorContribution +export class TabCompletionController { +} + +@Component({ + selector: 'angular-component', +}) +class AngularComponent { + @Input() myInput: string; +} + +class Class { + method( + @Decorator + { prop1, prop2 }: Type + ) { + doSomething(); + } +} + +class Class2 { + method( + @Decorator1 + @Decorator2 + { prop1, prop2 }: Type + ) { + doSomething(); + } +} + +class Class3 { + method( + @Decorator + { prop1_1, prop1_2 }: Type, + { prop2_1, prop2_2 }: Type + ) { + doSomething(); + } +} + +class Class4 { + method( + param1, + @Decorator + { prop1, prop2 }: Type + ) {} +} + +class Class5 { + method( + @Decorator { prop1 }: Type + ) {} +} + +class Class6 { + method( + @Decorator({}) { prop1 }: Type + ) {} + method( + @Decorator( + {}) { prop1 }: Type + ) {} + method( + @Decorator([]) { prop1 }: Type + ) {} + method( + @Decorator( + []) { prop1 }: Type + ) {} +} + + +@d1 +@d2(foo) +@d3.bar +@d4.baz() +class Class1 {} + +class Class2 { + @d1 + @d2(foo) + @d3.bar + @d4.baz() + method1() {} + + @d1 + method2() {} + + @d2(foo) + method3() {} + + @d3.bar + method4() {} +} + +class Class3 { + @d1 fieldA; + @d2(foo) fieldB; + @d3.bar fieldC; + @d4.baz() fieldD; + + constructor ( + @d1 private x: number, + @d2(foo) private y: number, + @d3('foo') private z: number, + @d4({ + x: string + }) private a: string, + ) {} +} + +@decorated class Foo {} + +class Bar { + @decorated method() {} +} + +class MyContainerComponent { + @ContentChildren(MyComponent) components: QueryListSomeBigName; +} + +@sealed +class Test { + @readonly + prop: string; + + constructor(@param test, @readonly private other, @aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last) {} + + method(@param a) {} + + get getter() {} + + set setter(@param param) {} +} + +class Class4 { + method( + @Decorator + { prop1_1, prop1_2 }: Type = {}, + { prop2_1, prop2_2 }: Type + ) { + doSomething(); + } +} + +class Class { + method(@aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last, @d2(foo) y: number,) { + + } +} + + +class Class2 { + constructor(@param test, @aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last, @d2(foo) y: number,) {} + + method(@aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last, @d2(foo) y: number,) { + + } +} + +class Class3 { + constructor ( + private aaaaaaaaaaaaaaaaa: {aaaaaaaaaaaaa: number; bbbbbbbbbbb: string; cccccccccccc: Type}, + @d1 private readonly x: number, + @d2(foo) private y: number, + @d3('foo') private z: number, + + ) {} + +} + +// comments +class Foo { + constructor( + //leading own line + /*leading same line*/ @Decorator /*trailing*/ + //leading own line between + /*leading same line between*/ @dec //trailing + /*leading parameter*/ + parameter: number + ) {} + + method( + //leading own line + /*leading same line*/ @Decorator /*trailing*/ + //leading own line between + /*leading same line between*/ @dec //trailing + /*leading parameter*/ + parameter + ) {} +} diff --git a/crates/rome_fmt/test_data/specs/ts/decoartors.ts.snap b/crates/rome_fmt/test_data/specs/ts/decoartors.ts.snap new file mode 100644 index 0000000..97b3955 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/decoartors.ts.snap @@ -0,0 +1,258 @@ +@sealed +class Test { + @readonly + prop: string; + + constructor( + @param test, + @readonly private other, + @aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last, + ) {} + + method(@param a) {} + + get getter() {} + + set setter(@param param) {} +} + +@sealed +export default class {} + +@sealed +export class Test {} + +// Leading comment before decorator +@test // first decorator +// Leading comment before class +class Test2 { + /* + * Leading multiline comment + */ + + @test /* trailing multiline comment + for decorator */ @anotherDecorator() + + // leading comment + prop: string; +} + +class Foo { + constructor( + @inject(Bar) + private readonly bar: IBar, + + @inject(MyProcessor) + private readonly myProcessor: IMyProcessor, + + @inject(InjectionTypes.AnotherThing) + private readonly anotherThing: IAnotherThing | undefined, + ) {} +} + +export class TestTextFileService { + constructor( + @ILifecycleService lifecycleService, + ) {} +} + +@commonEditorContribution +export class TabCompletionController {} + +@Component({ + selector: 'angular-component', +}) +class AngularComponent { + @Input() myInput: string; +} + +class Class { + method( + @Decorator + { prop1, prop2 }: Type, + ) { + doSomething(); + } +} + +class Class2 { + method( + @Decorator1 + @Decorator2 + { prop1, prop2 }: Type, + ) { + doSomething(); + } +} + +class Class3 { + method( + @Decorator + { prop1_1, prop1_2 }: Type, + { prop2_1, prop2_2 }: Type, + ) { + doSomething(); + } +} + +class Class4 { + method( + param1, + @Decorator + { prop1, prop2 }: Type, + ) {} +} + +class Class5 { + method( + @Decorator { prop1 }: Type, + ) {} +} + +class Class6 { + method( + @Decorator({}) { prop1 }: Type, + ) {} + method( + @Decorator( + {}) { prop1 }: Type, + ) {} + method( + @Decorator([]) { prop1 }: Type, + ) {} + method( + @Decorator( + []) { prop1 }: Type, + ) {} +} + +@d1 +@d2(foo) +@d3.bar +@d4.baz() +class Class1 {} + +class Class2 { + @d1 + @d2(foo) + @d3.bar + @d4.baz() + method1() {} + + @d1 + method2() {} + + @d2(foo) + method3() {} + + @d3.bar + method4() {} +} + +class Class3 { + @d1 fieldA; + @d2(foo) fieldB; + @d3.bar fieldC; + @d4.baz() fieldD; + + constructor( + @d1 private x: number, + @d2(foo) private y: number, + @d3('foo') private z: number, + @d4({ + x: string + }) private a: string, + ) {} +} + +@decorated class Foo {} + +class Bar { + @decorated method() {} +} + +class MyContainerComponent { + @ContentChildren(MyComponent) components: QueryListSomeBigName; +} + +@sealed +class Test { + @readonly + prop: string; + + constructor( + @param test, + @readonly private other, + @aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last, + ) {} + + method(@param a) {} + + get getter() {} + + set setter(@param param) {} +} + +class Class4 { + method( + @Decorator + { prop1_1, prop1_2 }: Type = {}, + { prop2_1, prop2_2 }: Type, + ) { + doSomething(); + } +} + +class Class { + method( + @aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last, + @d2(foo) y: number, + ) {} +} + +class Class2 { + constructor( + @param test, + @aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last, + @d2(foo) y: number, + ) {} + + method( + @aVeryLongDecoratorNameLetsSeeWhatHappensWithIt last, + @d2(foo) y: number, + ) {} +} + +class Class3 { + constructor( + private aaaaaaaaaaaaaaaaa: { + aaaaaaaaaaaaa: number; + bbbbbbbbbbb: string; + cccccccccccc: Type; + }, + @d1 private readonly x: number, + @d2(foo) private y: number, + @d3('foo') private z: number, + ) {} +} + +// comments +class Foo { + constructor( + //leading own line + /*leading same line*/ @Decorator /*trailing*/ + //leading own line between + /*leading same line between*/ @dec //trailing + /*leading parameter*/ + parameter: number, + ) {} + + method( + //leading own line + /*leading same line*/ @Decorator /*trailing*/ + //leading own line between + /*leading same line between*/ @dec //trailing + /*leading parameter*/ + parameter, + ) {} +} diff --git a/crates/rome_fmt/test_data/specs/ts/decorators/class_members.ts b/crates/rome_fmt/test_data/specs/ts/decorators/class_members.ts new file mode 100644 index 0000000..4f17f2e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/decorators/class_members.ts @@ -0,0 +1,92 @@ +class Foo { + // one decorator without a newline + @dec public property; + @dec public method() {} + @dec public async method() {} + @dec public *method() {} + @dec public get getter() {} + @dec public set setter(val) {} + + // two decorators without a newline + @dec @dec public property; + @dec @dec public method() {} + @dec @dec public async method() {} + @dec @dec public *method() {} + @dec @dec public get getter() {} + @dec @dec public set setter(val) {} + + // one decorator with a newline + @dec + public property; + @dec + public method() {} + @dec + public async method() {} + @dec + public *method() {} + @dec + public get getter() {} + @dec + public set setter(val) {} + + // two decorators without a newline + @dec + @dec public property; + @dec + @dec public method() {} + @dec + @dec public async method() {} + @dec + @dec public *method() {} + @dec + @dec public get getter() {} + @dec + @dec public set setter(val) {} +} + + +class Foo { + // one decorator without a newline + /*before*/ @dec /*after*/ public property; + /*before*/ @dec /*after*/ public method() {} + /*before*/ @dec /*after*/ public async method() {} + /*before*/ @dec /*after*/ public *method() {} + /*before*/ @dec /*after*/ public get getter() {} + /*before*/ @dec /*after*/ public set setter(val) {} + + // two decorators without a newline + /*before*/ @dec /*middle*/ @dec /*after*/ public property; + /*before*/ @dec /*middle*/ @dec /*after*/ public method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ public async method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ public *method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ public get getter() {} + /*before*/ @dec /*middle*/ @dec /*after*/ public set setter(val) {} + + // one decorator with a newline + @dec /*before*/ + /*after*/ public property; + @dec /*before*/ + /*after*/ public method() {} + @dec /*before*/ + /*after*/ public async method() {} + @dec /*before*/ + /*after*/ public *method() {} + @dec /*before*/ + /*after*/ public get getter() {} + @dec /*before*/ + /*after*/ public set setter(val) {} + + // two decorators without a newline + @dec /*before*/ + /*middle*/ @dec /*after*/ public property; + @dec /*before*/ + /*middle*/ @dec /*after*/ public method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ public async method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ public *method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ public get getter() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ public set setter(val) {} +} diff --git a/crates/rome_fmt/test_data/specs/ts/decorators/class_members.ts.snap b/crates/rome_fmt/test_data/specs/ts/decorators/class_members.ts.snap new file mode 100644 index 0000000..4307798 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/decorators/class_members.ts.snap @@ -0,0 +1,91 @@ +class Foo { + // one decorator without a newline + @dec public property; + @dec public method() {} + @dec public async method() {} + @dec public *method() {} + @dec public get getter() {} + @dec public set setter(val) {} + + // two decorators without a newline + @dec @dec public property; + @dec @dec public method() {} + @dec @dec public async method() {} + @dec @dec public *method() {} + @dec @dec public get getter() {} + @dec @dec public set setter(val) {} + + // one decorator with a newline + @dec + public property; + @dec + public method() {} + @dec + public async method() {} + @dec + public *method() {} + @dec + public get getter() {} + @dec + public set setter(val) {} + + // two decorators without a newline + @dec + @dec public property; + @dec + @dec public method() {} + @dec + @dec public async method() {} + @dec + @dec public *method() {} + @dec + @dec public get getter() {} + @dec + @dec public set setter(val) {} +} + +class Foo { + // one decorator without a newline + /*before*/ @dec /*after*/ public property; + /*before*/ @dec /*after*/ public method() {} + /*before*/ @dec /*after*/ public async method() {} + /*before*/ @dec /*after*/ public *method() {} + /*before*/ @dec /*after*/ public get getter() {} + /*before*/ @dec /*after*/ public set setter(val) {} + + // two decorators without a newline + /*before*/ @dec /*middle*/ @dec /*after*/ public property; + /*before*/ @dec /*middle*/ @dec /*after*/ public method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ public async method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ public *method() {} + /*before*/ @dec /*middle*/ @dec /*after*/ public get getter() {} + /*before*/ @dec /*middle*/ @dec /*after*/ public set setter(val) {} + + // one decorator with a newline + @dec /*before*/ + /*after*/ public property; + @dec /*before*/ + /*after*/ public method() {} + @dec /*before*/ + /*after*/ public async method() {} + @dec /*before*/ + /*after*/ public *method() {} + @dec /*before*/ + /*after*/ public get getter() {} + @dec /*before*/ + /*after*/ public set setter(val) {} + + // two decorators without a newline + @dec /*before*/ + /*middle*/ @dec /*after*/ public property; + @dec /*before*/ + /*middle*/ @dec /*after*/ public method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ public async method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ public *method() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ public get getter() {} + @dec /*before*/ + /*middle*/ @dec /*after*/ public set setter(val) {} +} diff --git a/crates/rome_fmt/test_data/specs/ts/enum/enum_trailing_comma.ts b/crates/rome_fmt/test_data/specs/ts/enum/enum_trailing_comma.ts new file mode 100644 index 0000000..b8fae49 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/enum/enum_trailing_comma.ts @@ -0,0 +1,5 @@ +enum A { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +} diff --git a/crates/rome_fmt/test_data/specs/ts/enum/enum_trailing_comma.ts.snap b/crates/rome_fmt/test_data/specs/ts/enum/enum_trailing_comma.ts.snap new file mode 100644 index 0000000..b8fae49 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/enum/enum_trailing_comma.ts.snap @@ -0,0 +1,5 @@ +enum A { + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +} diff --git a/crates/rome_fmt/test_data/specs/ts/expression/as_expression.ts b/crates/rome_fmt/test_data/specs/ts/expression/as_expression.ts new file mode 100644 index 0000000..c6cc72e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/as_expression.ts @@ -0,0 +1,4 @@ + +let a: any; +let b = + a as string; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/expression/as_expression.ts.snap b/crates/rome_fmt/test_data/specs/ts/expression/as_expression.ts.snap new file mode 100644 index 0000000..55a8242 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/as_expression.ts.snap @@ -0,0 +1,2 @@ +let a: any; +let b = a as string; diff --git a/crates/rome_fmt/test_data/specs/ts/expression/non_null_expression.ts b/crates/rome_fmt/test_data/specs/ts/expression/non_null_expression.ts new file mode 100644 index 0000000..2449b12 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/non_null_expression.ts @@ -0,0 +1,2 @@ +let a: any; +let b = a !; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/expression/non_null_expression.ts.snap b/crates/rome_fmt/test_data/specs/ts/expression/non_null_expression.ts.snap new file mode 100644 index 0000000..89d02b0 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/non_null_expression.ts.snap @@ -0,0 +1,2 @@ +let a: any; +let b = a!; diff --git a/crates/rome_fmt/test_data/specs/ts/expression/type_assertion_expression.ts b/crates/rome_fmt/test_data/specs/ts/expression/type_assertion_expression.ts new file mode 100644 index 0000000..99346e1 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/type_assertion_expression.ts @@ -0,0 +1,7 @@ +let x = < + const + >"hello"; +let y = < string > x; +var d = + ({ name: "foo", message: "bar" }) +; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/expression/type_assertion_expression.ts.snap b/crates/rome_fmt/test_data/specs/ts/expression/type_assertion_expression.ts.snap new file mode 100644 index 0000000..28113eb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/type_assertion_expression.ts.snap @@ -0,0 +1,3 @@ +let x = "hello"; +let y = x; +var d = { name: "foo", message: "bar" }; diff --git a/crates/rome_fmt/test_data/specs/ts/expression/type_expression.ts b/crates/rome_fmt/test_data/specs/ts/expression/type_expression.ts new file mode 100644 index 0000000..3df2341 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/type_expression.ts @@ -0,0 +1,105 @@ +import * as assert from "assert"; + +type A = string; +type B = number; +type C = null; +type D = undefined; +type E = never; +type F = unknown; +type G = object; +type H = any; +type I = boolean; +type J = bigint; +type K = symbol; +type L = void; +// @ts-ignore +type M = this; +type N = "foo"; +type O = true; +type P = false; +type Q = Function; +let a = 2; +type R = typeof a; +type S = 15n; +type T = -15n; +type U = 15; +// @ts-ignore +type V = infer U; +type W = { a: string; b: symbol; c: symbol;d: symbol;e: symbol;f: symbol;g: symbol; }; +type X = { a: string; b: symbol; } +type Z = { + a: string + b: symbol +} + +type OptionsFlags + = + { + + + readonly [Property + in + keyof + Type + as string] + -?: boolean; +}; + +type OptionsFlag + + = any> + = string; + + +type TupleA + = [ string ] + +type TupleB = [ ...string[ ] ] + +type TupleC = [ surname ?: + string[], + ...name: string[], ] + +type TupleD = [ + address: string, + address2: string, + address3: string, + address4: string, + address5: string, + surname ?: + string[], + ...name: string[], ] + +type PA = ( + string + ) + + +type FunctionType = (Lorem: string, ipsum: symbol, dolor: number, sit: boolean, amet: string, consectetur: symbol) => { + Lorem: string, ipsum: symbol, dolor: number, sit: boolean, amet: string, consectetur: symbol +} + +type FunctionTypeB = ( loreum: string ) => string ; + +type Indexed = string[ + number + ] + +function test(a: string): + a is string { return true } + + +type AbstractCompositeThingamabobberFactoryProvider = string; + +type ConstructorType = new ( options: { a: string, b: AbstractCompositeThingamabobberFactoryProvider }, +) => {}; + +type Constructor = new(...args: any[]) => T; + +function test2(a: string): + asserts a is string { } + + +type Type01 = 0 extends + (1 extends 2 ? 3 : 4) ? 5 : 6 + ; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/expression/type_expression.ts.snap b/crates/rome_fmt/test_data/specs/ts/expression/type_expression.ts.snap new file mode 100644 index 0000000..4f19f2d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/type_expression.ts.snap @@ -0,0 +1,110 @@ +import * as assert from "assert"; + +type A = string; +type B = number; +type C = null; +type D = undefined; +type E = never; +type F = unknown; +type G = object; +type H = any; +type I = boolean; +type J = bigint; +type K = symbol; +type L = void; +// @ts-ignore +type M = this; +type N = "foo"; +type O = true; +type P = false; +type Q = Function; +let a = 2; +type R = typeof a; +type S = 15n; +type T = -15n; +type U = 15; +// @ts-ignore +type V = infer U; +type W = { + a: string; + b: symbol; + c: symbol; + d: symbol; + e: symbol; + f: symbol; + g: symbol; +}; +type X = { a: string; b: symbol }; +type Z = { + a: string; + b: symbol; +}; + +type OptionsFlags = { + +readonly [Property in keyof Type as string]-?: boolean; +}; + +type OptionsFlag = any> = string; + +type TupleA = [string]; + +type TupleB = [...string[]]; + +type TupleC = [surname?: string[], ...name: string[]]; + +type TupleD = [ + address: string, + address2: string, + address3: string, + address4: string, + address5: string, + surname?: string[], + ...name: string[], +]; + +type PA = string; + +type FunctionType = < + Aaaaaaaaaaaaaaaaaaaaa, + bvvvvvvvvvvvvvvvvvvvvvv, + ceeeeeee, + deeeeeeeeeeeeee, + deeeeeeeeeeeeeee, + deeeeeeeeeeeeeeee, + deeeeeeeewweeeeee, +>( + Lorem: string, + ipsum: symbol, + dolor: number, + sit: boolean, + amet: string, + consectetur: symbol, +) => { + Lorem: string; + ipsum: symbol; + dolor: number; + sit: boolean; + amet: string; + consectetur: symbol; +}; + +type FunctionTypeB = (loreum: string) => string; + +type Indexed = string[number]; + +function test(a: string): a is string { + return true; +} + +type AbstractCompositeThingamabobberFactoryProvider = string; + +type ConstructorType = new (options: { + a: string; + b: AbstractCompositeThingamabobberFactoryProvider; +}) => {}; + +type Constructor = new (...args: any[]) => T; + +function test2(a: string): asserts a is string {} + +type Type01 = 0 extends (1 extends 2 ? 3 : 4) ? 5 : 6; diff --git a/crates/rome_fmt/test_data/specs/ts/expression/type_member.ts b/crates/rome_fmt/test_data/specs/ts/expression/type_member.ts new file mode 100644 index 0000000..35871fc --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/type_member.ts @@ -0,0 +1,47 @@ +type A = + { [ a: string ] : number } + +type B = { + (a: string, b: symbol, c: symbol, d: symbol ) +} + +type C = { + (loreum: string, ipsum: symbol, lapis: symbol, emerald: symbol, consequence: symbol, something_with_long_name: symbol, some_other_time: symbol ) +} +type D = { + + (loreum: string, ipsum: symbol, lapis: symbol, emerald: symbol, consequence: symbol, something_with_long_name: symbol, some_other_time: symbol ) +} + +type E = { + + (loreum: string ) +} + + +type F = { + + (loreum: string ) +} + +type G = { + + (loreum: string, ipsum: symbol, lapis: symbol, emerald: symbol, consequence: symbol, something_with_long_name: symbol, some_other_time: symbol ) +} + +type H = { + a?(): number; b?(): number, c?(): number + d(): string + bvvvvvvvvvvvvvvvvvvvvvv?(loreum: string, ipsum: symbol, lapis: symbol, emerald: symbol,): G +} + +type LoooooooooooooongTypeReturneeeeeeeeed = "0"; +type I = { + new(loreum: string, ipsum: symbol, lapis: symbol, emerald: symbol, consequence: symbol, something_with_long_name: symbol, some_other_time: symbol ): LoooooooooooooongTypeReturneeeeeeeeed +} + +type J = { + get something( ): LoooooooooooooongTypeReturneeeeeeeeed +} + +type K = { set something( something_with_long_name: string ) } \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/expression/type_member.ts.snap b/crates/rome_fmt/test_data/specs/ts/expression/type_member.ts.snap new file mode 100644 index 0000000..3082126 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/expression/type_member.ts.snap @@ -0,0 +1,98 @@ +type A = { [a: string]: number }; + +type B = { + (a: string, b: symbol, c: symbol, d: symbol); +}; + +type C = { + ( + loreum: string, + ipsum: symbol, + lapis: symbol, + emerald: symbol, + consequence: symbol, + something_with_long_name: symbol, + some_other_time: symbol, + ); +}; +type D = { + < + Aaaaaaaaaaaaaaaaaaaaa, + bvvvvvvvvvvvvvvvvvvvvvv, + ceeeeeee, + deeeeeeeeeeeeee, + deeeeeeeeeeeeeee, + deeeeeeeeeeeeeeee, + deeeeeeeewweeeeee, + >( + loreum: string, + ipsum: symbol, + lapis: symbol, + emerald: symbol, + consequence: symbol, + something_with_long_name: symbol, + some_other_time: symbol, + ); +}; + +type E = { + (loreum: string); +}; + +type F = { + < + Aaaaaaaaaaaaaaaaaaaaa, + bvvvvvvvvvvvvvvvvvvvvvv, + ceeeeeee, + deeeeeeeeeeeeee, + deeeeeeeeeeeeeee, + deeeeeeeeeeeeeeee, + deeeeeeeewweeeeee, + >( + loreum: string, + ); +}; + +type G = { + ( + loreum: string, + ipsum: symbol, + lapis: symbol, + emerald: symbol, + consequence: symbol, + something_with_long_name: symbol, + some_other_time: symbol, + ); +}; + +type H = { + a?(): number; + b?(): number; + c?(): number; + d(): string; + bvvvvvvvvvvvvvvvvvvvvvv?( + loreum: string, + ipsum: symbol, + lapis: symbol, + emerald: symbol, + ): G; +}; + +type LoooooooooooooongTypeReturneeeeeeeeed = "0"; +type I = { + new ( + loreum: string, + ipsum: symbol, + lapis: symbol, + emerald: symbol, + consequence: symbol, + something_with_long_name: symbol, + some_other_time: symbol, + ): LoooooooooooooongTypeReturneeeeeeeeed; +}; + +type J = { + get something(): LoooooooooooooongTypeReturneeeeeeeeed; +}; + +type K = { set something(something_with_long_name: string) }; diff --git a/crates/rome_fmt/test_data/specs/ts/function/parameters/function_parameters.ts b/crates/rome_fmt/test_data/specs/ts/function/parameters/function_parameters.ts new file mode 100644 index 0000000..43b3ca4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/function/parameters/function_parameters.ts @@ -0,0 +1,33 @@ +export function formatNumber1( + value: string, + { + a, + b, + c, + formatNumber, + ...props + }: Omit & { + useGrouping?: boolean; + } +): string {} + +export function formatNumber2( + value: string, + { a }: Omit & { + useGrouping?: boolean; + } +): string {} + + +export const findByDatefindByDatefindByDatefindByDate = + (_, { date }, { req } ) => findByDatefindByDatefindByDatefindByDate; + +export const queryAuditLog = async ({ + startDate, + endDate, + jobId, + src, + type, + }: Filter): Promise => { + +}; diff --git a/crates/rome_fmt/test_data/specs/ts/function/parameters/function_parameters.ts.snap b/crates/rome_fmt/test_data/specs/ts/function/parameters/function_parameters.ts.snap new file mode 100644 index 0000000..3ed84ce --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/function/parameters/function_parameters.ts.snap @@ -0,0 +1,35 @@ +export function formatNumber1( + value: string, + { + a, + b, + c, + formatNumber, + ...props + }: Omit & { + useGrouping?: boolean; + }, +): string {} + +export function formatNumber2( + value: string, + { + a, + }: Omit & { + useGrouping?: boolean; + }, +): string {} + +export const findByDatefindByDatefindByDatefindByDate = ( + _, + { date }, + { req }, +) => findByDatefindByDatefindByDatefindByDate; + +export const queryAuditLog = async ({ + startDate, + endDate, + jobId, + src, + type, +}: Filter): Promise => {}; diff --git a/crates/rome_fmt/test_data/specs/ts/function/trailing_comma/function_trailing_comma.ts b/crates/rome_fmt/test_data/specs/ts/function/trailing_comma/function_trailing_comma.ts new file mode 100644 index 0000000..dac84ac --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/function/trailing_comma/function_trailing_comma.ts @@ -0,0 +1,37 @@ +function test< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3 + >( + longlonglonglonglonglonglongItem1, + longlonglonglonglonglonglongItem2, + longlonglonglonglonglonglongItem3 +) {} +const test1 = < + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3 + >( + longlonglonglonglonglonglongItem1, + longlonglonglonglonglonglongItem2, + longlonglonglonglonglonglongItem3 +) => {}; +test< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3 + >( + longlonglonglonglonglonglongItem1, + longlonglonglonglonglonglongItem2, + longlonglonglonglonglonglongItem3, +); + +this.test( longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3); + +connect( + mapStateToPropsmapStateToProps, + mapDispatchToPropsmapDispatchToProps, + mergePropsmergeProps, +)(Component) diff --git a/crates/rome_fmt/test_data/specs/ts/function/trailing_comma/function_trailing_comma.ts.snap b/crates/rome_fmt/test_data/specs/ts/function/trailing_comma/function_trailing_comma.ts.snap new file mode 100644 index 0000000..a0f8501 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/function/trailing_comma/function_trailing_comma.ts.snap @@ -0,0 +1,39 @@ +function test< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3, +>( + longlonglonglonglonglonglongItem1, + longlonglonglonglonglonglongItem2, + longlonglonglonglonglonglongItem3, +) {} +const test1 = < + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3, +>( + longlonglonglonglonglonglongItem1, + longlonglonglonglonglonglongItem2, + longlonglonglonglonglonglongItem3, +) => {}; +test< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3 +>( + longlonglonglonglonglonglongItem1, + longlonglonglonglonglonglongItem2, + longlonglonglonglonglonglongItem3, +); + +this.test( + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3, +); + +connect( + mapStateToPropsmapStateToProps, + mapDispatchToPropsmapDispatchToProps, + mergePropsmergeProps, +)(Component); diff --git a/crates/rome_fmt/test_data/specs/ts/module/export_clause.ts b/crates/rome_fmt/test_data/specs/ts/module/export_clause.ts new file mode 100644 index 0000000..6fcc164 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/module/export_clause.ts @@ -0,0 +1,22 @@ +export type A = string; + +export enum B { + A, + B +} + +export interface C { } + +export namespace D { } + +export as namespace c; + +export = b; + +export import a = b; + +export declare class E { } + +export type * from "types"; + +export type * as types from "types"; diff --git a/crates/rome_fmt/test_data/specs/ts/module/export_clause.ts.snap b/crates/rome_fmt/test_data/specs/ts/module/export_clause.ts.snap new file mode 100644 index 0000000..b64ed03 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/module/export_clause.ts.snap @@ -0,0 +1,22 @@ +export type A = string; + +export enum B { + A, + B, +} + +export interface C {} + +export namespace D {} + +export as namespace c; + +export = b; + +export import a = b; + +export declare class E {} + +export type * from "types"; + +export type * as types from "types"; diff --git a/crates/rome_fmt/test_data/specs/ts/module/external_module_reference.ts b/crates/rome_fmt/test_data/specs/ts/module/external_module_reference.ts new file mode 100644 index 0000000..c4a2cc9 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/module/external_module_reference.ts @@ -0,0 +1,3 @@ +import name = require('module_source'); + +import name2 = require('other_source') diff --git a/crates/rome_fmt/test_data/specs/ts/module/external_module_reference.ts.snap b/crates/rome_fmt/test_data/specs/ts/module/external_module_reference.ts.snap new file mode 100644 index 0000000..3052398 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/module/external_module_reference.ts.snap @@ -0,0 +1,3 @@ +import name = require("module_source"); + +import name2 = require("other_source"); diff --git a/crates/rome_fmt/test_data/specs/ts/module/module_declaration.ts b/crates/rome_fmt/test_data/specs/ts/module/module_declaration.ts new file mode 100644 index 0000000..c457512 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/module/module_declaration.ts @@ -0,0 +1,4 @@ +module singleName { } + + +module qualified.name { } diff --git a/crates/rome_fmt/test_data/specs/ts/module/module_declaration.ts.snap b/crates/rome_fmt/test_data/specs/ts/module/module_declaration.ts.snap new file mode 100644 index 0000000..0563801 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/module/module_declaration.ts.snap @@ -0,0 +1,3 @@ +module singleName {} + +module qualified.name {} diff --git a/crates/rome_fmt/test_data/specs/ts/module/qualified_module_name.ts b/crates/rome_fmt/test_data/specs/ts/module/qualified_module_name.ts new file mode 100644 index 0000000..dec9a7a --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/module/qualified_module_name.ts @@ -0,0 +1 @@ +module a . b . c { } diff --git a/crates/rome_fmt/test_data/specs/ts/module/qualified_module_name.ts.snap b/crates/rome_fmt/test_data/specs/ts/module/qualified_module_name.ts.snap new file mode 100644 index 0000000..cf2a6ec --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/module/qualified_module_name.ts.snap @@ -0,0 +1 @@ +module a.b.c {} diff --git a/crates/rome_fmt/test_data/specs/ts/no-semi/class.ts b/crates/rome_fmt/test_data/specs/ts/no-semi/class.ts new file mode 100644 index 0000000..2cabb98 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/no-semi/class.ts @@ -0,0 +1,51 @@ +class A { + bar: A; + [baz] + + // none of the semicolons above this comment can be omitted. + // none of the semicolons below this comment are necessary. + + bar: A; + private [baz] +} + +const computed = "test"; + +class A { + test: string + + private [computed] + protected [computed] + public [computed] + static [computed] + + readonly [computed] + + [key: string]: string; + + async [computed]() {} +} + +declare module test { + class Declaration { + prop: string; + [computed]; + + constructor() + + [computed] + + get getter() + [computed] + + set setter(a: string) + [computed] + + method() + + [computed] + + [key: string]: string + [computed] + } +} diff --git a/crates/rome_fmt/test_data/specs/ts/no-semi/class.ts.snap b/crates/rome_fmt/test_data/specs/ts/no-semi/class.ts.snap new file mode 100644 index 0000000..e2ca11f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/no-semi/class.ts.snap @@ -0,0 +1,51 @@ +class A { + bar: A; + [baz]; + + // none of the semicolons above this comment can be omitted. + // none of the semicolons below this comment are necessary. + + bar: A; + private [baz]; +} + +const computed = "test"; + +class A { + test: string; + + private [computed]; + protected [computed]; + public [computed]; + static [computed]; + + readonly [computed]; + + [key: string]: string; + + async [computed]() {} +} + +declare module test { + class Declaration { + prop: string; + [computed]; + + constructor(); + + [computed]; + + get getter(); + [computed]; + + set setter(a: string); + [computed]; + + method(); + + [computed]; + + [key: string]: string; + [computed]; + } +} diff --git a/crates/rome_fmt/test_data/specs/ts/no-semi/non-null.ts b/crates/rome_fmt/test_data/specs/ts/no-semi/non-null.ts new file mode 100644 index 0000000..df503c0 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/no-semi/non-null.ts @@ -0,0 +1,3 @@ +// the 2nd line needs ASI protection +const el = ReactDOM.findDOMNode(ref) +;(el as HTMLElement)!.style.cursor = 'pointer' diff --git a/crates/rome_fmt/test_data/specs/ts/no-semi/non-null.ts.snap b/crates/rome_fmt/test_data/specs/ts/no-semi/non-null.ts.snap new file mode 100644 index 0000000..0d67bcb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/no-semi/non-null.ts.snap @@ -0,0 +1,3 @@ +// the 2nd line needs ASI protection +const el = ReactDOM.findDOMNode(ref); +(el as HTMLElement)!.style.cursor = "pointer"; diff --git a/crates/rome_fmt/test_data/specs/ts/no-semi/statements.ts b/crates/rome_fmt/test_data/specs/ts/no-semi/statements.ts new file mode 100644 index 0000000..731fd9d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/no-semi/statements.ts @@ -0,0 +1,14 @@ +declare module "test"; + + +declare module "a.b.c" + +type OptionsFlags = { + [Property in keyof Type]: boolean; +}; + +declare function test(): string; + +export declare function abcd(): string; + +declare let a; diff --git a/crates/rome_fmt/test_data/specs/ts/no-semi/statements.ts.snap b/crates/rome_fmt/test_data/specs/ts/no-semi/statements.ts.snap new file mode 100644 index 0000000..17952f6 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/no-semi/statements.ts.snap @@ -0,0 +1,13 @@ +declare module "test"; + +declare module "a.b.c"; + +type OptionsFlags = { + [Property in keyof Type]: boolean; +}; + +declare function test(): string; + +export declare function abcd(): string; + +declare let a; diff --git a/crates/rome_fmt/test_data/specs/ts/no-semi/types.ts b/crates/rome_fmt/test_data/specs/ts/no-semi/types.ts new file mode 100644 index 0000000..8749a6c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/no-semi/types.ts @@ -0,0 +1,13 @@ +type A = { a: string ; b: number ; c: string } + +type B = { + a: string + b: number + c: string +} + +interface C { a: string ; b: number ; c: string } + +type OptionsFlags = { + [Property in keyof Type]: boolean; +}; diff --git a/crates/rome_fmt/test_data/specs/ts/no-semi/types.ts.snap b/crates/rome_fmt/test_data/specs/ts/no-semi/types.ts.snap new file mode 100644 index 0000000..93fb236 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/no-semi/types.ts.snap @@ -0,0 +1,17 @@ +type A = { a: string; b: number; c: string }; + +type B = { + a: string; + b: number; + c: string; +}; + +interface C { + a: string; + b: number; + c: string; +} + +type OptionsFlags = { + [Property in keyof Type]: boolean; +}; diff --git a/crates/rome_fmt/test_data/specs/ts/object/object_trailing_comma.ts b/crates/rome_fmt/test_data/specs/ts/object/object_trailing_comma.ts new file mode 100644 index 0000000..7c3a794 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/object/object_trailing_comma.ts @@ -0,0 +1,22 @@ + +// object method +const obj = { + one< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3 + >( + adsadasdasdasdasdasdasdasdasdasdas1, + dsadsadasdasdasdasdasdasdasd2, + dsadsadasdasdasdasdasdasdasd + ) {}, + two< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3 + >( + adsadasdasdasdasdasdasdasdasdasdas1, + dsadsadasdasdasdasdasdasdasd2, + dsadsadasdasdasdasdasdasdasd + ) {}, +}; diff --git a/crates/rome_fmt/test_data/specs/ts/object/object_trailing_comma.ts.snap b/crates/rome_fmt/test_data/specs/ts/object/object_trailing_comma.ts.snap new file mode 100644 index 0000000..cea20e9 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/object/object_trailing_comma.ts.snap @@ -0,0 +1,21 @@ +// object method +const obj = { + one< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3, + >( + adsadasdasdasdasdasdasdasdasdasdas1, + dsadsadasdasdasdasdasdasdasd2, + dsadsadasdasdasdasdasdasdasd, + ) {}, + two< + longlonglonglonglonglonglongT1, + longlonglonglonglonglonglongT2, + longlonglonglonglonglonglongT3, + >( + adsadasdasdasdasdasdasdasdasdasdas1, + dsadsadasdasdasdasdasdasdasd2, + dsadsadasdasdasdasdasdasdasd, + ) {}, +}; diff --git a/crates/rome_fmt/test_data/specs/ts/parameters/parameters.ts b/crates/rome_fmt/test_data/specs/ts/parameters/parameters.ts new file mode 100644 index 0000000..10ed542 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/parameters/parameters.ts @@ -0,0 +1,3 @@ +function a( + this: string +) {} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/parameters/parameters.ts.snap b/crates/rome_fmt/test_data/specs/ts/parameters/parameters.ts.snap new file mode 100644 index 0000000..8f78893 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/parameters/parameters.ts.snap @@ -0,0 +1 @@ +function a(this: string) {} diff --git a/crates/rome_fmt/test_data/specs/ts/parenthesis.ts b/crates/rome_fmt/test_data/specs/ts/parenthesis.ts new file mode 100644 index 0000000..44c7668 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/parenthesis.ts @@ -0,0 +1,3 @@ +const a = (c && b) as boolean; +const a = (c && b) as boolean; +const a = !(c && b) as boolean; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/parenthesis.ts.snap b/crates/rome_fmt/test_data/specs/ts/parenthesis.ts.snap new file mode 100644 index 0000000..cd8f71e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/parenthesis.ts.snap @@ -0,0 +1,3 @@ +const a = (c && b) as boolean; +const a = ((c && b)) as boolean; +const a = !(c && b) as boolean; diff --git a/crates/rome_fmt/test_data/specs/ts/statement/empty_block.ts b/crates/rome_fmt/test_data/specs/ts/statement/empty_block.ts new file mode 100644 index 0000000..aaf7b4f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/statement/empty_block.ts @@ -0,0 +1,2 @@ +interface X {} +type X = {}; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/statement/empty_block.ts.snap b/crates/rome_fmt/test_data/specs/ts/statement/empty_block.ts.snap new file mode 100644 index 0000000..49e089b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/statement/empty_block.ts.snap @@ -0,0 +1,2 @@ +interface X {} +type X = {}; diff --git a/crates/rome_fmt/test_data/specs/ts/statement/enum_statement.ts b/crates/rome_fmt/test_data/specs/ts/statement/enum_statement.ts new file mode 100644 index 0000000..4d75a3d --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/statement/enum_statement.ts @@ -0,0 +1,13 @@ +enum A {} +enum B {a = "something", +b = "something", c = "something", +d = "something", +e = "something", f = "something", +} + +const enum C { + A, B, C, + D + , + F +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/statement/enum_statement.ts.snap b/crates/rome_fmt/test_data/specs/ts/statement/enum_statement.ts.snap new file mode 100644 index 0000000..1cd5aba --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/statement/enum_statement.ts.snap @@ -0,0 +1,17 @@ +enum A {} +enum B { + a = "something", + b = "something", + c = "something", + d = "something", + e = "something", + f = "something", +} + +const enum C { + A, + B, + C, + D, + F, +} diff --git a/crates/rome_fmt/test_data/specs/ts/string/parameter_quotes.ts b/crates/rome_fmt/test_data/specs/ts/string/parameter_quotes.ts new file mode 100644 index 0000000..3b5cd23 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/string/parameter_quotes.ts @@ -0,0 +1,36 @@ +import * as f from "f"; + +type X = { + "member": string; + // you stay like this + "member-member": number, + "4": number, + "with_underscore": number + "0197": number, + "3n": number, + "3p": number, + "p9": number + "_$_ff$_morning_not_quotes": number, + "_$_ff$_morning_yes_quotes_@": number +}; + + +interface Y { + "member": string; + // you stay like this + "member-member": number, + "4": number, + "with_underscore": number + "0197": number, + "3n": number, + "3p": number, + "p9": number + "_$_ff$_morning_not_quotes": number, + "_$_ff$_morning_yes_quotes_@": number +} + +const Y = { + "123": false, + "3n": false, + 12334: false +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/string/parameter_quotes.ts.snap b/crates/rome_fmt/test_data/specs/ts/string/parameter_quotes.ts.snap new file mode 100644 index 0000000..1674660 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/string/parameter_quotes.ts.snap @@ -0,0 +1,35 @@ +import * as f from "f"; + +type X = { + member: string; + // you stay like this + "member-member": number; + "4": number; + with_underscore: number; + "0197": number; + "3n": number; + "3p": number; + p9: number; + _$_ff$_morning_not_quotes: number; + "_$_ff$_morning_yes_quotes_@": number; +}; + +interface Y { + member: string; + // you stay like this + "member-member": number; + "4": number; + with_underscore: number; + "0197": number; + "3n": number; + "3p": number; + p9: number; + _$_ff$_morning_not_quotes: number; + "_$_ff$_morning_yes_quotes_@": number; +} + +const Y = { + "123": false, + "3n": false, + 12334: false, +}; diff --git a/crates/rome_fmt/test_data/specs/ts/suppressions.ts b/crates/rome_fmt/test_data/specs/ts/suppressions.ts new file mode 100644 index 0000000..e891319 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/suppressions.ts @@ -0,0 +1,7 @@ + +interface Suppressions { + // rome-ignore format: test + a: void + + b: void +} \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/suppressions.ts.snap b/crates/rome_fmt/test_data/specs/ts/suppressions.ts.snap new file mode 100644 index 0000000..728b024 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/suppressions.ts.snap @@ -0,0 +1,6 @@ +interface Suppressions { + // rome-ignore format: test + a: void + + b: void; +} diff --git a/crates/rome_fmt/test_data/specs/ts/type/conditional.ts b/crates/rome_fmt/test_data/specs/ts/type/conditional.ts new file mode 100644 index 0000000..3bb9bc5 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/conditional.ts @@ -0,0 +1,17 @@ +type test = string; + +type T1 = test extends string ? test extends number ? unknown : unknown : undefined; + +type T2 = test extends string ? unknown : test extends number ? undefined : undefined; + +type T3 = test extends string ? +// something + unknown : test extends number ? undefined : + // else + undefined; + +type T4 = test extends string + // something + ? unknown : test extends number ? undefined : + // else + undefined; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/type/conditional.ts.snap b/crates/rome_fmt/test_data/specs/ts/type/conditional.ts.snap new file mode 100644 index 0000000..288e44f --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/conditional.ts.snap @@ -0,0 +1,29 @@ +type test = string; + +type T1 = test extends string + ? test extends number + ? unknown + : unknown + : undefined; + +type T2 = test extends string + ? unknown + : test extends number + ? undefined + : undefined; + +type T3 = test extends string + ? // something + unknown + : test extends number + ? undefined + : // else + undefined; + +type T4 = test extends string + ? // something + unknown + : test extends number + ? undefined + : // else + undefined; diff --git a/crates/rome_fmt/test_data/specs/ts/type/import_type.ts b/crates/rome_fmt/test_data/specs/ts/type/import_type.ts new file mode 100644 index 0000000..33f1f28 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/import_type.ts @@ -0,0 +1,6 @@ +type ImportType1 = typeof import('source'); + +type ImportType2 = import('source'); + +type QualifiedImportType = typeof import('source').Qualified; + diff --git a/crates/rome_fmt/test_data/specs/ts/type/import_type.ts.snap b/crates/rome_fmt/test_data/specs/ts/type/import_type.ts.snap new file mode 100644 index 0000000..94be39b --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/import_type.ts.snap @@ -0,0 +1,5 @@ +type ImportType1 = typeof import("source"); + +type ImportType2 = import("source"); + +type QualifiedImportType = typeof import("source").Qualified; diff --git a/crates/rome_fmt/test_data/specs/ts/type/intersection_type.ts b/crates/rome_fmt/test_data/specs/ts/type/intersection_type.ts new file mode 100644 index 0000000..0b65269 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/intersection_type.ts @@ -0,0 +1,58 @@ +type ShortIntersection = + & A + & B + + +type LongIntersection = A & B & C & D & E & F & G & H & I & J & K & L & M & N & O & P & Q & R & S & T & U & V & W & X & Y & Z + +// cases from prettier +type Example = + & { + [A in B]: T; + } + & { + [A in B]: T; +}; + +const originalPrototype = originalConstructor.prototype as TComponent & InjectionTarget; + +export type AsyncExecuteOptions = + & child_process$execFileOpts + & { + // The contents to write to stdin. + stdin?: string; + dontLogInNuclide?: boolean; +}; + +type State = { + sharedProperty: any; +} & ( + | { discriminant: "FOO"; foo: any } + | { discriminant: "BAR"; bar: any } + | { discriminant: "BAZ"; baz: any } + ); + +// spec cases +//retain comment case +type TypeWithComments = /*1*/&/*2*/ /*3*/{}/*4*/ & /*5*/number[]/*6*/ & /*7*/SomeType/*8*/; + +type IndentAfterDifferentType1 = {} & SomeLongType & {somelonglonglongkey: number;} & {somelonglonglongkey: string;} & {somelonglonglongkey: SomeLongLongType} & {somelonglonglongkey: SomeLongLongType} +type IndentAfterDifferentType2 = SomeLongType1 & {} & SomeLongType2 & {somelonglonglongkey: number;} & {somelonglonglongkey: string;} & {somelonglonglongkey: SomeLongLongType} & {somelonglonglongkey: SomeLongLongType}; + +type NotIndent1 = {} & {somelonglonglongkey: number;} & {somelonglonglongkey: string;} & {somelonglonglongkey: SomeLongLongType} & {somelonglonglongkey: SomeLongLongType} +type NotIndent2 = SomeLongType1 & {somelonglonglongkey: number;} & {somelonglonglongkey: string;} & {somelonglonglongkey: SomeLongLongType} & {somelonglonglongkey: SomeLongLongType}; + +type FormatSequenceTwoObjects = {somelonglonglonglonglonglonglongkey1: number;} & {somelonglonglonglonglonglonglongkey2: number}; +type FormatSequenceObjects = {somelonglonglongkey1: number; somelonglonglongkey2: string} & {somelonglonglongkey1: string; somelonglonglongkey2: number} & {somelonglonglongkey1: string; somelonglonglongkey2: number}; +type FormatSequenceNotObjects = NotObjectLongLongLongLongLongLongType1 & NotObjectLongLongLongLongLongLongType2 & NotObjectLongLongLongLongLongLongType3; + +type FormatObjectArray = {somelonglonglonglonglonglonglongkey1: number;} & Array; +type FormatArrayObject = Array & {somelonglonglonglonglonglonglongkey1: number;}; + + +type SoftBreakBetweenNotObjectTypeInChain = {} & SomeLongType & { + somelonglonglongkey: number; + } & { somelonglonglongkey: string } & NotObjectLongLongLongLongLongLongType1 & + NotObjectLongLongLongLongLongLongType2 & { + somelonglonglongkey: SomeLongLongType; + } & { somelonglonglongkey: SomeLongLongType }; diff --git a/crates/rome_fmt/test_data/specs/ts/type/intersection_type.ts.snap b/crates/rome_fmt/test_data/specs/ts/type/intersection_type.ts.snap new file mode 100644 index 0000000..f2346cb --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/intersection_type.ts.snap @@ -0,0 +1,111 @@ +type ShortIntersection = A & B; + +type LongIntersection = A & + B & + C & + D & + E & + F & + G & + H & + I & + J & + K & + L & + M & + N & + O & + P & + Q & + R & + S & + T & + U & + V & + W & + X & + Y & + Z; + +// cases from prettier +type Example = { + [A in B]: T; +} & { + [A in B]: T; +}; + +const originalPrototype = originalConstructor.prototype as TComponent & + InjectionTarget; + +export type AsyncExecuteOptions = child_process$execFileOpts & { + // The contents to write to stdin. + stdin?: string; + dontLogInNuclide?: boolean; +}; + +type State = { + sharedProperty: any; +} & ( + | { discriminant: "FOO"; foo: any } + | { discriminant: "BAR"; bar: any } + | { discriminant: "BAZ"; baz: any } +); + +// spec cases +//retain comment case +type TypeWithComments = /*1*/ /*2*/ /*3*/ {} /*4*/ & /*5*/ number[] /*6*/ & + /*7*/ SomeType /*8*/; + +type IndentAfterDifferentType1 = {} & SomeLongType & { + somelonglonglongkey: number; + } & { somelonglonglongkey: string } & { + somelonglonglongkey: SomeLongLongType; + } & { somelonglonglongkey: SomeLongLongType }; +type IndentAfterDifferentType2 = SomeLongType1 & {} & SomeLongType2 & { + somelonglonglongkey: number; + } & { somelonglonglongkey: string } & { + somelonglonglongkey: SomeLongLongType; + } & { somelonglonglongkey: SomeLongLongType }; + +type NotIndent1 = {} & { somelonglonglongkey: number } & { + somelonglonglongkey: string; +} & { somelonglonglongkey: SomeLongLongType } & { + somelonglonglongkey: SomeLongLongType; +}; +type NotIndent2 = SomeLongType1 & { somelonglonglongkey: number } & { + somelonglonglongkey: string; +} & { somelonglonglongkey: SomeLongLongType } & { + somelonglonglongkey: SomeLongLongType; +}; + +type FormatSequenceTwoObjects = { + somelonglonglonglonglonglonglongkey1: number; +} & { somelonglonglonglonglonglonglongkey2: number }; +type FormatSequenceObjects = { + somelonglonglongkey1: number; + somelonglonglongkey2: string; +} & { somelonglonglongkey1: string; somelonglonglongkey2: number } & { + somelonglonglongkey1: string; + somelonglonglongkey2: number; +}; +type FormatSequenceNotObjects = NotObjectLongLongLongLongLongLongType1 & + NotObjectLongLongLongLongLongLongType2 & + NotObjectLongLongLongLongLongLongType3; + +type FormatObjectArray = { + somelonglonglonglonglonglonglongkey1: number; +} & Array< + NotObjectLongLongLongLongLongLongType2 & + NotObjectLongLongLongLongLongLongType3 +>; +type FormatArrayObject = Array< + NotObjectLongLongLongLongLongLongType2 & + NotObjectLongLongLongLongLongLongType3 +> & { somelonglonglonglonglonglonglongkey1: number }; + +type SoftBreakBetweenNotObjectTypeInChain = {} & SomeLongType & { + somelonglonglongkey: number; + } & { somelonglonglongkey: string } & NotObjectLongLongLongLongLongLongType1 & + NotObjectLongLongLongLongLongLongType2 & { + somelonglonglongkey: SomeLongLongType; + } & { somelonglonglongkey: SomeLongLongType }; diff --git a/crates/rome_fmt/test_data/specs/ts/type/mapped_type.ts b/crates/rome_fmt/test_data/specs/ts/type/mapped_type.ts new file mode 100644 index 0000000..b9fedaa --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/mapped_type.ts @@ -0,0 +1 @@ +type LongNameHereToCauseLineBreak_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ={ [K in "foo"]: string }; \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/type/mapped_type.ts.snap b/crates/rome_fmt/test_data/specs/ts/type/mapped_type.ts.snap new file mode 100644 index 0000000..d0d2972 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/mapped_type.ts.snap @@ -0,0 +1,2 @@ +type LongNameHereToCauseLineBreak_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = + { [K in "foo"]: string }; diff --git a/crates/rome_fmt/test_data/specs/ts/type/qualified_name.ts b/crates/rome_fmt/test_data/specs/ts/type/qualified_name.ts new file mode 100644 index 0000000..b42bd32 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/qualified_name.ts @@ -0,0 +1 @@ +type QualifiedType = A . B . C \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/type/qualified_name.ts.snap b/crates/rome_fmt/test_data/specs/ts/type/qualified_name.ts.snap new file mode 100644 index 0000000..251860a --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/qualified_name.ts.snap @@ -0,0 +1 @@ +type QualifiedType = A.B.C; diff --git a/crates/rome_fmt/test_data/specs/ts/type/template_type.ts b/crates/rome_fmt/test_data/specs/ts/type/template_type.ts new file mode 100644 index 0000000..2592684 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/template_type.ts @@ -0,0 +1,4 @@ +type TemplateType = ` + text + ${'lorem'| 'ipsum' |'dolor'| 'sit' |'amet'| 'consectetur' |'adipiscing'| 'elit' |'sed'} +` \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/ts/type/template_type.ts.snap b/crates/rome_fmt/test_data/specs/ts/type/template_type.ts.snap new file mode 100644 index 0000000..62b47b4 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/template_type.ts.snap @@ -0,0 +1,13 @@ +type TemplateType = ` + text + ${ + | "lorem" + | "ipsum" + | "dolor" + | "sit" + | "amet" + | "consectetur" + | "adipiscing" + | "elit" + | "sed"} +`; diff --git a/crates/rome_fmt/test_data/specs/ts/type/trailing-comma/type_trailing_comma.ts b/crates/rome_fmt/test_data/specs/ts/type/trailing-comma/type_trailing_comma.ts new file mode 100644 index 0000000..803fa32 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/trailing-comma/type_trailing_comma.ts @@ -0,0 +1,12 @@ + +type A = [ + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +]; + +interface C< adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd,> { + +} diff --git a/crates/rome_fmt/test_data/specs/ts/type/trailing-comma/type_trailing_comma.ts.snap b/crates/rome_fmt/test_data/specs/ts/type/trailing-comma/type_trailing_comma.ts.snap new file mode 100644 index 0000000..741ac4c --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/trailing-comma/type_trailing_comma.ts.snap @@ -0,0 +1,11 @@ +type A = [ + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +]; + +interface C< + adsadasdasdasdasdasdasdasdasdasdas, + dsadsadasdasdasdasdasdasdasd, + dsadsadasdasdasdasdasdasdasd, +> {} diff --git a/crates/rome_fmt/test_data/specs/ts/type/union_type.ts b/crates/rome_fmt/test_data/specs/ts/type/union_type.ts new file mode 100644 index 0000000..9cf9936 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/union_type.ts @@ -0,0 +1,246 @@ +type ShortUnion = + | A + | B + +type LongUnion = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z + +type Comments = + // leading separator + | + // leading type + A | B /* +trailing type */ + +type A = [ + /*leading comment with new line*/ + A | B, + ]; + +type RemoveLeadingSeparatorIfNotBreak = /*a*/ | /*b*/ A | B; + +type BreakLongTypeAddedLeadingSeparator = BBBBBBBBBBBBBBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD; +type BreakLongTypeWithLeadingComment = /*leading comment*/ BBBBBBBBBBBBBBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD; + + someLongLongObject.longlongmember; + + someLongLongObject.longlongmember; +( someLongLongObject.longlongmember) += 1 + +type FunctionTypeWithReturnUnion1 = () => /*1*/|/*2*/ A | B | C; + +type FunctionTypeWithReturnUnion2 = () => BBBBBBBBBBBBBBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD; + +type InlineType = TypeName | null | void; +type InlineTypeWithLongName = TypeNameTypeNameTypeNameTypeNameTypeNameTypeNameTypeName | null | void; + +type TypeWithTypleInsideShort = [ + A | [A, B, C] | C, + A | [A, B, C] | C, + ]; + +type TypeWithTypleInsideLong = [ + AAAAAAAAAAAAAAAAA | [AAAAAAAAAAAAAAAAA, BBBBBBBBBBBB, CCCCCCCCCCCCC] | CCCCCCCCCCCCCCCCCCCC, + AAAAAAAAAAAAAAAAA | [AAAAAAAAAAAAAAAAA, BBBBBBBBBBBB, CCCCCCCCCCCCC] | CCCCCCCCCCCCCCCCCCCC, + ]; + +type TypeWithUnionInsideIntersactionAddParenthesesShort = B & (C | A) & D; + +type TypeWithUnionInsideIntersactionAddParenthesesLong = BBBBBBBBBBBB & (CCCCCCCCCCCCC | AAAAAAAAAAAAAAAAA) & DDDDDDDDDDDDDDDDDDDDDDDDDDDDD; + +const fooo: SomeThingWithShortMappedType<{ + [P in A | B | C | string]: number; + }> = {}; + +const fooo: SomeThingWithLongMappedType<{ + [P in AAAAAAAAAAAAAAAAA | BBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD]: number; + }> = {}; + + export type A = + | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + +export type B = + | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + +export type C = + | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + +export type D = + | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + +export type Multi = (string | number)[]; + +function f(): string | number {} + +var x: string | number; +var y: string | number; + +class Foo {} + +interface Interface { + i: (X | Y) & Z; + j: Partial; +} + +type State = { + sharedProperty: any; +} & ( + | { discriminant: "FOO"; foo: any } + | { discriminant: "BAR"; bar: any } + | { discriminant: "BAZ"; baz: any } +); + +const foo1 = [abc, def, ghi, jkl, mno, pqr, stu, vwx, yz] as ( + | string + | undefined +)[]; + +const foo2: ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD +)[] = []; + +const foo3: keyof ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD +) = bar; + +const foo4: + | foo + | ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ) = bar; + +let a1: C; +let a2: C; +let a3: C; +let a4: C; +let a5: C; +let a6: /*1*/ C; +let a7: /*1*/ C; +let a8: /*1*/ C; +let a9: /*1*/ C; +let a10: /*1*/ /*2*/ C; +let a11: /*1*/ /*2*/ C; + +let aa1: /*1*/ /*2*/ C | D; +let aa2: /*1*/ /*2*/ C | /*3*/ D; +let aa3: /*1*/ /*2*/ C | /*3*/ D /*4*/; + +type A1 = C; +type A2 = C; +type A3 = C; +type A4 = C; +type A5 = C; +type A6 = /*1*/ C; +type A7 = /*1*/ C; +type A8 = /*1*/ C; +type A9 = /*1*/ C; +type A10 = /*1*/ /*2*/ C; +type A11 = /*1*/ /*2*/ C; +type A12 = /*1*/ C; +type A13 = /*1*/ C; + +type Aa1 = /*1*/ /*2*/ C | D; +type Aa2 = /*1*/ /*2*/ C | /*3*/ D; +type Aa3 = /*1*/ /*2*/ C | /*3*/ D /*4*/; + +type C1 = /*1*/ a | b; +type C2 = /*1*/ a | b; +type C3 = /*1*/ a | b; +type C4 = /*1*/ a | b; +type C5 = /*1*/ a | b; +type C6 /*0*/ = /*1*/ a | b; + +type Ctor = (new () => X) | Y; + +type A = [AAAAAAAAAAAAAAAAAAAAAA | BBBBBBBBBBBBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDD] + +type B = [ + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD +] + +type B1 = [ + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ) +] + +type C = [ + | [AAAAAAAAAAAAAAAAAAAAAA | BBBBBBBBBBBBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDD] + | [AAAAAAAAAAAAAAAAAAAAAA | BBBBBBBBBBBBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDD] +] + +type D = [ + (AAAAAAAAAAAAAAAAAAAAAA | BBBBBBBBBBBBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDD), + (AAAAAAAAAAAAAAAAAAAAAA | BBBBBBBBBBBBBBBBBBBBBB | CCCCCCCCCCCCCCCCCCCCCC | DDDDDDDDDDDDDDDDDDDDDD) +] + +type D1 = [ + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ), + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ) +] + +type D2 = [ + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD, + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD +] + +type E = [ AA | BB, AA | BB ] + +type F = [ + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD, + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB +] + +type GetChatsSagaEffects = + | CallEffect + | PutEffect< + | GetUsersRequestedAction + | GetChatsSucceededAction + | GetChatsFailedAction + | GetChatsStartedAction + > + | SelectEffect + +//https://github.com/prettier/prettier/issues/13153 +type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla = +| Fooo1000 +| Baz2000 +| BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong; diff --git a/crates/rome_fmt/test_data/specs/ts/type/union_type.ts.snap b/crates/rome_fmt/test_data/specs/ts/type/union_type.ts.snap new file mode 100644 index 0000000..d3fe439 --- /dev/null +++ b/crates/rome_fmt/test_data/specs/ts/type/union_type.ts.snap @@ -0,0 +1,328 @@ +type ShortUnion = A | B; + +type LongUnion = + | A + | B + | C + | D + | E + | F + | G + | H + | I + | J + | K + | L + | M + | N + | O + | P + | Q + | R + | S + | T + | U + | V + | W + | X + | Y + | Z; + +type Comments = + // leading separator + | // leading type + A + | B; /* +trailing type */ + +type A = [ + /*leading comment with new line*/ + A | B, +]; + +type RemoveLeadingSeparatorIfNotBreak = /*a*/ /*b*/ A | B; + +type BreakLongTypeAddedLeadingSeparator = + | BBBBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD; +type BreakLongTypeWithLeadingComment = + /*leading comment*/ + | BBBBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD; + +someLongLongObject.longlongmember; + +< + | BBBBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD +>someLongLongObject.longlongmember; +(< + | BBBBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD +>someLongLongObject.longlongmember) += 1; + +type FunctionTypeWithReturnUnion1 = () => /*1*/ /*2*/ A | B | C; + +type FunctionTypeWithReturnUnion2 = () => + | BBBBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD; + +type InlineType = TypeName | null | void; +type InlineTypeWithLongName = + TypeNameTypeNameTypeNameTypeNameTypeNameTypeNameTypeName | null | void; + +type TypeWithTypleInsideShort = [A | [A, B, C] | C, A | [A, B, C] | C]; + +type TypeWithTypleInsideLong = [ + ( + | AAAAAAAAAAAAAAAAA + | [AAAAAAAAAAAAAAAAA, BBBBBBBBBBBB, CCCCCCCCCCCCC] + | CCCCCCCCCCCCCCCCCCCC + ), + ( + | AAAAAAAAAAAAAAAAA + | [AAAAAAAAAAAAAAAAA, BBBBBBBBBBBB, CCCCCCCCCCCCC] + | CCCCCCCCCCCCCCCCCCCC + ), +]; + +type TypeWithUnionInsideIntersactionAddParenthesesShort = B & (C | A) & D; + +type TypeWithUnionInsideIntersactionAddParenthesesLong = BBBBBBBBBBBB & + (CCCCCCCCCCCCC | AAAAAAAAAAAAAAAAA) & + DDDDDDDDDDDDDDDDDDDDDDDDDDDDD; + +const fooo: SomeThingWithShortMappedType<{ + [P in A | B | C | string]: number; +}> = {}; + +const fooo: SomeThingWithLongMappedType<{ + [P in + | AAAAAAAAAAAAAAAAA + | BBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDDDDDDDDD]: number; +}> = {}; + +export type A = + | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + +export type B = + | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + +export type C = + | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + +export type D = + | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + | bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb; + +export type Multi = (string | number)[]; + +function f(): string | number {} + +var x: string | number; +var y: string | number; + +class Foo {} + +interface Interface { + i: (X | Y) & Z; + j: Partial; +} + +type State = { + sharedProperty: any; +} & ( + | { discriminant: "FOO"; foo: any } + | { discriminant: "BAR"; bar: any } + | { discriminant: "BAZ"; baz: any } +); + +const foo1 = [abc, def, ghi, jkl, mno, pqr, stu, vwx, yz] as ( + | string + | undefined +)[]; + +const foo2: ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD +)[] = []; + +const foo3: keyof ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD +) = bar; + +const foo4: + | foo + | ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ) = bar; + +let a1: C; +let a2: C; +let a3: C; +let a4: C; +let a5: C; +let a6: /*1*/ C; +let a7: /*1*/ C; +let a8: /*1*/ C; +let a9: /*1*/ C; +let a10: /*1*/ /*2*/ C; +let a11: /*1*/ /*2*/ C; + +let aa1: /*1*/ /*2*/ C | D; +let aa2: /*1*/ /*2*/ C | /*3*/ D; +let aa3: /*1*/ /*2*/ C | /*3*/ D /*4*/; + +type A1 = C; +type A2 = C; +type A3 = C; +type A4 = C; +type A5 = C; +type A6 = /*1*/ C; +type A7 = /*1*/ C; +type A8 = /*1*/ C; +type A9 = /*1*/ C; +type A10 = /*1*/ /*2*/ C; +type A11 = /*1*/ /*2*/ C; +type A12 = /*1*/ C; +type A13 = /*1*/ C; + +type Aa1 = /*1*/ /*2*/ C | D; +type Aa2 = /*1*/ /*2*/ C | /*3*/ D; +type Aa3 = /*1*/ /*2*/ C | /*3*/ D /*4*/; + +type C1 = /*1*/ a | b; +type C2 = /*1*/ a | b; +type C3 = /*1*/ a | b; +type C4 = /*1*/ a | b; +type C5 = /*1*/ a | b; +type C6 /*0*/ = /*1*/ a | b; + +type Ctor = (new () => X) | Y; + +type A = [ + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD, +]; + +type B = [ + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD, +]; + +type B1 = [ + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD, +]; + +type C = [ + | [ + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD, + ] + | [ + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD, + ], +]; + +type D = [ + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ), + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ), +]; + +type D1 = [ + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ), + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ), +]; + +type D2 = [ + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ), + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ), +]; + +type E = [AA | BB, AA | BB]; + +type F = [ + ( + | AAAAAAAAAAAAAAAAAAAAAA + | BBBBBBBBBBBBBBBBBBBBBB + | CCCCCCCCCCCCCCCCCCCCCC + | DDDDDDDDDDDDDDDDDDDDDD + ), + AAAAAAAAAAAAAAAAAAAAAA | BBBBBBBBBBBBBBBBBBBBBB, +]; + +type GetChatsSagaEffects = + | CallEffect + | PutEffect< + | GetUsersRequestedAction + | GetChatsSucceededAction + | GetChatsFailedAction + | GetChatsStartedAction + > + | SelectEffect; + +//https://github.com/prettier/prettier/issues/13153 +type SuperLongTypeNameLoremIpsumLoremIpsumBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBlaBla = + | Fooo1000 + | Baz2000 + | BarLoooooooooooooooooooooooooooooooooooooooooooooooooLong; diff --git a/crates/rome_fmt/test_data/specs/tsx/smoke.tsx b/crates/rome_fmt/test_data/specs/tsx/smoke.tsx new file mode 100644 index 0000000..7e9668e --- /dev/null +++ b/crates/rome_fmt/test_data/specs/tsx/smoke.tsx @@ -0,0 +1 @@ +"foo" \ No newline at end of file diff --git a/crates/rome_fmt/test_data/specs/tsx/smoke.tsx.snap b/crates/rome_fmt/test_data/specs/tsx/smoke.tsx.snap new file mode 100644 index 0000000..310cbfe --- /dev/null +++ b/crates/rome_fmt/test_data/specs/tsx/smoke.tsx.snap @@ -0,0 +1 @@ +"foo"; diff --git a/crates/rome_fmt/test_deno/deno.test.ts b/crates/rome_fmt/test_deno/deno.test.ts new file mode 100644 index 0000000..6386073 --- /dev/null +++ b/crates/rome_fmt/test_deno/deno.test.ts @@ -0,0 +1,31 @@ +import init, { format } from "../pkg/rome_fmt.js"; + +import { assertEquals } from "https://deno.land/std@0.200.0/assert/mod.ts"; +import { walk } from "https://deno.land/std@0.200.0/fs/walk.ts"; +import { relative } from "https://deno.land/std@0.200.0/path/mod.ts"; + +await init(); + +const update = Deno.args.includes("--update"); + +const test_root = new URL("../test_data", import.meta.url); + +for await (const entry of walk(test_root, { + includeDirs: false, + exts: ["js", "jsx", "ts", "tsx"], +})) { + const input = Deno.readTextFileSync(entry.path); + const expected = Deno.readTextFileSync(entry.path + ".snap"); + + const actual = format(input, entry.name); + + if (update) { + Deno.writeTextFileSync(entry.path + ".snap", actual); + } else { + const test_name = relative(test_root.pathname, entry.path); + + Deno.test(test_name, () => { + assertEquals(actual, expected); + }); + } +} diff --git a/crates/rome_fmt/test_node/test-node.mjs b/crates/rome_fmt/test_node/test-node.mjs new file mode 100644 index 0000000..545ad95 --- /dev/null +++ b/crates/rome_fmt/test_node/test-node.mjs @@ -0,0 +1,49 @@ +import init, { format } from "../pkg/rome_fmt.js"; +import { test } from "node:test"; +import assert from "node:assert/strict"; +import fs from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +await init(); + +/** + * @param {string} dir + * @returns {Generator} + */ +async function* walk(dir) { + for await (const d of await fs.opendir(dir)) { + const entry = path.join(dir, d.name); + if (d.isDirectory()) yield* walk(entry); + else if (d.isFile()) yield entry; + } +} + +const test_root = fileURLToPath(new URL("../test_data", import.meta.url)); + +for await (const input_path of walk(test_root)) { + const ext = path.extname(input_path); + + switch (ext) { + case ".js": + case ".jsx": + case ".ts": + case ".tsx": + break; + + default: + continue; + } + + const test_name = path.relative(test_root, input_path); + const [input, expected] = await Promise.all([ + fs.readFile(input_path, { encoding: "utf-8" }), + fs.readFile(input_path + ".snap", { encoding: "utf-8" }), + ]); + + const actual = format(input, input_path); + + test(test_name, () => { + assert.equal(actual, expected); + }); +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..748be27 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.72.0" +profile = "default"