This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 656
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rome_js_parser): EcmaScript @decorators #4252
- Loading branch information
1 parent
01c600b
commit 27ad5dd
Showing
51 changed files
with
6,518 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
crates/rome_js_formatter/tests/specs/prettier/js/babel-plugins/decorators.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
source: crates/rome_formatter_test/src/snapshot_builder.rs | ||
info: js/babel-plugins/decorators.js | ||
--- | ||
|
||
# Input | ||
|
||
```js | ||
// https://babeljs.io/docs/en/babel-plugin-proposal-decorators | ||
|
||
@annotation | ||
class MyClass { } | ||
|
||
function annotation(target) { | ||
target.annotated = true; | ||
} | ||
|
||
@isTestable(true) | ||
class MyClass { } | ||
|
||
function isTestable(value) { | ||
return function decorator(target) { | ||
target.isTestable = value; | ||
} | ||
} | ||
|
||
class C { | ||
@enumerable(false) | ||
method() { } | ||
} | ||
|
||
function enumerable(value) { | ||
return function (target, key, descriptor) { | ||
descriptor.enumerable = value; | ||
return descriptor; | ||
} | ||
} | ||
|
||
``` | ||
|
||
|
||
# Prettier differences | ||
|
||
```diff | ||
--- Prettier | ||
+++ Rome | ||
@@ -17,8 +17,7 @@ | ||
} | ||
|
||
class C { | ||
- @enumerable(false) | ||
- method() {} | ||
+ @enumerable(false) method() {} | ||
} | ||
|
||
function enumerable(value) { | ||
``` | ||
|
||
# Output | ||
|
||
```js | ||
// https://babeljs.io/docs/en/babel-plugin-proposal-decorators | ||
|
||
@annotation | ||
class MyClass {} | ||
|
||
function annotation(target) { | ||
target.annotated = true; | ||
} | ||
|
||
@isTestable(true) | ||
class MyClass {} | ||
|
||
function isTestable(value) { | ||
return function decorator(target) { | ||
target.isTestable = value; | ||
}; | ||
} | ||
|
||
class C { | ||
@enumerable(false) method() {} | ||
} | ||
|
||
function enumerable(value) { | ||
return function (target, key, descriptor) { | ||
descriptor.enumerable = value; | ||
return descriptor; | ||
}; | ||
} | ||
``` | ||
|
||
|
41 changes: 41 additions & 0 deletions
41
crates/rome_js_formatter/tests/specs/prettier/js/decorator-auto-accessors/comments.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
source: crates/rome_formatter_test/src/snapshot_builder.rs | ||
info: js/decorator-auto-accessors/comments.js | ||
--- | ||
|
||
# Input | ||
|
||
```js | ||
class A { | ||
@dec() | ||
// comment | ||
accessor b; | ||
} | ||
|
||
``` | ||
|
||
|
||
# Prettier differences | ||
|
||
```diff | ||
--- Prettier | ||
+++ Rome | ||
@@ -1,5 +1,4 @@ | ||
class A { | ||
- @dec() | ||
- // comment | ||
+ @dec() // comment | ||
accessor b; | ||
} | ||
``` | ||
|
||
# Output | ||
|
||
```js | ||
class A { | ||
@dec() // comment | ||
accessor b; | ||
} | ||
``` | ||
|
||
|
1 change: 0 additions & 1 deletion
1
crates/rome_js_formatter/tests/specs/prettier/js/decorator-comments/comments.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.