From 18df5e4fed7197a289d279e45e064b068162f64d Mon Sep 17 00:00:00 2001 From: Denis Bezrukov <6227442+denbezrukov@users.noreply.github.com> Date: Sun, 16 Apr 2023 18:47:33 +0300 Subject: [PATCH] feat(rome_js_parser): EcmaScript @decorators #4252 class member --- crates/rome_js_formatter/tests/quick_test.rs | 105 +- .../prettier/js/decorators/mixed.js.snap | 62 + .../decorators/decorators-comments.ts.snap | 83 +- crates/rome_js_parser/src/syntax/class.rs | 4 +- crates/rome_js_parser/src/syntax/expr.rs | 12 +- crates/rome_js_parser/src/tests.rs | 7 +- .../test_data/inline/err/decorator.rast | 1280 ++++++++++++----- .../err/decorator_class_declaration.rast | 12 +- ...decorator_class_declaration_top_level.rast | 10 +- .../inline/err/decorator_class_member.rast | 34 +- .../err/decorator_export_class_clause.rast | 10 +- .../err/decorator_expression_class.rast | 52 +- .../err/decorator_precede_class_member.rast | 56 +- .../inline/err/import_attribute_err.rast | 110 +- .../err/ts_declare_const_initializer.rast | 16 +- .../inline/err/ts_export_declare.rast | 16 +- .../ts_invalid_decorated_class_members.rast | 558 ++++--- ...lization_block_member_with_decorators.rast | 4 +- 18 files changed, 1595 insertions(+), 836 deletions(-) create mode 100644 crates/rome_js_formatter/tests/specs/prettier/js/decorators/mixed.js.snap diff --git a/crates/rome_js_formatter/tests/quick_test.rs b/crates/rome_js_formatter/tests/quick_test.rs index 4c083f72ae4..b79ff6704b9 100644 --- a/crates/rome_js_formatter/tests/quick_test.rs +++ b/crates/rome_js_formatter/tests/quick_test.rs @@ -13,109 +13,12 @@ mod language { // use this test check if your snippet prints as you wish, without using a snapshot fn quick_test() { let src = r#" -import { LitElement, html } from '@polymer/lit-element'; - -class MyElement extends LitElement { - static get properties() { - return { - mood: { type: String } - }; - } - - constructor() { - super(); - this.mood = 'happy'; - } - - render() { - return html` - - - Web Components are ${ - this.mood - - }! - `; +@foo +export default class MyComponent { + @task + *foo() { } } - -customElements.define('my-element', MyElement); - -const someHtml1 = html`
hello ${world}
`; -const someHtml2 = /* HTML */ `
hello ${world}
`; - -html`` - -html``; - -html` <${Footer} >footer content ` - -html`
` - -html` -
-` - -html`onetwothree`; - -function HelloWorld() { - return html` -

Bar List

- ${bars.map(bar => html` -

${bar}

- `)} - `; -} - -const trickyParens = html``; -const nestedFun = /* HTML */ `${outerExpr( 1 )} `; - -const closingScriptTagShouldBeEscapedProperly = /* HTML */ ` - -`; - -const closingScriptTag2 = /* HTML */ `