Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of comments with decorators before
export
- Loading branch information
1 parent
30a16a2
commit 4acb0d3
Showing
19 changed files
with
609 additions
and
7 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
packages/babel-generator/test/fixtures/comments/decorators-after-export/input.js
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,2 @@ | ||
/* 1 */ export /* 2 */ @dec1 /* 3 */ @dec2 | ||
/* 4 */ class /* 5 */ C /* 6 */ { /* 7 */ } /* 8 */ |
4 changes: 4 additions & 0 deletions
4
packages/babel-generator/test/fixtures/comments/decorators-after-export/options.json
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,4 @@ | ||
{ | ||
"plugins": [["decorators", { "decoratorsBeforeExport": false }]], | ||
"decoratorsBeforeExport": false | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-generator/test/fixtures/comments/decorators-after-export/output.js
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,3 @@ | ||
/* 1 */export /* 2 */@dec1 | ||
/* 3 */@dec2 | ||
/* 4 */class /* 5 */C /* 6 */ {/* 7 */} /* 8 */ |
2 changes: 2 additions & 0 deletions
2
packages/babel-generator/test/fixtures/comments/decorators-before-export/input.js
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,2 @@ | ||
/* 1 */ @dec1 /* 2 */ @dec2 /* 3 */ | ||
export /* 4 */ class /* 5 */ C /* 6 */ { /* 7 */ } /* 8 */ |
4 changes: 4 additions & 0 deletions
4
packages/babel-generator/test/fixtures/comments/decorators-before-export/options.json
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,4 @@ | ||
{ | ||
"plugins": [["decorators", { "decoratorsBeforeExport": true }]], | ||
"decoratorsBeforeExport": true | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-generator/test/fixtures/comments/decorators-before-export/output.js
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,3 @@ | ||
/* 1 */@dec1 | ||
/* 2 */@dec2 | ||
/* 3 */export /* 4 */class /* 5 */C /* 6 */ {/* 7 */} /* 8 */ |
2 changes: 2 additions & 0 deletions
2
packages/babel-generator/test/fixtures/comments/decorators-legacy-before-export/input.js
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,2 @@ | ||
/* 1 */ @dec1 /* 2 */ @dec2 /* 3 */ | ||
export /* 4 */ class /* 5 */ C /* 6 */ { /* 7 */ } /* 8 */ |
4 changes: 4 additions & 0 deletions
4
packages/babel-generator/test/fixtures/comments/decorators-legacy-before-export/options.json
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,4 @@ | ||
{ | ||
"plugins": ["decorators-legacy"], | ||
"decoratorsBeforeExport": true | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-generator/test/fixtures/comments/decorators-legacy-before-export/output.js
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,3 @@ | ||
/* 1 */@dec1 | ||
/* 2 */@dec2 | ||
/* 3 */export /* 4 */class /* 5 */C /* 6 */ {/* 7 */} /* 8 */ |
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
2 changes: 2 additions & 0 deletions
2
packages/babel-parser/test/fixtures/comments/decorators/decorators-after-export/input.js
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,2 @@ | ||
/* 1 */ export /* 2 */ @dec1 /* 3 */ @dec2 | ||
/* 4 */ class /* 5 */ C /* 6 */ { /* 7 */ } /* 8 */ |
3 changes: 3 additions & 0 deletions
3
packages/babel-parser/test/fixtures/comments/decorators/decorators-after-export/options.json
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,3 @@ | ||
{ | ||
"plugins": [["decorators", { "decoratorsBeforeExport": false }]] | ||
} |
169 changes: 169 additions & 0 deletions
169
packages/babel-parser/test/fixtures/comments/decorators/decorators-after-export/output.json
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,169 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":94,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":51,"index":94}}, | ||
"errors": [ | ||
"SyntaxError: 'import' and 'export' may appear only with 'sourceType: \"module\"' (1:8)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":94,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":2,"column":51,"index":94}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExportNamedDeclaration", | ||
"start":8,"end":86,"loc":{"start":{"line":1,"column":8,"index":8},"end":{"line":2,"column":43,"index":86}}, | ||
"specifiers": [], | ||
"source": null, | ||
"declaration": { | ||
"type": "ClassDeclaration", | ||
"start":23,"end":86,"loc":{"start":{"line":1,"column":23,"index":23},"end":{"line":2,"column":43,"index":86}}, | ||
"decorators": [ | ||
{ | ||
"type": "Decorator", | ||
"start":23,"end":28,"loc":{"start":{"line":1,"column":23,"index":23},"end":{"line":1,"column":28,"index":28}}, | ||
"expression": { | ||
"type": "Identifier", | ||
"start":24,"end":28,"loc":{"start":{"line":1,"column":24,"index":24},"end":{"line":1,"column":28,"index":28},"identifierName":"dec1"}, | ||
"name": "dec1" | ||
}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 3 ", | ||
"start":29,"end":36,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":36,"index":36}} | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "Decorator", | ||
"start":37,"end":42,"loc":{"start":{"line":1,"column":37,"index":37},"end":{"line":1,"column":42,"index":42}}, | ||
"expression": { | ||
"type": "Identifier", | ||
"start":38,"end":42,"loc":{"start":{"line":1,"column":38,"index":38},"end":{"line":1,"column":42,"index":42},"identifierName":"dec2"}, | ||
"name": "dec2" | ||
}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 4 ", | ||
"start":43,"end":50,"loc":{"start":{"line":2,"column":0,"index":43},"end":{"line":2,"column":7,"index":50}} | ||
} | ||
], | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 3 ", | ||
"start":29,"end":36,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":36,"index":36}} | ||
} | ||
] | ||
} | ||
], | ||
"id": { | ||
"type": "Identifier", | ||
"start":65,"end":66,"loc":{"start":{"line":2,"column":22,"index":65},"end":{"line":2,"column":23,"index":66},"identifierName":"C"}, | ||
"name": "C", | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 6 ", | ||
"start":67,"end":74,"loc":{"start":{"line":2,"column":24,"index":67},"end":{"line":2,"column":31,"index":74}} | ||
} | ||
], | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 5 ", | ||
"start":57,"end":64,"loc":{"start":{"line":2,"column":14,"index":57},"end":{"line":2,"column":21,"index":64}} | ||
} | ||
] | ||
}, | ||
"superClass": null, | ||
"body": { | ||
"type": "ClassBody", | ||
"start":75,"end":86,"loc":{"start":{"line":2,"column":32,"index":75},"end":{"line":2,"column":43,"index":86}}, | ||
"body": [], | ||
"innerComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 7 ", | ||
"start":77,"end":84,"loc":{"start":{"line":2,"column":34,"index":77},"end":{"line":2,"column":41,"index":84}} | ||
} | ||
], | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 6 ", | ||
"start":67,"end":74,"loc":{"start":{"line":2,"column":24,"index":67},"end":{"line":2,"column":31,"index":74}} | ||
} | ||
] | ||
}, | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 2 ", | ||
"start":15,"end":22,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":22,"index":22}} | ||
} | ||
] | ||
}, | ||
"trailingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 8 ", | ||
"start":87,"end":94,"loc":{"start":{"line":2,"column":44,"index":87},"end":{"line":2,"column":51,"index":94}} | ||
} | ||
], | ||
"leadingComments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 1 ", | ||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":7,"index":7}} | ||
} | ||
] | ||
} | ||
], | ||
"directives": [] | ||
}, | ||
"comments": [ | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 1 ", | ||
"start":0,"end":7,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":7,"index":7}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 2 ", | ||
"start":15,"end":22,"loc":{"start":{"line":1,"column":15,"index":15},"end":{"line":1,"column":22,"index":22}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 3 ", | ||
"start":29,"end":36,"loc":{"start":{"line":1,"column":29,"index":29},"end":{"line":1,"column":36,"index":36}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 4 ", | ||
"start":43,"end":50,"loc":{"start":{"line":2,"column":0,"index":43},"end":{"line":2,"column":7,"index":50}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 5 ", | ||
"start":57,"end":64,"loc":{"start":{"line":2,"column":14,"index":57},"end":{"line":2,"column":21,"index":64}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 6 ", | ||
"start":67,"end":74,"loc":{"start":{"line":2,"column":24,"index":67},"end":{"line":2,"column":31,"index":74}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 7 ", | ||
"start":77,"end":84,"loc":{"start":{"line":2,"column":34,"index":77},"end":{"line":2,"column":41,"index":84}} | ||
}, | ||
{ | ||
"type": "CommentBlock", | ||
"value": " 8 ", | ||
"start":87,"end":94,"loc":{"start":{"line":2,"column":44,"index":87},"end":{"line":2,"column":51,"index":94}} | ||
} | ||
] | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/babel-parser/test/fixtures/comments/decorators/decorators-before-export/input.js
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,2 @@ | ||
/* 1 */ @dec1 /* 2 */ @dec2 /* 3 */ | ||
export /* 4 */ class /* 5 */ C /* 6 */ { /* 7 */ } /* 8 */ |
3 changes: 3 additions & 0 deletions
3
...ages/babel-parser/test/fixtures/comments/decorators/decorators-before-export/options.json
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,3 @@ | ||
{ | ||
"plugins": [["decorators", { "decoratorsBeforeExport": true }]] | ||
} |
Oops, something went wrong.