Skip to content

Commit

Permalink
Build(deps): Bump @babel/parser from 7.13.13 to 7.13.15 (#10682)
Browse files Browse the repository at this point in the history
* Build(deps): Bump @babel/parser from 7.13.13 to 7.13.15

Bumps [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) from 7.13.13 to 7.13.15.
- [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.15/packages/babel-parser)

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

* Add test for babel/babel#13099

* Test babel/babel#13049

* Test babel/babel#13101

* Add long name test

* Style

* Print necessary parens in `{ a: (b as any) = 2000 }`

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: fisker Cheung <lionkay@gmail.com>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
  • Loading branch information
3 people committed Apr 12, 2021
1 parent 62b9c63 commit 147c30f
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"@angular/compiler": "11.2.9",
"@babel/code-frame": "7.12.13",
"@babel/parser": "7.13.13",
"@babel/parser": "7.13.15",
"@glimmer/syntax": "0.77.6",
"@iarna/toml": "2.2.5",
"@typescript-eslint/typescript-estree": "4.19.0",
Expand Down
1 change: 1 addition & 0 deletions src/language-js/needs-parens.js
Expand Up @@ -267,6 +267,7 @@ function needsParens(path, options) {
return name === "object";

case "AssignmentExpression":
case "AssignmentPattern":
return (
name === "left" &&
(node.type === "TSTypeAssertion" || node.type === "TSAsExpression")
Expand Down
109 changes: 109 additions & 0 deletions tests/misc/errors/js/for-of/__snapshots__/jsfmt.spec.js.snap
@@ -0,0 +1,109 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`snippet: #0 [babel] format 1`] = `
"Unexpected reserved word 'let' (1:6)
> 1 | for (let.foo of []);
| ^"
`;

exports[`snippet: #0 [babel-flow] format 1`] = `
"Unexpected reserved word 'let' (1:6)
> 1 | for (let.foo of []);
| ^"
`;

exports[`snippet: #0 [babel-ts] format 1`] = `
"The left-hand side of a for-of loop may not start with 'let'. (1:6)
> 1 | for (let.foo of []);
| ^"
`;

exports[`snippet: #0 [flow] format 1`] = `
"Unexpected token \`.\`, expected an identifier (1:9)
> 1 | for (let.foo of []);
| ^"
`;

exports[`snippet: #0 [meriyah] format 1`] = `
"[1:9]: Identifier \\"let\\" disallowed as left-hand side expression in strict mode (1:9)
> 1 | for (let.foo of []);
| ^"
`;

exports[`snippet: #0 [typescript] format 1`] = `
"Variable declaration expected. (1:9)
> 1 | for (let.foo of []);
| ^"
`;

exports[`snippet: #1 [babel] format 1`] = `
"Unexpected reserved word 'let' (1:6)
> 1 | for (let().bar of []);
| ^"
`;

exports[`snippet: #1 [babel-flow] format 1`] = `
"Unexpected reserved word 'let' (1:6)
> 1 | for (let().bar of []);
| ^"
`;

exports[`snippet: #1 [babel-ts] format 1`] = `
"The left-hand side of a for-of loop may not start with 'let'. (1:6)
> 1 | for (let().bar of []);
| ^"
`;

exports[`snippet: #1 [flow] format 1`] = `
"Unexpected token \`(\`, expected an identifier (1:9)
> 1 | for (let().bar of []);
| ^"
`;

exports[`snippet: #1 [meriyah] format 1`] = `
"[1:9]: Identifier \\"let\\" disallowed as left-hand side expression in strict mode (1:9)
> 1 | for (let().bar of []);
| ^"
`;

exports[`snippet: #1 [typescript] format 1`] = `
"Variable declaration expected. (1:9)
> 1 | for (let().bar of []);
| ^"
`;

exports[`snippet: #2 [babel] format 1`] = `
"Unexpected reserved word 'let' (1:6)
> 1 | for (let\`\`.bar of []);
| ^"
`;

exports[`snippet: #2 [babel-flow] format 1`] = `
"Unexpected reserved word 'let' (1:6)
> 1 | for (let\`\`.bar of []);
| ^"
`;

exports[`snippet: #2 [babel-ts] format 1`] = `
"The left-hand side of a for-of loop may not start with 'let'. (1:6)
> 1 | for (let\`\`.bar of []);
| ^"
`;

exports[`snippet: #2 [flow] format 1`] = `
"Unexpected template literal part, expected an identifier (1:9)
> 1 | for (let\`\`.bar of []);
| ^^"
`;

exports[`snippet: #2 [meriyah] format 1`] = `
"[1:10]: Identifier \\"let\\" disallowed as left-hand side expression in strict mode (1:10)
> 1 | for (let\`\`.bar of []);
| ^"
`;

exports[`snippet: #2 [typescript] format 1`] = `
"Variable declaration expected. (1:9)
> 1 | for (let\`\`.bar of []);
| ^"
`;
20 changes: 20 additions & 0 deletions tests/misc/errors/js/for-of/jsfmt.spec.js
@@ -0,0 +1,20 @@
run_spec(
{
dirname: __dirname,
snippets: [
"for (let.foo of []);",
"for (let().bar of []);",
"for (let``.bar of []);",
],
},
[
"babel",
// Espree didn't throw https://github.com/acornjs/acorn/issues/1009
// "espree",
"meriyah",
"flow",
"typescript",
"babel-flow",
"babel-ts",
]
);
Expand Up @@ -15,3 +15,21 @@ exports[`classAbstractMethodWithImplementation.ts [babel-ts] format 1`] = `
| ^
3 | }"
`;

exports[`snippet: #0 [babel-ts] format 1`] = `
"Invalid left-hand side in assignment expression (1:1)
> 1 | foo as any = 10;
| ^"
`;

exports[`snippet: #1 [babel-ts] format 1`] = `
"Invalid left-hand side in assignment expression (1:7)
> 1 | ({ a: b as any = 2000 } = x);
| ^"
`;

exports[`snippet: #2 [babel-ts] format 1`] = `
"Unterminated JSX contents (1:9)
> 1 | <string>foo = '100';
| ^"
`;
12 changes: 11 additions & 1 deletion tests/misc/errors/typescript/babel-ts/jsfmt.spec.js
@@ -1 +1,11 @@
run_spec(__dirname, ["babel-ts"]);
run_spec(
{
dirname: __dirname,
snippets: [
"foo as any = 10;",
"({ a: b as any = 2000 } = x);",
"<string>foo = '100';",
],
},
["babel-ts"]
);
15 changes: 15 additions & 0 deletions tests/typescript/cast/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -22,6 +22,21 @@ let x = "123" as const;
================================================================================
`;

exports[`assert-and-assign.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
| printWidth
=====================================input======================================
(a as number) = 42;
({ a: (b as any) = 2000 } = x);
=====================================output=====================================
(a as number) = 42;
({ a: (b as any) = 2000 } = x);
================================================================================
`;

exports[`generic-cast.ts format 1`] = `
====================================options=====================================
parsers: ["typescript"]
Expand Down
2 changes: 2 additions & 0 deletions tests/typescript/cast/assert-and-assign.ts
@@ -0,0 +1,2 @@
(a as number) = 42;
({ a: (b as any) = 2000 } = x);
@@ -0,0 +1,58 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`function-rest-trailing-comma.ts - {"trailingComma":"all"} format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
trailingComma: "all"
| printWidth
=====================================input======================================
declare function foo(...args: any[], )
declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], )
=====================================output=====================================
declare function foo(...args: any[]);
declare function foo(
...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[]
);
================================================================================
`;

exports[`function-rest-trailing-comma.ts - {"trailingComma":"es5"} format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
trailingComma: "es5"
| printWidth
=====================================input======================================
declare function foo(...args: any[], )
declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], )
=====================================output=====================================
declare function foo(...args: any[]);
declare function foo(
...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[]
);
================================================================================
`;

exports[`function-rest-trailing-comma.ts - {"trailingComma":"none"} format 1`] = `
====================================options=====================================
parsers: ["typescript"]
printWidth: 80
trailingComma: "none"
| printWidth
=====================================input======================================
declare function foo(...args: any[], )
declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], )
=====================================output=====================================
declare function foo(...args: any[]);
declare function foo(
...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[]
);
================================================================================
`;
@@ -0,0 +1,2 @@
declare function foo(...args: any[], )
declare function foo(...long_long_long_long_long_long_long_long_long_long_long_long_long_long_long_args: any[], )
3 changes: 3 additions & 0 deletions tests/typescript/declare/trailing-comma/jsfmt.spec.js
@@ -0,0 +1,3 @@
run_spec(__dirname, ["typescript"], { trailingComma: "es5" });
run_spec(__dirname, ["typescript"], { trailingComma: "none" });
run_spec(__dirname, ["typescript"], { trailingComma: "all" });
7 changes: 1 addition & 6 deletions yarn.lock
Expand Up @@ -281,12 +281,7 @@
chalk "^2.0.0"
js-tokens "^4.0.0"

"@babel/parser@7.13.13":
version "7.13.13"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.13.tgz#42f03862f4aed50461e543270916b47dd501f0df"
integrity sha512-OhsyMrqygfk5v8HmWwOzlYjJrtLaFhF34MrfG/Z73DgYCI6ojNUTUp2TYbtnjo8PegeJp12eamsNettCQjKjVw==

"@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.15":
"@babel/parser@7.13.15", "@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.15":
version "7.13.15"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.15.tgz#8e66775fb523599acb6a289e12929fa5ab0954d8"
integrity sha512-b9COtcAlVEQljy/9fbcMHpG+UIW9ReF+gpaxDHTlZd0c6/UU9ng8zdySAW9sRTzpvcdCHn6bUcbuYUgGzLAWVQ==
Expand Down

0 comments on commit 147c30f

Please sign in to comment.