diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap index dd3cc9111cf..40c8ad4fa9f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap @@ -23,7 +23,7 @@ export default @decorator class {} -@decorator +export @decorator class Foo {} - + -export default -@decorator -class {} diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/arguments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/arguments.js.snap index d767f373428..8c2b7d88ef5 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/arguments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/arguments.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/class-expression/arguments.js --- @@ -42,41 +41,4 @@ console.log(@deco class Foo {}); console.log(@deco class {}); ``` -# Errors -``` -arguments.js:1:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected an expression but instead found '@deco class Foo {}' - - > 1 │ console.log(@deco class Foo {}) - │ ^^^^^^^^^^^^^^^^^^ - 2 │ console.log(@deco class {}) - 3 │ - - i Expected an expression here - - > 1 │ console.log(@deco class Foo {}) - │ ^^^^^^^^^^^^^^^^^^ - 2 │ console.log(@deco class {}) - 3 │ - -arguments.js:2:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected an expression but instead found '@deco class {}' - - 1 │ console.log(@deco class Foo {}) - > 2 │ console.log(@deco class {}) - │ ^^^^^^^^^^^^^^ - 3 │ - - i Expected an expression here - - 1 │ console.log(@deco class Foo {}) - > 2 │ console.log(@deco class {}) - │ ^^^^^^^^^^^^^^ - 3 │ - - -``` - diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/class-expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/class-expression.js.snap index 08c856f278e..0261d96a5e8 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/class-expression.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/class-expression.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/class-expression/class-expression.js --- @@ -30,7 +29,7 @@ const b2 = [] ```diff --- Prettier +++ Rome -@@ -1,35 +1,26 @@ +@@ -1,34 +1,18 @@ -const a1 = - ( - @deco @@ -41,292 +40,64 @@ const b2 = [] - @deco - class {} - ); -+const a1 = ( -+@deco class Foo {} -+) -+const a2 = ( -+@deco class {} -+) - - ( ++const a1 = @deco class Foo {}; ++const a2 = @deco class {}; + +-( - @deco - class Foo {} -); -+@deco class Foo {} -+) - ( +-( - @deco - class {} -); -+@deco class {} -+) - ++(@deco ++class Foo {}); ++(@deco ++class {}); + const b1 = []; - ( +-( - @deco - class Foo {} -); -+@deco class Foo {} -+) - ++(@deco ++class Foo {}); + const b2 = []; - ( +-( - @deco - class {} -); -+@deco class {} -+) - ++(@deco ++class {}); + // This is not a `ClassExpression` but `ClassDeclaration` --@deco --class Foo {} -+@deco class Foo {} + @deco ``` # Output ```js -const a1 = ( -@deco class Foo {} -) -const a2 = ( -@deco class {} -) +const a1 = @deco class Foo {}; +const a2 = @deco class {}; -( -@deco class Foo {} -) -( -@deco class {} -) +(@deco +class Foo {}); +(@deco +class {}); const b1 = []; -( -@deco class Foo {} -) +(@deco +class Foo {}); const b2 = []; -( -@deco class {} -) +(@deco +class {}); // This is not a `ClassExpression` but `ClassDeclaration` -@deco class Foo {} -``` - -# Errors -``` -class-expression.js:1:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - > 1 │ const a1 = (@deco class Foo {}); - │ ^ - 2 │ const a2 = (@deco class {}); - 3 │ - - i Remove @ - -class-expression.js:1:31 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ')' - - > 1 │ const a1 = (@deco class Foo {}); - │ ^ - 2 │ const a2 = (@deco class {}); - 3 │ - - i Expected a statement here - - > 1 │ const a1 = (@deco class Foo {}); - │ ^ - 2 │ const a2 = (@deco class {}); - 3 │ - -class-expression.js:2:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - 1 │ const a1 = (@deco class Foo {}); - > 2 │ const a2 = (@deco class {}); - │ ^ - 3 │ - 4 │ (@deco class Foo {}); - - i Remove @ - -class-expression.js:2:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × class declarations must have a name - - 1 │ const a1 = (@deco class Foo {}); - > 2 │ const a2 = (@deco class {}); - │ ^^^^^^ - 3 │ - 4 │ (@deco class Foo {}); - -class-expression.js:2:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ')' - - 1 │ const a1 = (@deco class Foo {}); - > 2 │ const a2 = (@deco class {}); - │ ^ - 3 │ - 4 │ (@deco class Foo {}); - - i Expected a statement here - - 1 │ const a1 = (@deco class Foo {}); - > 2 │ const a2 = (@deco class {}); - │ ^ - 3 │ - 4 │ (@deco class Foo {}); - -class-expression.js:4:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - 2 │ const a2 = (@deco class {}); - 3 │ - > 4 │ (@deco class Foo {}); - │ ^ - 5 │ (@deco class {}); - 6 │ - - i Remove @ - -class-expression.js:4:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ')' - - 2 │ const a2 = (@deco class {}); - 3 │ - > 4 │ (@deco class Foo {}); - │ ^ - 5 │ (@deco class {}); - 6 │ - - i Expected a statement here - - 2 │ const a2 = (@deco class {}); - 3 │ - > 4 │ (@deco class Foo {}); - │ ^ - 5 │ (@deco class {}); - 6 │ - -class-expression.js:5:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - 4 │ (@deco class Foo {}); - > 5 │ (@deco class {}); - │ ^ - 6 │ - 7 │ const b1 = [] - - i Remove @ - -class-expression.js:5:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × class declarations must have a name - - 4 │ (@deco class Foo {}); - > 5 │ (@deco class {}); - │ ^^^^^^ - 6 │ - 7 │ const b1 = [] - -class-expression.js:5:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ')' - - 4 │ (@deco class Foo {}); - > 5 │ (@deco class {}); - │ ^ - 6 │ - 7 │ const b1 = [] - - i Expected a statement here - - 4 │ (@deco class Foo {}); - > 5 │ (@deco class {}); - │ ^ - 6 │ - 7 │ const b1 = [] - -class-expression.js:8:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - 7 │ const b1 = [] - > 8 │ ;(@deco class Foo {}) - │ ^ - 9 │ - 10 │ const b2 = [] - - i Remove @ - -class-expression.js:8:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ')' - - 7 │ const b1 = [] - > 8 │ ;(@deco class Foo {}) - │ ^ - 9 │ - 10 │ const b2 = [] - - i Expected a statement here - - 7 │ const b1 = [] - > 8 │ ;(@deco class Foo {}) - │ ^ - 9 │ - 10 │ const b2 = [] - -class-expression.js:11:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - 10 │ const b2 = [] - > 11 │ ;(@deco class {}) - │ ^ - 12 │ - 13 │ // This is not a `ClassExpression` but `ClassDeclaration` - - i Remove @ - -class-expression.js:11:9 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × class declarations must have a name - - 10 │ const b2 = [] - > 11 │ ;(@deco class {}) - │ ^^^^^^ - 12 │ - 13 │ // This is not a `ClassExpression` but `ClassDeclaration` - -class-expression.js:11:17 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ')' - - 10 │ const b2 = [] - > 11 │ ;(@deco class {}) - │ ^ - 12 │ - 13 │ // This is not a `ClassExpression` but `ClassDeclaration` - - i Expected a statement here - - 10 │ const b2 = [] - > 11 │ ;(@deco class {}) - │ ^ - 12 │ - 13 │ // This is not a `ClassExpression` but `ClassDeclaration` - - +@deco +class Foo {} ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap index 3689c35d016..87883594442 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/class-expression/member-expression.js --- @@ -18,98 +17,28 @@ info: js/decorators/class-expression/member-expression.js ```diff --- Prettier +++ Rome -@@ -1,8 +1,6 @@ - ( +@@ -1,8 +1,4 @@ +-( - @deco - class Foo {} -).name; -+@deco class Foo {} -+).name - ( +-( - @deco - class {} -).name; -+@deco class {} -+).name ++(@deco ++class Foo {}).name; ++(@deco ++class {}).name; ``` # Output ```js -( -@deco class Foo {} -).name -( -@deco class {} -).name -``` - -# Errors -``` -member-expression.js:1:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - > 1 │ (@deco class Foo {}).name; - │ ^ - 2 │ (@deco class {}).name; - 3 │ - - i Remove @ - -member-expression.js:1:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ').name' - - > 1 │ (@deco class Foo {}).name; - │ ^^^^^^ - 2 │ (@deco class {}).name; - 3 │ - - i Expected a statement here - - > 1 │ (@deco class Foo {}).name; - │ ^^^^^^ - 2 │ (@deco class {}).name; - 3 │ - -member-expression.js:2:2 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - 1 │ (@deco class Foo {}).name; - > 2 │ (@deco class {}).name; - │ ^ - 3 │ - - i Remove @ - -member-expression.js:2:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × class declarations must have a name - - 1 │ (@deco class Foo {}).name; - > 2 │ (@deco class {}).name; - │ ^^^^^^ - 3 │ - -member-expression.js:2:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ').name' - - 1 │ (@deco class Foo {}).name; - > 2 │ (@deco class {}).name; - │ ^^^^^^ - 3 │ - - i Expected a statement here - - 1 │ (@deco class Foo {}).name; - > 2 │ (@deco class {}).name; - │ ^^^^^^ - 3 │ - - +(@deco +class Foo {}).name; +(@deco +class {}).name; ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/super-class.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/super-class.js.snap index 10697199ca7..836d1f81d0e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/super-class.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/super-class.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/class-expression/super-class.js --- @@ -19,143 +18,26 @@ class Foo extends (@deco class {}){} ```diff --- Prettier +++ Rome -@@ -1,9 +1,9 @@ +@@ -1,9 +1,3 @@ -class Foo extends ( - @deco - class Foo {} -) {} -+class Foo extends (@deco class Foo {} -+) -+{ -+} - ++class Foo extends @deco class Foo {} {} + -class Foo extends ( - @deco - class {} -) {} -+class Foo extends (@deco class {} -+) -+{ -+} ++class Foo extends @deco class {} {} ``` # Output ```js -class Foo extends (@deco class Foo {} -) -{ -} - -class Foo extends (@deco class {} -) -{ -} -``` - -# Errors -``` -super-class.js:1:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - > 1 │ class Foo extends (@deco class Foo {}){} - │ ^ - 2 │ - 3 │ class Foo extends (@deco class {}){} - - i Remove @ - -super-class.js:1:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a semicolon to end the class property, but found none - - > 1 │ class Foo extends (@deco class Foo {}){} - │ ^^^ - 2 │ - 3 │ class Foo extends (@deco class {}){} - -super-class.js:1:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found '{' - - > 1 │ class Foo extends (@deco class Foo {}){} - │ ^ - 2 │ - 3 │ class Foo extends (@deco class {}){} - - i Expected an identifier, a string literal, a number literal, a private field name, or a computed name here - - > 1 │ class Foo extends (@deco class Foo {}){} - │ ^ - 2 │ - 3 │ class Foo extends (@deco class {}){} - -super-class.js:1:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ')' - - > 1 │ class Foo extends (@deco class Foo {}){} - │ ^ - 2 │ - 3 │ class Foo extends (@deco class {}){} - - i Expected a statement here - - > 1 │ class Foo extends (@deco class Foo {}){} - │ ^ - 2 │ - 3 │ class Foo extends (@deco class {}){} - -super-class.js:3:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `)` but instead found `@` - - 1 │ class Foo extends (@deco class Foo {}){} - 2 │ - > 3 │ class Foo extends (@deco class {}){} - │ ^ - 4 │ - - i Remove @ - -super-class.js:3:32 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected an identifier, a string literal, a number literal, a private field name, or a computed name but instead found '{' - - 1 │ class Foo extends (@deco class Foo {}){} - 2 │ - > 3 │ class Foo extends (@deco class {}){} - │ ^ - 4 │ - - i Expected an identifier, a string literal, a number literal, a private field name, or a computed name here - - 1 │ class Foo extends (@deco class Foo {}){} - 2 │ - > 3 │ class Foo extends (@deco class {}){} - │ ^ - 4 │ - -super-class.js:3:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found ')' - - 1 │ class Foo extends (@deco class Foo {}){} - 2 │ - > 3 │ class Foo extends (@deco class {}){} - │ ^ - 4 │ - - i Expected a statement here - - 1 │ class Foo extends (@deco class Foo {}){} - 2 │ - > 3 │ class Foo extends (@deco class {}){} - │ ^ - 4 │ - +class Foo extends @deco class Foo {} {} +class Foo extends @deco class {} {} ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap index 140067513bd..c47087452db 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/classes.js --- @@ -31,126 +30,82 @@ const bar = ```diff --- Prettier +++ Rome -@@ -1,24 +1,16 @@ --@deco --class Foo {} -+@deco class Foo {} - --@deco --export class Bar {} -+@deco export class Bar {} - --@deco --export default class Baz {} -+@deco export default class Baz {} - - const foo = +@@ -7,18 +7,12 @@ + @deco + export default class Baz {} + +-const foo = - ( - @deco - class { - // - } - ); -+@deco class { ++const foo = @deco ++class { + // -+} - - const bar = ++}; + +-const bar = - ( - @deco - class { - // - } - ); -+@deco -+ class { -+ // -+ } ++const bar = @deco ++class { ++ // ++}; ``` # Output ```js -@deco class Foo {} +@deco +class Foo {} -@deco export class Bar {} +@deco +export class Bar {} -@deco export default class Baz {} +@deco +export default class Baz {} -const foo = -@deco class { +const foo = @deco +class { // -} +}; -const bar = -@deco - class { - // - } +const bar = @deco +class { + // +}; ``` # Errors ``` -classes.js:7:13 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected an expression, or an assignment but instead found '@' - - 5 │ @deco export default class Baz {} - 6 │ - > 7 │ const foo = @deco class { - │ ^ - 8 │ // - 9 │ }; - - i Expected an expression, or an assignment here - - 5 │ @deco export default class Baz {} - 6 │ - > 7 │ const foo = @deco class { - │ ^ - 8 │ // - 9 │ }; - -classes.js:7:19 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × class declarations must have a name - +classes.js:3:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 1 │ @deco class Foo {} + 2 │ + > 3 │ @deco export class Bar {} + │ ^^^^^ + 4 │ 5 │ @deco export default class Baz {} - 6 │ - > 7 │ const foo = @deco class { - │ ^^^^^^ - 8 │ // - 9 │ }; - -classes.js:12:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected an expression, or an assignment but instead found '@' - - 11 │ const bar = - > 12 │ @deco - │ ^ - 13 │ class { - 14 │ // - - i Expected an expression, or an assignment here - - 11 │ const bar = - > 12 │ @deco - │ ^ - 13 │ class { - 14 │ // - -classes.js:13:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × class declarations must have a name - - 11 │ const bar = - 12 │ @deco - > 13 │ class { - │ ^^^^^^ - 14 │ // - 15 │ }; - + +classes.js:5:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 3 │ @deco export class Bar {} + 4 │ + > 5 │ @deco export default class Baz {} + │ ^^^^^ + 6 │ + 7 │ const foo = @deco class { + ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap index a3e8797fa82..a158cd182cd 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/comments.js --- @@ -49,7 +48,7 @@ export class Bar{} +++ Rome @@ -1,9 +1,9 @@ var x = 100; - + @Hello({ - a: "a", // Comment is in the wrong place + a: 'a', // Comment is in the wrong place @@ -58,7 +57,7 @@ export class Bar{} + b: '2' }) class X {} - + ``` # Output @@ -94,4 +93,36 @@ export class AppModule {} export class Bar {} ``` +# Errors +``` +comments.js:13:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 13 │ @NgModule({ + │ ^^^^^^^^^^^ + > 14 │ // Imports. + ... + > 22 │ ], + > 23 │ }) + │ ^^ + 24 │ export class AppModule {} + 25 │ + +comments.js:27:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 26 │ // A + > 27 │ @Foo() + │ ^^^^^^ + > 28 │ // B + > 29 │ @Bar() + │ ^^^^^^ + 30 │ // C + 31 │ export class Bar{} + + +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/member-expression.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/member-expression.js.snap index 4e40530cead..ac64593e657 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/member-expression.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/member-expression.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/member-expression.js --- @@ -75,7 +74,7 @@ info: js/decorators/member-expression.js }, class { - @decorators [0]; -+ @decorators[0] ++ @decorators[0]; method() {} }, class { @@ -101,20 +100,21 @@ info: js/decorators/member-expression.js method() {} }, class { +- @decorators[first] + @(decorators[first]) + method() {} + }, + class { - @decorators[first] ++ @decorators[first]; ++ method() {} ++ }, ++ class { ++ @(decorators["first"]) method() {} }, ++ @(decorators[first]) class { - @decorators [first]; -+ @(decorators["first"]) -+ method() {} -+ }, -+ @(decorators[first]) -+ class { method() {} }, + @(decorators[0]) @@ -134,8 +134,7 @@ info: js/decorators/member-expression.js - method() {} - } - ), --]; -+] + ]; ``` # Output @@ -147,7 +146,7 @@ info: js/decorators/member-expression.js method() {} }, class { - @decorators[0] + @decorators[0]; method() {} }, class { @@ -175,7 +174,7 @@ info: js/decorators/member-expression.js method() {} }, class { - @decorators[first] + @decorators[first]; method() {} }, class { @@ -190,104 +189,7 @@ info: js/decorators/member-expression.js class { method() {} }, -] -``` - -# Errors -``` -member-expression.js:42:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a property, an expression, or a method but instead found '@' - - 40 │ method() {} - 41 │ }, - > 42 │ @(decorators[first]) - │ ^ - 43 │ class { - 44 │ method() {} - - i Expected a property, an expression, or a method here - - 40 │ method() {} - 41 │ }, - > 42 │ @(decorators[first]) - │ ^ - 43 │ class { - 44 │ method() {} - -member-expression.js:42:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `,` but instead found `(` - - 40 │ method() {} - 41 │ }, - > 42 │ @(decorators[first]) - │ ^ - 43 │ class { - 44 │ method() {} - - i Remove ( - -member-expression.js:43:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `,` but instead found `class` - - 41 │ }, - 42 │ @(decorators[first]) - > 43 │ class { - │ ^^^^^ - 44 │ method() {} - 45 │ }, - - i Remove class - -member-expression.js:46:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a property, an expression, or a method but instead found '@' - - 44 │ method() {} - 45 │ }, - > 46 │ @(decorators[0]) - │ ^ - 47 │ class { - 48 │ method() {} - - i Expected a property, an expression, or a method here - - 44 │ method() {} - 45 │ }, - > 46 │ @(decorators[0]) - │ ^ - 47 │ class { - 48 │ method() {} - -member-expression.js:46:4 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `,` but instead found `(` - - 44 │ method() {} - 45 │ }, - > 46 │ @(decorators[0]) - │ ^ - 47 │ class { - 48 │ method() {} - - i Remove ( - -member-expression.js:47:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected `,` but instead found `class` - - 45 │ }, - 46 │ @(decorators[0]) - > 47 │ class { - │ ^^^^^ - 48 │ method() {} - 49 │ }, - - i Remove class - - +]; ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap index 4ef3952c1e0..2f1c5db09bf 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/mobx.js --- @@ -34,13 +33,13 @@ import {observable} from "mobx"; setPrice(price) { this.price = price; } - + @computed @computed @computed @computed @computed @computed @computed get total() { return this.price * this.amount; } @action handleDecrease = (event: React.ChangeEvent) => this.count--; - + @action handleSomething = (event: React.ChangeEvent) => doSomething(); } @@ -52,23 +51,21 @@ import {observable} from "mobx"; ```diff --- Prettier +++ Rome -@@ -1,9 +1,8 @@ - import { observable } from "mobx"; - --@observer --class OrderLine { +@@ -2,8 +2,8 @@ + + @observer + class OrderLine { - @observable price: number = 0; - @observable amount: number = 1; -+@observer class OrderLine { + @observable price:number = 0; + @observable amount:number = 1; - + constructor(price) { this.price = price; -@@ -27,20 +26,11 @@ +@@ -27,20 +27,11 @@ this.price = price; } - + - @computed - @computed - @computed @@ -80,11 +77,11 @@ import {observable} from "mobx"; + @computed @computed @computed @computed @computed @computed @computed get total() { return this.price * this.amount; } - + - @action handleDecrease = (event: React.ChangeEvent) => - this.count--; + @action handleDecrease = (event: React.ChangeEvent) => this.count--; - + - @action handleSomething = (event: React.ChangeEvent) => - doSomething(); + @action handleSomething = (event: React.ChangeEvent) => doSomething(); @@ -96,7 +93,8 @@ import {observable} from "mobx"; ```js import { observable } from "mobx"; -@observer class OrderLine { +@observer +class OrderLine { @observable price:number = 0; @observable amount:number = 1; @@ -137,62 +135,62 @@ import { observable } from "mobx"; mobx.js:4:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × return types can only be used in TypeScript files - + 3 │ @observer class OrderLine { > 4 │ @observable price:number = 0; │ ^^^^^^^ 5 │ @observable amount:number = 1; - 6 │ - + 6 │ + i remove this type annotation - + mobx.js:5:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × return types can only be used in TypeScript files - + 3 │ @observer class OrderLine { 4 │ @observable price:number = 0; > 5 │ @observable amount:number = 1; │ ^^^^^^^ - 6 │ + 6 │ 7 │ constructor(price) { - + i remove this type annotation - + mobx.js:33:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax. - + 31 │ } - 32 │ + 32 │ > 33 │ @action handleDecrease = (event: React.ChangeEvent) => this.count--; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - 34 │ + 34 │ 35 │ @action handleSomething = (event: React.ChangeEvent) => doSomething(); - + i TypeScript only syntax - + mobx.js:35:35 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax. - + 33 │ @action handleDecrease = (event: React.ChangeEvent) => this.count--; - 34 │ + 34 │ > 35 │ @action handleSomething = (event: React.ChangeEvent) => doSomething(); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 36 │ } - 37 │ - + 37 │ + i TypeScript only syntax - + ``` # Lines exceeding max width of 80 characters ``` - 29: @computed @computed @computed @computed @computed @computed @computed get total() { - 33: @action handleDecrease = (event: React.ChangeEvent) => this.count--; - 35: @action handleSomething = (event: React.ChangeEvent) => doSomething(); + 30: @computed @computed @computed @computed @computed @computed @computed get total() { + 34: @action handleDecrease = (event: React.ChangeEvent) => this.count--; + 36: @action handleSomething = (event: React.ChangeEvent) => doSomething(); ``` diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap index a0325288c7f..837c0e88216 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/multiple.js --- @@ -31,30 +30,32 @@ const foo = { ```diff --- Prettier +++ Rome -@@ -1,18 +1,15 @@ +@@ -1,18 +1,17 @@ const dog = { - @readonly +@readonly @nonenumerable @doubledValue - legs: 4, - -- @readonly -+@readonly +- legs: 4, ++legs: 4, + + @readonly @nonenumerable @doubledValue - eyes: 2, -}; -+eyes: 2; ++ eyes ++: 2 +} - + const foo = { - @multipleDecorators - @inline - @theyWontAllFitInOneline - aVeryLongPropName: "A very long string as value", -}; -+@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value"; ++@multipleDecorators @inline @theyWontAllFitInOneline ++aVeryLongPropName: "A very long string as value"; +} ``` @@ -65,16 +66,18 @@ const dog = { @readonly @nonenumerable @doubledValue - legs: 4, +legs: 4, -@readonly + @readonly @nonenumerable @doubledValue -eyes: 2; + eyes +: 2 } const foo = { -@multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value"; +@multipleDecorators @inline @theyWontAllFitInOneline +aVeryLongPropName: "A very long string as value"; } ``` @@ -83,103 +86,107 @@ const foo = { multiple.js:2:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a property, a shorthand property, a getter, a setter, or a method but instead found '@' - + 1 │ const dog = { > 2 │ @readonly │ ^ 3 │ @nonenumerable 4 │ @doubledValue - + i Expected a property, a shorthand property, a getter, a setter, or a method here - + 1 │ const dog = { > 2 │ @readonly │ ^ 3 │ @nonenumerable 4 │ @doubledValue - + multiple.js:7:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - × expected an expression but instead found '@' - - 5 │ legs: 4, - 6 │ - > 7 │ @readonly - │ ^ - 8 │ @nonenumerable - 9 │ @doubledValue - - i Expected an expression here - - 5 │ legs: 4, - 6 │ - > 7 │ @readonly - │ ^ - 8 │ @nonenumerable - 9 │ @doubledValue - -multiple.js:11:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × expected a statement but instead found '}' - - 9 │ @doubledValue + × Decorators are not valid here. + + 5 │ legs: 4, + 6 │ + > 7 │ @readonly + │ ^^^^^^^^^ + > 8 │ @nonenumerable + > 9 │ @doubledValue + │ ^^^^^^^^^^^^^ 10 │ eyes: 2 - > 11 │ }; - │ ^ - 12 │ - 13 │ const foo = { - - i Expected a statement here + 11 │ }; + +multiple.js:10:7 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + × Expected a semicolon or an implicit semicolon after a statement, but found none + + 8 │ @nonenumerable 9 │ @doubledValue - 10 │ eyes: 2 - > 11 │ }; - │ ^ - 12 │ - 13 │ const foo = { - + > 10 │ eyes: 2 + │ ^ + 11 │ }; + 12 │ + + i An explicit or implicit semicolon is expected here... + + 8 │ @nonenumerable + 9 │ @doubledValue + > 10 │ eyes: 2 + │ ^ + 11 │ }; + 12 │ + + i ...Which is required to end this statement + + 3 │ @nonenumerable + 4 │ @doubledValue + > 5 │ legs: 4, + │ ^^ + > 6 │ + > 7 │ @readonly + > 8 │ @nonenumerable + > 9 │ @doubledValue + > 10 │ eyes: 2 + │ ^^^^^ + 11 │ }; + 12 │ + multiple.js:14:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a property, a shorthand property, a getter, a setter, or a method but instead found '@' - + 13 │ const foo = { > 14 │ @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value" │ ^ 15 │ }; - 16 │ - + 16 │ + i Expected a property, a shorthand property, a getter, a setter, or a method here - + 13 │ const foo = { > 14 │ @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value" │ ^ 15 │ }; - 16 │ - + 16 │ + multiple.js:15:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × expected a statement but instead found '}' - + 13 │ const foo = { 14 │ @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value" > 15 │ }; │ ^ - 16 │ - + 16 │ + i Expected a statement here - + 13 │ const foo = { 14 │ @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value" > 15 │ }; │ ^ - 16 │ - + 16 │ + ``` -# Lines exceeding max width of 80 characters -``` - 14: @multipleDecorators @inline @theyWontAllFitInOneline aVeryLongPropName: "A very long string as value"; -``` - diff --git a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap index 4c37ce1a1a8..4d8385acdb6 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: js/decorators/redux.js --- @@ -24,7 +23,7 @@ export class Home extends React.Component {} @@ -1,5 +1,5 @@ @connect(mapStateToProps, mapDispatchToProps) export class MyApp extends React.Component {} - + -@connect((state) => ({ todos: state.todos })) +@connect(state => ({ todos: state.todos })) export class Home extends React.Component {} @@ -40,4 +39,29 @@ export class MyApp extends React.Component {} export class Home extends React.Component {} ``` +# Errors +``` +redux.js:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 1 │ @connect(mapStateToProps, mapDispatchToProps) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 2 │ export class MyApp extends React.Component {} + 3 │ + +redux.js:4:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 2 │ export class MyApp extends React.Component {} + 3 │ + > 4 │ @connect(state => ({ todos: state.todos })) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + 5 │ export class Home extends React.Component {} + 6 │ + + +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap index e001c22ef6a..3d149f93881 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/angular-component-examples/test.component.ts.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: typescript/angular-component-examples/test.component.ts --- @@ -13,10 +12,10 @@ info: typescript/angular-component-examples/test.component.ts `, styles: [ ` - + :host { color: red; - } + } div { background: blue } ` @@ -54,10 +53,10 @@ class TestComponent {} + + `, + styles: [ ` -+ ++ + :host { + color: red; -+ } ++ } + div { background: blue + } +` @@ -76,10 +75,10 @@ class TestComponent {} `, styles: [ ` - + :host { color: red; - } + } div { background: blue } ` diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/angular.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/angular.ts.snap index cdfbb4d457a..dee6317f871 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/angular.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/angular.ts.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: typescript/decorators-ts/angular.ts --- @@ -48,4 +47,22 @@ export class HeroButtonComponent { } ``` +# Errors +``` +angular.ts:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 1 │ @Component({ + │ ^^^^^^^^^^^^ + > 2 │ selector: 'toh-hero-button', + > 3 │ template: `` + > 4 │ }) + │ ^^ + 5 │ export class HeroButtonComponent { + 6 │ @Output() change = new EventEmitter(); + + +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap index d4bc229bd67..31128d4952f 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators-ts/typeorm.ts.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: typescript/decorators-ts/typeorm.ts --- @@ -41,7 +40,7 @@ export class Board { @@ -15,6 +15,6 @@ @Column() description: string; - + - @OneToMany((type) => Topic, (topic) => topic.board) + @OneToMany(type => Topic, topic => topic.board) topics: Topic[]; @@ -73,4 +72,18 @@ export class Board { } ``` +# Errors +``` +typeorm.ts:1:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + > 1 │ @Entity() + │ ^^^^^^^^^ + 2 │ export class Board { + 3 │ + + +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap index e99e15b9e8b..aa755f59186 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: typescript/decorators/decorators.ts --- @@ -100,10 +99,10 @@ class Class6 { + @ILifecycleService lifecycleService, + ) {} } - + @commonEditorContribution export class TabCompletionController {} - + @Component({ - selector: "angular-component", + selector: 'angular-component', @@ -112,14 +111,14 @@ class Class6 { @Input() myInput: string; @@ -50,12 +52,24 @@ } - + class Class5 { - method(@Decorator { prop1 }: Type) {} + method( + @Decorator { prop1 }: Type, + ) {} } - + class Class6 { - method(@Decorator({}) { prop1 }: Type) {} - method(@Decorator({}) { prop1 }: Type) {} @@ -222,4 +221,20 @@ class Class6 { } ``` +# Errors +``` +decorators.ts:8:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + × Decorators are not valid here. + + 6 │ } + 7 │ + > 8 │ @commonEditorContribution + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ + 9 │ export class TabCompletionController { + 10 │ } + + +``` + diff --git a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap index 25e55d64a7e..c889770701e 100644 --- a/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap +++ b/crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap @@ -1,6 +1,5 @@ --- source: crates/rome_formatter_test/src/snapshot_builder.rs -assertion_line: 212 info: typescript/decorators/inline-decorators.ts --- @@ -66,7 +65,7 @@ class MyContainerComponent { --- Prettier +++ Rome @@ -6,9 +6,9 @@ - + class Class2 { @d1 - @d2(foo) @@ -76,9 +75,9 @@ class MyContainerComponent { + @d3.bar + @d4.baz() method1() {} - + @d1 -@@ -30,22 +30,19 @@ +@@ -30,11 +30,10 @@ constructor( @d1 private x: number, @d2(foo) private y: number, @@ -92,15 +91,10 @@ class MyContainerComponent { + }) private a: string, ) {} } - --@decorated --class Foo {} -+@decorated class Foo {} - - class Bar { - @decorated method() {} + +@@ -46,6 +45,5 @@ } - + class MyContainerComponent { - @ContentChildren(MyComponent) - components: QueryListSomeBigName; @@ -150,7 +144,8 @@ class Class3 { ) {} } -@decorated class Foo {} +@decorated +class Foo {} class Bar { @decorated method() {} @@ -163,7 +158,7 @@ class MyContainerComponent { # Lines exceeding max width of 80 characters ``` - 47: @ContentChildren(MyComponent) components: QueryListSomeBigName; + 48: @ContentChildren(MyComponent) components: QueryListSomeBigName; ```