Update to babel/parser 7.15.0 (#11310)
* Update to babel/parser 7.15 * Avoid plugin conflicts * Remove allowAwaitOutsideFunction * Add remove private-in * Update tests for top-level-await * Update typescript tests * Handle bar style record/tuple * Update tests * Use appendPlugin * Dont consider about bar style record and tuple * Revert appendChild * Update appendPlugins
This commit is contained in:
1 parent
51361ae851
commit
1645e7a9c4
9 files changed
+44
-17
No files matched your search
+1
-1
@@ -22,7 +22,7 @@
|
||||
"dependencies": {
|
||||
"@angular/compiler": "12.1.4",
|
||||
"@babel/code-frame": "7.14.5",
|
||||
"@babel/parser": "7.14.8",
|
||||
"@babel/parser": "7.15.0",
|
||||
"@glimmer/syntax": "0.80.0",
|
||||
"@iarna/toml": "2.2.5",
|
||||
"@typescript-eslint/typescript-estree": "4.28.5",
|
||||
|
||||
@@ -12,7 +12,6 @@ const jsonParsers = require("./json.js");
|
||||
|
||||
const parseOptions = {
|
||||
sourceType: "module",
|
||||
allowAwaitOutsideFunction: true,
|
||||
allowImportExportEverywhere: true,
|
||||
allowReturnOutsideFunction: true,
|
||||
allowSuperOutsideMethod: true,
|
||||
@@ -30,9 +29,7 @@ const parseOptions = {
|
||||
"v8intrinsic",
|
||||
"partialApplication",
|
||||
["decorators", { decoratorsBeforeExport: false }],
|
||||
"privateIn",
|
||||
"importAssertions",
|
||||
["recordAndTuple", { syntaxType: "hash" }],
|
||||
"decimal",
|
||||
"classStaticBlock",
|
||||
"moduleBlocks",
|
||||
@@ -41,14 +38,15 @@ const parseOptions = {
|
||||
tokens: true,
|
||||
ranges: true,
|
||||
};
|
||||
const recordAndTuplePlugin = ["recordAndTuple", { syntaxType: "hash" }];
|
||||
const pipelineOperatorPlugins = [
|
||||
["pipelineOperator", { proposal: "smart" }],
|
||||
["pipelineOperator", { proposal: "minimal" }],
|
||||
["pipelineOperator", { proposal: "fsharp" }],
|
||||
];
|
||||
const appendPlugins = (plugins) => ({
|
||||
...parseOptions,
|
||||
plugins: [...parseOptions.plugins, ...plugins],
|
||||
const appendPlugins = (plugins, options = parseOptions) => ({
|
||||
...options,
|
||||
plugins: [...options.plugins, ...plugins],
|
||||
});
|
||||
|
||||
// Similar to babel
|
||||
@@ -107,12 +105,17 @@ function createParse(parseMethod, ...optionsCombinations) {
|
||||
}));
|
||||
}
|
||||
|
||||
if (text.includes("#{") || text.includes("#[")) {
|
||||
combinations = combinations.map((options) =>
|
||||
appendPlugins([recordAndTuplePlugin], options)
|
||||
);
|
||||
}
|
||||
|
||||
if (text.includes("|>")) {
|
||||
combinations = pipelineOperatorPlugins.flatMap((pipelineOperatorPlugin) =>
|
||||
combinations.map((options) => ({
|
||||
...options,
|
||||
plugins: [...options.plugins, pipelineOperatorPlugin],
|
||||
}))
|
||||
combinations.map((options) =>
|
||||
appendPlugins([pipelineOperatorPlugin], options)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,9 +126,9 @@ exports[`snippet: #8 [babel] format 1`] = `
|
||||
`;
|
||||
|
||||
exports[`snippet: #9 [babel] format 1`] = `
|
||||
"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'. (1:1)
|
||||
"Unexpected token (1:2)
|
||||
> 1 | [| 1 |]
|
||||
| ^"
|
||||
| ^"
|
||||
`;
|
||||
|
||||
exports[`snippet: #10 [babel] format 1`] = `
|
||||
|
||||
@@ -55,7 +55,7 @@ exports[`snippet: #8 [babel] format 1`] = `
|
||||
`;
|
||||
|
||||
exports[`snippet: #9 [babel] format 1`] = `
|
||||
"Can not use 'yield' as identifier inside a generator. (1:39)
|
||||
"Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence. (1:39)
|
||||
> 1 | async function * a() { a |> foo(#) |> yield}
|
||||
| ^"
|
||||
`;
|
||||
@@ -87,6 +87,16 @@ abstract class Foo {
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`abstractPropertiesWithBreaks.ts [babel-ts] format 1`] = `
|
||||
"Property 'foobar' cannot have an initializer because it is marked abstract. (2:29)
|
||||
1 | abstract class Foo {
|
||||
> 2 | abstract private foobar =
|
||||
| ^
|
||||
3 | // comment to break
|
||||
4 | 1 +
|
||||
5 | // another comment to break"
|
||||
`;
|
||||
|
||||
exports[`abstractPropertiesWithBreaks.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
run_spec(__dirname, ["typescript"], {
|
||||
errors: {
|
||||
"babel-ts": ["abstractProperties.ts"],
|
||||
"babel-ts": ["abstractProperties.ts", "abstractPropertiesWithBreaks.ts"],
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,14 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`invalid-await.ts [babel-ts] format 1`] = `
|
||||
"'await' is only allowed within async functions and at the top levels of modules. (2:13)
|
||||
1 | namespace N {
|
||||
> 2 | const x = await 42;
|
||||
| ^
|
||||
3 | }
|
||||
4 |"
|
||||
`;
|
||||
|
||||
exports[`invalid-await.ts format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
|
||||
@@ -1 +1 @@
|
||||
run_spec(__dirname, ["typescript"]);
|
||||
run_spec(__dirname, ["typescript"], { errors: { "babel-ts": true } });
|
||||
@@ -288,7 +288,12 @@
|
||||
chalk "^2.0.0"
|
||||
js-tokens "^4.0.0"
|
||||
|
||||
"@babel/parser@7.14.8", "@babel/parser@^7.1.0", "@babel/parser@^7.14.5", "@babel/parser@^7.14.8", "@babel/parser@^7.7.2":
|
||||
"@babel/parser@7.15.0":
|
||||
version "7.15.0"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.15.0.tgz#b6d6e29058ca369127b0eeca2a1c4b5794f1b6b9"
|
||||
integrity sha512-0v7oNOjr6YT9Z2RAOTv4T9aP+ubfx4Q/OhVtAet7PFDt0t9Oy6Jn+/rfC6b8HJ5zEqrQCiMxJfgtHpmIminmJQ==
|
||||
|
||||
"@babel/parser@^7.1.0", "@babel/parser@^7.14.5", "@babel/parser@^7.14.8", "@babel/parser@^7.7.2":
|
||||
version "7.14.8"
|
||||
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.14.8.tgz#66fd41666b2d7b840bd5ace7f7416d5ac60208d4"
|
||||
integrity sha512-syoCQFOoo/fzkWDeM0dLEZi5xqurb5vuyzwIMNZRNun+N/9A4cUZeQaE7dTrB8jGaKuJRBtEOajtnmw0I5hvvA==
|
||||
|
||||
Reference in new issue
Block a user