Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update @babel/parser to 7.12 (#9408)
* Install babel/parser 7.12 * Add tests for babel/babel#12161 * Add test for babel/babel#12076 * Add test for babel/babel#12085 * Add test for babel/babel#12108 * Add test for babel/babel#12120 * Add test for babel/babel#12054 * Add test for babel/babel#12061 * Add test babel/babel#12093 * Add test for babel/babel#12065 * Add test for babel/babel#12111 * Add test for babel/babel#12072 * Switch syntax-module-attributes to syntax-import-assertion * Support "String import/export specifier" * Remove tests for module-attributes * Add changelog * Update to 7.12.3 * Fix by linter * Fix by spellchecker * Add tests for module attributes to errors * Add error test for module string name with import * Remove TSTypeCastExpression * Add tests for funny import-assertions * Update snapshots| * Add more tests
- Loading branch information
1 parent
bdcec2f
commit 3b7a7ba
Showing
53 changed files
with
432 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#### Update to `@babel/parser` 7.12 (#9408 by @sosukesuzuki) | ||
|
||
Updated the JavaScript parser to [`@babel/parser` 7.12](https://babeljs.io/blog/2020/10/15/7.12.0). This fixes several bugs and supports some new syntax. | ||
|
||
##### Support Import Assertions | ||
|
||
[The "module attributes" proposal supported on 2.1](https://prettier.io/blog/2020/08/24/2.1.0.html#support-es-module-attributes-and-json-modules-8436httpsgithubcomprettierprettierpull8436-by-fiskerhttpsgithubcomfisker) has been significantly changed and also renamed to "import assertions". | ||
|
||
```js | ||
import json from "./foo.json" assert { type: "json" }; | ||
``` | ||
|
||
##### Support imports and exports with string names | ||
|
||
<!-- TODO: Remove if the bug is fixed --> | ||
|
||
Due to a [bug in `@babel/parser`](https://github.com/babel/babel/issues/12209), Prettier can only use exports, but that will be fixed. | ||
|
||
```js | ||
let happy = "happy"; | ||
export { happy as "😃" }; | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("./foo.json", { assert: { type: "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 @@ | ||
import json from "./foo.json" assert { type: "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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
export { smile as "😄" } from "./emojis.js"; |
59 changes: 59 additions & 0 deletions
59
tests/js/import-assertions/__snapshots__/jsfmt.spec.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,59 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`import-assertions-dynamic.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
import("./foo.json", { assert: { type: "json" } }); | ||
=====================================output===================================== | ||
import("./foo.json", { assert: { type: "json" } }); | ||
================================================================================ | ||
`; | ||
|
||
exports[`import-assertions-multi-types.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
import json from "./foo.json" assert { type: "json", type: "bar" }; | ||
=====================================output===================================== | ||
import json from "./foo.json" assert { type: "json", type: "bar" }; | ||
================================================================================ | ||
`; | ||
|
||
exports[`import-assertions-static.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
import json from "./foo.json" assert { type: "json" }; | ||
=====================================output===================================== | ||
import json from "./foo.json" assert { type: "json" }; | ||
================================================================================ | ||
`; | ||
|
||
exports[`not-import-assertions.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
import "x" | ||
assert ({type: 'json'}); | ||
=====================================output===================================== | ||
import "x"; | ||
assert({ type: "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 @@ | ||
import("./foo.json", { assert: { type: "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 @@ | ||
import json from "./foo.json" assert { type: "json", type: "bar" }; |
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 @@ | ||
import json from "./foo.json" assert { type: "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,9 @@ | ||
run_spec(__dirname, ["babel"], { | ||
errors: { | ||
espree: [ | ||
"import-assertions-dynamic.js", | ||
"import-assertions-multi-types.js", | ||
"import-assertions-static.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 @@ | ||
import "x" | ||
assert ({type: '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
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 @@ | ||
12.3e |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
// flow-parser@0.38.0 fails to parse `1.e1`, so use babel here. | ||
run_spec(__dirname, ["babel", "typescript"], { errors: { espree: true } }); | ||
run_spec(__dirname, ["babel", "typescript"], { | ||
errors: { espree: true, typescript: ["invalid-exponent.js"] }, | ||
}); |
29 changes: 0 additions & 29 deletions
29
tests/js/module-attributes/__snapshots__/jsfmt.spec.js.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
tests/js/module-string-names/__snapshots__/jsfmt.spec.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,32 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`module-string-names.js format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["babel"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
export { smile as "smile" } from "./emojis.js"; | ||
export { "smile" as smile } from "./emojis.js"; | ||
export { "smile" as "smile" } from "./emojis.js"; | ||
export { foo, bar as "foo" } from "./emojis.js"; | ||
export { foo, bar as "foo" }; | ||
export { "學而時習之,不亦說乎?", "吾道一以貫之。" as "忠恕。" } from "Confucius"; | ||
export * as "foo", { default as "quux" } from "module-b"; | ||
export { "smile" } from "./emojis.js"; | ||
=====================================output===================================== | ||
export { smile as "smile" } from "./emojis.js"; | ||
export { "smile" as smile } from "./emojis.js"; | ||
export { "smile" as "smile" } from "./emojis.js"; | ||
export { foo, bar as "foo" } from "./emojis.js"; | ||
export { foo, bar as "foo" }; | ||
export { | ||
"學而時習之,不亦說乎?", | ||
"吾道一以貫之。" as "忠恕。", | ||
} from "Confucius"; | ||
export * as "foo", { default as "quux" } from "module-b"; | ||
export { "smile" } from "./emojis.js"; | ||
================================================================================ | ||
`; |
File renamed without changes.
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,8 @@ | ||
export { smile as "smile" } from "./emojis.js"; | ||
export { "smile" as smile } from "./emojis.js"; | ||
export { "smile" as "smile" } from "./emojis.js"; | ||
export { foo, bar as "foo" } from "./emojis.js"; | ||
export { foo, bar as "foo" }; | ||
export { "學而時習之,不亦說乎?", "吾道一以貫之。" as "忠恕。" } from "Confucius"; | ||
export * as "foo", { default as "quux" } from "module-b"; | ||
export { "smile" } from "./emojis.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
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 @@ | ||
({ set x(){} }); |
Oops, something went wrong.