-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update @babel/parser to 7.12 #9408
Changes from 14 commits
c87b672
b5308bd
7979066
b19743f
d599e72
7417d90
cf0ed63
2e42f06
6c20b0d
58cbf8b
cab1ee7
e418282
d2365f6
26ec800
9eb8275
ac9f558
71128fe
766c4cf
c06180e
b1558d1
6452008
f1182e7
226b1db
bc5251d
0fddd9a
7042f57
aaa7326
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -808,14 +808,21 @@ function printPathNoParens(path, options, print, args) { | |
} | ||
|
||
return concat(parts); | ||
case "ExportSpecifier": | ||
case "ExportSpecifier": { | ||
parts.push(path.call(print, "local")); | ||
|
||
if (n.exported && n.exported.name !== n.local.name) { | ||
const { exported, local } = n; | ||
if ( | ||
exported && | ||
(exported.type !== local.type || | ||
(exported.type === "Identifier" && exported.name !== local.name) || | ||
(exported.type === "StringLiteral" && exported.value !== local.value)) | ||
) { | ||
parts.push(" as ", path.call(print, "exported")); | ||
} | ||
|
||
return concat(parts); | ||
} | ||
case "ImportNamespaceSpecifier": | ||
parts.push("* as "); | ||
parts.push(path.call(print, "local")); | ||
|
@@ -875,8 +882,12 @@ function printPathNoParens(path, options, print, args) { | |
parts.push(" ", path.call(print, "source")); | ||
} | ||
|
||
if (Array.isArray(n.attributes) && n.attributes.length !== 0) { | ||
parts.push(" with ", concat(path.map(print, "attributes"))); | ||
if (Array.isArray(n.assertions) && n.assertions.length !== 0) { | ||
parts.push( | ||
" assert { ", | ||
join(", ", path.map(print, "assertions")), | ||
" }" | ||
); | ||
} | ||
|
||
parts.push(semi); | ||
|
@@ -913,7 +924,8 @@ function printPathNoParens(path, options, print, args) { | |
parent.type === "DoWhileStatement" || | ||
parent.type === "DoExpression" || | ||
(parent.type === "CatchClause" && !parentParent.finalizer) || | ||
parent.type === "TSModuleDeclaration") | ||
parent.type === "TSModuleDeclaration" || | ||
parent.type === "TSDeclareFunction") | ||
) { | ||
return "{}"; | ||
} | ||
|
@@ -2886,7 +2898,8 @@ function printPathNoParens(path, options, print, args) { | |
|
||
return group(concat(parts)); | ||
} | ||
case "TypeCastExpression": { | ||
case "TypeCastExpression": | ||
case "TSTypeCastExpression": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 226b1db 👍 |
||
return concat([ | ||
"(", | ||
path.call(print, "expression"), | ||
|
@@ -3116,6 +3129,7 @@ function printPathNoParens(path, options, print, args) { | |
n.accessibility ? concat([n.accessibility, " "]) : "", | ||
n.static ? "static " : "", | ||
n.readonly ? "readonly " : "", | ||
n.declare ? "declare " : "", | ||
"[", | ||
n.parameters ? parametersGroup : "", | ||
n.typeAnnotation ? "]: " : "]", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("./foo.json", { assert: { type: "json" } }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import json from "./foo.json" assert { type: "json" }; |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { smile as "😄" } from "./emojis.js"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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" }; | ||
|
||
================================================================================ | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import("./foo.json", { assert: { type: "json" } }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import json from "./foo.json" assert { type: "json", type: "bar" }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import json from "./foo.json" assert { type: "json" }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12.3e |
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"] }, | ||
}); |
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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"; | ||
|
||
=====================================output===================================== | ||
export { smile as "smile" } from "./emojis.js"; | ||
export { "smile" as smile } from "./emojis.js"; | ||
export { "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"; | ||
|
||
================================================================================ | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
run_spec(__dirname, ["babel"], { errors: { espree: true } }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
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"; | ||
Comment on lines
+1
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only have tests for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add one case in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. f1182e7 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
({ set x(){} }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
run_spec(__dirname, ["babel"], { | ||
errors: { espree: ["expression.js", "invalid-accessor-generator.js"] }, | ||
errors: { | ||
espree: [ | ||
"expression.js", | ||
"invalid-accessor-generator.js", | ||
"invalid-setter.js", | ||
], | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const foo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need compare
raw
?Prettier pr-9408
Playground link
Input:
Output:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Thank you.
Btw, I'm not sure if Prettier should omit
as
whenexported
andlocal
are the same. I think it's Linter's job.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this too, but we can fix it later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raised an issue #9434
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. Thank you.
Also, if we use
raw
, Prettier treats single quotes and double quotes as different things. That meansThis is strange. Let's keep the current behavior as this PR and fix #9434 after merging this.