Revert "Parenthesized expressions (#8025)"
This reverts commit dd8b700a2c4c975584c7b2ea43023aa275c16167.
This commit is contained in:
parent
9f3457797f
commit
fc1ea7f496
@ -1,12 +0,0 @@
|
|||||||
// One
|
|
||||||
(1);
|
|
||||||
|
|
||||||
/* Two */
|
|
||||||
(2);
|
|
||||||
|
|
||||||
(
|
|
||||||
// Three
|
|
||||||
3
|
|
||||||
);
|
|
||||||
|
|
||||||
(/* Four */ 4);
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"parserOpts": {"createParenthesizedExpressions": true}
|
|
||||||
}
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
// One
|
|
||||||
(1);
|
|
||||||
/* Two */
|
|
||||||
|
|
||||||
(2);
|
|
||||||
( // Three
|
|
||||||
3);
|
|
||||||
(
|
|
||||||
/* Four */
|
|
||||||
4);
|
|
||||||
@ -492,7 +492,6 @@ suites.forEach(function(testSuite) {
|
|||||||
strictMode: false,
|
strictMode: false,
|
||||||
sourceType: "module",
|
sourceType: "module",
|
||||||
sourceMaps: !!task.sourceMap,
|
sourceMaps: !!task.sourceMap,
|
||||||
...task.options.parserOpts,
|
|
||||||
});
|
});
|
||||||
const options = {
|
const options = {
|
||||||
sourceFileName: path.relative(__dirname, actual.loc),
|
sourceFileName: path.relative(__dirname, actual.loc),
|
||||||
|
|||||||
@ -78,7 +78,6 @@ These are the core @babel/parser (babylon) AST node types.
|
|||||||
- [CallExpression](#callexpression)
|
- [CallExpression](#callexpression)
|
||||||
- [NewExpression](#newexpression)
|
- [NewExpression](#newexpression)
|
||||||
- [SequenceExpression](#sequenceexpression)
|
- [SequenceExpression](#sequenceexpression)
|
||||||
- [ParenthesizedExpression](#parenthesizedexpression)
|
|
||||||
- [DoExpression](#doexpression)
|
- [DoExpression](#doexpression)
|
||||||
- [Template Literals](#template-literals)
|
- [Template Literals](#template-literals)
|
||||||
- [TemplateLiteral](#templateliteral)
|
- [TemplateLiteral](#templateliteral)
|
||||||
@ -937,17 +936,6 @@ interface SequenceExpression <: Expression {
|
|||||||
|
|
||||||
A sequence expression, i.e., a comma-separated sequence of expressions.
|
A sequence expression, i.e., a comma-separated sequence of expressions.
|
||||||
|
|
||||||
## ParenthesizedExpression
|
|
||||||
|
|
||||||
```js
|
|
||||||
interface ParenthesizedExpression <: Expression {
|
|
||||||
type "ParenthesizedExpression";
|
|
||||||
expression: Expression;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
An expression wrapped by parentheses.
|
|
||||||
|
|
||||||
## DoExpression
|
## DoExpression
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -19,7 +19,6 @@ export type Options = {
|
|||||||
strictMode: ?boolean,
|
strictMode: ?boolean,
|
||||||
ranges: boolean,
|
ranges: boolean,
|
||||||
tokens: boolean,
|
tokens: boolean,
|
||||||
createParenthesizedExpressions: boolean,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultOptions: Options = {
|
export const defaultOptions: Options = {
|
||||||
@ -56,9 +55,6 @@ export const defaultOptions: Options = {
|
|||||||
ranges: false,
|
ranges: false,
|
||||||
// Adds all parsed tokens to a `tokens` property on the `File` node
|
// Adds all parsed tokens to a `tokens` property on the `File` node
|
||||||
tokens: false,
|
tokens: false,
|
||||||
// Whether to create ParenthesizedExpression AST nodes (if false
|
|
||||||
// the parser sets extra.parenthesized on the expression nodes instead).
|
|
||||||
createParenthesizedExpressions: false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Interpret and default an options object
|
// Interpret and default an options object
|
||||||
|
|||||||
@ -185,28 +185,17 @@ export default class ExpressionParser extends LValParser {
|
|||||||
|
|
||||||
let patternErrorMsg;
|
let patternErrorMsg;
|
||||||
let elementName;
|
let elementName;
|
||||||
|
if (left.type === "ObjectPattern") {
|
||||||
const unwrap = node => {
|
|
||||||
return node.type === "ParenthesizedExpression"
|
|
||||||
? unwrap(node.expression)
|
|
||||||
: node;
|
|
||||||
};
|
|
||||||
const maybePattern = unwrap(left);
|
|
||||||
if (maybePattern.type === "ObjectPattern") {
|
|
||||||
patternErrorMsg = "`({a}) = 0` use `({a} = 0)`";
|
patternErrorMsg = "`({a}) = 0` use `({a} = 0)`";
|
||||||
elementName = "property";
|
elementName = "property";
|
||||||
} else if (maybePattern.type === "ArrayPattern") {
|
} else if (left.type === "ArrayPattern") {
|
||||||
patternErrorMsg = "`([a]) = 0` use `([a] = 0)`";
|
patternErrorMsg = "`([a]) = 0` use `([a] = 0)`";
|
||||||
elementName = "element";
|
elementName = "element";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (patternErrorMsg && left.extra && left.extra.parenthesized) {
|
||||||
patternErrorMsg &&
|
|
||||||
((left.extra && left.extra.parenthesized) ||
|
|
||||||
left.type === "ParenthesizedExpression")
|
|
||||||
) {
|
|
||||||
this.raise(
|
this.raise(
|
||||||
maybePattern.start,
|
left.start,
|
||||||
`You're trying to assign to a parenthesized expression, eg. instead of ${patternErrorMsg}`,
|
`You're trying to assign to a parenthesized expression, eg. instead of ${patternErrorMsg}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -320,8 +309,7 @@ export default class ExpressionParser extends LValParser {
|
|||||||
if (
|
if (
|
||||||
operator === "**" &&
|
operator === "**" &&
|
||||||
left.type === "UnaryExpression" &&
|
left.type === "UnaryExpression" &&
|
||||||
(this.options.createParenthesizedExpressions ||
|
!(left.extra && left.extra.parenthesized)
|
||||||
!(left.extra && left.extra.parenthesized))
|
|
||||||
) {
|
) {
|
||||||
this.raise(
|
this.raise(
|
||||||
left.argument.start,
|
left.argument.start,
|
||||||
@ -1167,6 +1155,13 @@ export default class ExpressionParser extends LValParser {
|
|||||||
return this.finishNode(node, type);
|
return this.finishNode(node, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseParenExpression(): N.Expression {
|
||||||
|
this.expect(tt.parenL);
|
||||||
|
const val = this.parseExpression();
|
||||||
|
this.expect(tt.parenR);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
parseParenAndDistinguishExpression(canBeArrow: boolean): N.Expression {
|
parseParenAndDistinguishExpression(canBeArrow: boolean): N.Expression {
|
||||||
const startPos = this.state.start;
|
const startPos = this.state.start;
|
||||||
const startLoc = this.state.startLoc;
|
const startLoc = this.state.startLoc;
|
||||||
@ -1277,16 +1272,10 @@ export default class ExpressionParser extends LValParser {
|
|||||||
val = exprList[0];
|
val = exprList[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.options.createParenthesizedExpressions) {
|
this.addExtra(val, "parenthesized", true);
|
||||||
this.addExtra(val, "parenthesized", true);
|
this.addExtra(val, "parenStart", startPos);
|
||||||
this.addExtra(val, "parenStart", startPos);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
const parenExpression = this.startNodeAt(startPos, startLoc);
|
return val;
|
||||||
parenExpression.expression = val;
|
|
||||||
this.finishNode(parenExpression, "ParenthesizedExpression");
|
|
||||||
return parenExpression;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldParseArrow(): boolean {
|
shouldParseArrow(): boolean {
|
||||||
|
|||||||
@ -92,14 +92,6 @@ export default class LValParser extends NodeUtils {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ParenthesizedExpression":
|
|
||||||
node.expression = this.toAssignable(
|
|
||||||
node.expression,
|
|
||||||
isBinding,
|
|
||||||
contextDescription,
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "MemberExpression":
|
case "MemberExpression":
|
||||||
if (!isBinding) break;
|
if (!isBinding) break;
|
||||||
|
|
||||||
@ -415,15 +407,6 @@ export default class LValParser extends NodeUtils {
|
|||||||
this.checkLVal(expr.argument, isBinding, checkClashes, "rest element");
|
this.checkLVal(expr.argument, isBinding, checkClashes, "rest element");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ParenthesizedExpression":
|
|
||||||
this.checkLVal(
|
|
||||||
expr.expression,
|
|
||||||
isBinding,
|
|
||||||
checkClashes,
|
|
||||||
"parenthesized expression",
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
const message =
|
const message =
|
||||||
(isBinding
|
(isBinding
|
||||||
|
|||||||
@ -426,13 +426,6 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
return this.finishNode(node, "DebuggerStatement");
|
return this.finishNode(node, "DebuggerStatement");
|
||||||
}
|
}
|
||||||
|
|
||||||
parseHeaderExpression(): N.Expression {
|
|
||||||
this.expect(tt.parenL);
|
|
||||||
const val = this.parseExpression();
|
|
||||||
this.expect(tt.parenR);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
parseDoStatement(node: N.DoWhileStatement): N.DoWhileStatement {
|
parseDoStatement(node: N.DoWhileStatement): N.DoWhileStatement {
|
||||||
this.next();
|
this.next();
|
||||||
this.state.labels.push(loopLabel);
|
this.state.labels.push(loopLabel);
|
||||||
@ -449,7 +442,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
this.state.labels.pop();
|
this.state.labels.pop();
|
||||||
|
|
||||||
this.expect(tt._while);
|
this.expect(tt._while);
|
||||||
node.test = this.parseHeaderExpression();
|
node.test = this.parseParenExpression();
|
||||||
this.eat(tt.semi);
|
this.eat(tt.semi);
|
||||||
return this.finishNode(node, "DoWhileStatement");
|
return this.finishNode(node, "DoWhileStatement");
|
||||||
}
|
}
|
||||||
@ -538,7 +531,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
|
|
||||||
parseIfStatement(node: N.IfStatement): N.IfStatement {
|
parseIfStatement(node: N.IfStatement): N.IfStatement {
|
||||||
this.next();
|
this.next();
|
||||||
node.test = this.parseHeaderExpression();
|
node.test = this.parseParenExpression();
|
||||||
node.consequent = this.parseStatement("if");
|
node.consequent = this.parseStatement("if");
|
||||||
node.alternate = this.eat(tt._else) ? this.parseStatement("if") : null;
|
node.alternate = this.eat(tt._else) ? this.parseStatement("if") : null;
|
||||||
return this.finishNode(node, "IfStatement");
|
return this.finishNode(node, "IfStatement");
|
||||||
@ -567,7 +560,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
|
|
||||||
parseSwitchStatement(node: N.SwitchStatement): N.SwitchStatement {
|
parseSwitchStatement(node: N.SwitchStatement): N.SwitchStatement {
|
||||||
this.next();
|
this.next();
|
||||||
node.discriminant = this.parseHeaderExpression();
|
node.discriminant = this.parseParenExpression();
|
||||||
const cases = (node.cases = []);
|
const cases = (node.cases = []);
|
||||||
this.expect(tt.braceL);
|
this.expect(tt.braceL);
|
||||||
this.state.labels.push(switchLabel);
|
this.state.labels.push(switchLabel);
|
||||||
@ -676,7 +669,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
|
|
||||||
parseWhileStatement(node: N.WhileStatement): N.WhileStatement {
|
parseWhileStatement(node: N.WhileStatement): N.WhileStatement {
|
||||||
this.next();
|
this.next();
|
||||||
node.test = this.parseHeaderExpression();
|
node.test = this.parseParenExpression();
|
||||||
this.state.labels.push(loopLabel);
|
this.state.labels.push(loopLabel);
|
||||||
|
|
||||||
node.body =
|
node.body =
|
||||||
@ -698,7 +691,7 @@ export default class StatementParser extends ExpressionParser {
|
|||||||
this.raise(this.state.start, "'with' in strict mode");
|
this.raise(this.state.start, "'with' in strict mode");
|
||||||
}
|
}
|
||||||
this.next();
|
this.next();
|
||||||
node.object = this.parseHeaderExpression();
|
node.object = this.parseParenExpression();
|
||||||
|
|
||||||
node.body =
|
node.body =
|
||||||
// For the smartPipelines plugin:
|
// For the smartPipelines plugin:
|
||||||
|
|||||||
@ -566,11 +566,6 @@ export type SequenceExpression = NodeBase & {
|
|||||||
expressions: $ReadOnlyArray<Expression>,
|
expressions: $ReadOnlyArray<Expression>,
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ParenthesizedExpression = NodeBase & {
|
|
||||||
type: "ParenthesizedExpression",
|
|
||||||
expression: Expression,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Pipelines
|
// Pipelines
|
||||||
|
|
||||||
export type PipelineBody = NodeBase & {
|
export type PipelineBody = NodeBase & {
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
// One
|
|
||||||
(1);
|
|
||||||
|
|
||||||
/* Two */
|
|
||||||
(2);
|
|
||||||
|
|
||||||
(
|
|
||||||
// Three
|
|
||||||
3
|
|
||||||
);
|
|
||||||
|
|
||||||
(/* Four */ 4);
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true
|
|
||||||
}
|
|
||||||
@ -1,391 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "File",
|
|
||||||
"start": 0,
|
|
||||||
"end": 65,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 15
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"program": {
|
|
||||||
"type": "Program",
|
|
||||||
"start": 0,
|
|
||||||
"end": 65,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 15
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"sourceType": "script",
|
|
||||||
"interpreter": null,
|
|
||||||
"body": [
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 7,
|
|
||||||
"end": 11,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 4
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "ParenthesizedExpression",
|
|
||||||
"start": 7,
|
|
||||||
"end": 10,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "NumericLiteral",
|
|
||||||
"start": 8,
|
|
||||||
"end": 9,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"rawValue": 1,
|
|
||||||
"raw": "1"
|
|
||||||
},
|
|
||||||
"value": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"leadingComments": [
|
|
||||||
{
|
|
||||||
"type": "CommentLine",
|
|
||||||
"value": " One",
|
|
||||||
"start": 0,
|
|
||||||
"end": 6,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 6
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"trailingComments": [
|
|
||||||
{
|
|
||||||
"type": "CommentBlock",
|
|
||||||
"value": " Two ",
|
|
||||||
"start": 13,
|
|
||||||
"end": 22,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 9
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 23,
|
|
||||||
"end": 27,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 5,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 5,
|
|
||||||
"column": 4
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "ParenthesizedExpression",
|
|
||||||
"start": 23,
|
|
||||||
"end": 26,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 5,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 5,
|
|
||||||
"column": 3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "NumericLiteral",
|
|
||||||
"start": 24,
|
|
||||||
"end": 25,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 5,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 5,
|
|
||||||
"column": 2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"rawValue": 2,
|
|
||||||
"raw": "2"
|
|
||||||
},
|
|
||||||
"value": 2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"leadingComments": [
|
|
||||||
{
|
|
||||||
"type": "CommentBlock",
|
|
||||||
"value": " Two ",
|
|
||||||
"start": 13,
|
|
||||||
"end": 22,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 9
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 29,
|
|
||||||
"end": 48,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 7,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 10,
|
|
||||||
"column": 2
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "ParenthesizedExpression",
|
|
||||||
"start": 29,
|
|
||||||
"end": 47,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 7,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 10,
|
|
||||||
"column": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "NumericLiteral",
|
|
||||||
"start": 44,
|
|
||||||
"end": 45,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 9,
|
|
||||||
"column": 2
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 9,
|
|
||||||
"column": 3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"rawValue": 3,
|
|
||||||
"raw": "3"
|
|
||||||
},
|
|
||||||
"value": 3,
|
|
||||||
"leadingComments": [
|
|
||||||
{
|
|
||||||
"type": "CommentLine",
|
|
||||||
"value": " Three",
|
|
||||||
"start": 33,
|
|
||||||
"end": 41,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 8,
|
|
||||||
"column": 2
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 8,
|
|
||||||
"column": 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 50,
|
|
||||||
"end": 65,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 15
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "ParenthesizedExpression",
|
|
||||||
"start": 50,
|
|
||||||
"end": 64,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 14
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "NumericLiteral",
|
|
||||||
"start": 62,
|
|
||||||
"end": 63,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 12
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 13
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"rawValue": 4,
|
|
||||||
"raw": "4"
|
|
||||||
},
|
|
||||||
"value": 4,
|
|
||||||
"leadingComments": [
|
|
||||||
{
|
|
||||||
"type": "CommentBlock",
|
|
||||||
"value": " Four ",
|
|
||||||
"start": 51,
|
|
||||||
"end": 61,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 11
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"directives": []
|
|
||||||
},
|
|
||||||
"comments": [
|
|
||||||
{
|
|
||||||
"type": "CommentLine",
|
|
||||||
"value": " One",
|
|
||||||
"start": 0,
|
|
||||||
"end": 6,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 6
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "CommentBlock",
|
|
||||||
"value": " Two ",
|
|
||||||
"start": 13,
|
|
||||||
"end": 22,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 9
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "CommentLine",
|
|
||||||
"value": " Three",
|
|
||||||
"start": 33,
|
|
||||||
"end": 41,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 8,
|
|
||||||
"column": 2
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 8,
|
|
||||||
"column": 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "CommentBlock",
|
|
||||||
"value": " Four ",
|
|
||||||
"start": 51,
|
|
||||||
"end": 61,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 12,
|
|
||||||
"column": 11
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
({x}) = {x: 1};
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true,
|
|
||||||
"throws": "You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)"
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
("hello");
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true
|
|
||||||
}
|
|
||||||
@ -1,85 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "File",
|
|
||||||
"start": 0,
|
|
||||||
"end": 10,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 10
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"program": {
|
|
||||||
"type": "Program",
|
|
||||||
"start": 0,
|
|
||||||
"end": 10,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 10
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"sourceType": "script",
|
|
||||||
"interpreter": null,
|
|
||||||
"body": [
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 0,
|
|
||||||
"end": 10,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 10
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "ParenthesizedExpression",
|
|
||||||
"start": 0,
|
|
||||||
"end": 9,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 9
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "StringLiteral",
|
|
||||||
"start": 1,
|
|
||||||
"end": 8,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"rawValue": "hello",
|
|
||||||
"raw": "\"hello\""
|
|
||||||
},
|
|
||||||
"value": "hello"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"directives": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
([a]) = []
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true,
|
|
||||||
"throws": "You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)"
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
(foo) => {}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true
|
|
||||||
}
|
|
||||||
@ -1,104 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "File",
|
|
||||||
"start": 0,
|
|
||||||
"end": 11,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 11
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"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": "ArrowFunctionExpression",
|
|
||||||
"start": 0,
|
|
||||||
"end": 11,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 11
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"id": null,
|
|
||||||
"generator": false,
|
|
||||||
"async": false,
|
|
||||||
"params": [
|
|
||||||
{
|
|
||||||
"type": "Identifier",
|
|
||||||
"start": 1,
|
|
||||||
"end": 4,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 4
|
|
||||||
},
|
|
||||||
"identifierName": "foo"
|
|
||||||
},
|
|
||||||
"name": "foo"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"body": {
|
|
||||||
"type": "BlockStatement",
|
|
||||||
"start": 9,
|
|
||||||
"end": 11,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 9
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 11
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"body": [],
|
|
||||||
"directives": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"directives": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
var a;
|
|
||||||
(a) = {};
|
|
||||||
(a.b) = {};
|
|
||||||
(a['c']) = {};
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true
|
|
||||||
}
|
|
||||||
@ -1,392 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "File",
|
|
||||||
"start": 0,
|
|
||||||
"end": 43,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 14
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"program": {
|
|
||||||
"type": "Program",
|
|
||||||
"start": 0,
|
|
||||||
"end": 43,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 14
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"sourceType": "script",
|
|
||||||
"interpreter": null,
|
|
||||||
"body": [
|
|
||||||
{
|
|
||||||
"type": "VariableDeclaration",
|
|
||||||
"start": 0,
|
|
||||||
"end": 6,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 6
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"declarations": [
|
|
||||||
{
|
|
||||||
"type": "VariableDeclarator",
|
|
||||||
"start": 4,
|
|
||||||
"end": 5,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 4
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"id": {
|
|
||||||
"type": "Identifier",
|
|
||||||
"start": 4,
|
|
||||||
"end": 5,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 4
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 1,
|
|
||||||
"column": 5
|
|
||||||
},
|
|
||||||
"identifierName": "a"
|
|
||||||
},
|
|
||||||
"name": "a"
|
|
||||||
},
|
|
||||||
"init": null
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"kind": "var"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 7,
|
|
||||||
"end": 16,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 9
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "AssignmentExpression",
|
|
||||||
"start": 7,
|
|
||||||
"end": 15,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"operator": "=",
|
|
||||||
"left": {
|
|
||||||
"type": "ParenthesizedExpression",
|
|
||||||
"start": 7,
|
|
||||||
"end": 10,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "Identifier",
|
|
||||||
"start": 8,
|
|
||||||
"end": 9,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 2
|
|
||||||
},
|
|
||||||
"identifierName": "a"
|
|
||||||
},
|
|
||||||
"name": "a"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
"type": "ObjectExpression",
|
|
||||||
"start": 13,
|
|
||||||
"end": 15,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 6
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 2,
|
|
||||||
"column": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 17,
|
|
||||||
"end": 28,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 11
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "AssignmentExpression",
|
|
||||||
"start": 17,
|
|
||||||
"end": 27,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 10
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"operator": "=",
|
|
||||||
"left": {
|
|
||||||
"type": "ParenthesizedExpression",
|
|
||||||
"start": 17,
|
|
||||||
"end": 22,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "MemberExpression",
|
|
||||||
"start": 18,
|
|
||||||
"end": 21,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 4
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"object": {
|
|
||||||
"type": "Identifier",
|
|
||||||
"start": 18,
|
|
||||||
"end": 19,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 2
|
|
||||||
},
|
|
||||||
"identifierName": "a"
|
|
||||||
},
|
|
||||||
"name": "a"
|
|
||||||
},
|
|
||||||
"property": {
|
|
||||||
"type": "Identifier",
|
|
||||||
"start": 20,
|
|
||||||
"end": 21,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 3
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 4
|
|
||||||
},
|
|
||||||
"identifierName": "b"
|
|
||||||
},
|
|
||||||
"name": "b"
|
|
||||||
},
|
|
||||||
"computed": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
"type": "ObjectExpression",
|
|
||||||
"start": 25,
|
|
||||||
"end": 27,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 8
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 3,
|
|
||||||
"column": 10
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "ExpressionStatement",
|
|
||||||
"start": 29,
|
|
||||||
"end": 43,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 14
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "AssignmentExpression",
|
|
||||||
"start": 29,
|
|
||||||
"end": 42,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 13
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"operator": "=",
|
|
||||||
"left": {
|
|
||||||
"type": "ParenthesizedExpression",
|
|
||||||
"start": 29,
|
|
||||||
"end": 37,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 0
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 8
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"expression": {
|
|
||||||
"type": "MemberExpression",
|
|
||||||
"start": 30,
|
|
||||||
"end": 36,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 7
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"object": {
|
|
||||||
"type": "Identifier",
|
|
||||||
"start": 30,
|
|
||||||
"end": 31,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 1
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 2
|
|
||||||
},
|
|
||||||
"identifierName": "a"
|
|
||||||
},
|
|
||||||
"name": "a"
|
|
||||||
},
|
|
||||||
"property": {
|
|
||||||
"type": "StringLiteral",
|
|
||||||
"start": 32,
|
|
||||||
"end": 35,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 3
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 6
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"rawValue": "c",
|
|
||||||
"raw": "'c'"
|
|
||||||
},
|
|
||||||
"value": "c"
|
|
||||||
},
|
|
||||||
"computed": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
"type": "ObjectExpression",
|
|
||||||
"start": 40,
|
|
||||||
"end": 42,
|
|
||||||
"loc": {
|
|
||||||
"start": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 11
|
|
||||||
},
|
|
||||||
"end": {
|
|
||||||
"line": 4,
|
|
||||||
"column": 13
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"properties": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"directives": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
([a.a]) => 42
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true,
|
|
||||||
"throws": "Invalid left-hand side in arrow function parameters (1:2)"
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
-(5) ** 6;
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true,
|
|
||||||
"throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:1)"
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
(-5 ** 6);
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"createParenthesizedExpressions": true,
|
|
||||||
"throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)"
|
|
||||||
}
|
|
||||||
@ -124,4 +124,4 @@
|
|||||||
],
|
],
|
||||||
"directives": []
|
"directives": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,4 +160,4 @@
|
|||||||
],
|
],
|
||||||
"directives": []
|
"directives": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,4 +156,4 @@
|
|||||||
],
|
],
|
||||||
"directives": []
|
"directives": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,4 +124,4 @@
|
|||||||
],
|
],
|
||||||
"directives": []
|
"directives": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,14 +78,6 @@ export interface ParserOptions {
|
|||||||
* Adds all parsed tokens to a tokens property on the File node.
|
* Adds all parsed tokens to a tokens property on the File node.
|
||||||
*/
|
*/
|
||||||
tokens?: boolean;
|
tokens?: boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* By default, the parser adds information about parentheses by setting
|
|
||||||
* `extra.parenthesized` to `true` as needed.
|
|
||||||
* When this option is `true` the parser creates `ParenthesizedExpression`
|
|
||||||
* AST nodes instead of using the `extra` property.
|
|
||||||
*/
|
|
||||||
createParenthesizedExpressions?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ParserPlugin =
|
export type ParserPlugin =
|
||||||
|
|||||||
@ -102,10 +102,6 @@ export function SequenceExpression() {
|
|||||||
.getTypeAnnotation();
|
.getTypeAnnotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ParenthesizedExpression() {
|
|
||||||
return this.get("expression").getTypeAnnotation();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AssignmentExpression() {
|
export function AssignmentExpression() {
|
||||||
return this.get("right").getTypeAnnotation();
|
return this.get("right").getTypeAnnotation();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -162,12 +162,6 @@ export function assertSequenceExpression(
|
|||||||
): void {
|
): void {
|
||||||
assert("SequenceExpression", node, opts);
|
assert("SequenceExpression", node, opts);
|
||||||
}
|
}
|
||||||
export function assertParenthesizedExpression(
|
|
||||||
node: Object,
|
|
||||||
opts?: Object = {},
|
|
||||||
): void {
|
|
||||||
assert("ParenthesizedExpression", node, opts);
|
|
||||||
}
|
|
||||||
export function assertSwitchCase(node: Object, opts?: Object = {}): void {
|
export function assertSwitchCase(node: Object, opts?: Object = {}): void {
|
||||||
assert("SwitchCase", node, opts);
|
assert("SwitchCase", node, opts);
|
||||||
}
|
}
|
||||||
@ -660,6 +654,12 @@ export function assertJSXClosingFragment(
|
|||||||
export function assertNoop(node: Object, opts?: Object = {}): void {
|
export function assertNoop(node: Object, opts?: Object = {}): void {
|
||||||
assert("Noop", node, opts);
|
assert("Noop", node, opts);
|
||||||
}
|
}
|
||||||
|
export function assertParenthesizedExpression(
|
||||||
|
node: Object,
|
||||||
|
opts?: Object = {},
|
||||||
|
): void {
|
||||||
|
assert("ParenthesizedExpression", node, opts);
|
||||||
|
}
|
||||||
export function assertAwaitExpression(node: Object, opts?: Object = {}): void {
|
export function assertAwaitExpression(node: Object, opts?: Object = {}): void {
|
||||||
assert("AwaitExpression", node, opts);
|
assert("AwaitExpression", node, opts);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -161,10 +161,6 @@ export function SequenceExpression(...args: Array<any>): Object {
|
|||||||
return builder("SequenceExpression", ...args);
|
return builder("SequenceExpression", ...args);
|
||||||
}
|
}
|
||||||
export { SequenceExpression as sequenceExpression };
|
export { SequenceExpression as sequenceExpression };
|
||||||
export function ParenthesizedExpression(...args: Array<any>): Object {
|
|
||||||
return builder("ParenthesizedExpression", ...args);
|
|
||||||
}
|
|
||||||
export { ParenthesizedExpression as parenthesizedExpression };
|
|
||||||
export function SwitchCase(...args: Array<any>): Object {
|
export function SwitchCase(...args: Array<any>): Object {
|
||||||
return builder("SwitchCase", ...args);
|
return builder("SwitchCase", ...args);
|
||||||
}
|
}
|
||||||
@ -596,6 +592,10 @@ export function Noop(...args: Array<any>): Object {
|
|||||||
return builder("Noop", ...args);
|
return builder("Noop", ...args);
|
||||||
}
|
}
|
||||||
export { Noop as noop };
|
export { Noop as noop };
|
||||||
|
export function ParenthesizedExpression(...args: Array<any>): Object {
|
||||||
|
return builder("ParenthesizedExpression", ...args);
|
||||||
|
}
|
||||||
|
export { ParenthesizedExpression as parenthesizedExpression };
|
||||||
export function AwaitExpression(...args: Array<any>): Object {
|
export function AwaitExpression(...args: Array<any>): Object {
|
||||||
return builder("AwaitExpression", ...args);
|
return builder("AwaitExpression", ...args);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -731,16 +731,6 @@ defineType("SequenceExpression", {
|
|||||||
aliases: ["Expression"],
|
aliases: ["Expression"],
|
||||||
});
|
});
|
||||||
|
|
||||||
defineType("ParenthesizedExpression", {
|
|
||||||
visitor: ["expression"],
|
|
||||||
aliases: ["Expression", "ExpressionWrapper"],
|
|
||||||
fields: {
|
|
||||||
expression: {
|
|
||||||
validate: assertNodeType("Expression"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
defineType("SwitchCase", {
|
defineType("SwitchCase", {
|
||||||
visitor: ["test", "consequent"],
|
visitor: ["test", "consequent"],
|
||||||
fields: {
|
fields: {
|
||||||
|
|||||||
@ -1,6 +1,16 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import defineType from "./utils";
|
import defineType, { assertNodeType } from "./utils";
|
||||||
|
|
||||||
defineType("Noop", {
|
defineType("Noop", {
|
||||||
visitor: [],
|
visitor: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineType("ParenthesizedExpression", {
|
||||||
|
visitor: ["expression"],
|
||||||
|
aliases: ["Expression", "ExpressionWrapper"],
|
||||||
|
fields: {
|
||||||
|
expression: {
|
||||||
|
validate: assertNodeType("Expression"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
@ -551,23 +551,6 @@ export function isSequenceExpression(node: ?Object, opts?: Object): boolean {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
export function isParenthesizedExpression(
|
|
||||||
node: ?Object,
|
|
||||||
opts?: Object,
|
|
||||||
): boolean {
|
|
||||||
if (!node) return false;
|
|
||||||
|
|
||||||
const nodeType = node.type;
|
|
||||||
if (nodeType === "ParenthesizedExpression") {
|
|
||||||
if (typeof opts === "undefined") {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return shallowEqual(node, opts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
export function isSwitchCase(node: ?Object, opts?: Object): boolean {
|
export function isSwitchCase(node: ?Object, opts?: Object): boolean {
|
||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
|
|
||||||
@ -2093,6 +2076,23 @@ export function isNoop(node: ?Object, opts?: Object): boolean {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
export function isParenthesizedExpression(
|
||||||
|
node: ?Object,
|
||||||
|
opts?: Object,
|
||||||
|
): boolean {
|
||||||
|
if (!node) return false;
|
||||||
|
|
||||||
|
const nodeType = node.type;
|
||||||
|
if (nodeType === "ParenthesizedExpression") {
|
||||||
|
if (typeof opts === "undefined") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return shallowEqual(node, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
export function isAwaitExpression(node: ?Object, opts?: Object): boolean {
|
export function isAwaitExpression(node: ?Object, opts?: Object): boolean {
|
||||||
if (!node) return false;
|
if (!node) return false;
|
||||||
|
|
||||||
@ -3242,7 +3242,6 @@ export function isExpression(node: ?Object, opts?: Object): boolean {
|
|||||||
"NewExpression" === nodeType ||
|
"NewExpression" === nodeType ||
|
||||||
"ObjectExpression" === nodeType ||
|
"ObjectExpression" === nodeType ||
|
||||||
"SequenceExpression" === nodeType ||
|
"SequenceExpression" === nodeType ||
|
||||||
"ParenthesizedExpression" === nodeType ||
|
|
||||||
"ThisExpression" === nodeType ||
|
"ThisExpression" === nodeType ||
|
||||||
"UnaryExpression" === nodeType ||
|
"UnaryExpression" === nodeType ||
|
||||||
"UpdateExpression" === nodeType ||
|
"UpdateExpression" === nodeType ||
|
||||||
@ -3256,6 +3255,7 @@ export function isExpression(node: ?Object, opts?: Object): boolean {
|
|||||||
"TypeCastExpression" === nodeType ||
|
"TypeCastExpression" === nodeType ||
|
||||||
"JSXElement" === nodeType ||
|
"JSXElement" === nodeType ||
|
||||||
"JSXFragment" === nodeType ||
|
"JSXFragment" === nodeType ||
|
||||||
|
"ParenthesizedExpression" === nodeType ||
|
||||||
"AwaitExpression" === nodeType ||
|
"AwaitExpression" === nodeType ||
|
||||||
"BindExpression" === nodeType ||
|
"BindExpression" === nodeType ||
|
||||||
"OptionalMemberExpression" === nodeType ||
|
"OptionalMemberExpression" === nodeType ||
|
||||||
@ -3545,8 +3545,8 @@ export function isExpressionWrapper(node: ?Object, opts?: Object): boolean {
|
|||||||
if (
|
if (
|
||||||
nodeType === "ExpressionWrapper" ||
|
nodeType === "ExpressionWrapper" ||
|
||||||
"ExpressionStatement" === nodeType ||
|
"ExpressionStatement" === nodeType ||
|
||||||
"ParenthesizedExpression" === nodeType ||
|
"TypeCastExpression" === nodeType ||
|
||||||
"TypeCastExpression" === nodeType
|
"ParenthesizedExpression" === nodeType
|
||||||
) {
|
) {
|
||||||
if (typeof opts === "undefined") {
|
if (typeof opts === "undefined") {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user