Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
validate parentheses in the left-hand side of assignment expressions (#…
…10576) * invalid left-hand assignments based on parenthesis * validate against nested ParenthesizedExpressions
- Loading branch information
Showing
48 changed files
with
2,811 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/core/categorized/invalid-assignment-pattern-1/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
(a = 1) = t |
5 changes: 5 additions & 0 deletions
5
...ges/babel-parser/test/fixtures/core/categorized/invalid-assignment-pattern-1/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [ | ||
"estree" | ||
] | ||
} |
138 changes: 138 additions & 0 deletions
138
...ages/babel-parser/test/fixtures/core/categorized/invalid-assignment-pattern-1/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 11, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 11 | ||
} | ||
}, | ||
"errors": [ | ||
"SyntaxError: Invalid parenthesized assignment pattern (1:1)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 11, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 11 | ||
} | ||
}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start": 0, | ||
"end": 11, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 11 | ||
} | ||
}, | ||
"expression": { | ||
"type": "AssignmentExpression", | ||
"start": 0, | ||
"end": 11, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 11 | ||
} | ||
}, | ||
"operator": "=", | ||
"left": { | ||
"type": "AssignmentPattern", | ||
"start": 1, | ||
"end": 6, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 6 | ||
} | ||
}, | ||
"left": { | ||
"type": "Identifier", | ||
"start": 1, | ||
"end": 2, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 2 | ||
}, | ||
"identifierName": "a" | ||
}, | ||
"name": "a" | ||
}, | ||
"right": { | ||
"type": "Literal", | ||
"start": 5, | ||
"end": 6, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 5 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 6 | ||
} | ||
}, | ||
"value": 1, | ||
"raw": "1" | ||
}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 0 | ||
} | ||
}, | ||
"right": { | ||
"type": "Identifier", | ||
"start": 10, | ||
"end": 11, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 10 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 11 | ||
}, | ||
"identifierName": "t" | ||
}, | ||
"name": "t" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/core/categorized/invalid-assignment-pattern-2/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[(a = 1)] = t |
5 changes: 5 additions & 0 deletions
5
...ges/babel-parser/test/fixtures/core/categorized/invalid-assignment-pattern-2/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"plugins": [ | ||
"estree" | ||
] | ||
} |
155 changes: 155 additions & 0 deletions
155
...ages/babel-parser/test/fixtures/core/categorized/invalid-assignment-pattern-2/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 13, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 13 | ||
} | ||
}, | ||
"errors": [ | ||
"SyntaxError: Invalid parenthesized assignment pattern (1:2)" | ||
], | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 13, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 13 | ||
} | ||
}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ExpressionStatement", | ||
"start": 0, | ||
"end": 13, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 13 | ||
} | ||
}, | ||
"expression": { | ||
"type": "AssignmentExpression", | ||
"start": 0, | ||
"end": 13, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 13 | ||
} | ||
}, | ||
"operator": "=", | ||
"left": { | ||
"type": "ArrayPattern", | ||
"start": 0, | ||
"end": 9, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 9 | ||
} | ||
}, | ||
"elements": [ | ||
{ | ||
"type": "AssignmentPattern", | ||
"start": 2, | ||
"end": 7, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 7 | ||
} | ||
}, | ||
"left": { | ||
"type": "Identifier", | ||
"start": 2, | ||
"end": 3, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 2 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 3 | ||
}, | ||
"identifierName": "a" | ||
}, | ||
"name": "a" | ||
}, | ||
"right": { | ||
"type": "Literal", | ||
"start": 6, | ||
"end": 7, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 6 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 7 | ||
} | ||
}, | ||
"value": 1, | ||
"raw": "1" | ||
}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 1 | ||
} | ||
} | ||
] | ||
}, | ||
"right": { | ||
"type": "Identifier", | ||
"start": 12, | ||
"end": 13, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 12 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 13 | ||
}, | ||
"identifierName": "t" | ||
}, | ||
"name": "t" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/core/categorized/invalid-assignment-pattern-3/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[({ a: [b = 2]})] = t |
Oops, something went wrong.