Upgrade flow parser to 0.45 (#1447)
This fixes all the unicode issues and spacing between elements in array. Fixes #1336 Fixes #1427 Fixes #770master
parent
e75d3a4af3
commit
3161bd0787
|
@ -15,7 +15,7 @@
|
|||
"babylon": "7.0.0-beta.8",
|
||||
"chalk": "1.1.3",
|
||||
"esutils": "2.0.2",
|
||||
"flow-parser": "0.43.0",
|
||||
"flow-parser": "0.45.0",
|
||||
"get-stdin": "5.0.1",
|
||||
"glob": "7.1.1",
|
||||
"jest-validate": "19.0.0",
|
||||
|
|
|
@ -2180,10 +2180,7 @@ function printPropertyKey(path, options, print) {
|
|||
(key.type === "StringLiteral" ||
|
||||
(key.type === "Literal" && typeof key.value === "string")) &&
|
||||
isIdentifierName(key.value) &&
|
||||
!node.computed &&
|
||||
// There's a bug in the flow parser where it throws if there are
|
||||
// unquoted unicode literals as keys. Let's quote them for now.
|
||||
(options.parser !== "flow" || key.value.match(/[a-zA-Z0-9$_]/))
|
||||
!node.computed
|
||||
) {
|
||||
// 'a' -> a
|
||||
return path.call(
|
||||
|
@ -3412,13 +3409,6 @@ function nodeStr(node, options) {
|
|||
const str = node.value;
|
||||
isString.assert(str);
|
||||
|
||||
// Workaround a bug in the Javascript version of the flow parser where
|
||||
// astral unicode characters like \uD801\uDC28 are incorrectly parsed as
|
||||
// a sequence of \uFFFD.
|
||||
if (options.parser === "flow" && str.indexOf("\ufffd") !== -1) {
|
||||
return node.raw;
|
||||
}
|
||||
|
||||
const raw = node.extra ? node.extra.raw : node.raw;
|
||||
// `rawContent` is the string exactly like it appeared in the input source
|
||||
// code, with its enclosing quote.
|
||||
|
|
|
@ -341,6 +341,7 @@ Foo.bar();
|
|||
|
||||
var FooLegacy = React.createClass({
|
||||
is_mounted: (undefined: ?boolean),
|
||||
|
||||
propTypes: {
|
||||
x: React.PropTypes.number.isRequired
|
||||
},
|
||||
|
|
|
@ -2220,6 +2220,7 @@ function foo(text: string | number): string {
|
|||
return "wat";
|
||||
}
|
||||
}
|
||||
|
||||
function bar(text: string | number): string {
|
||||
switch (typeof text) {
|
||||
case "string":
|
||||
|
@ -2228,16 +2229,17 @@ function bar(text: string | number): string {
|
|||
return text++ + "";
|
||||
}
|
||||
}
|
||||
|
||||
function baz1(text: string | number): string {
|
||||
switch (typeof text) {
|
||||
case "number":
|
||||
case "string":
|
||||
return text[0];
|
||||
// error, [0] on number
|
||||
return text[0]; // error, [0] on number
|
||||
default:
|
||||
return "wat";
|
||||
}
|
||||
}
|
||||
|
||||
function baz2(text: string | number): string {
|
||||
switch (typeof text) {
|
||||
case "string":
|
||||
|
@ -2247,12 +2249,15 @@ function baz2(text: string | number): string {
|
|||
return "wat";
|
||||
}
|
||||
}
|
||||
|
||||
function corge(text: string | number | Array<string>): string {
|
||||
switch (typeof text) {
|
||||
case "object":
|
||||
return text[0];
|
||||
case "string":
|
||||
case "number": // using ++ since it isn't valid on arrays or strings. // should only error for string since Array was filtered out.
|
||||
case "number":
|
||||
// using ++ since it isn't valid on arrays or strings.
|
||||
// should only error for string since Array was filtered out.
|
||||
return text++ + "";
|
||||
default:
|
||||
return "wat";
|
||||
|
|
|
@ -320,3 +320,46 @@ exports[`quotes.js 1`] = `
|
|||
<div id={"'\\""<>&quot;"} />;
|
||||
|
||||
`;
|
||||
|
||||
exports[`spacing.js 1`] = `
|
||||
const Labels = {
|
||||
label1: (
|
||||
<fbt>
|
||||
Label 1
|
||||
</fbt>
|
||||
),
|
||||
|
||||
label2: (
|
||||
<fbt>
|
||||
Label 2
|
||||
</fbt>
|
||||
),
|
||||
|
||||
label3: (
|
||||
<fbt>
|
||||
Label 3
|
||||
</fbt>
|
||||
),
|
||||
};
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
const Labels = {
|
||||
label1: (
|
||||
<fbt>
|
||||
Label 1
|
||||
</fbt>
|
||||
),
|
||||
|
||||
label2: (
|
||||
<fbt>
|
||||
Label 2
|
||||
</fbt>
|
||||
),
|
||||
|
||||
label3: (
|
||||
<fbt>
|
||||
Label 3
|
||||
</fbt>
|
||||
)
|
||||
};
|
||||
|
||||
`;
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
const Labels = {
|
||||
label1: (
|
||||
<fbt>
|
||||
Label 1
|
||||
</fbt>
|
||||
),
|
||||
|
||||
label2: (
|
||||
<fbt>
|
||||
Label 2
|
||||
</fbt>
|
||||
),
|
||||
|
||||
label3: (
|
||||
<fbt>
|
||||
Label 3
|
||||
</fbt>
|
||||
),
|
||||
};
|
|
@ -26,6 +26,7 @@ raw_amp = <span>foo & bar</span>
|
|||
many_nbsp = <div> </div>;
|
||||
single_nbsp = <div> </div>;
|
||||
many_raw_nbsp = <div> </div>;
|
||||
|
||||
amp = <span>foo & bar</span>;
|
||||
raw_amp = <span>foo & bar</span>;
|
||||
|
||||
|
|
|
@ -305,6 +305,7 @@ class A {
|
|||
|
||||
// none of the semicolons above this comment can be omitted.
|
||||
// none of the semicolons below this comment are necessary.
|
||||
|
||||
q() {}
|
||||
[h]() {}
|
||||
|
||||
|
@ -632,6 +633,7 @@ class A {
|
|||
|
||||
// none of the semicolons above this comment can be omitted.
|
||||
// none of the semicolons below this comment are necessary.
|
||||
|
||||
q() {}
|
||||
[h]() {}
|
||||
|
||||
|
|
|
@ -117,31 +117,44 @@ exports[`strings.js 1`] = `
|
|||
"\\0";
|
||||
|
||||
// Emoji.
|
||||
"🐶"; // Empty string.
|
||||
"🐶";
|
||||
// Empty string.
|
||||
"";
|
||||
""; // Single double quote.
|
||||
"";
|
||||
// Single double quote.
|
||||
'"';
|
||||
'"'; // Single single quote.
|
||||
'"';
|
||||
// Single single quote.
|
||||
"'";
|
||||
"'"; // Unnecessary escapes.
|
||||
"'";
|
||||
'"'; // One of each.
|
||||
// Unnecessary escapes.
|
||||
"'";
|
||||
'"';
|
||||
// One of each.
|
||||
"\\"'";
|
||||
"\\"'"; // One of each with unnecessary escapes.
|
||||
"\\"'";
|
||||
"\\"'"; // More double quotes than single quotes.
|
||||
// One of each with unnecessary escapes.
|
||||
"\\"'";
|
||||
"\\"'";
|
||||
// More double quotes than single quotes.
|
||||
'"\\'"';
|
||||
'"\\'"'; // More single quotes than double quotes.
|
||||
'"\\'"';
|
||||
// More single quotes than double quotes.
|
||||
"\\"''";
|
||||
"\\"''"; // Two of each.
|
||||
"\\"''";
|
||||
// Two of each.
|
||||
"\\"\\"''";
|
||||
"\\"\\"''"; // Single backslash.
|
||||
"\\"\\"''";
|
||||
// Single backslash.
|
||||
"\\\\";
|
||||
"\\\\"; // Backslases.
|
||||
"\\\\";
|
||||
// Backslases.
|
||||
"\\"\\\\\\"\\\\\\\\\\" ''\\\\'\\\\'\\\\\\\\'";
|
||||
'\\'\\\\\\'\\\\\\\\\\' ""\\\\"\\\\"\\\\\\\\"'; // Somewhat more real-word example.
|
||||
'\\'\\\\\\'\\\\\\\\\\' ""\\\\"\\\\"\\\\\\\\"';
|
||||
// Somewhat more real-word example.
|
||||
"He's sayin': \\"How's it goin'?\\" Don't ask me why.";
|
||||
"He's sayin': \\"How's it goin'?\\" Don't ask me why."; // Somewhat more real-word example 2.
|
||||
"He's sayin': \\"How's it goin'?\\" Don't ask me why.";
|
||||
// Somewhat more real-word example 2.
|
||||
'var backslash = "\\\\", doubleQuote = \\'"\\';';
|
||||
'var backslash = "\\\\", doubleQuote = \\'"\\';';
|
||||
|
||||
|
@ -234,31 +247,44 @@ exports[`strings.js 2`] = `
|
|||
'\\0';
|
||||
|
||||
// Emoji.
|
||||
'🐶'; // Empty string.
|
||||
'🐶';
|
||||
// Empty string.
|
||||
'';
|
||||
''; // Single double quote.
|
||||
'';
|
||||
// Single double quote.
|
||||
'"';
|
||||
'"'; // Single single quote.
|
||||
'"';
|
||||
// Single single quote.
|
||||
"'";
|
||||
"'"; // Unnecessary escapes.
|
||||
"'";
|
||||
'"'; // One of each.
|
||||
// Unnecessary escapes.
|
||||
"'";
|
||||
'"';
|
||||
// One of each.
|
||||
'"\\'';
|
||||
'"\\''; // One of each with unnecessary escapes.
|
||||
'"\\'';
|
||||
'"\\''; // More double quotes than single quotes.
|
||||
// One of each with unnecessary escapes.
|
||||
'"\\'';
|
||||
'"\\'';
|
||||
// More double quotes than single quotes.
|
||||
'"\\'"';
|
||||
'"\\'"'; // More single quotes than double quotes.
|
||||
'"\\'"';
|
||||
// More single quotes than double quotes.
|
||||
"\\"''";
|
||||
"\\"''"; // Two of each.
|
||||
"\\"''";
|
||||
// Two of each.
|
||||
'""\\'\\'';
|
||||
'""\\'\\''; // Single backslash.
|
||||
'""\\'\\'';
|
||||
// Single backslash.
|
||||
'\\\\';
|
||||
'\\\\'; // Backslases.
|
||||
'\\\\';
|
||||
// Backslases.
|
||||
"\\"\\\\\\"\\\\\\\\\\" ''\\\\'\\\\'\\\\\\\\'";
|
||||
'\\'\\\\\\'\\\\\\\\\\' ""\\\\"\\\\"\\\\\\\\"'; // Somewhat more real-word example.
|
||||
'\\'\\\\\\'\\\\\\\\\\' ""\\\\"\\\\"\\\\\\\\"';
|
||||
// Somewhat more real-word example.
|
||||
"He's sayin': \\"How's it goin'?\\" Don't ask me why.";
|
||||
"He's sayin': \\"How's it goin'?\\" Don't ask me why."; // Somewhat more real-word example 2.
|
||||
"He's sayin': \\"How's it goin'?\\" Don't ask me why.";
|
||||
// Somewhat more real-word example 2.
|
||||
'var backslash = "\\\\", doubleQuote = \\'"\\';';
|
||||
'var backslash = "\\\\", doubleQuote = \\'"\\';';
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ exports[`strings.js 1`] = `
|
|||
|
||||
"\\0",
|
||||
"🐶",
|
||||
'\\uD801\\uDC28'
|
||||
"\\uD801\\uDC28"
|
||||
];
|
||||
|
||||
`;
|
||||
|
@ -103,7 +103,7 @@ exports[`strings.js 2`] = `
|
|||
|
||||
"\\0",
|
||||
"🐶",
|
||||
'\\uD801\\uDC28',
|
||||
"\\uD801\\uDC28",
|
||||
];
|
||||
|
||||
`;
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
exports[`keys.js 1`] = `
|
||||
({'この事はつもり素晴らしいことさ': '35jL9V'})
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
({ "この事はつもり素晴らしいことさ": "35jL9V" });
|
||||
({ この事はつもり素晴らしいことさ: "35jL9V" });
|
||||
|
||||
`;
|
||||
|
|
|
@ -746,9 +746,9 @@ find-up@^2.1.0:
|
|||
dependencies:
|
||||
locate-path "^2.0.0"
|
||||
|
||||
flow-parser@0.43.0:
|
||||
version "0.43.0"
|
||||
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.43.0.tgz#e2b8eb1ac83dd53f7b6b04a7c35b6a52c33479b7"
|
||||
flow-parser@0.45.0:
|
||||
version "0.45.0"
|
||||
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.45.0.tgz#aa29d4ae27f06aa02817772bba0fcbefef7e62f0"
|
||||
|
||||
for-in@^0.1.5:
|
||||
version "0.1.6"
|
||||
|
|
Loading…
Reference in New Issue