forked from rome/tools
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 rome#4252
class member
- Loading branch information
1 parent
e431795
commit f6c4dc0
Showing
52 changed files
with
11,430 additions
and
2,963 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
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; | ||
}; | ||
} | ||
``` | ||
|
||
|
3 changes: 1 addition & 2 deletions
3
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
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
Oops, something went wrong.