Build(deps): Bump @babel/parser from 7.12.11 to 7.13.4 (#10397)

* Build(deps): Bump @babel/parser from 7.12.11 to 7.13.4

Bumps [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) from 7.12.11 to 7.13.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.13.4/packages/babel-parser)

Signed-off-by: dependabot[bot] <support@github.com>

* Add unstable AST compare testing

* Remove error tests for this type with babel-flow

* Fix typo

* Add changelog

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: sosukesuzuki <aosukeke@gmail.com>
This commit is contained in:
dependabot[bot]andsosukesuzuki authored and GitHub committed 2021-02-26 22:04:53 +09:00
1 parent 95c8086c2c
commit 478107836d
6 files changed
+57 -48

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
#### Support `this` type annotation in functions via `babel-flow` (#10397 by @sosukesuzuki)
`this` type annotation is supported since [Babel 7.13](https://babeljs.io/blog/2021/02/22/7.13.0#new-flow-features-12193httpsgithubcombabelbabelpull12193-12234httpsgithubcombabelbabelpull12234).
```js
// Input
var foo: (this: boolean) => void;
// Prettier stable
SyntaxError: Unexpected token, expected ")" (1:15)
// Prettier main
var foo: (this: boolean) => void;
```
+1 -1
View File
@@ -22,7 +22,7 @@
"dependencies": {
"@angular/compiler": "11.2.1",
"@babel/code-frame": "7.12.13",
"@babel/parser": "7.12.17",
"@babel/parser": "7.13.4",
"@glimmer/syntax": "0.77.1",
"@iarna/toml": "2.2.5",
"@typescript-eslint/typescript-estree": "4.15.1",
@@ -54,17 +54,6 @@ function baz(this: number, ...a) {}
================================================================================
`;
exports[`function_type.js - {"trailingComma":"all"} [babel-flow] format 1`] = `
"Unexpected token, expected \\")\\" (3:16)
1 | // @flow
2 |
> 3 | type T = (this : number, a : string, b : number) => void
| ^
4 |
5 | type U = (this : number, ...c : any) => void
6 |"
`;
exports[`function_type.js - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["flow", "babel-flow"]
@@ -92,17 +81,6 @@ type V = (this: number) => void;
================================================================================
`;
exports[`line_break.js - {"trailingComma":"all"} [babel-flow] format 1`] = `
"Unexpected token, expected \\")\\" (3:15)
1 | // @flow
2 |
> 3 | type T = (this: boolean,
| ^
4 | a: number,
5 |
6 | b: number,"
`;
exports[`line_break.js - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["flow", "babel-flow"]
@@ -195,17 +173,6 @@ class A {
================================================================================
`;
exports[`union_type.js - {"trailingComma":"all"} [babel-flow] format 1`] = `
"Unexpected token, expected \\")\\" (4:7)
2 |
3 | type A = (
> 4 | this: | SupperLongLongLongLongLongLongLongLongLongLongLongType | FooBarBazLorem12345,
| ^
5 | b: number,
6 | ) => boolean;
7 |"
`;
exports[`union_type.js - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["flow", "babel-flow"]
-3
View File
@@ -1,6 +1,3 @@
run_spec(__dirname, ["flow", "babel-flow"], {
trailingComma: "all",
errors: {
"babel-flow": ["function_type.js", "line_break.js", "union_type.js"],
},
});
+37 -1
View File
@@ -47,6 +47,27 @@ const unstableTests = new Map(
})
);
// This is temporary.
// This will be removed once https://github.com/babel/babel/issues/12915 is fixed
const unstableAstTests = new Map(
[
[
"flow/function-parentheses/single.js",
(options) =>
options.parser.startsWith("babel") && options.arrowParens !== "avoid",
],
[
"flow/function-parentheses/test.js",
(options) => options.parser.startsWith("babel"),
],
].map((fixture) => {
const [file, isUnstable = () => true] = Array.isArray(fixture)
? fixture
: [fixture];
return [path.join(__dirname, "../tests/", file), isUnstable];
})
);
const espreeDisabledTests = new Set(
[
// These tests only work for `babel`
@@ -65,6 +86,16 @@ const isUnstable = (filename, options) => {
return testFunction(options);
};
const isAstUnstable = (filename, options) => {
const testFunction = unstableAstTests.get(filename);
if (!testFunction) {
return false;
}
return testFunction(options);
};
const shouldThrowOnFormat = (filename, options) => {
const { errors = {} } = options;
if (errors === true) {
@@ -293,13 +324,18 @@ function runTest({
});
}
const isAstUnstableTest = isAstUnstable(filename, formatOptions);
// Some parsers skip parsing empty files
if (formatResult.changed && code.trim()) {
test(`[${parser}] compare AST`, () => {
const { input, output } = formatResult;
const originalAst = parse(input, formatOptions);
const formattedAst = parse(output, formatOptions);
expect(formattedAst).toEqual(originalAst);
if (isAstUnstableTest) {
expect(formattedAst).not.toEqual(originalAst);
} else {
expect(formattedAst).toEqual(originalAst);
}
});
}
+4 -10
View File
@@ -267,15 +267,10 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
"@babel/parser@7.12.17":
version "7.12.17"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.17.tgz#bc85d2d47db38094e5bb268fc761716e7d693848"
integrity sha512-r1yKkiUTYMQ8LiEI0UcQx5ETw5dpTLn9wijn9hk6KkTtOK95FndDN10M+8/s6k/Ymlbivw0Av9q4SlgF80PtHg==
"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.12.17", "@babel/parser@^7.7.0":
version "7.12.17"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.12.17.tgz#bc85d2d47db38094e5bb268fc761716e7d693848"
integrity sha512-r1yKkiUTYMQ8LiEI0UcQx5ETw5dpTLn9wijn9hk6KkTtOK95FndDN10M+8/s6k/Ymlbivw0Av9q4SlgF80PtHg==
"@babel/parser@7.13.4", "@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.12.17", "@babel/parser@^7.7.0":
version "7.13.4"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.4.tgz#340211b0da94a351a6f10e63671fa727333d13ab"
integrity sha512-uvoOulWHhI+0+1f9L4BoozY7U5cIkZ9PgJqvb041d6vypgUmtVPG4vmGm4pSggjl8BELzvHyUeJSUyEMY6b+qA==
"@babel/plugin-proposal-async-generator-functions@^7.12.13":
version "7.12.13"
@@ -3078,7 +3073,6 @@ eslint-plugin-jest@24.1.5:
"eslint-plugin-prettier-internal-rules@link:scripts/tools/eslint-plugin-prettier-internal-rules":
version "0.0.0"
uid ""
eslint-plugin-react@7.22.0:
version "7.22.0"