From fc1ea7f496ae3d67a8f3ef1b6c7fdc4c73bee168 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Sat, 23 Feb 2019 04:48:05 -0500 Subject: [PATCH 01/58] Revert "Parenthesized expressions (#8025)" This reverts commit dd8b700a2c4c975584c7b2ea43023aa275c16167. --- .../create-parenthesized-expressions/input.js | 12 - .../options.json | 3 - .../output.js | 10 - packages/babel-generator/test/index.js | 1 - packages/babel-parser/ast/spec.md | 12 - packages/babel-parser/src/options.js | 4 - .../babel-parser/src/parser/expression.js | 41 +- packages/babel-parser/src/parser/lval.js | 17 - packages/babel-parser/src/parser/statement.js | 17 +- packages/babel-parser/src/types.js | 5 - .../create-parenthesized-expressions/input.js | 12 - .../options.json | 3 - .../output.json | 391 ----------------- .../fixtures/core/uncategorised/556/input.js | 1 - .../core/uncategorised/556/options.json | 4 - .../fixtures/core/uncategorised/557/input.js | 1 - .../core/uncategorised/557/options.json | 3 - .../core/uncategorised/557/output.json | 85 ---- .../fixtures/core/uncategorised/558/input.js | 1 - .../core/uncategorised/558/options.json | 4 - .../create-parenthesized-expressions/input.js | 1 - .../options.json | 3 - .../output.json | 104 ----- .../es2015/uncategorised/394/input.js | 4 - .../es2015/uncategorised/394/options.json | 3 - .../es2015/uncategorised/394/output.json | 392 ------------------ .../es2015/uncategorised/395/input.js | 1 - .../es2015/uncategorised/395/options.json | 4 - .../exponentiation-operator/15/input.js | 1 - .../exponentiation-operator/15/options.json | 4 - .../exponentiation-operator/16/input.js | 1 - .../exponentiation-operator/16/options.json | 4 - .../exponentiation-operator/2/output.json | 2 +- .../exponentiation-operator/7/output.json | 2 +- .../exponentiation-operator/8/output.json | 2 +- .../exponentiation-operator/9/output.json | 2 +- .../babel-parser/typings/babel-parser.d.ts | 8 - .../src/path/inference/inferers.js | 4 - .../src/asserts/generated/index.js | 12 +- .../src/builders/generated/index.js | 8 +- packages/babel-types/src/definitions/core.js | 10 - packages/babel-types/src/definitions/misc.js | 12 +- .../src/validators/generated/index.js | 40 +- 43 files changed, 65 insertions(+), 1186 deletions(-) delete mode 100644 packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/input.js delete mode 100644 packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/options.json delete mode 100644 packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/output.js delete mode 100644 packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/input.js delete mode 100644 packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/options.json delete mode 100644 packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/output.json delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/556/input.js delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/556/options.json delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/557/input.js delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/557/options.json delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/557/output.json delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/558/input.js delete mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/558/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/input.js delete mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/394/input.js delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/394/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/394/output.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/395/input.js delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/input.js delete mode 100644 packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/input.js delete mode 100644 packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json diff --git a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/input.js b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/input.js deleted file mode 100644 index 753a9cfbb2b5..000000000000 --- a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/input.js +++ /dev/null @@ -1,12 +0,0 @@ -// One -(1); - -/* Two */ -(2); - -( - // Three - 3 -); - -(/* Four */ 4); diff --git a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/options.json b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/options.json deleted file mode 100644 index 7c49b91ec9b2..000000000000 --- a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parserOpts": {"createParenthesizedExpressions": true} -} diff --git a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/output.js b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/output.js deleted file mode 100644 index b78500e8017f..000000000000 --- a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/output.js +++ /dev/null @@ -1,10 +0,0 @@ -// One -(1); -/* Two */ - -(2); -( // Three -3); -( -/* Four */ -4); \ No newline at end of file diff --git a/packages/babel-generator/test/index.js b/packages/babel-generator/test/index.js index fc20e8ad425e..c8b60b4051db 100644 --- a/packages/babel-generator/test/index.js +++ b/packages/babel-generator/test/index.js @@ -492,7 +492,6 @@ suites.forEach(function(testSuite) { strictMode: false, sourceType: "module", sourceMaps: !!task.sourceMap, - ...task.options.parserOpts, }); const options = { sourceFileName: path.relative(__dirname, actual.loc), diff --git a/packages/babel-parser/ast/spec.md b/packages/babel-parser/ast/spec.md index 31afe89aab02..716097280327 100644 --- a/packages/babel-parser/ast/spec.md +++ b/packages/babel-parser/ast/spec.md @@ -78,7 +78,6 @@ These are the core @babel/parser (babylon) AST node types. - [CallExpression](#callexpression) - [NewExpression](#newexpression) - [SequenceExpression](#sequenceexpression) - - [ParenthesizedExpression](#parenthesizedexpression) - [DoExpression](#doexpression) - [Template Literals](#template-literals) - [TemplateLiteral](#templateliteral) @@ -937,17 +936,6 @@ interface SequenceExpression <: Expression { 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 ```js diff --git a/packages/babel-parser/src/options.js b/packages/babel-parser/src/options.js index 347c1099b2a0..3bab7c04a287 100755 --- a/packages/babel-parser/src/options.js +++ b/packages/babel-parser/src/options.js @@ -19,7 +19,6 @@ export type Options = { strictMode: ?boolean, ranges: boolean, tokens: boolean, - createParenthesizedExpressions: boolean, }; export const defaultOptions: Options = { @@ -56,9 +55,6 @@ export const defaultOptions: Options = { ranges: false, // Adds all parsed tokens to a `tokens` property on the `File` node 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 diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 4e68ecc2e7f9..01f7dc03a2e1 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -185,28 +185,17 @@ export default class ExpressionParser extends LValParser { let patternErrorMsg; let elementName; - - const unwrap = node => { - return node.type === "ParenthesizedExpression" - ? unwrap(node.expression) - : node; - }; - const maybePattern = unwrap(left); - if (maybePattern.type === "ObjectPattern") { + if (left.type === "ObjectPattern") { patternErrorMsg = "`({a}) = 0` use `({a} = 0)`"; elementName = "property"; - } else if (maybePattern.type === "ArrayPattern") { + } else if (left.type === "ArrayPattern") { patternErrorMsg = "`([a]) = 0` use `([a] = 0)`"; elementName = "element"; } - if ( - patternErrorMsg && - ((left.extra && left.extra.parenthesized) || - left.type === "ParenthesizedExpression") - ) { + if (patternErrorMsg && left.extra && left.extra.parenthesized) { this.raise( - maybePattern.start, + left.start, `You're trying to assign to a parenthesized expression, eg. instead of ${patternErrorMsg}`, ); } @@ -320,8 +309,7 @@ export default class ExpressionParser extends LValParser { if ( operator === "**" && left.type === "UnaryExpression" && - (this.options.createParenthesizedExpressions || - !(left.extra && left.extra.parenthesized)) + !(left.extra && left.extra.parenthesized) ) { this.raise( left.argument.start, @@ -1167,6 +1155,13 @@ export default class ExpressionParser extends LValParser { 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 { const startPos = this.state.start; const startLoc = this.state.startLoc; @@ -1277,16 +1272,10 @@ export default class ExpressionParser extends LValParser { val = exprList[0]; } - if (!this.options.createParenthesizedExpressions) { - this.addExtra(val, "parenthesized", true); - this.addExtra(val, "parenStart", startPos); - return val; - } + this.addExtra(val, "parenthesized", true); + this.addExtra(val, "parenStart", startPos); - const parenExpression = this.startNodeAt(startPos, startLoc); - parenExpression.expression = val; - this.finishNode(parenExpression, "ParenthesizedExpression"); - return parenExpression; + return val; } shouldParseArrow(): boolean { diff --git a/packages/babel-parser/src/parser/lval.js b/packages/babel-parser/src/parser/lval.js index d200bc7c07e8..6b9e6c6ac979 100644 --- a/packages/babel-parser/src/parser/lval.js +++ b/packages/babel-parser/src/parser/lval.js @@ -92,14 +92,6 @@ export default class LValParser extends NodeUtils { } break; - case "ParenthesizedExpression": - node.expression = this.toAssignable( - node.expression, - isBinding, - contextDescription, - ); - break; - case "MemberExpression": if (!isBinding) break; @@ -415,15 +407,6 @@ export default class LValParser extends NodeUtils { this.checkLVal(expr.argument, isBinding, checkClashes, "rest element"); break; - case "ParenthesizedExpression": - this.checkLVal( - expr.expression, - isBinding, - checkClashes, - "parenthesized expression", - ); - break; - default: { const message = (isBinding diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 35a291d08b9e..88d6555d5f30 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -426,13 +426,6 @@ export default class StatementParser extends ExpressionParser { 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 { this.next(); this.state.labels.push(loopLabel); @@ -449,7 +442,7 @@ export default class StatementParser extends ExpressionParser { this.state.labels.pop(); this.expect(tt._while); - node.test = this.parseHeaderExpression(); + node.test = this.parseParenExpression(); this.eat(tt.semi); return this.finishNode(node, "DoWhileStatement"); } @@ -538,7 +531,7 @@ export default class StatementParser extends ExpressionParser { parseIfStatement(node: N.IfStatement): N.IfStatement { this.next(); - node.test = this.parseHeaderExpression(); + node.test = this.parseParenExpression(); node.consequent = this.parseStatement("if"); node.alternate = this.eat(tt._else) ? this.parseStatement("if") : null; return this.finishNode(node, "IfStatement"); @@ -567,7 +560,7 @@ export default class StatementParser extends ExpressionParser { parseSwitchStatement(node: N.SwitchStatement): N.SwitchStatement { this.next(); - node.discriminant = this.parseHeaderExpression(); + node.discriminant = this.parseParenExpression(); const cases = (node.cases = []); this.expect(tt.braceL); this.state.labels.push(switchLabel); @@ -676,7 +669,7 @@ export default class StatementParser extends ExpressionParser { parseWhileStatement(node: N.WhileStatement): N.WhileStatement { this.next(); - node.test = this.parseHeaderExpression(); + node.test = this.parseParenExpression(); this.state.labels.push(loopLabel); node.body = @@ -698,7 +691,7 @@ export default class StatementParser extends ExpressionParser { this.raise(this.state.start, "'with' in strict mode"); } this.next(); - node.object = this.parseHeaderExpression(); + node.object = this.parseParenExpression(); node.body = // For the smartPipelines plugin: diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index fe8e7070590e..06e5a03a71d8 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -566,11 +566,6 @@ export type SequenceExpression = NodeBase & { expressions: $ReadOnlyArray, }; -export type ParenthesizedExpression = NodeBase & { - type: "ParenthesizedExpression", - expression: Expression, -}; - // Pipelines export type PipelineBody = NodeBase & { diff --git a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/input.js b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/input.js deleted file mode 100644 index 753a9cfbb2b5..000000000000 --- a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/input.js +++ /dev/null @@ -1,12 +0,0 @@ -// One -(1); - -/* Two */ -(2); - -( - // Three - 3 -); - -(/* Four */ 4); diff --git a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/options.json b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/options.json deleted file mode 100644 index 0861962d889d..000000000000 --- a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "createParenthesizedExpressions": true -} diff --git a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/output.json b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/output.json deleted file mode 100644 index 761463790803..000000000000 --- a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/output.json +++ /dev/null @@ -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 - } - } - } - ] -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/556/input.js b/packages/babel-parser/test/fixtures/core/uncategorised/556/input.js deleted file mode 100644 index 13cfa4015d22..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/556/input.js +++ /dev/null @@ -1 +0,0 @@ -({x}) = {x: 1}; diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json deleted file mode 100644 index eff49cbfba64..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json +++ /dev/null @@ -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)" -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/557/input.js b/packages/babel-parser/test/fixtures/core/uncategorised/557/input.js deleted file mode 100644 index 40d925520dfa..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/557/input.js +++ /dev/null @@ -1 +0,0 @@ -("hello"); diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/557/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/557/options.json deleted file mode 100644 index 0861962d889d..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/557/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "createParenthesizedExpressions": true -} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/557/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/557/output.json deleted file mode 100644 index b1f49f00e99f..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/557/output.json +++ /dev/null @@ -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": [] - } -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/558/input.js b/packages/babel-parser/test/fixtures/core/uncategorised/558/input.js deleted file mode 100644 index 2cf717d47db3..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/558/input.js +++ /dev/null @@ -1 +0,0 @@ -([a]) = [] diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json deleted file mode 100644 index f37c4bc95c57..000000000000 --- a/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json +++ /dev/null @@ -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)" -} diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/input.js b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/input.js deleted file mode 100644 index 6626a35389c8..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/input.js +++ /dev/null @@ -1 +0,0 @@ -(foo) => {} diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/options.json deleted file mode 100644 index 0861962d889d..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "createParenthesizedExpressions": true -} diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/output.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/output.json deleted file mode 100644 index 09568c70bbb9..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/output.json +++ /dev/null @@ -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": [] - } -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/input.js deleted file mode 100644 index d6a05dcf09c2..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/input.js +++ /dev/null @@ -1,4 +0,0 @@ -var a; -(a) = {}; -(a.b) = {}; -(a['c']) = {}; diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/options.json deleted file mode 100644 index 0861962d889d..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "createParenthesizedExpressions": true -} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/output.json deleted file mode 100644 index 3eccd63cbd63..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/output.json +++ /dev/null @@ -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": [] - } -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/input.js deleted file mode 100644 index 874dec75a9cc..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/input.js +++ /dev/null @@ -1 +0,0 @@ -([a.a]) => 42 \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json deleted file mode 100644 index db72a6af957d..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "createParenthesizedExpressions": true, - "throws": "Invalid left-hand side in arrow function parameters (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/input.js b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/input.js deleted file mode 100644 index 63fce35a8a19..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/input.js +++ /dev/null @@ -1 +0,0 @@ --(5) ** 6; diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json deleted file mode 100644 index c694133bf2b1..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "createParenthesizedExpressions": true, - "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:1)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/input.js b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/input.js deleted file mode 100644 index 47b91d35a849..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/input.js +++ /dev/null @@ -1 +0,0 @@ -(-5 ** 6); diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json deleted file mode 100644 index 19687fbe197a..000000000000 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "createParenthesizedExpressions": true, - "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)" -} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/2/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/2/output.json index e840aecbd18a..e4e9ecd32a5d 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/2/output.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/2/output.json @@ -124,4 +124,4 @@ ], "directives": [] } -} +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/7/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/7/output.json index 2fb85f363b06..c4f295eacffd 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/7/output.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/7/output.json @@ -160,4 +160,4 @@ ], "directives": [] } -} +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/8/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/8/output.json index 56c71d7d2533..fd863ac0f6f6 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/8/output.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/8/output.json @@ -156,4 +156,4 @@ ], "directives": [] } -} +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/9/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/9/output.json index 2691c6433738..c3f4e42e1c0c 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/9/output.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/9/output.json @@ -124,4 +124,4 @@ ], "directives": [] } -} +} \ No newline at end of file diff --git a/packages/babel-parser/typings/babel-parser.d.ts b/packages/babel-parser/typings/babel-parser.d.ts index deba6be0e6a7..b3f745f61a93 100644 --- a/packages/babel-parser/typings/babel-parser.d.ts +++ b/packages/babel-parser/typings/babel-parser.d.ts @@ -78,14 +78,6 @@ export interface ParserOptions { * Adds all parsed tokens to a tokens property on the File node. */ 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 = diff --git a/packages/babel-traverse/src/path/inference/inferers.js b/packages/babel-traverse/src/path/inference/inferers.js index fb9a467b1f64..2f8ab658389b 100644 --- a/packages/babel-traverse/src/path/inference/inferers.js +++ b/packages/babel-traverse/src/path/inference/inferers.js @@ -102,10 +102,6 @@ export function SequenceExpression() { .getTypeAnnotation(); } -export function ParenthesizedExpression() { - return this.get("expression").getTypeAnnotation(); -} - export function AssignmentExpression() { return this.get("right").getTypeAnnotation(); } diff --git a/packages/babel-types/src/asserts/generated/index.js b/packages/babel-types/src/asserts/generated/index.js index c0f94dc64281..890e3d6e8d3d 100644 --- a/packages/babel-types/src/asserts/generated/index.js +++ b/packages/babel-types/src/asserts/generated/index.js @@ -162,12 +162,6 @@ export function assertSequenceExpression( ): void { assert("SequenceExpression", node, opts); } -export function assertParenthesizedExpression( - node: Object, - opts?: Object = {}, -): void { - assert("ParenthesizedExpression", node, opts); -} export function assertSwitchCase(node: Object, opts?: Object = {}): void { assert("SwitchCase", node, opts); } @@ -660,6 +654,12 @@ export function assertJSXClosingFragment( export function assertNoop(node: Object, opts?: Object = {}): void { assert("Noop", node, opts); } +export function assertParenthesizedExpression( + node: Object, + opts?: Object = {}, +): void { + assert("ParenthesizedExpression", node, opts); +} export function assertAwaitExpression(node: Object, opts?: Object = {}): void { assert("AwaitExpression", node, opts); } diff --git a/packages/babel-types/src/builders/generated/index.js b/packages/babel-types/src/builders/generated/index.js index 3a227b735e9d..a77b43cbb613 100644 --- a/packages/babel-types/src/builders/generated/index.js +++ b/packages/babel-types/src/builders/generated/index.js @@ -161,10 +161,6 @@ export function SequenceExpression(...args: Array): Object { return builder("SequenceExpression", ...args); } export { SequenceExpression as sequenceExpression }; -export function ParenthesizedExpression(...args: Array): Object { - return builder("ParenthesizedExpression", ...args); -} -export { ParenthesizedExpression as parenthesizedExpression }; export function SwitchCase(...args: Array): Object { return builder("SwitchCase", ...args); } @@ -596,6 +592,10 @@ export function Noop(...args: Array): Object { return builder("Noop", ...args); } export { Noop as noop }; +export function ParenthesizedExpression(...args: Array): Object { + return builder("ParenthesizedExpression", ...args); +} +export { ParenthesizedExpression as parenthesizedExpression }; export function AwaitExpression(...args: Array): Object { return builder("AwaitExpression", ...args); } diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index 5f240992a49a..a92e8d2725b8 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -731,16 +731,6 @@ defineType("SequenceExpression", { aliases: ["Expression"], }); -defineType("ParenthesizedExpression", { - visitor: ["expression"], - aliases: ["Expression", "ExpressionWrapper"], - fields: { - expression: { - validate: assertNodeType("Expression"), - }, - }, -}); - defineType("SwitchCase", { visitor: ["test", "consequent"], fields: { diff --git a/packages/babel-types/src/definitions/misc.js b/packages/babel-types/src/definitions/misc.js index 6bc22babc05f..2fc1334aac61 100644 --- a/packages/babel-types/src/definitions/misc.js +++ b/packages/babel-types/src/definitions/misc.js @@ -1,6 +1,16 @@ // @flow -import defineType from "./utils"; +import defineType, { assertNodeType } from "./utils"; defineType("Noop", { visitor: [], }); + +defineType("ParenthesizedExpression", { + visitor: ["expression"], + aliases: ["Expression", "ExpressionWrapper"], + fields: { + expression: { + validate: assertNodeType("Expression"), + }, + }, +}); diff --git a/packages/babel-types/src/validators/generated/index.js b/packages/babel-types/src/validators/generated/index.js index 972d398297b2..ab746105189c 100644 --- a/packages/babel-types/src/validators/generated/index.js +++ b/packages/babel-types/src/validators/generated/index.js @@ -551,23 +551,6 @@ export function isSequenceExpression(node: ?Object, opts?: Object): boolean { 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 { if (!node) return false; @@ -2093,6 +2076,23 @@ export function isNoop(node: ?Object, opts?: Object): boolean { 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 { if (!node) return false; @@ -3242,7 +3242,6 @@ export function isExpression(node: ?Object, opts?: Object): boolean { "NewExpression" === nodeType || "ObjectExpression" === nodeType || "SequenceExpression" === nodeType || - "ParenthesizedExpression" === nodeType || "ThisExpression" === nodeType || "UnaryExpression" === nodeType || "UpdateExpression" === nodeType || @@ -3256,6 +3255,7 @@ export function isExpression(node: ?Object, opts?: Object): boolean { "TypeCastExpression" === nodeType || "JSXElement" === nodeType || "JSXFragment" === nodeType || + "ParenthesizedExpression" === nodeType || "AwaitExpression" === nodeType || "BindExpression" === nodeType || "OptionalMemberExpression" === nodeType || @@ -3545,8 +3545,8 @@ export function isExpressionWrapper(node: ?Object, opts?: Object): boolean { if ( nodeType === "ExpressionWrapper" || "ExpressionStatement" === nodeType || - "ParenthesizedExpression" === nodeType || - "TypeCastExpression" === nodeType + "TypeCastExpression" === nodeType || + "ParenthesizedExpression" === nodeType ) { if (typeof opts === "undefined") { return true; From 4540f2653ba2056b2f996926c26035b926c5b6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 25 Feb 2019 19:18:44 +0100 Subject: [PATCH 02/58] Update CHAMGELOG.md using the "Trigger GitHub release" action (#9561) Update CHANGELOG.md using the "Trigger GitHub release" action --- .../actions/trigger-github-release/Dockerfile | 1 + .../trigger-github-release/entrypoint.sh | 20 ++++++++---- .../update-changelog.js | 31 +++++++++++++++++++ .github/main.workflow | 5 +++ CHANGELOG.md | 3 ++ 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 .github/actions/trigger-github-release/update-changelog.js diff --git a/.github/actions/trigger-github-release/Dockerfile b/.github/actions/trigger-github-release/Dockerfile index 69b3cb60f5e8..c7e17c775bae 100644 --- a/.github/actions/trigger-github-release/Dockerfile +++ b/.github/actions/trigger-github-release/Dockerfile @@ -12,6 +12,7 @@ ADD entrypoint.sh /action/entrypoint.sh ADD package.json /action/package.json ADD package-lock.json /action/package-lock.json ADD release.js /action/release.js +ADD update-changelog.js /action/update-changelog.js RUN chmod +x /action/entrypoint.sh diff --git a/.github/actions/trigger-github-release/entrypoint.sh b/.github/actions/trigger-github-release/entrypoint.sh index c5fcecaffb52..11c7f193e359 100755 --- a/.github/actions/trigger-github-release/entrypoint.sh +++ b/.github/actions/trigger-github-release/entrypoint.sh @@ -5,21 +5,18 @@ set -e echo "INFO: Installing action dependencies..." (cd /action; npm ci) -echo "INFO: Checking out current commit..." -git -c advice.detachedHead=false checkout $GITHUB_SHA - # GitHub doesn't support running actions on new tags yet: we need to run it on the commit. # For this reason, we can't be sure that the tag already exists. We can use the commit # message to create the tag. If the tag already exists locally, they won't conflict because # they have the same name and are on the same commit. echo "INFO: Getting release version..." -# current_tag=$(git describe --abbrev=0 --tags HEAD) -current_tag=$(git log --oneline --format=%B -1 HEAD) +# current_tag=$(git describe --abbrev=0 --tags $GITHUB_SHA) +current_tag=$(git log --oneline --format=%B -1 $GITHUB_SHA) echo "INFO: Creating new tag..." (git tag $current_tag $GITHUB_SHA) || echo "INFO: Tag already exists" -last_tag=$(git describe --abbrev=0 --tags HEAD^) +last_tag=$(git describe --abbrev=0 --tags $current_tag^) echo "INFO: New version is $current_tag; last version is $last_tag." echo "INFO: Generating the changelog..." @@ -35,4 +32,15 @@ changelog=$( echo "INFO: Publishing the new GitHub release..." echo "$changelog" | node /action/release $current_tag +echo "INFO: Updating CHANGELOG.md..." +echo "$changelog" | node /action/update-changelog + +echo "INFO: Committing changelog..." +git add CHANGELOG.md +git -c user.name="$COMMIT_AUTHOR_NAME" -c user.email="$COMMIT_AUTHOR_EMAIL" \ + commit -m "Add $current_tag to CHANGELOG.md [skip ci]" --no-verify --quiet + +echo "INFO: Pushing updates..." +git push "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" master + echo "INFO: Done! Don't forget to thank new contributors :)" diff --git a/.github/actions/trigger-github-release/update-changelog.js b/.github/actions/trigger-github-release/update-changelog.js new file mode 100644 index 000000000000..f7fdd7fbdedd --- /dev/null +++ b/.github/actions/trigger-github-release/update-changelog.js @@ -0,0 +1,31 @@ +"use strict"; + +const getStdin = require("get-stdin"); +const fs = require("fs").promises; +const path = require("path"); + +const { GITHUB_WORKSPACE } = process.env; + +const INSERTION_POINT = ""; +const CHANGELOG = path.resolve(GITHUB_WORKSPACE, "CHANGELOG.md"); + +main(); +async function main() { + let [stdin, changelog] = await Promise.all([ + getStdin(), + fs.readFile(CHANGELOG, "utf8"), + ]); + + if (!changelog.includes(INSERTION_POINT)) { + throw new Error(`Missing "${INSERTION_POINT}" in CHANGELOG.md`); + } + + // Remove committers + stdin = stdin.split("\n\n#### Committers")[0]; + changelog = changelog.replace( + INSERTION_POINT, + INSERTION_POINT + "\n" + stdin + ); + + await fs.writeFile(CHANGELOG, changelog); +} diff --git a/.github/main.workflow b/.github/main.workflow index bb88d85128d8..1a6c5a4058d2 100644 --- a/.github/main.workflow +++ b/.github/main.workflow @@ -7,6 +7,11 @@ action "Trigger GitHub release" { uses = "./.github/actions/trigger-github-release/" secrets = ["GITHUB_TOKEN"] + env = { + COMMIT_AUTHOR_NAME = "Babel Bot" + COMMIT_AUTHOR_EMAIL = "babel@hopeinsource.com" + } + # When GitHub Actions will support the "release" event for public # repositories, we won't need these checks anymore. needs = [ diff --git a/CHANGELOG.md b/CHANGELOG.md index ec87f4f4176a..b31d200c469b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ See [CHANGELOG - v4](/.github/CHANGELOG-v4.md), [CHANGELOG - v5](/.github/CHANGE See [CHANGELOG - 6to5](/.github/CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0.0-beta.29 version changelog. + + + ## v7.3.3 (2019-02-15) #### :eyeglasses: Spec Compliancy From 1f6454cc90fe33e0a32260871212e2f719f35741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 25 Feb 2019 19:29:12 +0100 Subject: [PATCH 03/58] v7.3.4 --- lerna.json | 2 +- packages/babel-core/package.json | 10 ++++---- packages/babel-generator/package.json | 6 ++--- .../package.json | 6 ++--- .../babel-helper-replace-supers/package.json | 6 ++--- packages/babel-parser/package.json | 2 +- .../package.json | 6 ++--- .../package.json | 4 ++-- .../package.json | 6 ++--- .../package.json | 4 ++-- .../package.json | 4 ++-- .../package.json | 6 ++--- .../package.json | 4 ++-- .../package.json | 4 ++-- .../package.json | 4 ++-- .../package.json | 10 ++++---- .../babel-preset-env-standalone/package.json | 6 ++--- packages/babel-preset-env/package.json | 16 ++++++------- packages/babel-runtime-corejs2/package.json | 2 +- packages/babel-runtime/package.json | 2 +- packages/babel-standalone/package.json | 24 +++++++++---------- packages/babel-traverse/package.json | 8 +++---- packages/babel-types/package.json | 6 ++--- 23 files changed, 74 insertions(+), 74 deletions(-) diff --git a/lerna.json b/lerna.json index ce4edadaea0a..806b98265731 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "7.3.3", + "version": "7.3.4", "changelog": { "repo": "babel/babel", "cacheDir": ".changelog", diff --git a/packages/babel-core/package.json b/packages/babel-core/package.json index a3820f8a760d..d07beafc0c8b 100644 --- a/packages/babel-core/package.json +++ b/packages/babel-core/package.json @@ -1,6 +1,6 @@ { "name": "@babel/core", - "version": "7.3.3", + "version": "7.3.4", "description": "Babel compiler core.", "main": "lib/index.js", "author": "Sebastian McKenzie ", @@ -34,12 +34,12 @@ }, "dependencies": { "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.3.3", + "@babel/generator": "^7.3.4", "@babel/helpers": "^7.2.0", - "@babel/parser": "^7.3.3", + "@babel/parser": "^7.3.4", "@babel/template": "^7.2.2", - "@babel/traverse": "^7.2.2", - "@babel/types": "^7.3.3", + "@babel/traverse": "^7.3.4", + "@babel/types": "^7.3.4", "convert-source-map": "^1.1.0", "debug": "^4.1.0", "json5": "^2.1.0", diff --git a/packages/babel-generator/package.json b/packages/babel-generator/package.json index ed5860c96e80..85fe45c82400 100644 --- a/packages/babel-generator/package.json +++ b/packages/babel-generator/package.json @@ -1,6 +1,6 @@ { "name": "@babel/generator", - "version": "7.3.3", + "version": "7.3.4", "description": "Turns an AST into code.", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -14,7 +14,7 @@ "lib" ], "dependencies": { - "@babel/types": "^7.3.3", + "@babel/types": "^7.3.4", "jsesc": "^2.5.1", "lodash": "^4.17.11", "source-map": "^0.5.0", @@ -22,6 +22,6 @@ }, "devDependencies": { "@babel/helper-fixtures": "^7.2.0", - "@babel/parser": "^7.3.3" + "@babel/parser": "^7.3.4" } } diff --git a/packages/babel-helper-create-class-features-plugin/package.json b/packages/babel-helper-create-class-features-plugin/package.json index 81056b4bef10..54f3d95dd86b 100644 --- a/packages/babel-helper-create-class-features-plugin/package.json +++ b/packages/babel-helper-create-class-features-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-create-class-features-plugin", - "version": "7.3.2", + "version": "7.3.4", "author": "The Babel Team (https://babeljs.io/team)", "license": "MIT", "description": "Compile class public and private fields, private methods and decorators to ES6", @@ -18,14 +18,14 @@ "@babel/helper-member-expression-to-functions": "^7.0.0", "@babel/helper-optimise-call-expression": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.2.3", + "@babel/helper-replace-supers": "^7.3.4", "@babel/helper-split-export-declaration": "^7.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0" }, "devDependencies": { - "@babel/core": "^7.2.2", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-helper-replace-supers/package.json b/packages/babel-helper-replace-supers/package.json index 309e682b3abe..1bc336576a3a 100644 --- a/packages/babel-helper-replace-supers/package.json +++ b/packages/babel-helper-replace-supers/package.json @@ -1,6 +1,6 @@ { "name": "@babel/helper-replace-supers", - "version": "7.2.3", + "version": "7.3.4", "description": "Helper function to replace supers", "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers", "license": "MIT", @@ -11,7 +11,7 @@ "dependencies": { "@babel/helper-member-expression-to-functions": "^7.0.0", "@babel/helper-optimise-call-expression": "^7.0.0", - "@babel/traverse": "^7.2.3", - "@babel/types": "^7.0.0" + "@babel/traverse": "^7.3.4", + "@babel/types": "^7.3.4" } } diff --git a/packages/babel-parser/package.json b/packages/babel-parser/package.json index 555014a52b19..cf31022a2ccc 100644 --- a/packages/babel-parser/package.json +++ b/packages/babel-parser/package.json @@ -1,6 +1,6 @@ { "name": "@babel/parser", - "version": "7.3.3", + "version": "7.3.4", "description": "A JavaScript parser", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", diff --git a/packages/babel-plugin-proposal-class-properties/package.json b/packages/babel-plugin-proposal-class-properties/package.json index 67b9c5dc1cb0..1ef6ae5a6465 100644 --- a/packages/babel-plugin-proposal-class-properties/package.json +++ b/packages/babel-plugin-proposal-class-properties/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-class-properties", - "version": "7.3.3", + "version": "7.3.4", "description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-class-properties", "license": "MIT", @@ -12,14 +12,14 @@ "babel-plugin" ], "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.3.0", + "@babel/helper-create-class-features-plugin": "^7.3.4", "@babel/helper-plugin-utils": "^7.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.3.3", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-proposal-object-rest-spread/package.json b/packages/babel-plugin-proposal-object-rest-spread/package.json index 5393072d5241..f3154500e817 100644 --- a/packages/babel-plugin-proposal-object-rest-spread/package.json +++ b/packages/babel-plugin-proposal-object-rest-spread/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-object-rest-spread", - "version": "7.3.2", + "version": "7.3.4", "description": "Compile object rest and spread to ES5", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-object-rest-spread", "license": "MIT", @@ -19,7 +19,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-proposal-private-methods/package.json b/packages/babel-plugin-proposal-private-methods/package.json index 19677ee72a73..eedfe8ca427b 100644 --- a/packages/babel-plugin-proposal-private-methods/package.json +++ b/packages/babel-plugin-proposal-private-methods/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-proposal-private-methods", - "version": "7.3.2", + "version": "7.3.4", "description": "This plugin transforms private class methods", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-private-methods", "license": "MIT", @@ -12,14 +12,14 @@ "babel-plugin" ], "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.3.2", + "@babel/helper-create-class-features-plugin": "^7.3.4", "@babel/helper-plugin-utils": "^7.0.0" }, "peerDependencies": { "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-async-to-generator/package.json b/packages/babel-plugin-transform-async-to-generator/package.json index 315b8fe9eb01..2ebabcc5e44d 100644 --- a/packages/babel-plugin-transform-async-to-generator/package.json +++ b/packages/babel-plugin-transform-async-to-generator/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-async-to-generator", - "version": "7.2.0", + "version": "7.3.4", "description": "Turn async functions into ES2015 generators", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-async-to-generator", "license": "MIT", @@ -20,7 +20,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-block-scoping/package.json b/packages/babel-plugin-transform-block-scoping/package.json index d33ff7e546ca..8c5e6ce4fb24 100644 --- a/packages/babel-plugin-transform-block-scoping/package.json +++ b/packages/babel-plugin-transform-block-scoping/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-block-scoping", - "version": "7.2.0", + "version": "7.3.4", "description": "Compile ES2015 block scoping (const and let) to ES5", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-block-scoping", "license": "MIT", @@ -19,7 +19,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-classes/package.json b/packages/babel-plugin-transform-classes/package.json index f11bd579cafc..6691ee8d0ea0 100644 --- a/packages/babel-plugin-transform-classes/package.json +++ b/packages/babel-plugin-transform-classes/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-classes", - "version": "7.3.3", + "version": "7.3.4", "description": "Compile ES2015 classes to ES5", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-classes", "license": "MIT", @@ -14,7 +14,7 @@ "@babel/helper-function-name": "^7.1.0", "@babel/helper-optimise-call-expression": "^7.0.0", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.1.0", + "@babel/helper-replace-supers": "^7.3.4", "@babel/helper-split-export-declaration": "^7.0.0", "globals": "^11.1.0" }, @@ -25,7 +25,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.3.3", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-flow-strip-types/package.json b/packages/babel-plugin-transform-flow-strip-types/package.json index 765f29d27d92..8a4d321097db 100644 --- a/packages/babel-plugin-transform-flow-strip-types/package.json +++ b/packages/babel-plugin-transform-flow-strip-types/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-flow-strip-types", - "version": "7.2.3", + "version": "7.3.4", "description": "Strip flow type annotations from your output code.", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-flow-strip-types", "license": "MIT", @@ -19,7 +19,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-modules-systemjs/package.json b/packages/babel-plugin-transform-modules-systemjs/package.json index c2ba50d968e5..90782b80892e 100644 --- a/packages/babel-plugin-transform-modules-systemjs/package.json +++ b/packages/babel-plugin-transform-modules-systemjs/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-modules-systemjs", - "version": "7.2.0", + "version": "7.3.4", "description": "This plugin transforms ES2015 modules to SystemJS", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-modules-systemjs", "license": "MIT", @@ -19,7 +19,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.2.0" } diff --git a/packages/babel-plugin-transform-regenerator/package.json b/packages/babel-plugin-transform-regenerator/package.json index a0b491feea4f..069c8bd78da9 100644 --- a/packages/babel-plugin-transform-regenerator/package.json +++ b/packages/babel-plugin-transform-regenerator/package.json @@ -2,7 +2,7 @@ "name": "@babel/plugin-transform-regenerator", "author": "Ben Newman ", "description": "Explode async and generator functions into a state machine.", - "version": "7.0.0", + "version": "7.3.4", "homepage": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-regenerator", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-regenerator", "main": "lib/index.js", @@ -17,7 +17,7 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.0.0", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0" } } diff --git a/packages/babel-plugin-transform-runtime/package.json b/packages/babel-plugin-transform-runtime/package.json index 932aad78f1a1..773794e3d57e 100644 --- a/packages/babel-plugin-transform-runtime/package.json +++ b/packages/babel-plugin-transform-runtime/package.json @@ -1,6 +1,6 @@ { "name": "@babel/plugin-transform-runtime", - "version": "7.2.0", + "version": "7.3.4", "description": "Externalise references to helpers and builtins, automatically polyfilling your code without polluting globals", "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime", "license": "MIT", @@ -21,12 +21,12 @@ "@babel/core": "^7.0.0-0" }, "devDependencies": { - "@babel/core": "^7.2.0", + "@babel/core": "^7.3.4", "@babel/helper-plugin-test-runner": "^7.0.0", "@babel/helpers": "^7.2.0", - "@babel/plugin-transform-runtime": "^7.2.0", - "@babel/preset-env": "^7.2.0", - "@babel/runtime": "^7.2.0", + "@babel/plugin-transform-runtime": "^7.3.4", + "@babel/preset-env": "^7.3.4", + "@babel/runtime": "^7.3.4", "@babel/template": "^7.0.0", "@babel/types": "7.0.0-beta.53" } diff --git a/packages/babel-preset-env-standalone/package.json b/packages/babel-preset-env-standalone/package.json index dd404a10a445..ece2257a407b 100644 --- a/packages/babel-preset-env-standalone/package.json +++ b/packages/babel-preset-env-standalone/package.json @@ -1,6 +1,6 @@ { "name": "@babel/preset-env-standalone", - "version": "7.3.3", + "version": "7.3.4", "description": "Standalone build of babel-prest-env for use in non-Node.js environments.", "main": "babel-preset-env.js", "files": [ @@ -12,8 +12,8 @@ "@babel/plugin-proposal-json-strings": "^7.0.0", "@babel/plugin-transform-named-capturing-groups-regex": "^7.3.0", "@babel/plugin-transform-new-target": "^7.0.0", - "@babel/preset-env": "^7.3.1", - "@babel/standalone": "^7.3.3" + "@babel/preset-env": "^7.3.4", + "@babel/standalone": "^7.3.4" }, "keywords": [ "babel", diff --git a/packages/babel-preset-env/package.json b/packages/babel-preset-env/package.json index 8106cdf0a094..234208b68a99 100644 --- a/packages/babel-preset-env/package.json +++ b/packages/babel-preset-env/package.json @@ -1,6 +1,6 @@ { "name": "@babel/preset-env", - "version": "7.3.1", + "version": "7.3.4", "description": "A Babel preset for each environment.", "author": "Henry Zhu ", "homepage": "https://babeljs.io/", @@ -18,7 +18,7 @@ "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-proposal-async-generator-functions": "^7.2.0", "@babel/plugin-proposal-json-strings": "^7.2.0", - "@babel/plugin-proposal-object-rest-spread": "^7.3.1", + "@babel/plugin-proposal-object-rest-spread": "^7.3.4", "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", "@babel/plugin-proposal-unicode-property-regex": "^7.2.0", "@babel/plugin-syntax-async-generators": "^7.2.0", @@ -26,10 +26,10 @@ "@babel/plugin-syntax-object-rest-spread": "^7.2.0", "@babel/plugin-syntax-optional-catch-binding": "^7.2.0", "@babel/plugin-transform-arrow-functions": "^7.2.0", - "@babel/plugin-transform-async-to-generator": "^7.2.0", + "@babel/plugin-transform-async-to-generator": "^7.3.4", "@babel/plugin-transform-block-scoped-functions": "^7.2.0", - "@babel/plugin-transform-block-scoping": "^7.2.0", - "@babel/plugin-transform-classes": "^7.2.0", + "@babel/plugin-transform-block-scoping": "^7.3.4", + "@babel/plugin-transform-classes": "^7.3.4", "@babel/plugin-transform-computed-properties": "^7.2.0", "@babel/plugin-transform-destructuring": "^7.2.0", "@babel/plugin-transform-dotall-regex": "^7.2.0", @@ -40,13 +40,13 @@ "@babel/plugin-transform-literals": "^7.2.0", "@babel/plugin-transform-modules-amd": "^7.2.0", "@babel/plugin-transform-modules-commonjs": "^7.2.0", - "@babel/plugin-transform-modules-systemjs": "^7.2.0", + "@babel/plugin-transform-modules-systemjs": "^7.3.4", "@babel/plugin-transform-modules-umd": "^7.2.0", "@babel/plugin-transform-named-capturing-groups-regex": "^7.3.0", "@babel/plugin-transform-new-target": "^7.0.0", "@babel/plugin-transform-object-super": "^7.2.0", "@babel/plugin-transform-parameters": "^7.2.0", - "@babel/plugin-transform-regenerator": "^7.0.0", + "@babel/plugin-transform-regenerator": "^7.3.4", "@babel/plugin-transform-shorthand-properties": "^7.2.0", "@babel/plugin-transform-spread": "^7.2.0", "@babel/plugin-transform-sticky-regex": "^7.2.0", @@ -63,7 +63,7 @@ }, "devDependencies": { "@babel/cli": "^7.2.3", - "@babel/core": "^7.2.0", + "@babel/core": "^7.3.4", "@babel/helper-fixtures": "^7.2.0", "@babel/helper-plugin-test-runner": "^7.0.0", "caniuse-db": "1.0.30000851", diff --git a/packages/babel-runtime-corejs2/package.json b/packages/babel-runtime-corejs2/package.json index 6bfa58204018..e2c4304aecac 100644 --- a/packages/babel-runtime-corejs2/package.json +++ b/packages/babel-runtime-corejs2/package.json @@ -1,6 +1,6 @@ { "name": "@babel/runtime-corejs2", - "version": "7.3.1", + "version": "7.3.4", "description": "babel's modular runtime helpers with core-js@2 polyfilling", "license": "MIT", "publishConfig": { diff --git a/packages/babel-runtime/package.json b/packages/babel-runtime/package.json index 678b6ae4d616..b0b406145355 100644 --- a/packages/babel-runtime/package.json +++ b/packages/babel-runtime/package.json @@ -1,6 +1,6 @@ { "name": "@babel/runtime", - "version": "7.3.1", + "version": "7.3.4", "description": "babel's modular runtime helpers", "license": "MIT", "publishConfig": { diff --git a/packages/babel-standalone/package.json b/packages/babel-standalone/package.json index 3fa63ee985b3..f3108bab07de 100644 --- a/packages/babel-standalone/package.json +++ b/packages/babel-standalone/package.json @@ -1,6 +1,6 @@ { "name": "@babel/standalone", - "version": "7.3.3", + "version": "7.3.4", "description": "Standalone build of Babel for use in non-Node.js environments.", "main": "babel.js", "files": [ @@ -9,11 +9,11 @@ "src" ], "devDependencies": { - "@babel/core": "^7.3.3", + "@babel/core": "^7.3.4", "@babel/helper-plugin-utils": "^7.0.0", "@babel/plugin-external-helpers": "^7.2.0", "@babel/plugin-proposal-async-generator-functions": "^7.2.0", - "@babel/plugin-proposal-class-properties": "^7.3.3", + "@babel/plugin-proposal-class-properties": "^7.3.4", "@babel/plugin-proposal-decorators": "^7.3.0", "@babel/plugin-proposal-do-expressions": "^7.2.0", "@babel/plugin-proposal-export-default-from": "^7.2.0", @@ -24,11 +24,11 @@ "@babel/plugin-proposal-logical-assignment-operators": "^7.2.0", "@babel/plugin-proposal-nullish-coalescing-operator": "^7.2.0", "@babel/plugin-proposal-numeric-separator": "^7.2.0", - "@babel/plugin-proposal-object-rest-spread": "^7.3.2", + "@babel/plugin-proposal-object-rest-spread": "^7.3.4", "@babel/plugin-proposal-optional-catch-binding": "^7.2.0", "@babel/plugin-proposal-optional-chaining": "^7.2.0", "@babel/plugin-proposal-pipeline-operator": "^7.3.2", - "@babel/plugin-proposal-private-methods": "^7.3.2", + "@babel/plugin-proposal-private-methods": "^7.3.4", "@babel/plugin-proposal-throw-expressions": "^7.2.0", "@babel/plugin-proposal-unicode-property-regex": "^7.2.0", "@babel/plugin-syntax-async-generators": "^7.2.0", @@ -48,17 +48,17 @@ "@babel/plugin-syntax-pipeline-operator": "^7.3.0", "@babel/plugin-syntax-typescript": "^7.3.3", "@babel/plugin-transform-arrow-functions": "^7.2.0", - "@babel/plugin-transform-async-to-generator": "^7.2.0", + "@babel/plugin-transform-async-to-generator": "^7.3.4", "@babel/plugin-transform-block-scoped-functions": "^7.2.0", - "@babel/plugin-transform-block-scoping": "^7.2.0", - "@babel/plugin-transform-classes": "^7.3.3", + "@babel/plugin-transform-block-scoping": "^7.3.4", + "@babel/plugin-transform-classes": "^7.3.4", "@babel/plugin-transform-computed-properties": "^7.2.0", "@babel/plugin-transform-destructuring": "^7.3.2", "@babel/plugin-transform-dotall-regex": "^7.2.0", "@babel/plugin-transform-duplicate-keys": "^7.2.0", "@babel/plugin-transform-exponentiation-operator": "^7.2.0", "@babel/plugin-transform-flow-comments": "^7.2.0", - "@babel/plugin-transform-flow-strip-types": "^7.2.3", + "@babel/plugin-transform-flow-strip-types": "^7.3.4", "@babel/plugin-transform-for-of": "^7.2.0", "@babel/plugin-transform-function-name": "^7.2.0", "@babel/plugin-transform-instanceof": "^7.2.0", @@ -67,7 +67,7 @@ "@babel/plugin-transform-member-expression-literals": "^7.2.0", "@babel/plugin-transform-modules-amd": "^7.2.0", "@babel/plugin-transform-modules-commonjs": "^7.2.0", - "@babel/plugin-transform-modules-systemjs": "^7.2.0", + "@babel/plugin-transform-modules-systemjs": "^7.3.4", "@babel/plugin-transform-modules-umd": "^7.2.0", "@babel/plugin-transform-new-target": "^7.0.0", "@babel/plugin-transform-object-assign": "^7.2.0", @@ -84,8 +84,8 @@ "@babel/plugin-transform-react-jsx-compat": "^7.2.0", "@babel/plugin-transform-react-jsx-self": "^7.2.0", "@babel/plugin-transform-react-jsx-source": "^7.2.0", - "@babel/plugin-transform-regenerator": "^7.0.0", - "@babel/plugin-transform-runtime": "^7.2.0", + "@babel/plugin-transform-regenerator": "^7.3.4", + "@babel/plugin-transform-runtime": "^7.3.4", "@babel/plugin-transform-shorthand-properties": "^7.2.0", "@babel/plugin-transform-spread": "^7.2.2", "@babel/plugin-transform-sticky-regex": "^7.2.0", diff --git a/packages/babel-traverse/package.json b/packages/babel-traverse/package.json index 993535f4aa4c..e71adbc215c1 100644 --- a/packages/babel-traverse/package.json +++ b/packages/babel-traverse/package.json @@ -1,6 +1,6 @@ { "name": "@babel/traverse", - "version": "7.2.3", + "version": "7.3.4", "description": "The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -12,11 +12,11 @@ "main": "lib/index.js", "dependencies": { "@babel/code-frame": "^7.0.0", - "@babel/generator": "^7.2.2", + "@babel/generator": "^7.3.4", "@babel/helper-function-name": "^7.1.0", "@babel/helper-split-export-declaration": "^7.0.0", - "@babel/parser": "^7.2.3", - "@babel/types": "^7.2.2", + "@babel/parser": "^7.3.4", + "@babel/types": "^7.3.4", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.11" diff --git a/packages/babel-types/package.json b/packages/babel-types/package.json index b88f576df2fd..f402356a1b03 100644 --- a/packages/babel-types/package.json +++ b/packages/babel-types/package.json @@ -1,6 +1,6 @@ { "name": "@babel/types", - "version": "7.3.3", + "version": "7.3.4", "description": "Babel Types is a Lodash-esque utility library for AST nodes", "author": "Sebastian McKenzie ", "homepage": "https://babeljs.io/", @@ -14,7 +14,7 @@ "to-fast-properties": "^2.0.0" }, "devDependencies": { - "@babel/generator": "^7.3.3", - "@babel/parser": "^7.3.3" + "@babel/generator": "^7.3.4", + "@babel/parser": "^7.3.4" } } From 918f149a6385f2c59fffabe7bb558724aacdb217 Mon Sep 17 00:00:00 2001 From: Babel Bot Date: Mon, 25 Feb 2019 18:37:14 +0000 Subject: [PATCH 04/58] Add v7.3.4 to CHANGELOG.md [skip ci] --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b31d200c469b..f0a65682a747 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,34 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0 +## v7.3.4 (2019-02-25) + +#### :bug: Bug Fix +* `babel-parser` + * [#9572](https://github.com/babel/babel/pull/9572) Fix TypeScript parsers missing token check (#9571) ([@elevatebart](https://github.com/elevatebart)) + * [#9521](https://github.com/babel/babel/pull/9521) Also check AssignmentPatterns for duplicate export name ([@danez](https://github.com/danez)) +* `babel-helper-create-class-features-plugin`, `babel-helper-replace-supers`, `babel-plugin-proposal-class-properties`, `babel-traverse` + * [#9508](https://github.com/babel/babel/pull/9508) Use correct "this" in static fields ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-preset-env` + * [#9566](https://github.com/babel/babel/pull/9566) Closes [#9465](https://github.com/babel/babel/issues/9465) ([@zloirock](https://github.com/zloirock)) +* `babel-types` + * [#9539](https://github.com/babel/babel/pull/9539) babel-types is* type checks accept null | undefiend as value TS type ([@ian-craig](https://github.com/ian-craig)) +* `babel-plugin-transform-block-scoping`, `babel-traverse` + * [#9532](https://github.com/babel/babel/pull/9532) Migrate some duplicate binding tests to traverse ([@danez](https://github.com/danez)) +* `babel-generator` + * [#9524](https://github.com/babel/babel/pull/9524) Fix typescript generator params ([@tanhauhau](https://github.com/tanhauhau)) + * [#9523](https://github.com/babel/babel/pull/9523) Fix flow babel-generator function parantheses ([@tanhauhau](https://github.com/tanhauhau)) + +#### :house: Internal +* Other + * [#9561](https://github.com/babel/babel/pull/9561) Update CHANGELOG.md using the "Trigger GitHub release" action ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) +* `babel-plugin-proposal-object-rest-spread`, `babel-plugin-transform-modules-systemjs` + * [#9541](https://github.com/babel/babel/pull/9541) Enable eqeqeq rule in eslint ([@danez](https://github.com/danez)) +* `babel-generator`, `babel-parser`, `babel-plugin-transform-flow-strip-types`, `babel-traverse` + * [#9522](https://github.com/babel/babel/pull/9522) Make tests spec compliant by avoiding duplicate declarations in input files ([@danez](https://github.com/danez)) +* `babel-plugin-transform-proto-to-assign` + * [#9533](https://github.com/babel/babel/pull/9533) Add import/no-extraneous-dependencies to ESLint ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) + ## v7.3.3 (2019-02-15) #### :eyeglasses: Spec Compliancy From a7391144b3db8cb3b360ecd6fb32a681e8ef9e98 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Mon, 25 Feb 2019 11:04:52 -0800 Subject: [PATCH 05/58] Introduce scope tracking in the parser (#9493) * Introduce scope tracking * Fix tests * Add new tests * Remove constructor-super check from transform as it is now in parser * Correctly handle class properties and class scope * Fix duplicate name check * Convert scope identifier storage to array * Enter a new scope in typescript module blocks * Add test for duplicate declaration * Rename error for duplicate exports * Treat class declarations as lexical declaration * Update whitelist * Add tests * Fix scope tracking for function declarations * Migrate try-catch duplicate error * Fix test * More tests * One more test * Make scope a separate class and fix review comments * Do not allow new.target in top scope arrow function * Correctly enter new scope for declare module and treat type aliases as lexical declarations * Tests for typescript scope tracking to not mark type aliases as duplicate * Fix flow scope tracking * Remove ident from test names as redundant * Add test case for var and function * Improve error messages * Improve literal regex --- .../fixtures/flow/declare-exports/input.js | 8 +- .../fixtures/flow/declare-exports/output.js | 8 +- .../fixtures/flow/def-site-variance/input.js | 8 +- .../fixtures/flow/def-site-variance/output.js | 8 +- .../test/fixtures/flow/internal-slot/input.js | 10 +- .../fixtures/flow/internal-slot/output.js | 12 +- .../flow/object-literal-types/input.js | 18 +- .../flow/object-literal-types/output.js | 18 +- .../fixtures/flow/opaque-type-alias/input.js | 2 +- .../fixtures/flow/opaque-type-alias/output.js | 2 +- .../test/fixtures/flow/type-alias/input.js | 2 +- .../test/fixtures/flow/type-alias/output.js | 2 +- packages/babel-parser/src/parser/base.js | 2 + .../babel-parser/src/parser/expression.js | 202 ++++--- packages/babel-parser/src/parser/index.js | 4 + packages/babel-parser/src/parser/lval.js | 35 +- packages/babel-parser/src/parser/statement.js | 291 +++++---- packages/babel-parser/src/parser/util.js | 18 +- packages/babel-parser/src/plugins/estree.js | 14 +- packages/babel-parser/src/plugins/flow.js | 44 +- .../babel-parser/src/plugins/typescript.js | 43 +- .../babel-parser/src/tokenizer/context.js | 2 +- packages/babel-parser/src/tokenizer/state.js | 6 +- packages/babel-parser/src/util/scope.js | 160 +++++ packages/babel-parser/src/util/scopeflags.js | 52 ++ .../fail/7/options.json | 2 +- .../invalid-fn-decl-inside-loop/options.json | 2 +- .../options.json | 2 +- .../scope/dupl-bind-catch-arr-destr/input.js | 3 + .../dupl-bind-catch-arr-destr/options.json | 3 + .../scope/dupl-bind-catch-dbl-let/input.js | 1 + .../dupl-bind-catch-dbl-let/options.json | 3 + .../core/scope/dupl-bind-catch-func/input.js | 4 + .../scope/dupl-bind-catch-func/options.json | 3 + .../scope/dupl-bind-catch-hang-func/input.js | 4 + .../dupl-bind-catch-hang-func/output.json | 207 +++++++ .../dupl-bind-catch-let-outside/input.js | 4 + .../dupl-bind-catch-let-outside/output.json | 169 ++++++ .../core/scope/dupl-bind-catch-let/input.js | 4 + .../scope/dupl-bind-catch-let/options.json | 3 + .../scope/dupl-bind-catch-obj-destr/input.js | 3 + .../dupl-bind-catch-obj-destr/options.json | 3 + .../dupl-bind-catch-var-arr-destr/input.js | 4 + .../options.json | 3 + .../scope/dupl-bind-catch-var-nested/input.js | 7 + .../dupl-bind-catch-var-nested/output.json | 254 ++++++++ .../dupl-bind-catch-var-obj-destr/input.js | 4 + .../options.json | 3 + .../dupl-bind-catch-var-outside/input.js | 4 + .../dupl-bind-catch-var-outside/output.json | 169 ++++++ .../core/scope/dupl-bind-catch-var/input.js | 4 + .../scope/dupl-bind-catch-var/output.json | 170 ++++++ .../core/scope/dupl-bind-class-class/input.js | 2 + .../scope/dupl-bind-class-class/options.json | 3 + .../core/scope/dupl-bind-class-const/input.js | 2 + .../scope/dupl-bind-class-const/options.json | 3 + .../core/scope/dupl-bind-class-func/input.js | 2 + .../scope/dupl-bind-class-func/options.json | 3 + .../core/scope/dupl-bind-class-let/input.js | 2 + .../scope/dupl-bind-class-let/options.json | 3 + .../core/scope/dupl-bind-class-var/input.js | 2 + .../scope/dupl-bind-class-var/options.json | 3 + .../core/scope/dupl-bind-const-const/input.js | 1 + .../scope/dupl-bind-const-const/options.json | 3 + .../core/scope/dupl-bind-func-gen/input.js | 1 + .../scope/dupl-bind-func-gen/options.json | 3 + .../dupl-bind-func-module-sloppy/input.js | 1 + .../dupl-bind-func-module-sloppy/options.json | 4 + .../core/scope/dupl-bind-func-module/input.js | 2 + .../scope/dupl-bind-func-module/options.json | 4 + .../dupl-bind-func-script-sloppy/input.js | 1 + .../dupl-bind-func-script-sloppy/options.json | 3 + .../dupl-bind-func-script-sloppy/output.json | 157 +++++ .../core/scope/dupl-bind-func-script/input.js | 2 + .../scope/dupl-bind-func-script/options.json | 3 + .../scope/dupl-bind-func-script/output.json | 139 +++++ .../scope/dupl-bind-func-var-sloppy/input.js | 4 + .../dupl-bind-func-var-sloppy/options.json | 3 + .../core/scope/dupl-bind-func-var/input.js | 2 + .../core/scope/dupl-bind-func-var/output.json | 157 +++++ .../core/scope/dupl-bind-gen-func/input.js | 1 + .../scope/dupl-bind-gen-func/options.json | 3 + .../scope/dupl-bind-gen-gen-script/input.js | 2 + .../dupl-bind-gen-gen-script/options.json | 3 + .../dupl-bind-gen-gen-script/output.json | 169 ++++++ .../core/scope/dupl-bind-let-let/input.js | 1 + .../core/scope/dupl-bind-let-let/options.json | 3 + .../scope/dupl-bind-nested-let-var/input.js | 4 + .../dupl-bind-nested-let-var/options.json | 3 + .../scope/dupl-bind-nested-var-let/input.js | 4 + .../dupl-bind-nested-var-let/output.json | 173 ++++++ .../core/scope/dupl-bind-var-var/input.js | 1 + .../core/scope/dupl-bind-var-var/output.json | 119 ++++ .../fixtures/core/scope/let-assign/input.js | 1 + .../core/scope/let-assign/output.json | 173 ++++++ .../core/uncategorised/401/options.json | 2 +- .../core/uncategorised/402/options.json | 2 +- .../core/uncategorised/403/options.json | 2 +- .../core/uncategorised/404/options.json | 2 +- .../core/uncategorised/514/options.json | 2 +- .../core/uncategorised/517/options.json | 2 +- .../core/uncategorised/518/options.json | 2 +- .../core/uncategorised/519/options.json | 2 +- .../options.json | 2 +- .../generators/invalid-hanging/input.js | 1 + .../generators/invalid-hanging/options.json | 3 + .../meta-properties/expression/input.js | 3 + .../meta-properties/expression/output.json | 186 ++++++ .../invalid-arrow-function/input.js | 3 + .../invalid-arrow-function/options.json | 3 + .../nested-arrow-function/input.js | 1 + .../nested-arrow-function/output.json | 171 ++++++ .../es2015/meta-properties/statement/input.js | 3 + .../meta-properties/statement/output.json | 152 +++++ .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../label-invalid-const/options.json | 2 +- .../label-invalid-func-async/options.json | 2 +- .../label-invalid-func-generator/options.json | 2 +- .../label-invalid-func-strict/options.json | 2 +- .../es2015/uncategorised/123/options.json | 3 + .../es2015/uncategorised/123/output.json | 243 -------- .../es2015/uncategorised/166/options.json | 3 + .../es2015/uncategorised/166/output.json | 177 ------ .../es2015/uncategorised/226/options.json | 2 +- .../es2015/uncategorised/228/options.json | 2 +- .../es2015/uncategorised/248/options.json | 2 +- .../es2015/uncategorised/280/options.json | 2 +- .../es2015/uncategorised/281/options.json | 2 +- .../es2015/uncategorised/329/options.json | 2 +- .../input.js | 9 + .../output.json | 552 +++++++++++++++++ .../array-pattern-default/options.json | 2 +- .../array-pattern/options.json | 2 +- .../arrow-function/options.json | 2 +- .../async-arrow-function/options.json | 2 +- .../async-function/options.json | 2 +- .../default/options.json | 2 +- .../generator-function/options.json | 2 +- .../generator-method/options.json | 2 +- .../simple-parameter-list/method/options.json | 2 +- .../object-pattern-default/options.json | 2 +- .../object-pattern/options.json | 2 +- .../simple-parameter-list/rest/options.json | 2 +- .../invalid-inside-loop/options.json | 2 +- .../es2018/object-rest-spread/11/options.json | 2 +- .../es2018/object-rest-spread/12/options.json | 2 +- .../es2018/object-rest-spread/13/options.json | 2 +- .../es2018/object-rest-spread/14/options.json | 2 +- .../es2018/object-rest-spread/15/options.json | 2 +- .../dupe-param/options.json | 2 +- .../invalid-dup-param/options.json | 2 +- .../dupe-param-1/options.json | 2 +- .../dupe-param-2/options.json | 2 +- .../dupe-param-3/options.json | 2 +- .../patterned-catch-dupe/input.js | 1 - .../patterned-catch-dupe/options.json | 3 - .../options.json | 2 +- .../invalid-duplicated-params/options.json | 2 +- .../invalid-syntax/migrated_0092/options.json | 2 +- .../invalid-syntax/migrated_0093/options.json | 2 +- .../invalid-syntax/migrated_0142/options.json | 2 +- .../invalid-syntax/migrated_0240/options.json | 2 +- .../invalid-syntax/migrated_0243/options.json | 2 +- .../invalid-syntax/migrated_0244/options.json | 2 +- .../invalid-syntax/migrated_0245/options.json | 2 +- .../invalid-syntax/migrated_0249/options.json | 2 +- .../super-call/options.json | 2 +- .../class-properties/super-call/options.json | 2 +- .../flow/declare-statements/15/input.js | 2 +- .../flow/declare-statements/15/output.json | 76 +-- .../.dupl-decl-const-declare-class/input.js | 2 + .../options.json | 3 + .../input.js | 2 + .../options.json | 3 + .../scope/.dupl-decl-const-interface/input.js | 2 + .../.dupl-decl-const-interface/options.json | 3 + .../input.js | 2 + .../input.js | 2 + .../options.json | 3 + .../input.js | 2 + .../output.json | 197 +++++++ .../input.js | 2 + .../options.json | 3 + .../.dupl-decl-declare-func-func/input.js | 2 + .../.dupl-decl-declare-func-func/options.json | 3 + .../.dupl-decl-declare-func-let/input.js | 2 + .../.dupl-decl-declare-func-let/options.json | 3 + .../input.js | 2 + .../options.json | 3 + .../input.js | 2 + .../output.json | 159 +++++ .../scope/.dupl-decl-declare-var-let/input.js | 2 + .../.dupl-decl-declare-var-let/options.json | 3 + .../.dupl-decl-interface-interface/input.js | 2 + .../options.json | 3 + .../.dupl-decl-let-declare-class/input.js | 2 + .../.dupl-decl-let-declare-class/options.json | 3 + .../.dupl-decl-let-declare-interface/input.js | 2 + .../options.json | 3 + .../scope/.dupl-decl-let-interface/input.js | 2 + .../.dupl-decl-let-interface/options.json | 3 + .../scope/.dupl-decl-type-interface/input.js | 2 + .../.dupl-decl-type-interface/options.json | 3 + .../.dupl-decl-var-declare-class/input.js | 2 + .../.dupl-decl-var-declare-class/options.json | 3 + .../.dupl-decl-var-declare-interface/input.js | 2 + .../options.json | 3 + .../scope/.dupl-decl-var-interface/input.js | 2 + .../.dupl-decl-var-interface/options.json | 3 + .../flow/scope/declare-module/input.js | 5 + .../flow/scope/declare-module/output.json | 190 ++++++ .../dupl-decl-const-opaque-type/input.js | 2 + .../dupl-decl-const-opaque-type/options.json | 3 + .../flow/scope/dupl-decl-const-type/input.js | 2 + .../scope/dupl-decl-const-type/options.json | 3 + .../scope/dupl-decl-let-opaque-type/input.js | 2 + .../dupl-decl-let-opaque-type/options.json | 3 + .../flow/scope/dupl-decl-let-type/input.js | 2 + .../scope/dupl-decl-let-type/options.json | 3 + .../dupl-decl-opaque-type-const/input.js | 2 + .../dupl-decl-opaque-type-const/options.json | 3 + .../scope/dupl-decl-opaque-type-let/input.js | 2 + .../dupl-decl-opaque-type-let/options.json | 3 + .../input.js | 2 + .../options.json | 3 + .../scope/dupl-decl-opaque-type-type/input.js | 2 + .../dupl-decl-opaque-type-type/options.json | 3 + .../scope/dupl-decl-opaque-type-var/input.js | 2 + .../dupl-decl-opaque-type-var/options.json | 3 + .../flow/scope/dupl-decl-type-const/input.js | 2 + .../scope/dupl-decl-type-const/options.json | 3 + .../flow/scope/dupl-decl-type-let/input.js | 2 + .../scope/dupl-decl-type-let/options.json | 3 + .../scope/dupl-decl-type-opaque-type/input.js | 2 + .../dupl-decl-type-opaque-type/options.json | 3 + .../flow/scope/dupl-decl-type-type/input.js | 2 + .../scope/dupl-decl-type-type/options.json | 3 + .../flow/scope/dupl-decl-type-var/input.js | 2 + .../scope/dupl-decl-type-var/options.json | 3 + .../scope/dupl-decl-var-opaque-type/input.js | 2 + .../dupl-decl-var-opaque-type/options.json | 3 + .../flow/scope/dupl-decl-var-type/input.js | 2 + .../scope/dupl-decl-var-type/options.json | 3 + .../sourcetype-script/export-named/input.js | 2 +- .../export-named/output.json | 32 +- .../flow/type-annotations/builtin/input.js | 26 +- .../flow/type-annotations/builtin/output.json | 340 +++++------ .../object-type-method/input.js | 18 +- .../object-type-method/output.json | 556 +++++++++--------- .../scope/no-dupl-decl-type-const/input.js | 2 + .../scope/no-dupl-decl-type-const/output.json | 152 +++++ .../scope/no-dupl-decl-type-let/input.js | 2 + .../scope/no-dupl-decl-type-let/output.json | 152 +++++ .../scope/no-dupl-decl-type-var/input.js | 2 + .../scope/no-dupl-decl-type-var/output.json | 152 +++++ .../src/transformClass.js | 23 - .../input.js | 5 - .../options.json | 4 - .../options.json | 2 +- .../flow-comments/export-type-alias/input.js | 4 +- .../flow-comments/export-type-alias/output.js | 4 +- .../strip-types/def-site-variance/input.js | 8 +- .../strip-opaque-type-alias/input.js | 6 +- .../strip-types/strip-type-alias/input.js | 2 +- .../fixtures/errors/new-target-arrow/input.js | 5 - .../errors/new-target-arrow/options.json | 4 - scripts/tests/test262/test262_whitelist.txt | 370 ------------ 284 files changed, 5792 insertions(+), 1730 deletions(-) create mode 100644 packages/babel-parser/src/util/scope.js create mode 100644 packages/babel-parser/src/util/scopeflags.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/let-assign/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/let-assign/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/expression/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/expression/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/statement/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/statement/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/output.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/input.js delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-class/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/output.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/output.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/declare-module/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/declare-module/output.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/output.json create mode 100644 packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/output.json create mode 100644 packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/output.json delete mode 100644 packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/input.js delete mode 100644 packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/options.json delete mode 100644 packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/input.js delete mode 100644 packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/options.json diff --git a/packages/babel-generator/test/fixtures/flow/declare-exports/input.js b/packages/babel-generator/test/fixtures/flow/declare-exports/input.js index ea4a8c7cd463..279e6ab4f9f9 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-exports/input.js +++ b/packages/babel-generator/test/fixtures/flow/declare-exports/input.js @@ -24,9 +24,9 @@ declare module B { } declare module "foo" { declare export type * from "bar"; } -declare export opaque type Foo; +declare export opaque type Foo1; declare export opaque type Bar; declare export opaque type Baz: Foo; -declare export opaque type Foo: Bar; -declare export opaque type Foo: Bar; -declare export opaque type Foo: Bar; +declare export opaque type Foo3: Bar; +declare export opaque type Foo4: Bar; +declare export opaque type Foo5: Bar; diff --git a/packages/babel-generator/test/fixtures/flow/declare-exports/output.js b/packages/babel-generator/test/fixtures/flow/declare-exports/output.js index da22c014154d..877c43099415 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-exports/output.js +++ b/packages/babel-generator/test/fixtures/flow/declare-exports/output.js @@ -33,9 +33,9 @@ declare module B { declare module "foo" { declare export type * from "bar"; } -declare export opaque type Foo; +declare export opaque type Foo1; declare export opaque type Bar; declare export opaque type Baz: Foo; -declare export opaque type Foo: Bar; -declare export opaque type Foo: Bar; -declare export opaque type Foo: Bar; \ No newline at end of file +declare export opaque type Foo3: Bar; +declare export opaque type Foo4: Bar; +declare export opaque type Foo5: Bar; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/flow/def-site-variance/input.js b/packages/babel-generator/test/fixtures/flow/def-site-variance/input.js index 5cda68f8e9c5..9f00e80993d1 100644 --- a/packages/babel-generator/test/fixtures/flow/def-site-variance/input.js +++ b/packages/babel-generator/test/fixtures/flow/def-site-variance/input.js @@ -1,10 +1,10 @@ class C1<+T, -U> {} function f<+T, -U>() {} type T<+T, -U> = {}; -type T = { +p: T }; -type T = { -p: T }; -type T = { +[k:K]: V }; -type T = { -[k:K]: V }; +type T2 = { +p: T }; +type T3 = { -p: T }; +type T4 = { +[k:K]: V }; +type T5 = { -[k:K]: V }; interface I { +p: T } interface I { -p: T } interface I { +[k:K]: V } diff --git a/packages/babel-generator/test/fixtures/flow/def-site-variance/output.js b/packages/babel-generator/test/fixtures/flow/def-site-variance/output.js index e411f4646133..5c2b69d1a6dd 100644 --- a/packages/babel-generator/test/fixtures/flow/def-site-variance/output.js +++ b/packages/babel-generator/test/fixtures/flow/def-site-variance/output.js @@ -3,16 +3,16 @@ class C1<+T, -U> {} function f<+T, -U>() {} type T<+T, -U> = {}; -type T = { +type T2 = { +p: T }; -type T = { +type T3 = { -p: T }; -type T = { +type T4 = { +[k: K]: V }; -type T = { +type T5 = { -[k: K]: V }; interface I { diff --git a/packages/babel-generator/test/fixtures/flow/internal-slot/input.js b/packages/babel-generator/test/fixtures/flow/internal-slot/input.js index 7888fc6cb43e..b00d3bd76f22 100644 --- a/packages/babel-generator/test/fixtures/flow/internal-slot/input.js +++ b/packages/babel-generator/test/fixtures/flow/internal-slot/input.js @@ -1,7 +1,7 @@ declare class C { static [[foo]]: T } declare class C { [[foo]]: T } -interface T { [[foo]]: X } -interface T { [[foo]](): X } -type T = { [[foo]]: X } -type T = { [[foo]](): X } -type T = { [[foo]]?: X } +interface I { [[foo]]: X } +interface I { [[foo]](): X } +type T1 = { [[foo]]: X } +type T2 = { [[foo]](): X } +type T3 = { [[foo]]?: X } diff --git a/packages/babel-generator/test/fixtures/flow/internal-slot/output.js b/packages/babel-generator/test/fixtures/flow/internal-slot/output.js index a8c375a2c456..2a48fb9f186a 100644 --- a/packages/babel-generator/test/fixtures/flow/internal-slot/output.js +++ b/packages/babel-generator/test/fixtures/flow/internal-slot/output.js @@ -4,18 +4,18 @@ declare class C { declare class C { [[foo]]: T } -interface T { +interface I { [[foo]]: X } -interface T { +interface I { [[foo]]() => X } -type T = { +type T1 = { [[foo]]: X }; -type T = { +type T2 = { [[foo]]() => X }; -type T = { +type T3 = { [[foo]]?: X -}; +}; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/flow/object-literal-types/input.js b/packages/babel-generator/test/fixtures/flow/object-literal-types/input.js index 6d747ee65e10..f3139a94e350 100644 --- a/packages/babel-generator/test/fixtures/flow/object-literal-types/input.js +++ b/packages/babel-generator/test/fixtures/flow/object-literal-types/input.js @@ -1,11 +1,11 @@ type U = {}; type V = {}; -type T = { ...U, }; -type T = { ...U, ...V }; -type T = { p: V, ...U }; -type T = { ...U, p: V, }; -type T = { ...{}|{ p: V, }}; -type T = { foo(): number } -type T = { foo: () => number } -type T = { [string]: U }; -type T = { [param: string]: U }; +type T1 = { ...U, }; +type T2 = { ...U, ...V }; +type T3 = { p: V, ...U }; +type T4 = { ...U, p: V, }; +type T5 = { ...{}|{ p: V, }}; +type T6 = { foo(): number } +type T7 = { foo: () => number } +type T8 = { [string]: U }; +type T9 = { [param: string]: U }; diff --git a/packages/babel-generator/test/fixtures/flow/object-literal-types/output.js b/packages/babel-generator/test/fixtures/flow/object-literal-types/output.js index 952f62e3022e..5c02e095e3fa 100644 --- a/packages/babel-generator/test/fixtures/flow/object-literal-types/output.js +++ b/packages/babel-generator/test/fixtures/flow/object-literal-types/output.js @@ -1,30 +1,30 @@ type U = {}; type V = {}; -type T = { ...U +type T1 = { ...U }; -type T = { ...U, +type T2 = { ...U, ...V, }; -type T = { +type T3 = { p: V, ...U, }; -type T = { ...U, +type T4 = { ...U, p: V, }; -type T = { ...{} | { +type T5 = { ...{} | { p: V } }; -type T = { +type T6 = { foo(): number }; -type T = { +type T7 = { foo: () => number }; -type T = { +type T8 = { [string]: U }; -type T = { +type T9 = { [param: string]: U }; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/flow/opaque-type-alias/input.js b/packages/babel-generator/test/fixtures/flow/opaque-type-alias/input.js index 1988fcaeed71..3e77fce2b1ca 100644 --- a/packages/babel-generator/test/fixtures/flow/opaque-type-alias/input.js +++ b/packages/babel-generator/test/fixtures/flow/opaque-type-alias/input.js @@ -1,7 +1,7 @@ opaque type ID = string; opaque type Foo = Bar; opaque type Maybe = _Maybe; -export opaque type Foo = number; +export opaque type Foo2 = number; opaque type union = | {type: "A"} diff --git a/packages/babel-generator/test/fixtures/flow/opaque-type-alias/output.js b/packages/babel-generator/test/fixtures/flow/opaque-type-alias/output.js index b4f20f2d705e..293f54010947 100644 --- a/packages/babel-generator/test/fixtures/flow/opaque-type-alias/output.js +++ b/packages/babel-generator/test/fixtures/flow/opaque-type-alias/output.js @@ -1,7 +1,7 @@ opaque type ID = string; opaque type Foo = Bar; opaque type Maybe = _Maybe; -export opaque type Foo = number; +export opaque type Foo2 = number; opaque type union = { type: "A" } | { diff --git a/packages/babel-generator/test/fixtures/flow/type-alias/input.js b/packages/babel-generator/test/fixtures/flow/type-alias/input.js index f71342c5265f..c1d567e6dfdd 100644 --- a/packages/babel-generator/test/fixtures/flow/type-alias/input.js +++ b/packages/babel-generator/test/fixtures/flow/type-alias/input.js @@ -1,7 +1,7 @@ type FBID = number; type Foo = Bar; type Maybe = _Maybe; -export type Foo = number; +export type Foo2 = number; type union = | {type: "A"} diff --git a/packages/babel-generator/test/fixtures/flow/type-alias/output.js b/packages/babel-generator/test/fixtures/flow/type-alias/output.js index a8263f67218b..51933a7a774e 100644 --- a/packages/babel-generator/test/fixtures/flow/type-alias/output.js +++ b/packages/babel-generator/test/fixtures/flow/type-alias/output.js @@ -1,7 +1,7 @@ type FBID = number; type Foo = Bar; type Maybe = _Maybe; -export type Foo = number; +export type Foo2 = number; type union = { type: "A" } | { diff --git a/packages/babel-parser/src/parser/base.js b/packages/babel-parser/src/parser/base.js index a56058c7c2b7..f0719402338f 100644 --- a/packages/babel-parser/src/parser/base.js +++ b/packages/babel-parser/src/parser/base.js @@ -3,11 +3,13 @@ import type { Options } from "../options"; import type State from "../tokenizer/state"; import type { PluginsMap } from "./index"; +import type ScopeHandler from "../util/scope"; export default class BaseParser { // Properties set by constructor in index.js options: Options; inModule: boolean; + scope: ScopeHandler; plugins: PluginsMap; filename: ?string; sawUnambiguousESM: boolean = false; diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 01f7dc03a2e1..f2bcfb19d3ad 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -29,10 +29,23 @@ import { } from "../util/identifier"; import type { Pos, Position } from "../util/location"; import * as charCodes from "charcodes"; +import { + BIND_OUTSIDE, + BIND_VAR, + functionFlags, + SCOPE_ARROW, + SCOPE_CLASS, + SCOPE_DIRECT_SUPER, + SCOPE_SUPER, + SCOPE_PROGRAM, +} from "../util/scopeflags"; export default class ExpressionParser extends LValParser { // Forward-declaration: defined in statement.js - +parseBlock: (allowDirectives?: boolean) => N.BlockStatement; + +parseBlock: ( + allowDirectives?: boolean, + createNewLexicalScope?: boolean, + ) => N.BlockStatement; +parseClass: ( node: N.Class, isStatement: boolean, @@ -41,10 +54,9 @@ export default class ExpressionParser extends LValParser { +parseDecorators: (allowExport?: boolean) => void; +parseFunction: ( node: T, - isStatement: boolean, + statement?: number, allowExpressionBody?: boolean, isAsync?: boolean, - optionalId?: boolean, ) => T; +parseFunctionParams: (node: N.Function, allowModifiers?: boolean) => void; +takeDecorators: (node: N.HasDecorators) => void; @@ -74,6 +86,7 @@ export default class ExpressionParser extends LValParser { // Convenience method to parse an Expression only getExpression(): N.Expression { + this.scope.enter(SCOPE_PROGRAM); this.nextToken(); const expr = this.parseExpression(); if (!this.match(tt.eof)) { @@ -128,7 +141,7 @@ export default class ExpressionParser extends LValParser { const startPos = this.state.start; const startLoc = this.state.startLoc; if (this.isContextual("yield")) { - if (this.state.inGenerator) { + if (this.scope.inGenerator) { let left = this.parseYield(noIn); if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); @@ -336,7 +349,7 @@ export default class ExpressionParser extends LValParser { if ( this.match(tt.name) && this.state.value === "await" && - this.state.inAsync + this.scope.inAsync ) { throw this.raise( this.state.start, @@ -421,8 +434,8 @@ export default class ExpressionParser extends LValParser { parseMaybeUnary(refShorthandDefaultPos: ?Pos): N.Expression { if ( this.isContextual("await") && - (this.state.inAsync || - (!this.state.inFunction && this.options.allowAwaitOutsideFunction)) + (this.scope.inAsync || + (!this.scope.inFunction && this.options.allowAwaitOutsideFunction)) ) { return this.parseAwait(); } else if (this.state.type.prefix) { @@ -806,11 +819,7 @@ export default class ExpressionParser extends LValParser { switch (this.state.type) { case tt._super: - if ( - !this.state.inMethod && - !this.state.inClassProperty && - !this.options.allowSuperOutsideMethod - ) { + if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) { this.raise( this.state.start, "super is only allowed in object methods and classes", @@ -819,24 +828,26 @@ export default class ExpressionParser extends LValParser { node = this.startNode(); this.next(); - if ( - !this.match(tt.parenL) && - !this.match(tt.bracketL) && - !this.match(tt.dot) - ) { - this.unexpected(); - } if ( this.match(tt.parenL) && - this.state.inMethod !== "constructor" && + !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod ) { this.raise( node.start, - "super() is only valid inside a class constructor. " + - "Make sure the method name is spelled exactly as 'constructor'.", + "super() is only valid inside a class constructor of a subclass. " + + "Maybe a typo in the method name ('constructor') or not extending another class?", ); } + + if ( + !this.match(tt.parenL) && + !this.match(tt.bracketL) && + !this.match(tt.dot) + ) { + this.unexpected(); + } + return this.finishNode(node, "Super"); case tt._import: @@ -870,20 +881,17 @@ export default class ExpressionParser extends LValParser { !this.canInsertSemicolon() ) { this.next(); - return this.parseFunction(node, false, false, true); + return this.parseFunction(node, undefined, false, true); } else if ( canBeArrow && id.name === "async" && this.match(tt.name) && !this.canInsertSemicolon() ) { - const oldInAsync = this.state.inAsync; - this.state.inAsync = true; const params = [this.parseIdentifier()]; this.expect(tt.arrow); // let foo = async bar => {}; this.parseArrowExpression(node, params, true); - this.state.inAsync = oldInAsync; return node; } @@ -900,12 +908,9 @@ export default class ExpressionParser extends LValParser { this.expectPlugin("doExpressions"); const node = this.startNode(); this.next(); - const oldInFunction = this.state.inFunction; const oldLabels = this.state.labels; this.state.labels = []; - this.state.inFunction = false; - node.body = this.parseBlock(false); - this.state.inFunction = oldInFunction; + node.body = this.parseBlock(); this.state.labels = oldLabels; return this.finishNode(node, "DoExpression"); } @@ -1068,10 +1073,10 @@ export default class ExpressionParser extends LValParser { this.next(); meta = this.createIdentifier(meta, "function"); - if (this.state.inGenerator && this.eat(tt.dot)) { + if (this.scope.inGenerator && this.eat(tt.dot)) { return this.parseMetaProperty(node, meta, "sent"); } - return this.parseFunction(node, false); + return this.parseFunction(node); } parseMetaProperty( @@ -1309,7 +1314,7 @@ export default class ExpressionParser extends LValParser { if (this.eat(tt.dot)) { const metaProp = this.parseMetaProperty(node, meta, "target"); - if (!this.state.inFunction && !this.state.inClassProperty) { + if (!this.scope.inNonArrowFunction && !this.state.inClassProperty) { let error = "new.target can only be used in functions"; if (this.hasPlugin("classProperties")) { @@ -1575,6 +1580,7 @@ export default class ExpressionParser extends LValParser { isGenerator, isAsync, /* isConstructor */ false, + false, "ObjectMethod", ); } @@ -1588,6 +1594,7 @@ export default class ExpressionParser extends LValParser { /* isGenerator */ false, /* isAsync */ false, /* isConstructor */ false, + false, "ObjectMethod", ); this.checkGetterSetterParams(prop); @@ -1713,32 +1720,28 @@ export default class ExpressionParser extends LValParser { isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowDirectSuper: boolean, type: string, + inClassScope: boolean = false, ): T { - const oldInFunc = this.state.inFunction; - const oldInMethod = this.state.inMethod; - const oldInAsync = this.state.inAsync; - const oldInGenerator = this.state.inGenerator; const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; - this.state.inFunction = true; - this.state.inMethod = node.kind || true; - this.state.inAsync = isAsync; - this.state.inGenerator = isGenerator; this.state.yieldPos = 0; this.state.awaitPos = 0; this.initFunction(node, isAsync); node.generator = !!isGenerator; const allowModifiers = isConstructor; // For TypeScript parameter properties + this.scope.enter( + functionFlags(isAsync, node.generator) | + SCOPE_SUPER | + (inClassScope ? SCOPE_CLASS : 0) | + (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0), + ); this.parseFunctionParams((node: any), allowModifiers); this.checkYieldAwaitInDefaultParams(); this.parseFunctionBodyAndFinish(node, type); - this.state.inFunction = oldInFunc; - this.state.inMethod = oldInMethod; - this.state.inAsync = oldInAsync; - this.state.inGenerator = oldInGenerator; this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; @@ -1753,17 +1756,12 @@ export default class ExpressionParser extends LValParser { params: ?(N.Expression[]), isAsync: boolean, ): N.ArrowFunctionExpression { + this.scope.enter(functionFlags(isAsync, false) | SCOPE_ARROW); this.initFunction(node, isAsync); - const oldInFunc = this.state.inFunction; - const oldInAsync = this.state.inAsync; - const oldInGenerator = this.state.inGenerator; const oldMaybeInArrowParameters = this.state.maybeInArrowParameters; const oldYieldPos = this.state.yieldPos; const oldAwaitPos = this.state.awaitPos; - this.state.inFunction = true; - this.state.inAsync = isAsync; - this.state.inGenerator = false; this.state.maybeInArrowParameters = false; this.state.yieldPos = 0; this.state.awaitPos = 0; @@ -1771,9 +1769,6 @@ export default class ExpressionParser extends LValParser { if (params) this.setArrowFunctionParameters(node, params); this.parseFunctionBody(node, true); - this.state.inAsync = oldInAsync; - this.state.inGenerator = oldInGenerator; - this.state.inFunction = oldInFunc; this.state.maybeInArrowParameters = oldMaybeInArrowParameters; this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; @@ -1819,55 +1814,87 @@ export default class ExpressionParser extends LValParser { // Parse function body and check parameters. parseFunctionBody(node: N.Function, allowExpression: ?boolean): void { const isExpression = allowExpression && !this.match(tt.braceL); + const oldStrict = this.state.strict; + let useStrict = false; const oldInParameters = this.state.inParameters; this.state.inParameters = false; if (isExpression) { node.body = this.parseMaybeAssign(); + this.checkParams(node, false, allowExpression); } else { + const nonSimple = !this.isSimpleParamList(node.params); + if (!oldStrict || nonSimple) { + useStrict = this.strictDirective(this.state.end); + // If this is a strict mode function, verify that argument names + // are not repeated, and it does not try to bind the words `eval` + // or `arguments`. + if (useStrict && nonSimple) { + // This logic is here to align the error location with the estree plugin + const errorPos = + // $FlowIgnore + (node.kind === "method" || node.kind === "constructor") && + // $FlowIgnore + !!node.key + ? node.key.end + : node.start; + this.raise( + errorPos, + "Illegal 'use strict' directive in function with non-simple parameter list", + ); + } + } // Start a new scope with regard to labels // flag (restore them to their old value afterwards). - const oldInFunc = this.state.inFunction; const oldLabels = this.state.labels; - this.state.inFunction = true; this.state.labels = []; - node.body = this.parseBlock(true); - this.state.inFunction = oldInFunc; + if (useStrict) this.state.strict = true; + // Add the params to varDeclaredNames to ensure that an error is thrown + // if a let/const declaration in the function clashes with one of the params. + this.checkParams( + node, + !oldStrict && !useStrict && !allowExpression && !nonSimple, + allowExpression, + ); + node.body = this.parseBlock(true, false); this.state.labels = oldLabels; } + this.scope.exit(); - this.checkFunctionNameAndParams(node, allowExpression); this.state.inParameters = oldInParameters; + // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval' + if (this.state.strict && node.id) { + this.checkLVal(node.id, BIND_OUTSIDE, undefined, "function name"); + } + this.state.strict = oldStrict; } - checkFunctionNameAndParams( + isSimpleParamList( + params: $ReadOnlyArray, + ): boolean { + for (let i = 0, len = params.length; i < len; i++) { + if (params[i].type !== "Identifier") return false; + } + return true; + } + + checkParams( node: N.Function, + allowDuplicates: boolean, + // eslint-disable-next-line no-unused-vars isArrowFunction: ?boolean, ): void { - // If this is a strict mode function, verify that argument names - // are not repeated, and it does not try to bind the words `eval` - // or `arguments`. - const isStrict = this.isStrictBody(node); - // Also check for arrow functions - const checkLVal = this.state.strict || isStrict || isArrowFunction; - - const oldStrict = this.state.strict; - if (isStrict) this.state.strict = isStrict; - - if (checkLVal) { - const nameHash: any = Object.create(null); - if (node.id) { - this.checkLVal(node.id, true, undefined, "function name"); - } - for (const param of node.params) { - if (isStrict && param.type !== "Identifier") { - this.raise(param.start, "Non-simple parameter in strict mode"); - } - this.checkLVal(param, true, nameHash, "function parameter list"); - } + // $FlowIssue + const nameHash: {} = Object.create(null); + for (let i = 0; i < node.params.length; i++) { + this.checkLVal( + node.params[i], + BIND_VAR, + allowDuplicates ? null : nameHash, + "function paramter list", + ); } - this.state.strict = oldStrict; } // Parses a comma-separated list of expressions, and returns them as @@ -1987,22 +2014,21 @@ export default class ExpressionParser extends LValParser { checkKeywords: boolean, isBinding: boolean, ): void { - const state = this.state; - if (state.inGenerator && word === "yield") { + if (this.scope.inGenerator && word === "yield") { this.raise( startLoc, "Can not use 'yield' as identifier inside a generator", ); } - if (state.inAsync && word === "await") { + if (this.scope.inAsync && word === "await") { this.raise( startLoc, "Can not use 'await' as identifier inside an async function", ); } - if (state.inClassProperty && word === "arguments") { + if (this.state.inClassProperty && word === "arguments") { this.raise( startLoc, "'arguments' is not allowed in class field initializer", @@ -2012,14 +2038,14 @@ export default class ExpressionParser extends LValParser { this.raise(startLoc, `Unexpected keyword '${word}'`); } - const reservedTest = !state.strict + const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord; if (reservedTest(word, this.inModule)) { - if (!state.inAsync && word === "await") { + if (!this.scope.inAsync && word === "await") { this.raise( startLoc, "Can not use keyword 'await' outside an async function", diff --git a/packages/babel-parser/src/parser/index.js b/packages/babel-parser/src/parser/index.js index 00617bd8632c..b92ecb8203ad 100644 --- a/packages/babel-parser/src/parser/index.js +++ b/packages/babel-parser/src/parser/index.js @@ -5,6 +5,8 @@ import type { File, JSXOpeningElement } from "../types"; import type { PluginList } from "../plugin-utils"; import { getOptions } from "../options"; import StatementParser from "./statement"; +import { SCOPE_PROGRAM } from "../util/scopeflags"; +import ScopeHandler from "../util/scope"; export type PluginsMap = Map; @@ -20,11 +22,13 @@ export default class Parser extends StatementParser { this.options = options; this.inModule = this.options.sourceType === "module"; + this.scope = new ScopeHandler(this.raise.bind(this), this.inModule); this.plugins = pluginsMap(this.options.plugins); this.filename = options.sourceFilename; } parse(): File { + this.scope.enter(SCOPE_PROGRAM); const file = this.startNode(); const program = this.startNode(); this.nextToken(); diff --git a/packages/babel-parser/src/parser/lval.js b/packages/babel-parser/src/parser/lval.js index 6b9e6c6ac979..1711b7ae7d81 100644 --- a/packages/babel-parser/src/parser/lval.js +++ b/packages/babel-parser/src/parser/lval.js @@ -16,6 +16,7 @@ import type { import type { Pos, Position } from "../util/location"; import { isStrictBindReservedWord } from "../util/identifier"; import { NodeUtils } from "./node"; +import { type BindingTypes, BIND_NONE, BIND_OUTSIDE } from "../util/scopeflags"; export default class LValParser extends NodeUtils { // Forward-declaration: defined in expression.js @@ -262,7 +263,7 @@ export default class LValParser extends NodeUtils { elts.push(this.parseAssignableListItemTypes(this.parseRest())); this.checkCommaAfterRest( close, - this.state.inFunction && this.state.inParameters + this.scope.inFunction && this.state.inParameters ? "parameter" : "element", ); @@ -325,7 +326,7 @@ export default class LValParser extends NodeUtils { checkLVal( expr: Expression, - isBinding: ?boolean, + bindingType: ?BindingTypes = BIND_NONE, checkClashes: ?{ [key: string]: boolean }, contextDescription: string, ): void { @@ -337,7 +338,7 @@ export default class LValParser extends NodeUtils { ) { this.raise( expr.start, - `${isBinding ? "Binding" : "Assigning to"} '${ + `${bindingType === BIND_NONE ? "Assigning to" : "Binding"} '${ expr.name }' in strict mode`, ); @@ -358,15 +359,20 @@ export default class LValParser extends NodeUtils { const key = `_${expr.name}`; if (checkClashes[key]) { - this.raise(expr.start, "Argument name clash in strict mode"); + this.raise(expr.start, "Argument name clash"); } else { checkClashes[key] = true; } } + if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) { + this.scope.declareName(expr.name, bindingType, expr.start); + } break; case "MemberExpression": - if (isBinding) this.raise(expr.start, "Binding member expression"); + if (bindingType !== BIND_NONE) { + this.raise(expr.start, "Binding member expression"); + } break; case "ObjectPattern": @@ -374,7 +380,7 @@ export default class LValParser extends NodeUtils { if (prop.type === "ObjectProperty") prop = prop.value; this.checkLVal( prop, - isBinding, + bindingType, checkClashes, "object destructuring pattern", ); @@ -386,7 +392,7 @@ export default class LValParser extends NodeUtils { if (elem) { this.checkLVal( elem, - isBinding, + bindingType, checkClashes, "array destructuring pattern", ); @@ -397,21 +403,26 @@ export default class LValParser extends NodeUtils { case "AssignmentPattern": this.checkLVal( expr.left, - isBinding, + bindingType, checkClashes, "assignment pattern", ); break; case "RestElement": - this.checkLVal(expr.argument, isBinding, checkClashes, "rest element"); + this.checkLVal( + expr.argument, + bindingType, + checkClashes, + "rest element", + ); break; default: { const message = - (isBinding - ? /* istanbul ignore next */ "Binding invalid" - : "Invalid") + + (bindingType === BIND_NONE + ? "Invalid" + : /* istanbul ignore next */ "Binding invalid") + " left-hand side" + (contextDescription ? " in " + contextDescription diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 88d6555d5f30..5e77de8ba31a 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -10,6 +10,17 @@ import { } from "../util/identifier"; import { lineBreak, skipWhiteSpace } from "../util/whitespace"; import * as charCodes from "charcodes"; +import { + BIND_SIMPLE_CATCH, + BIND_LEXICAL, + BIND_VAR, + BIND_FUNCTION, + functionFlags, + SCOPE_CLASS, + SCOPE_OTHER, + SCOPE_SIMPLE_CATCH, + SCOPE_SUPER, +} from "../util/scopeflags"; // Reused empty array added for node fields that are always empty. @@ -18,6 +29,11 @@ const empty = []; const loopLabel = { kind: "loop" }, switchLabel = { kind: "switch" }; +const FUNC_NO_FLAGS = 0b000, + FUNC_STATEMENT = 0b001, + FUNC_HANGING_STATEMENT = 0b010, + FUNC_NULLABLE_ID = 0b100; + export default class StatementParser extends ExpressionParser { // ### Statement parsing @@ -144,26 +160,24 @@ export default class StatementParser extends ExpressionParser { return this.parseDoStatement(node); case tt._for: return this.parseForStatement(node); - case tt._function: { + case tt._function: if (this.lookahead().type === tt.dot) break; - if ( - context && - (this.state.strict || (context !== "if" && context !== "label")) - ) { - this.raise( - this.state.start, - "Function declaration not allowed in this context", - ); - } - const result = this.parseFunctionStatement(node); - - // TODO: Remove this once we have proper scope tracking in place. - if (context && result.generator) { - this.unexpected(node.start); + if (context) { + if (this.state.strict) { + this.raise( + this.state.start, + "In strict mode code, functions can only be declared at top level or inside a block", + ); + } else if (context !== "if" && context !== "label") { + this.raise( + this.state.start, + "In non-strict mode code, functions can only be declared at top level, " + + "inside a block, or as the body of an if statement", + ); + } } + return this.parseFunctionStatement(node, false, !context); - return result; - } case tt._class: if (context) this.unexpected(); return this.parseClass(node, true); @@ -182,7 +196,12 @@ export default class StatementParser extends ExpressionParser { case tt._const: case tt._var: kind = kind || this.state.value; - if (context && kind !== "var") this.unexpected(); + if (context && kind !== "var") { + this.unexpected( + this.state.start, + "Lexical declaration cannot appear in a single-statement context", + ); + } return this.parseVarStatement(node, kind); case tt._while: @@ -237,24 +256,19 @@ export default class StatementParser extends ExpressionParser { return result; } - case tt.name: - if (this.isContextual("async")) { - // peek ahead and see if next token is a function - const state = this.state.clone(); - this.next(); - if (this.match(tt._function) && !this.canInsertSemicolon()) { - if (context) { - this.raise( - this.state.lastTokStart, - "Function declaration not allowed in this context", - ); - } - this.next(); - return this.parseFunction(node, true, false, true); - } else { - this.state = state; + + default: { + if (this.isAsyncFunction()) { + if (context) { + this.unexpected( + null, + "Async functions can only be declared at the top level or inside a block", + ); } + this.next(); + return this.parseFunctionStatement(node, true, !context); } + } } // If the statement does not start with a statement keyword or a @@ -461,12 +475,13 @@ export default class StatementParser extends ExpressionParser { let awaitAt = -1; if ( - (this.state.inAsync || - (!this.state.inFunction && this.options.allowAwaitOutsideFunction)) && + (this.scope.inAsync || + (!this.scope.inFunction && this.options.allowAwaitOutsideFunction)) && this.eatContextual("await") ) { awaitAt = this.state.lastTokStart; } + this.scope.enter(SCOPE_OTHER); this.expect(tt.parenL); if (this.match(tt.semi)) { @@ -524,9 +539,18 @@ export default class StatementParser extends ExpressionParser { return this.parseFor(node, init); } - parseFunctionStatement(node: N.FunctionDeclaration): N.FunctionDeclaration { + parseFunctionStatement( + node: N.FunctionDeclaration, + isAsync?: boolean, + declarationPosition?: boolean, + ): N.FunctionDeclaration { this.next(); - return this.parseFunction(node, true); + return this.parseFunction( + node, + FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), + false, + isAsync, + ); } parseIfStatement(node: N.IfStatement): N.IfStatement { @@ -538,7 +562,7 @@ export default class StatementParser extends ExpressionParser { } parseReturnStatement(node: N.ReturnStatement): N.ReturnStatement { - if (!this.state.inFunction && !this.options.allowReturnOutsideFunction) { + if (!this.scope.inFunction && !this.options.allowReturnOutsideFunction) { this.raise(this.state.start, "'return' outside of function"); } @@ -564,6 +588,7 @@ export default class StatementParser extends ExpressionParser { const cases = (node.cases = []); this.expect(tt.braceL); this.state.labels.push(switchLabel); + this.scope.enter(SCOPE_OTHER); // Statements under must be grouped (by label) in SwitchCase // nodes. `cur` is used to keep the node that we are currently @@ -595,6 +620,7 @@ export default class StatementParser extends ExpressionParser { } } } + this.scope.exit(); if (cur) this.finishNode(cur, "SwitchCase"); this.next(); // Closing brace this.state.labels.pop(); @@ -627,11 +653,18 @@ export default class StatementParser extends ExpressionParser { if (this.match(tt.parenL)) { this.expect(tt.parenL); clause.param = this.parseBindingAtom(); - const clashes: any = Object.create(null); - this.checkLVal(clause.param, true, clashes, "catch clause"); + const simple = clause.param.type === "Identifier"; + this.scope.enter(simple ? SCOPE_SIMPLE_CATCH : 0); + this.checkLVal( + clause.param, + simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL, + null, + "catch clause", + ); this.expect(tt.parenR); } else { clause.param = null; + this.scope.enter(SCOPE_OTHER); } clause.body = @@ -641,8 +674,9 @@ export default class StatementParser extends ExpressionParser { // outside of the function body. this.withTopicForbiddingContext(() => // Parse the catch clause's body. - this.parseBlock(false), + this.parseBlock(false, false), ); + this.scope.exit(); node.handler = this.finishNode(clause, "CatchClause"); } @@ -769,10 +803,19 @@ export default class StatementParser extends ExpressionParser { // strict"` declarations when `allowStrict` is true (used for // function bodies). - parseBlock(allowDirectives?: boolean): N.BlockStatement { + parseBlock( + allowDirectives?: boolean = false, + createNewLexicalScope?: boolean = true, + ): N.BlockStatement { const node = this.startNode(); this.expect(tt.braceL); + if (createNewLexicalScope) { + this.scope.enter(SCOPE_OTHER); + } this.parseBlockBody(node, allowDirectives, false, tt.braceR); + if (createNewLexicalScope) { + this.scope.exit(); + } return this.finishNode(node, "BlockStatement"); } @@ -858,6 +901,7 @@ export default class StatementParser extends ExpressionParser { node.update = this.match(tt.parenR) ? null : this.parseExpression(); this.expect(tt.parenR); + this.scope.exit(); node.body = // For the smartPipelines plugin: Disable topic references from outer // contexts within the loop body. They are permitted in test expressions, @@ -893,6 +937,7 @@ export default class StatementParser extends ExpressionParser { node.right = this.parseExpression(); this.expect(tt.parenR); + this.scope.exit(); node.body = // For the smartPipelines plugin: // Disable topic references from outer contexts within the loop body. @@ -954,7 +999,12 @@ export default class StatementParser extends ExpressionParser { this.unexpected(null, "let is disallowed as a lexically bound name"); } decl.id = this.parseBindingAtom(); - this.checkLVal(decl.id, true, undefined, "variable declaration"); + this.checkLVal( + decl.id, + kind === "var" ? BIND_VAR : BIND_LEXICAL, + undefined, + "variable declaration", + ); } // Parse a function declaration or literal (depending on the @@ -962,51 +1012,56 @@ export default class StatementParser extends ExpressionParser { parseFunction( node: T, - isStatement: boolean, + statement?: number = FUNC_NO_FLAGS, allowExpressionBody?: boolean = false, isAsync?: boolean = false, - optionalId?: boolean = false, ): T { - const oldInFunc = this.state.inFunction; - const oldInMethod = this.state.inMethod; - const oldInAsync = this.state.inAsync; - const oldInGenerator = this.state.inGenerator; - const oldInClassProperty = this.state.inClassProperty; - const oldYieldPos = this.state.yieldPos; - const oldAwaitPos = this.state.awaitPos; - this.state.inFunction = true; - this.state.inMethod = false; - this.state.inClassProperty = false; - this.state.yieldPos = 0; - this.state.awaitPos = 0; + const isStatement = statement & FUNC_STATEMENT; + const isHangingStatement = statement & FUNC_HANGING_STATEMENT; this.initFunction(node, isAsync); + if (this.match(tt.star) && isHangingStatement) { + this.unexpected( + this.state.start, + "Generators can only be declared at the top level or inside a block", + ); + } node.generator = this.eat(tt.star); - if (isStatement && !optionalId && !this.match(tt.name)) { - this.unexpected(); + if (isStatement) { + node.id = + statement & FUNC_NULLABLE_ID && !this.match(tt.name) + ? null + : this.parseIdentifier(); + if (node.id && !isHangingStatement) { + // If it is a regular function declaration in sloppy mode, then it is + // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding + // mode depends on properties of the current scope (see + // treatFunctionsAsVar). + this.checkLVal( + node.id, + this.state.strict || node.generator || node.async + ? this.scope.treatFunctionsAsVar + ? BIND_VAR + : BIND_LEXICAL + : BIND_FUNCTION, + null, + "function name", + ); + } } - // When parsing function expression, the binding identifier is parsed - // according to the rules inside the function. - // e.g. (function* yield() {}) is invalid because "yield" is disallowed in - // generators. - // This isn't the case with function declarations: function* yield() {} is - // valid because yield is parsed as if it was outside the generator. - // Therefore, this.state.inGenerator is set before or after parsing the - // function id according to the "isStatement" parameter. - // The same applies to await & async functions. + const oldInClassProperty = this.state.inClassProperty; + const oldYieldPos = this.state.yieldPos; + const oldAwaitPos = this.state.awaitPos; + this.state.inClassProperty = false; + this.state.yieldPos = 0; + this.state.awaitPos = 0; + this.scope.enter(functionFlags(node.async, node.generator)); + if (!isStatement) { - this.state.inAsync = isAsync; - this.state.inGenerator = node.generator; - } - if (this.match(tt.name)) { - node.id = this.parseIdentifier(); - } - if (isStatement) { - this.state.inAsync = isAsync; - this.state.inGenerator = node.generator; + node.id = this.match(tt.name) ? this.parseIdentifier() : null; } this.parseFunctionParams(node); @@ -1023,10 +1078,6 @@ export default class StatementParser extends ExpressionParser { ); }); - this.state.inFunction = oldInFunc; - this.state.inMethod = oldInMethod; - this.state.inAsync = oldInAsync; - this.state.inGenerator = oldInGenerator; this.state.inClassProperty = oldInClassProperty; this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; @@ -1099,11 +1150,12 @@ export default class StatementParser extends ExpressionParser { const state = { hadConstructor: false }; let decorators: N.Decorator[] = []; const classBody: N.ClassBody = this.startNode(); - classBody.body = []; this.expect(tt.braceL); + const constructorAllowsSuper = node.superClass !== null; + // For the smartPipelines plugin: Disable topic references from outer // contexts within the class body. They are permitted in test expressions, // outside of the class body. @@ -1133,7 +1185,7 @@ export default class StatementParser extends ExpressionParser { decorators = []; } - this.parseClassMember(classBody, member, state); + this.parseClassMember(classBody, member, state, constructorAllowsSuper); if ( member.kind === "constructor" && @@ -1164,6 +1216,7 @@ export default class StatementParser extends ExpressionParser { classBody: N.ClassBody, member: N.ClassMember, state: { hadConstructor: boolean }, + constructorAllowsSuper: boolean, ): void { let isStatic = false; const containsEsc = this.state.containsEsc; @@ -1185,6 +1238,7 @@ export default class StatementParser extends ExpressionParser { false, false, /* isConstructor */ false, + false, ); return; } else if (this.isClassProperty()) { @@ -1204,7 +1258,13 @@ export default class StatementParser extends ExpressionParser { isStatic = true; } - this.parseClassMemberWithIsStatic(classBody, member, state, isStatic); + this.parseClassMemberWithIsStatic( + classBody, + member, + state, + isStatic, + constructorAllowsSuper, + ); } parseClassMemberWithIsStatic( @@ -1212,6 +1272,7 @@ export default class StatementParser extends ExpressionParser { member: N.ClassMember, state: { hadConstructor: boolean }, isStatic: boolean, + constructorAllowsSuper: boolean, ) { const publicMethod: $FlowSubtype = member; const privateMethod: $FlowSubtype = member; @@ -1244,6 +1305,7 @@ export default class StatementParser extends ExpressionParser { true, false, /* isConstructor */ false, + false, ); return; @@ -1266,7 +1328,7 @@ export default class StatementParser extends ExpressionParser { // a normal method const isConstructor = this.isNonstaticConstructor(publicMethod); - + let allowsDirectSuper = false; if (isConstructor) { publicMethod.kind = "constructor"; @@ -1282,6 +1344,7 @@ export default class StatementParser extends ExpressionParser { this.raise(key.start, "Duplicate constructor in the same class"); } state.hadConstructor = true; + allowsDirectSuper = constructorAllowsSuper; } this.pushClassMethod( @@ -1290,6 +1353,7 @@ export default class StatementParser extends ExpressionParser { false, false, isConstructor, + allowsDirectSuper, ); } else if (this.isClassProperty()) { if (isPrivate) { @@ -1327,6 +1391,7 @@ export default class StatementParser extends ExpressionParser { isGenerator, true, /* isConstructor */ false, + false, ); } } else if ( @@ -1356,6 +1421,7 @@ export default class StatementParser extends ExpressionParser { false, false, /* isConstructor */ false, + false, ); } @@ -1422,6 +1488,7 @@ export default class StatementParser extends ExpressionParser { isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowsDirectSuper: boolean, ): void { classBody.body.push( this.parseMethod( @@ -1429,7 +1496,9 @@ export default class StatementParser extends ExpressionParser { isGenerator, isAsync, isConstructor, + allowsDirectSuper, "ClassMethod", + true, ), ); } @@ -1447,7 +1516,9 @@ export default class StatementParser extends ExpressionParser { isGenerator, isAsync, /* isConstructor */ false, + false, "ClassPrivateMethod", + true, ), ); } @@ -1466,13 +1537,16 @@ export default class StatementParser extends ExpressionParser { parseClassPrivateProperty( node: N.ClassPrivateProperty, ): N.ClassPrivateProperty { - const oldInMethod = this.state.inMethod; - this.state.inMethod = false; this.state.inClassProperty = true; + + this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); + node.value = this.eat(tt.eq) ? this.parseMaybeAssign() : null; this.semicolon(); this.state.inClassProperty = false; - this.state.inMethod = oldInMethod; + + this.scope.exit(); + return this.finishNode(node, "ClassPrivateProperty"); } @@ -1481,10 +1555,10 @@ export default class StatementParser extends ExpressionParser { this.expectPlugin("classProperties"); } - const oldInMethod = this.state.inMethod; - this.state.inMethod = false; this.state.inClassProperty = true; + this.scope.enter(SCOPE_CLASS | SCOPE_SUPER); + if (this.match(tt.eq)) { this.expectPlugin("classProperties"); this.next(); @@ -1494,7 +1568,8 @@ export default class StatementParser extends ExpressionParser { } this.semicolon(); this.state.inClassProperty = false; - this.state.inMethod = oldInMethod; + + this.scope.exit(); return this.finishNode(node, "ClassProperty"); } @@ -1506,6 +1581,9 @@ export default class StatementParser extends ExpressionParser { ): void { if (this.match(tt.name)) { node.id = this.parseIdentifier(); + if (isStatement) { + this.checkLVal(node.id, BIND_LEXICAL, undefined, "class name"); + } } else { if (optionalId || !isStatement) { node.id = null; @@ -1642,7 +1720,7 @@ export default class StatementParser extends ExpressionParser { return false; } - isAsyncFunction() { + isAsyncFunction(): boolean { if (!this.isContextual("async")) return false; const { input, pos, length } = this.state; @@ -1666,13 +1744,18 @@ export default class StatementParser extends ExpressionParser { const isAsync = this.isAsyncFunction(); - if (this.eat(tt._function) || isAsync) { + if (this.match(tt._function) || isAsync) { + this.next(); if (isAsync) { - this.eatContextual("async"); - this.expect(tt._function); + this.next(); } - return this.parseFunction(expr, true, false, isAsync, true); + return this.parseFunction( + expr, + FUNC_STATEMENT | FUNC_NULLABLE_ID, + false, + isAsync, + ); } else if (this.match(tt._class)) { return this.parseClass(expr, true, true); } else if (this.match(tt.at)) { @@ -1927,7 +2010,12 @@ export default class StatementParser extends ExpressionParser { contextDescription: string, ): void { specifier.local = this.parseIdentifier(); - this.checkLVal(specifier.local, true, undefined, contextDescription); + this.checkLVal( + specifier.local, + BIND_LEXICAL, + undefined, + contextDescription, + ); node.specifiers.push(this.finishNode(specifier, type)); } @@ -2000,7 +2088,12 @@ export default class StatementParser extends ExpressionParser { ); specifier.local = specifier.imported.__clone(); } - this.checkLVal(specifier.local, true, undefined, "import specifier"); + this.checkLVal( + specifier.local, + BIND_LEXICAL, + undefined, + "import specifier", + ); node.specifiers.push(this.finishNode(specifier, "ImportSpecifier")); } } diff --git a/packages/babel-parser/src/parser/util.js b/packages/babel-parser/src/parser/util.js index 1ea8aeaf8f1c..4c8eb453a8c3 100644 --- a/packages/babel-parser/src/parser/util.js +++ b/packages/babel-parser/src/parser/util.js @@ -3,7 +3,9 @@ import { types as tt, type TokenType } from "../tokenizer/types"; import Tokenizer from "../tokenizer"; import type { Node } from "../types"; -import { lineBreak } from "../util/whitespace"; +import { lineBreak, skipWhiteSpace } from "../util/whitespace"; + +const literal = /^(?:;|('|")((?:\\?.)*?)\1)/; // ## Parser utilities @@ -165,4 +167,18 @@ export default class UtilParser extends Tokenizer { ); } } + + strictDirective(start: number): boolean { + for (;;) { + skipWhiteSpace.lastIndex = start; + // $FlowIgnore + start += skipWhiteSpace.exec(this.state.input)[0].length; + const match = literal.exec(this.state.input.slice(start)); + if (!match) break; + if (match[2] === "use strict") return true; + start += match[0].length; + } + + return false; + } } diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index ae859107b066..0a5a276a2bf0 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -4,6 +4,7 @@ import { types as tt, TokenType } from "../tokenizer/types"; import type Parser from "../parser"; import * as N from "../types"; import type { Pos, Position } from "../util/location"; +import { type BindingTypes, BIND_NONE } from "../util/scopeflags"; function isSimpleProperty(node: N.Node): boolean { return ( @@ -104,7 +105,7 @@ export default (superClass: Class): Class => checkLVal( expr: N.Expression, - isBinding: ?boolean, + bindingType: ?BindingTypes = BIND_NONE, checkClashes: ?{ [key: string]: boolean }, contextDescription: string, ): void { @@ -113,14 +114,14 @@ export default (superClass: Class): Class => expr.properties.forEach(prop => { this.checkLVal( prop.type === "Property" ? prop.value : prop, - isBinding, + bindingType, checkClashes, "object destructuring pattern", ); }); break; default: - super.checkLVal(expr, isBinding, checkClashes, contextDescription); + super.checkLVal(expr, bindingType, checkClashes, contextDescription); } } @@ -203,13 +204,16 @@ export default (superClass: Class): Class => isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowsDirectSuper: boolean, ): void { this.parseMethod( method, isGenerator, isAsync, isConstructor, + allowsDirectSuper, "MethodDefinition", + true, ); if (method.typeParameters) { // $FlowIgnore @@ -265,7 +269,9 @@ export default (superClass: Class): Class => isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowDirectSuper: boolean, type: string, + inClassScope: boolean = false, ): T { let funcNode = this.startNode(); funcNode.kind = node.kind; // provide kind, so super method correctly sets state @@ -274,7 +280,9 @@ export default (superClass: Class): Class => isGenerator, isAsync, isConstructor, + allowDirectSuper, "FunctionExpression", + inClassScope, ); delete funcNode.kind; // $FlowIgnore diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index 1effe1725c0e..af151c317dfe 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -9,6 +9,12 @@ import type State from "../tokenizer/state"; import { types as tc } from "../tokenizer/context"; import * as charCodes from "charcodes"; import { isIteratorStart } from "../util/identifier"; +import { + type BindingTypes, + BIND_NONE, + BIND_LEXICAL, + SCOPE_OTHER, +} from "../util/scopeflags"; const reservedTypes = [ "any", @@ -257,6 +263,8 @@ export default (superClass: Class): Class => flowParseDeclareModule(node: N.FlowDeclareModule): N.FlowDeclareModule { this.next(); + this.scope.enter(SCOPE_OTHER); + if (this.match(tt.string)) { node.id = this.parseExprAtom(); } else { @@ -290,6 +298,9 @@ export default (superClass: Class): Class => body.push(bodyNode); } + + this.scope.exit(); + this.expect(tt.braceR); this.finishNode(bodyNode, "BlockStatement"); @@ -518,6 +529,7 @@ export default (superClass: Class): Class => flowParseTypeAlias(node: N.FlowTypeAlias): N.FlowTypeAlias { node.id = this.flowParseRestrictedIdentifier(); + this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); if (this.isRelational("<")) { node.typeParameters = this.flowParseTypeParameterDeclaration(); @@ -537,6 +549,7 @@ export default (superClass: Class): Class => ): N.FlowOpaqueType { this.expectContextual("type"); node.id = this.flowParseRestrictedIdentifier(/*liberal*/ true); + this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start); if (this.isRelational("<")) { node.typeParameters = this.flowParseTypeParameterDeclaration(); @@ -1761,7 +1774,7 @@ export default (superClass: Class): Class => "arrow function parameters", ); // Use super's method to force the parameters to be checked - super.checkFunctionNameAndParams(node, true); + super.checkParams(node, false, true); } else { arrows.push(node); } @@ -1995,14 +2008,14 @@ export default (superClass: Class): Class => checkLVal( expr: N.Expression, - isBinding: ?boolean, + bindingType: ?BindingTypes = BIND_NONE, checkClashes: ?{ [key: string]: boolean }, contextDescription: string, ): void { if (expr.type !== "TypeCastExpression") { return super.checkLVal( expr, - isBinding, + bindingType, checkClashes, contextDescription, ); @@ -2047,6 +2060,7 @@ export default (superClass: Class): Class => isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowsDirectSuper: boolean, ): void { if ((method: $FlowFixMe).variance) { this.unexpected((method: $FlowFixMe).variance.start); @@ -2064,6 +2078,7 @@ export default (superClass: Class): Class => isGenerator, isAsync, isConstructor, + allowsDirectSuper, ); } @@ -2217,7 +2232,12 @@ export default (superClass: Class): Class => ? this.flowParseRestrictedIdentifier(true) : this.parseIdentifier(); - this.checkLVal(specifier.local, true, undefined, contextDescription); + this.checkLVal( + specifier.local, + BIND_LEXICAL, + undefined, + contextDescription, + ); node.specifiers.push(this.finishNode(specifier, type)); } @@ -2327,12 +2347,17 @@ export default (superClass: Class): Class => ); } - this.checkLVal(specifier.local, true, undefined, "import specifier"); + this.checkLVal( + specifier.local, + BIND_LEXICAL, + undefined, + "import specifier", + ); node.specifiers.push(this.finishNode(specifier, "ImportSpecifier")); } // parse function type parameters - function foo() {} - parseFunctionParams(node: N.Function): void { + parseFunctionParams(node: N.Function, allowModifiers?: boolean): void { // $FlowFixMe const kind = node.kind; if (kind !== "get" && kind !== "set" && this.isRelational("<")) { @@ -2340,7 +2365,7 @@ export default (superClass: Class): Class => /* allowDefault */ false, ); } - super.parseFunctionParams(node); + super.parseFunctionParams(node, allowModifiers); } // parse flow type annotations on variable declarator heads - let foo: string = bar @@ -2519,8 +2544,9 @@ export default (superClass: Class): Class => } } - checkFunctionNameAndParams( + checkParams( node: N.Function, + allowDuplicates: boolean, isArrowFunction: ?boolean, ): void { if ( @@ -2530,7 +2556,7 @@ export default (superClass: Class): Class => return; } - return super.checkFunctionNameAndParams(node, isArrowFunction); + return super.checkParams(node, allowDuplicates, isArrowFunction); } parseParenAndDistinguishExpression(canBeArrow: boolean): N.Expression { diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 1c0961ab9733..7418fd7221ea 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -6,6 +6,13 @@ import { types as ct } from "../tokenizer/context"; import * as N from "../types"; import type { Pos, Position } from "../util/location"; import Parser from "../parser"; +import { + type BindingTypes, + functionFlags, + BIND_NONE, + SCOPE_ARROW, + SCOPE_OTHER, +} from "../util/scopeflags"; type TsModifier = | "readonly" @@ -1071,6 +1078,8 @@ export default (superClass: Class): Class => tsParseModuleBlock(): N.TsModuleBlock { const node: N.TsModuleBlock = this.startNode(); + this.scope.enter(SCOPE_OTHER); + this.expect(tt.braceL); // Inside of a module block is considered "top-level", meaning it can have imports and exports. this.parseBlockOrModuleBlockBody( @@ -1079,6 +1088,7 @@ export default (superClass: Class): Class => /* topLevel */ true, /* end */ tt.braceR, ); + this.scope.exit(); return this.finishNode(node, "TSModuleBlock"); } @@ -1217,8 +1227,7 @@ export default (superClass: Class): Class => switch (starttype) { case tt._function: - this.next(); - return this.parseFunction(nany, /* isStatement */ true); + return this.parseFunctionStatement(nany); case tt._class: return this.parseClass( nany, @@ -1372,17 +1381,13 @@ export default (superClass: Class): Class => return undefined; } - const oldInAsync = this.state.inAsync; - const oldInGenerator = this.state.inGenerator; - this.state.inAsync = true; - this.state.inGenerator = false; + this.scope.enter(functionFlags(true, false) | SCOPE_ARROW); + res.id = null; res.generator = false; res.expression = true; // May be set again by parseFunctionBody. res.async = true; this.parseFunctionBody(res, true); - this.state.inAsync = oldInAsync; - this.state.inGenerator = oldInGenerator; return this.finishNode(res, "ArrowFunctionExpression"); } @@ -1721,11 +1726,12 @@ export default (superClass: Class): Class => classBody: N.ClassBody, member: any, state: { hadConstructor: boolean }, + constructorAllowsSuper: boolean, ): void { const accessibility = this.parseAccessModifier(); if (accessibility) member.accessibility = accessibility; - super.parseClassMember(classBody, member, state); + super.parseClassMember(classBody, member, state, constructorAllowsSuper); } parseClassMemberWithIsStatic( @@ -1733,6 +1739,7 @@ export default (superClass: Class): Class => member: any, state: { hadConstructor: boolean }, isStatic: boolean, + constructorAllowsSuper: boolean, ): void { const methodOrProp: N.ClassMethod | N.ClassProperty = member; const prop: N.ClassProperty = member; @@ -1773,7 +1780,13 @@ export default (superClass: Class): Class => return; } - super.parseClassMemberWithIsStatic(classBody, member, state, isStatic); + super.parseClassMemberWithIsStatic( + classBody, + member, + state, + isStatic, + constructorAllowsSuper, + ); } parsePostMemberNameModifiers( @@ -1923,6 +1936,7 @@ export default (superClass: Class): Class => isGenerator: boolean, isAsync: boolean, isConstructor: boolean, + allowsDirectSuper: boolean, ): void { const typeParameters = this.tsTryParseTypeParameters(); if (typeParameters) method.typeParameters = typeParameters; @@ -1932,6 +1946,7 @@ export default (superClass: Class): Class => isGenerator, isAsync, isConstructor, + allowsDirectSuper, ); } @@ -2154,7 +2169,7 @@ export default (superClass: Class): Class => checkLVal( expr: N.Expression, - isBinding: ?boolean, + bindingType: ?BindingTypes = BIND_NONE, checkClashes: ?{ [key: string]: boolean }, contextDescription: string, ): void { @@ -2167,7 +2182,7 @@ export default (superClass: Class): Class => case "TSParameterProperty": this.checkLVal( expr.parameter, - isBinding, + bindingType, checkClashes, "parameter property", ); @@ -2177,13 +2192,13 @@ export default (superClass: Class): Class => case "TSTypeAssertion": this.checkLVal( expr.expression, - isBinding, + bindingType, checkClashes, contextDescription, ); return; default: - super.checkLVal(expr, isBinding, checkClashes, contextDescription); + super.checkLVal(expr, bindingType, checkClashes, contextDescription); return; } } diff --git a/packages/babel-parser/src/tokenizer/context.js b/packages/babel-parser/src/tokenizer/context.js index 6add1a4cf7d3..f89897b27a04 100644 --- a/packages/babel-parser/src/tokenizer/context.js +++ b/packages/babel-parser/src/tokenizer/context.js @@ -60,7 +60,7 @@ tt.name.updateContext = function(prevType) { if (prevType !== tt.dot) { if ( (this.state.value === "of" && !this.state.exprAllowed) || - (this.state.value === "yield" && this.state.inGenerator) + (this.state.value === "yield" && this.scope.inGenerator) ) { allowed = true; } diff --git a/packages/babel-parser/src/tokenizer/state.js b/packages/babel-parser/src/tokenizer/state.js index 0215532dd0f8..c8ef367425dc 100644 --- a/packages/babel-parser/src/tokenizer/state.js +++ b/packages/babel-parser/src/tokenizer/state.js @@ -66,13 +66,9 @@ export default class State { // and then convert them, we need to track it. commaAfterSpreadAt: number = -1; - // Flags to track whether we are in a function, a generator. - inFunction: boolean = false; + // Flags to track inParameters: boolean = false; maybeInArrowParameters: boolean = false; - inGenerator: boolean = false; - inMethod: boolean | N.MethodKind = false; - inAsync: boolean = false; inPipeline: boolean = false; inType: boolean = false; noAnonFunctionType: boolean = false; diff --git a/packages/babel-parser/src/util/scope.js b/packages/babel-parser/src/util/scope.js new file mode 100644 index 000000000000..496814cd96b0 --- /dev/null +++ b/packages/babel-parser/src/util/scope.js @@ -0,0 +1,160 @@ +// @flow +import { + SCOPE_ARROW, + SCOPE_ASYNC, + SCOPE_DIRECT_SUPER, + SCOPE_FUNCTION, + SCOPE_GENERATOR, + SCOPE_SIMPLE_CATCH, + SCOPE_SUPER, + SCOPE_PROGRAM, + SCOPE_VAR, + BIND_SIMPLE_CATCH, + BIND_LEXICAL, + BIND_FUNCTION, + type ScopeFlags, + type BindingTypes, + SCOPE_CLASS, +} from "./scopeflags"; + +// Start an AST node, attaching a start offset. +class Scope { + flags: ScopeFlags; + // A list of var-declared names in the current lexical scope + var: string[] = []; + // A list of lexically-declared names in the current lexical scope + lexical: string[] = []; + // A list of lexically-declared FunctionDeclaration names in the current lexical scope + functions: string[] = []; + + constructor(flags: ScopeFlags) { + this.flags = flags; + } +} + +type raiseFunction = (number, string) => void; + +// The functions in this module keep track of declared variables in the +// current scope in order to detect duplicate variable names. +export default class ScopeHandler { + scopeStack: Array = []; + raise: raiseFunction; + inModule: boolean; + + constructor(raise: raiseFunction, inModule: boolean) { + this.raise = raise; + this.inModule = inModule; + } + + get inFunction() { + return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0; + } + get inGenerator() { + return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0; + } + get inAsync() { + return (this.currentVarScope().flags & SCOPE_ASYNC) > 0; + } + get allowSuper() { + return (this.currentThisScope().flags & SCOPE_SUPER) > 0; + } + get allowDirectSuper() { + return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0; + } + get inNonArrowFunction() { + return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0; + } + get treatFunctionsAsVar() { + return this.treatFunctionsAsVarInScope(this.currentScope()); + } + + enter(flags: ScopeFlags) { + this.scopeStack.push(new Scope(flags)); + } + + exit() { + this.scopeStack.pop(); + } + + // The spec says: + // > At the top level of a function, or script, function declarations are + // > treated like var declarations rather than like lexical declarations. + treatFunctionsAsVarInScope(scope: Scope): boolean { + return !!( + scope.flags & SCOPE_FUNCTION || + (!this.inModule && scope.flags & SCOPE_PROGRAM) + ); + } + + declareName(name: string, bindingType: ?BindingTypes, pos: number) { + let redeclared = false; + if (bindingType === BIND_LEXICAL) { + const scope = this.currentScope(); + redeclared = + scope.lexical.indexOf(name) > -1 || + scope.functions.indexOf(name) > -1 || + scope.var.indexOf(name) > -1; + scope.lexical.push(name); + } else if (bindingType === BIND_SIMPLE_CATCH) { + const scope = this.currentScope(); + scope.lexical.push(name); + } else if (bindingType === BIND_FUNCTION) { + const scope = this.currentScope(); + if (this.treatFunctionsAsVar) { + redeclared = scope.lexical.indexOf(name) > -1; + } else { + redeclared = + scope.lexical.indexOf(name) > -1 || scope.var.indexOf(name) > -1; + } + scope.functions.push(name); + } else { + for (let i = this.scopeStack.length - 1; i >= 0; --i) { + const scope = this.scopeStack[i]; + if ( + (scope.lexical.indexOf(name) > -1 && + !(scope.flags & SCOPE_SIMPLE_CATCH) && + scope.lexical[0] === name) || + (!this.treatFunctionsAsVarInScope(scope) && + scope.functions.indexOf(name) > -1) + ) { + redeclared = true; + break; + } + scope.var.push(name); + + if (scope.flags & SCOPE_VAR) break; + } + } + if (redeclared) { + this.raise(pos, `Identifier '${name}' has already been declared`); + } + } + + currentScope(): Scope { + return this.scopeStack[this.scopeStack.length - 1]; + } + + // $FlowIgnore + currentVarScope(): Scope { + for (let i = this.scopeStack.length - 1; ; i--) { + const scope = this.scopeStack[i]; + if (scope.flags & SCOPE_VAR) { + return scope; + } + } + } + + // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`. + // $FlowIgnore + currentThisScope(): Scope { + for (let i = this.scopeStack.length - 1; ; i--) { + const scope = this.scopeStack[i]; + if ( + (scope.flags & SCOPE_VAR || scope.flags & SCOPE_CLASS) && + !(scope.flags & SCOPE_ARROW) + ) { + return scope; + } + } + } +} diff --git a/packages/babel-parser/src/util/scopeflags.js b/packages/babel-parser/src/util/scopeflags.js new file mode 100644 index 000000000000..35ba7fe30301 --- /dev/null +++ b/packages/babel-parser/src/util/scopeflags.js @@ -0,0 +1,52 @@ +// @flow + +// Each scope gets a bitset that may contain these flags +// prettier-ignore +export const SCOPE_OTHER = 0b000000000, + SCOPE_PROGRAM = 0b000000001, + SCOPE_FUNCTION = 0b000000010, + SCOPE_ASYNC = 0b000000100, + SCOPE_GENERATOR = 0b000001000, + SCOPE_ARROW = 0b000010000, + SCOPE_SIMPLE_CATCH = 0b000100000, + SCOPE_SUPER = 0b001000000, + SCOPE_DIRECT_SUPER = 0b010000000, + SCOPE_CLASS = 0b100000000, + SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION; + +export type ScopeFlags = + | typeof SCOPE_OTHER + | typeof SCOPE_PROGRAM + | typeof SCOPE_FUNCTION + | typeof SCOPE_VAR + | typeof SCOPE_ASYNC + | typeof SCOPE_GENERATOR + | typeof SCOPE_ARROW + | typeof SCOPE_SIMPLE_CATCH + | typeof SCOPE_SUPER + | typeof SCOPE_DIRECT_SUPER + | typeof SCOPE_CLASS; + +export function functionFlags(isAsync: boolean, isGenerator: boolean) { + return ( + SCOPE_FUNCTION | + (isAsync ? SCOPE_ASYNC : 0) | + (isGenerator ? SCOPE_GENERATOR : 0) + ); +} + +// Used in checkLVal and declareName to determine the type of a binding +export const BIND_NONE = 0, // Not a binding + BIND_VAR = 1, // Var-style binding + BIND_LEXICAL = 2, // Let- or const-style binding + BIND_FUNCTION = 3, // Function declaration + BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding + BIND_OUTSIDE = 5; // Special case for function names as bound inside the function + +export type BindingTypes = + | typeof BIND_NONE + | typeof BIND_VAR + | typeof BIND_LEXICAL + | typeof BIND_FUNCTION + | typeof BIND_SIMPLE_CATCH + | typeof BIND_OUTSIDE; diff --git a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json index d58bb015bf01..12b18792fcc4 100644 --- a/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json +++ b/packages/babel-parser/test/expressions/is-expression-babel-parser/fail/7/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:10)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json index c1cad1bfedad..05a7826ae8ba 100644 --- a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json +++ b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-inside-loop/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:10)" + "throws": "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement (1:10)" } diff --git a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json index 1397e6a76220..395620bfa2f8 100644 --- a/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json +++ b/packages/babel-parser/test/fixtures/core/categorized/invalid-fn-decl-labeled-inside-loop/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:20)" + "throws": "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement (1:20)" } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/input.js new file mode 100644 index 000000000000..0ed8680e4854 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/input.js @@ -0,0 +1,3 @@ +try { +} catch ([foo, foo]) { +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json new file mode 100644 index 000000000000..70121ca46ead --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-arr-destr/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:15)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/input.js new file mode 100644 index 000000000000..5ccd99323ac8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/input.js @@ -0,0 +1 @@ +let foo; try {} catch (foo) {} let foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json new file mode 100644 index 000000000000..386e81ecdc4c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-dbl-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (1:35)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/input.js new file mode 100644 index 000000000000..c53b6b3d03fc --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { + function foo() {} +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json new file mode 100644 index 000000000000..62b0c73eb164 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/input.js new file mode 100644 index 000000000000..32d85119a543 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { + if (1) function foo() {} +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json new file mode 100644 index 000000000000..b576780b7063 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json @@ -0,0 +1,207 @@ +{ + "type": "File", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 50, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "IfStatement", + "start": 24, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "test": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + }, + "consequent": { + "type": "FunctionDeclaration", + "start": 31, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "id": { + "type": "Identifier", + "start": 40, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 21 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 46, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "body": [], + "directives": [] + } + }, + "alternate": null + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/input.js new file mode 100644 index 000000000000..f223972849fe --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { +} +let foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json new file mode 100644 index 000000000000..677fad5fcdc7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + }, + { + "type": "VariableDeclaration", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/input.js new file mode 100644 index 000000000000..8e4af00ffaed --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { + let foo; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json new file mode 100644 index 000000000000..254a763e653e --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:6)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/input.js new file mode 100644 index 000000000000..b8a800685aa4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/input.js @@ -0,0 +1,3 @@ +try { +} catch ({ a: foo, b: { c: [foo] } }) { +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json new file mode 100644 index 000000000000..a00c2989e1b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-obj-destr/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:28)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/input.js new file mode 100644 index 000000000000..0c5630af7e93 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/input.js @@ -0,0 +1,4 @@ +try { +} catch ([foo]) { + var foo; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json new file mode 100644 index 000000000000..ff69adb0860a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-arr-destr/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/input.js new file mode 100644 index 000000000000..6cdcb267c2b3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/input.js @@ -0,0 +1,7 @@ +try { +} catch (foo) { + try { + } catch (_) { + var foo; + } +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json new file mode 100644 index 000000000000..6b4c229346ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json @@ -0,0 +1,254 @@ +{ + "type": "File", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 64, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 64, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 7, + "column": 1 + } + }, + "body": [ + { + "type": "TryStatement", + "start": 24, + "end": 62, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "block": { + "type": "BlockStatement", + "start": 28, + "end": 33, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 34, + "end": 62, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "param": { + "type": "Identifier", + "start": 41, + "end": 42, + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 12 + }, + "identifierName": "_" + }, + "name": "_" + }, + "body": { + "type": "BlockStatement", + "start": 44, + "end": 62, + "loc": { + "start": { + "line": 4, + "column": 14 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 50, + "end": 58, + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 54, + "end": 57, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 11 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/input.js new file mode 100644 index 000000000000..a93f6a37bda5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/input.js @@ -0,0 +1,4 @@ +try { +} catch ({ foo }) { + var foo; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json new file mode 100644 index 000000000000..ff69adb0860a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-obj-destr/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/input.js new file mode 100644 index 000000000000..cd2df9964963 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { +} +var foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json new file mode 100644 index 000000000000..439f7f105f01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + }, + { + "type": "VariableDeclaration", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/input.js new file mode 100644 index 000000000000..e2983d96dca8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/input.js @@ -0,0 +1,4 @@ +try { +} catch (foo) { + var foo; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json new file mode 100644 index 000000000000..66d668784cab --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json @@ -0,0 +1,170 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 8, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "param": { + "type": "Identifier", + "start": 15, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "body": { + "type": "BlockStatement", + "start": 20, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/input.js new file mode 100644 index 000000000000..3996f21e1238 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/input.js @@ -0,0 +1,2 @@ +class foo {}; +class foo {}; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json new file mode 100644 index 000000000000..cdd0ac832c57 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/input.js new file mode 100644 index 000000000000..0f7aaf2b6905 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/input.js @@ -0,0 +1,2 @@ +class foo {}; +const foo = 1; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json new file mode 100644 index 000000000000..c45b9bf38290 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-const/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/input.js new file mode 100644 index 000000000000..0953b37d0ca1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/input.js @@ -0,0 +1,2 @@ +class foo {}; +function foo () {}; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json new file mode 100644 index 000000000000..58aaf9d99d22 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/input.js new file mode 100644 index 000000000000..970f577a71e9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/input.js @@ -0,0 +1,2 @@ +class foo {}; +let foo = 1; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json new file mode 100644 index 000000000000..bf89e4692c99 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:4)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/input.js new file mode 100644 index 000000000000..0cbd916cdb6b --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/input.js @@ -0,0 +1,2 @@ +class foo {}; +var foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json new file mode 100644 index 000000000000..bf89e4692c99 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-class-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (2:4)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/input.js new file mode 100644 index 000000000000..206de74b498c --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/input.js @@ -0,0 +1 @@ +const foo=1, foo=2; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json new file mode 100644 index 000000000000..d62aabfd1b07 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-const-const/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (1:13)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/input.js new file mode 100644 index 000000000000..b5a6ac21d8aa --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/input.js @@ -0,0 +1 @@ +{ function f() {} function* f() {} } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json new file mode 100644 index 000000000000..c083e3d4c063 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-gen/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'f' has already been declared (1:28)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/input.js new file mode 100644 index 000000000000..31ea14cffbb8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/input.js @@ -0,0 +1 @@ +{ function foo() {} function foo() {} } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json new file mode 100644 index 000000000000..3f4250fbe917 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module-sloppy/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Identifier 'foo' has already been declared (1:29)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/input.js new file mode 100644 index 000000000000..11a6da2a7eb8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/input.js @@ -0,0 +1,2 @@ +function foo() {} +function foo() {} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json new file mode 100644 index 000000000000..23553cce3705 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-module/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws":"Identifier 'foo' has already been declared (2:9)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/input.js new file mode 100644 index 000000000000..31ea14cffbb8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/input.js @@ -0,0 +1 @@ +{ function foo() {} function foo() {} } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/options.json new file mode 100644 index 000000000000..b412ffe6712f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/output.json new file mode 100644 index 000000000000..94ae24d249a9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script-sloppy/output.json @@ -0,0 +1,157 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "body": [ + { + "type": "FunctionDeclaration", + "start": 2, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": { + "type": "Identifier", + "start": 11, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 20, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 35, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 37 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/input.js new file mode 100644 index 000000000000..11a6da2a7eb8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/input.js @@ -0,0 +1,2 @@ +function foo() {} +function foo() {} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/options.json new file mode 100644 index 000000000000..b412ffe6712f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/output.json new file mode 100644 index 000000000000..af377ce80461 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-script/output.json @@ -0,0 +1,139 @@ +{ + "type": "File", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "FunctionDeclaration", + "start": 18, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 27, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 33, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/input.js new file mode 100644 index 000000000000..7f32f625bccf --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/input.js @@ -0,0 +1,4 @@ +{ + function foo() {} + var foo = 1; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json new file mode 100644 index 000000000000..ff69adb0860a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var-sloppy/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/input.js new file mode 100644 index 000000000000..3248c1cf455b --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/input.js @@ -0,0 +1,2 @@ +function foo() {} +var foo = 1; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/output.json new file mode 100644 index 000000000000..d2a2c6f9982d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-func-var/output.json @@ -0,0 +1,157 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 15, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "VariableDeclaration", + "start": 18, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 22, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "id": { + "type": "Identifier", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": { + "type": "NumericLiteral", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/input.js new file mode 100644 index 000000000000..cc9c09466785 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/input.js @@ -0,0 +1 @@ +{ function* f() {} function f() {} } diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json new file mode 100644 index 000000000000..c083e3d4c063 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'f' has already been declared (1:28)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/input.js new file mode 100644 index 000000000000..a43e0c8581d5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/input.js @@ -0,0 +1,2 @@ +function *foo() {}; +function *foo() {}; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/options.json new file mode 100644 index 000000000000..b412ffe6712f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "script" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/output.json new file mode 100644 index 000000000000..e5bce9fb21da --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-gen-gen-script/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "EmptyStatement", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 19 + } + } + }, + { + "type": "FunctionDeclaration", + "start": 20, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 30, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "EmptyStatement", + "start": 38, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 19 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/input.js new file mode 100644 index 000000000000..60494395b6a6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/input.js @@ -0,0 +1 @@ +let foo, foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json new file mode 100644 index 000000000000..714354e14501 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-let-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (1:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/input.js new file mode 100644 index 000000000000..79a65c0ee2de --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/input.js @@ -0,0 +1,4 @@ +{ + let a; + { var a; } +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json new file mode 100644 index 000000000000..a0925d495610 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-let-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'a' has already been declared (3:8)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/input.js new file mode 100644 index 000000000000..b5bbb6d44168 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/input.js @@ -0,0 +1,4 @@ +{ + var a; + { let a; } +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/output.json new file mode 100644 index 000000000000..239db26973c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-nested-var-let/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "BlockStatement", + "start": 13, + "end": 23, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } + ], + "directives": [] + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/input.js new file mode 100644 index 000000000000..260da8ced85a --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/input.js @@ -0,0 +1 @@ +var foo, foo; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/output.json new file mode 100644 index 000000000000..0be8a0eea29f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-var-var/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/let-assign/input.js b/packages/babel-parser/test/fixtures/core/scope/let-assign/input.js new file mode 100644 index 000000000000..a66eb5ab6774 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/let-assign/input.js @@ -0,0 +1 @@ +let x = 1; x = 2; diff --git a/packages/babel-parser/test/fixtures/core/scope/let-assign/output.json b/packages/babel-parser/test/fixtures/core/scope/let-assign/output.json new file mode 100644 index 000000000000..508af9fc85d2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/let-assign/output.json @@ -0,0 +1,173 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + "init": { + "type": "NumericLiteral", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "let" + }, + { + "type": "ExpressionStatement", + "start": 11, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 11, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "NumericLiteral", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "extra": { + "rawValue": 2, + "raw": "2" + }, + "value": 2 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json index 2a28555f76db..fa57d4f43f70 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/401/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'null' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json index 2a28555f76db..c4a7ead13704 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/402/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'true' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json index 2a28555f76db..0e9cf8962aae 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/403/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'false' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json index 2a28555f76db..a87aa98c0e01 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/404/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'if' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json index e23388601bb0..8b20b9a7df36 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/514/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:14)" + "throws": "Argument name clash (1:14)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json index 660e54ca2a82..9d2a58081596 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/517/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:43)" + "throws": "Argument name clash (1:43)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json index 28545ded1456..61c3bbb5abe0 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/518/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:15)" + "throws": "Argument name clash (1:15)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json index 0f592c74a35b..ae469fbd59da 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/519/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:44)" + "throws": "Argument name clash (1:44)" } diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json index faef53359bea..9461325c423a 100644 --- a/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/direct-super-outside-constructor/options.json @@ -1,3 +1,3 @@ { - "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'. (2:8)" + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (2:8)" } diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/input.js b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/input.js new file mode 100644 index 000000000000..b6864d7c339c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/input.js @@ -0,0 +1 @@ +if (1) function *foo() {} diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json new file mode 100644 index 000000000000..8cdac51705a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-hanging/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Generators can only be declared at the top level or inside a block (1:16)" +} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/input.js new file mode 100644 index 000000000000..932ee841bdb3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/input.js @@ -0,0 +1,3 @@ +const A = function() { + new.target; +}; diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/output.json new file mode 100644 index 000000000000..f5f3e41b514d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/expression/output.json @@ -0,0 +1,186 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "init": { + "type": "FunctionExpression", + "start": 10, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 21, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 25, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "expression": { + "type": "MetaProperty", + "start": 25, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "meta": { + "type": "Identifier", + "start": 25, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 29, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "directives": [] + } + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/input.js new file mode 100644 index 000000000000..f13bdd7175a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/input.js @@ -0,0 +1,3 @@ +const A = () => { + new.target; +} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json new file mode 100644 index 000000000000..4be1533d8e29 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/invalid-arrow-function/options.json @@ -0,0 +1,3 @@ +{ + "throws": "new.target can only be used in functions (2:2)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/input.js new file mode 100644 index 000000000000..a3f74c60f128 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/input.js @@ -0,0 +1 @@ +function A() { return () => new.target } diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/output.json new file mode 100644 index 000000000000..447bc2741c32 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/nested-arrow-function/output.json @@ -0,0 +1,171 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "A" + }, + "name": "A" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 15, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "argument": { + "type": "ArrowFunctionExpression", + "start": 22, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "MetaProperty", + "start": 28, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "meta": { + "type": "Identifier", + "start": 28, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 32, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/input.js new file mode 100644 index 000000000000..ecd7c772f6c6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/input.js @@ -0,0 +1,3 @@ +function A() { + new.target; +} diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/output.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/output.json new file mode 100644 index 000000000000..80af5ec9a8db --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/statement/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "A" + }, + "name": "A" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 17, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "expression": { + "type": "MetaProperty", + "start": 17, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "meta": { + "type": "Identifier", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "new" + }, + "name": "new" + }, + "property": { + "type": "Identifier", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "target" + }, + "name": "target" + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json index c8c111d88d34..446a980f5409 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring10/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:20)" + "throws": "Identifier 'foo' has already been declared (2:20)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json index cf1dcd59dc8e..09b3fa97a0d1 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring11/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo4` has already been exported. Exported identifiers must be unique. (2:50)" + "throws": "Identifier 'foo4' has already been declared (2:50)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json index c2f8cdda986d..3a7173c837e3 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring12/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo4` has already been exported. Exported identifiers must be unique. (2:49)" + "throws": "Identifier 'foo4' has already been declared (2:49)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json index 1cd229e76cc6..d3fc42a61ba1 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring13/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo4` has already been exported. Exported identifiers must be unique. (2:58)" + "throws": "Identifier 'foo4' has already been declared (2:58)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json index e6aaa311fc54..80640e0ce127 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring14/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:21)" + "throws": "Identifier 'foo' has already been declared (2:21)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json index 4eb6f26f952b..ea3a9b62f493 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring15/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo2` has already been exported. Exported identifiers must be unique. (2:13)" + "throws": "Identifier 'foo2' has already been declared (2:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json index 4f3ba9d9d20a..42c862ad273a 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring16/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:22)" + "throws": "Identifier 'foo' has already been declared (2:22)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json index dab0e075b01d..125c2618435d 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring17/options.json @@ -1,3 +1,3 @@ { - "throws": "`bar` has already been exported. Exported identifiers must be unique. (2:13)" + "throws": "Identifier 'bar' has already been declared (2:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json index 7ee0cc434182..bf345ea77127 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring18/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:28)" + "throws": "Identifier 'foo' has already been declared (2:28)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json index 72b54a0a77cb..bf2483362193 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring19/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:29)" + "throws": "Identifier 'foo' has already been declared (2:29)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json index f28333f6f8ad..2cbe06c40914 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring2/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:15)" + "throws": "Identifier 'foo' has already been declared (2:15)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json index 1923e4752336..d36390356990 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring3/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:0)" + "throws": "Identifier 'foo' has already been declared (2:16)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json index 37d131b70f3c..46358493589c 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring4/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:14)" + "throws": "Identifier 'foo' has already been declared (2:14)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json index 1923e4752336..d36390356990 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring5/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:0)" + "throws": "Identifier 'foo' has already been declared (2:16)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json index 37d131b70f3c..46358493589c 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring6/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:14)" + "throws": "Identifier 'foo' has already been declared (2:14)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json index f28333f6f8ad..2cbe06c40914 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring7/options.json @@ -1,3 +1,3 @@ { - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:15)" + "throws": "Identifier 'foo' has already been declared (2:15)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json index 8ef246d83cc0..982078d803c6 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring8/options.json @@ -1,3 +1,3 @@ { - "throws": "`Foo` has already been exported. Exported identifiers must be unique. (2:15)" + "throws": "Identifier 'Foo' has already been declared (2:15)" } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json index 6b46482b6ed6..f79b5469b1c0 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-destructuring9/options.json @@ -1,3 +1,3 @@ { - "throws": "`Foo` has already been exported. Exported identifiers must be unique. (2:14)" + "throws": "Identifier 'Foo' has already been declared (2:14)" } diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json index 91b308200e05..a064a678e553 100644 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-const/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:5)" + "throws": "Lexical declaration cannot appear in a single-statement context (1:5)" } diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json index 042d7e196224..95aaacb458f8 100644 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-async/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:5)" + "throws": "Async functions can only be declared at the top level or inside a block (1:5)" } diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json index 91b308200e05..3f6e90c7cd27 100644 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-generator/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:5)" + "throws": "Generators can only be declared at the top level or inside a block (1:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json index ee5cd5b13513..1eebe15c408e 100644 --- a/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json +++ b/packages/babel-parser/test/fixtures/es2015/statements/label-invalid-func-strict/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:35)" + "throws": "In strict mode code, functions can only be declared at top level or inside a block (1:35)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json new file mode 100644 index 000000000000..fdf74cefe1b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/options.json @@ -0,0 +1,3 @@ +{ + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (1:40)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json deleted file mode 100644 index 56f49a7b6964..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/123/output.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 51, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 51 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 51, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 51 - } - }, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "ExpressionStatement", - "start": 14, - "end": 51, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 51 - } - }, - "expression": { - "type": "ClassExpression", - "start": 15, - "end": 50, - "loc": { - "start": { - "line": 1, - "column": 15 - }, - "end": { - "line": 1, - "column": 50 - } - }, - "id": { - "type": "Identifier", - "start": 21, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 21 - }, - "end": { - "line": 1, - "column": 22 - }, - "identifierName": "A" - }, - "name": "A" - }, - "superClass": null, - "body": { - "type": "ClassBody", - "start": 23, - "end": 50, - "loc": { - "start": { - "line": 1, - "column": 23 - }, - "end": { - "line": 1, - "column": 50 - } - }, - "body": [ - { - "type": "ClassMethod", - "start": 24, - "end": 49, - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 49 - } - }, - "static": false, - "key": { - "type": "Identifier", - "start": 24, - "end": 35, - "loc": { - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 35 - }, - "identifierName": "constructor" - }, - "name": "constructor" - }, - "computed": false, - "kind": "constructor", - "id": null, - "generator": false, - "async": false, - "params": [], - "body": { - "type": "BlockStatement", - "start": 38, - "end": 49, - "loc": { - "start": { - "line": 1, - "column": 38 - }, - "end": { - "line": 1, - "column": 49 - } - }, - "body": [ - { - "type": "ExpressionStatement", - "start": 40, - "end": 47, - "loc": { - "start": { - "line": 1, - "column": 40 - }, - "end": { - "line": 1, - "column": 47 - } - }, - "expression": { - "type": "CallExpression", - "start": 40, - "end": 47, - "loc": { - "start": { - "line": 1, - "column": 40 - }, - "end": { - "line": 1, - "column": 47 - } - }, - "callee": { - "type": "Super", - "start": 40, - "end": 45, - "loc": { - "start": { - "line": 1, - "column": 40 - }, - "end": { - "line": 1, - "column": 45 - } - } - }, - "arguments": [] - } - } - ], - "directives": [] - } - } - ] - }, - "extra": { - "parenthesized": true, - "parenStart": 14 - } - } - } - ], - "directives": [ - { - "type": "Directive", - "start": 0, - "end": 13, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 13 - } - }, - "value": { - "type": "DirectiveLiteral", - "start": 0, - "end": 12, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 12 - } - }, - "value": "use strict", - "extra": { - "raw": "\"use strict\"", - "rawValue": "use strict" - } - } - } - ] - } -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json new file mode 100644 index 000000000000..3481bedf3cc1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Argument name clash (1:16)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json deleted file mode 100644 index 8f278a52ae1e..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/166/output.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "sourceType": "script", - "interpreter": null, - "body": [ - { - "type": "FunctionDeclaration", - "start": 0, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "id": { - "type": "Identifier", - "start": 9, - "end": 10, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - }, - "identifierName": "x" - }, - "name": "x" - }, - "generator": false, - "async": false, - "params": [ - { - "type": "Identifier", - "start": 11, - "end": 12, - "loc": { - "start": { - "line": 1, - "column": 11 - }, - "end": { - "line": 1, - "column": 12 - }, - "identifierName": "a" - }, - "name": "a" - }, - { - "type": "ObjectPattern", - "start": 14, - "end": 19, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 19 - } - }, - "properties": [ - { - "type": "ObjectProperty", - "start": 16, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 17 - } - }, - "method": false, - "key": { - "type": "Identifier", - "start": 16, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 17 - }, - "identifierName": "a" - }, - "name": "a" - }, - "computed": false, - "shorthand": true, - "value": { - "type": "Identifier", - "start": 16, - "end": 17, - "loc": { - "start": { - "line": 1, - "column": 16 - }, - "end": { - "line": 1, - "column": 17 - }, - "identifierName": "a" - }, - "name": "a" - }, - "extra": { - "shorthand": true - } - } - ] - } - ], - "body": { - "type": "BlockStatement", - "start": 20, - "end": 22, - "loc": { - "start": { - "line": 1, - "column": 20 - }, - "end": { - "line": 1, - "column": 22 - } - }, - "body": [], - "directives": [] - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json index 2a28555f76db..74c1a72d5030 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/226/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Unexpected keyword 'default' (1:9)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json index 9f34dba23230..a33dde469094 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/228/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:37)" + "throws": "Argument name clash (1:37)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json index 6d0445e20eb7..b99fd35222b1 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/248/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:18)" + "throws": "Argument name clash (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json index 0c0a9d0136e3..5cbee309bd50 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/280/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:30)" + "throws": "Argument name clash (1:30)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json index 4773c60e5b99..8dba9882c0dc 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/281/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:47)" + "throws": "Argument name clash (1:47)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json index 2a28555f76db..97818d2eea7e 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/329/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Lexical declaration cannot appear in a single-statement context (1:9)" } diff --git a/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/input.js b/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/input.js new file mode 100644 index 000000000000..c1ce97544cdb --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/input.js @@ -0,0 +1,9 @@ +var yieldSet, C, iter; +function* g() { + class C_ { + get [yield]() { return 'get yield'; } + set [yield](param) { yieldSet = param; } + } + + C = C_; +} diff --git a/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/output.json b/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/output.json new file mode 100644 index 000000000000..1082894c21d5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/yield/accessor-name-inst-computed-yield-expr/output.json @@ -0,0 +1,552 @@ +{ + "type": "File", + "start": 0, + "end": 155, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 155, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "yieldSet" + }, + "name": "yieldSet" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 14, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "C" + }, + "name": "C" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "iter" + }, + "name": "iter" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "FunctionDeclaration", + "start": 23, + "end": 155, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 33, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 37, + "end": 155, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "body": [ + { + "type": "ClassDeclaration", + "start": 41, + "end": 142, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "id": { + "type": "Identifier", + "start": 47, + "end": 49, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 10 + }, + "identifierName": "C_" + }, + "name": "C_" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 50, + "end": 142, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 6, + "column": 3 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 56, + "end": 93, + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 41 + } + }, + "static": false, + "key": { + "type": "YieldExpression", + "start": 61, + "end": 66, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "delegate": false, + "argument": null + }, + "computed": true, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 70, + "end": 93, + "loc": { + "start": { + "line": 4, + "column": 18 + }, + "end": { + "line": 4, + "column": 41 + } + }, + "body": [ + { + "type": "ReturnStatement", + "start": 72, + "end": 91, + "loc": { + "start": { + "line": 4, + "column": 20 + }, + "end": { + "line": 4, + "column": 39 + } + }, + "argument": { + "type": "StringLiteral", + "start": 79, + "end": 90, + "loc": { + "start": { + "line": 4, + "column": 27 + }, + "end": { + "line": 4, + "column": 38 + } + }, + "extra": { + "rawValue": "get yield", + "raw": "'get yield'" + }, + "value": "get yield" + } + } + ], + "directives": [] + } + }, + { + "type": "ClassMethod", + "start": 98, + "end": 138, + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 44 + } + }, + "static": false, + "key": { + "type": "YieldExpression", + "start": 103, + "end": 108, + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "delegate": false, + "argument": null + }, + "computed": true, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 110, + "end": 115, + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 5, + "column": 21 + }, + "identifierName": "param" + }, + "name": "param" + } + ], + "body": { + "type": "BlockStatement", + "start": 117, + "end": 138, + "loc": { + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 5, + "column": 44 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 119, + "end": 136, + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 119, + "end": 135, + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 119, + "end": 127, + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 33 + }, + "identifierName": "yieldSet" + }, + "name": "yieldSet" + }, + "right": { + "type": "Identifier", + "start": 130, + "end": 135, + "loc": { + "start": { + "line": 5, + "column": 36 + }, + "end": { + "line": 5, + "column": 41 + }, + "identifierName": "param" + }, + "name": "param" + } + } + } + ], + "directives": [] + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 146, + "end": 153, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "expression": { + "type": "AssignmentExpression", + "start": 146, + "end": 152, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "operator": "=", + "left": { + "type": "Identifier", + "start": 146, + "end": 147, + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 3 + }, + "identifierName": "C" + }, + "name": "C" + }, + "right": { + "type": "Identifier", + "start": 150, + "end": 152, + "loc": { + "start": { + "line": 8, + "column": 6 + }, + "end": { + "line": 8, + "column": 8 + }, + "identifierName": "C_" + }, + "name": "C_" + } + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json index 5a257f4e5d33..12b18792fcc4 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern-default/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json index 5a257f4e5d33..12b18792fcc4 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/array-pattern/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json index 2e6ae0771c86..089b542c3704 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/arrow-function/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:9)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json index 0c31636171e0..089b542c3704 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-arrow-function/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:15)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json index ff8a46ae1aec..12b18792fcc4 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/async-function/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:17)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json index 5a257f4e5d33..12b18792fcc4 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/default/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json index 65ff709b5f39..12b18792fcc4 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-function/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:12)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json index dd467e6578aa..9908b496fd2a 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/generator-method/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (2:6)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (2:5)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json index ac620235e917..5d0e394f2b9d 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/method/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (2:4)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (2:3)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json index 5a257f4e5d33..12b18792fcc4 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern-default/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json index 5a257f4e5d33..12b18792fcc4 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/object-pattern/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json index 5a257f4e5d33..12b18792fcc4 100644 --- a/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json +++ b/packages/babel-parser/test/fixtures/es2016/simple-parameter-list/rest/options.json @@ -1,3 +1,3 @@ { - "throws": "Non-simple parameter in strict mode (1:11)" + "throws": "Illegal 'use strict' directive in function with non-simple parameter list (1:0)" } diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json index c1cad1bfedad..4bcd823e98be 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-inside-loop/options.json @@ -1,3 +1,3 @@ { - "throws": "Function declaration not allowed in this context (1:10)" + "throws": "Async functions can only be declared at the top level or inside a block (1:10)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json index b382a06ac5d7..6dad74eebd16 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/11/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:23)" + "throws": "Identifier 'foo' has already been declared (2:23)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json index d6149ed84502..165223a448a3 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/12/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`bar` has already been exported. Exported identifiers must be unique. (2:13)" + "throws": "Identifier 'bar' has already been declared (2:13)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json index 8daa306ff731..68df28e41c41 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/13/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:30)" + "throws": "Identifier 'foo' has already been declared (2:30)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json index a87b46d55ac6..280073b140f0 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/14/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:29)" + "throws": "Identifier 'foo' has already been declared (2:29)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json index 8daa306ff731..68df28e41c41 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/15/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "`foo` has already been exported. Exported identifiers must be unique. (2:30)" + "throws": "Identifier 'foo' has already been declared (2:30)" } diff --git a/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json b/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json index e23388601bb0..8b20b9a7df36 100644 --- a/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json +++ b/packages/babel-parser/test/fixtures/esprima/declaration-function/dupe-param/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:14)" + "throws": "Argument name clash (1:14)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json index 34197d2efee7..a4a6e207d28c 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-binding-pattern/invalid-dup-param/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:11)" + "throws": "Argument name clash (1:11)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json index d498cd8bd087..49e8d8e86314 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-1/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (2:14)" + "throws": "Argument name clash (2:14)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json index e3176a8e57eb..3829082a4878 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-2/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (2:17)" + "throws": "Argument name clash (2:17)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json index 2d74a95450d0..782073313a19 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/dupe-param-3/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (2:19)" + "throws": "Argument name clash (2:19)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/input.js deleted file mode 100644 index 417d6fc8492f..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/input.js +++ /dev/null @@ -1 +0,0 @@ -try {} catch ([a,a]) {} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/options.json deleted file mode 100644 index 7d5bec6e9b7b..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch-dupe/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Argument name clash in strict mode (1:17)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json index 4ebe77e8fc2b..fd74c5228531 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/complex-rest-in-arrow-not-allowed/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:7)" + "throws": "Argument name clash (1:7)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json index 0590c2b7e6bf..368006ae58bd 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/invalid-duplicated-params/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:4)" + "throws": "Argument name clash (1:4)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json index 0590c2b7e6bf..368006ae58bd 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0092/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:4)" + "throws": "Argument name clash (1:4)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json index 6d0445e20eb7..b99fd35222b1 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0093/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:18)" + "throws": "Argument name clash (1:18)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json index 2a28555f76db..97818d2eea7e 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0142/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token (1:9)" + "throws": "Lexical declaration cannot appear in a single-statement context (1:9)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json index e23388601bb0..8b20b9a7df36 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0240/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:14)" + "throws": "Argument name clash (1:14)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json index 660e54ca2a82..9d2a58081596 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0243/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:43)" + "throws": "Argument name clash (1:43)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json index 28545ded1456..61c3bbb5abe0 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0244/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:15)" + "throws": "Argument name clash (1:15)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json index 0f592c74a35b..ae469fbd59da 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0245/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:44)" + "throws": "Argument name clash (1:44)" } diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json index 172760cf2cf6..505798d5a203 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0249/options.json @@ -1,3 +1,3 @@ { - "throws": "Argument name clash in strict mode (1:36)" + "throws": "Argument name clash (1:36)" } diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json index e20043c3fa2e..2154c844bfd7 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/super-call/options.json @@ -1,4 +1,4 @@ { "plugins": ["classPrivateProperties"], - "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'. (4:13)" + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (4:13)" } diff --git a/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json b/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json index 3f06e4fecfc3..e8d509e27740 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-properties/super-call/options.json @@ -1,4 +1,4 @@ { "plugins": ["classProperties"], - "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'. (4:12)" + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class? (4:12)" } diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/15/input.js b/packages/babel-parser/test/fixtures/flow/declare-statements/15/input.js index e5d2353e55bd..63a4ecdb5b7e 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/15/input.js +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/15/input.js @@ -1,2 +1,2 @@ declare interface I { foo: string } -declare interface I { foo: T } +declare interface I2 { foo: T } diff --git a/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json b/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json index 6af031abc60f..619a44a76feb 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-statements/15/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 69, + "end": 70, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 2, - "column": 33 + "column": 34 } }, "program": { "type": "Program", "start": 0, - "end": 69, + "end": 70, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 2, - "column": 33 + "column": 34 } }, "sourceType": "module", @@ -142,7 +142,7 @@ { "type": "DeclareInterface", "start": 36, - "end": 69, + "end": 70, "loc": { "start": { "line": 2, @@ -150,13 +150,13 @@ }, "end": { "line": 2, - "column": 33 + "column": 34 } }, "id": { "type": "Identifier", "start": 54, - "end": 55, + "end": 56, "loc": { "start": { "line": 2, @@ -164,39 +164,39 @@ }, "end": { "line": 2, - "column": 19 + "column": 20 }, - "identifierName": "I" + "identifierName": "I2" }, - "name": "I" + "name": "I2" }, "typeParameters": { "type": "TypeParameterDeclaration", - "start": 55, - "end": 58, + "start": 56, + "end": 59, "loc": { "start": { "line": 2, - "column": 19 + "column": 20 }, "end": { "line": 2, - "column": 22 + "column": 23 } }, "params": [ { "type": "TypeParameter", - "start": 56, - "end": 57, + "start": 57, + "end": 58, "loc": { "start": { "line": 2, - "column": 20 + "column": 21 }, "end": { "line": 2, - "column": 21 + "column": 22 } }, "name": "T", @@ -209,46 +209,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 59, - "end": 69, + "start": 60, + "end": 70, "loc": { "start": { "line": 2, - "column": 23 + "column": 24 }, "end": { "line": 2, - "column": 33 + "column": 34 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 61, - "end": 67, + "start": 62, + "end": 68, "loc": { "start": { "line": 2, - "column": 25 + "column": 26 }, "end": { "line": 2, - "column": 31 + "column": 32 } }, "key": { "type": "Identifier", - "start": 61, - "end": 64, + "start": 62, + "end": 65, "loc": { "start": { "line": 2, - "column": 25 + "column": 26 }, "end": { "line": 2, - "column": 28 + "column": 29 }, "identifierName": "foo" }, @@ -260,31 +260,31 @@ "method": false, "value": { "type": "GenericTypeAnnotation", - "start": 66, - "end": 67, + "start": 67, + "end": 68, "loc": { "start": { "line": 2, - "column": 30 + "column": 31 }, "end": { "line": 2, - "column": 31 + "column": 32 } }, "typeParameters": null, "id": { "type": "Identifier", - "start": 66, - "end": 67, + "start": 67, + "end": 68, "loc": { "start": { "line": 2, - "column": 30 + "column": 31 }, "end": { "line": 2, - "column": 31 + "column": 32 }, "identifierName": "T" }, diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/input.js new file mode 100644 index 000000000000..6165683a9167 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/input.js @@ -0,0 +1,2 @@ +const A = 1; +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/options.json new file mode 100644 index 000000000000..4a1b4e5c5cd4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/input.js new file mode 100644 index 000000000000..c432acb46b72 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/input.js @@ -0,0 +1,2 @@ +const A = 1; +declare interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/options.json new file mode 100644 index 000000000000..187fea591b95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-declare-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:18)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/input.js new file mode 100644 index 000000000000..a03017e55c99 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/input.js @@ -0,0 +1,2 @@ +const A = 1; +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/options.json new file mode 100644 index 000000000000..04242bd1565b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-const-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-class/input.js new file mode 100644 index 000000000000..32acf9e66e25 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-class/input.js @@ -0,0 +1,2 @@ +declare class A {} +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/input.js new file mode 100644 index 000000000000..99bf15306148 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/input.js @@ -0,0 +1,2 @@ +declare class A {} +declare interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/options.json new file mode 100644 index 000000000000..187fea591b95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-class-declare-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:18)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/input.js new file mode 100644 index 000000000000..c3a6f63af3b3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/input.js @@ -0,0 +1,2 @@ +declare function A(): void; +declare function A(): void; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/output.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/output.json new file mode 100644 index 000000000000..c4c86f1991cd --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-func/output.json @@ -0,0 +1,197 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareFunction", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 18, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 18, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "typeParameters": null, + "params": [], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 22, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 26 + } + } + } + } + } + }, + "predicate": null + }, + { + "type": "DeclareFunction", + "start": 28, + "end": 55, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "id": { + "type": "Identifier", + "start": 45, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 26 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 46, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "typeAnnotation": { + "type": "FunctionTypeAnnotation", + "start": 46, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 26 + } + }, + "typeParameters": null, + "params": [], + "rest": null, + "returnType": { + "type": "VoidTypeAnnotation", + "start": 50, + "end": 54, + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 26 + } + } + } + } + } + }, + "predicate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/input.js new file mode 100644 index 000000000000..e1e2e647fa89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/input.js @@ -0,0 +1,2 @@ +declare function A(): void; +declare var A: number; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/options.json new file mode 100644 index 000000000000..81dc2c90799f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-declare-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/input.js new file mode 100644 index 000000000000..ccce4b510933 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/input.js @@ -0,0 +1,2 @@ +declare function A(): void; +function A() {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/options.json new file mode 100644 index 000000000000..5f6027f8dd3b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:9)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/input.js new file mode 100644 index 000000000000..58df0295d818 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/input.js @@ -0,0 +1,2 @@ +declare function A(): number; +let A; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/options.json new file mode 100644 index 000000000000..b6ff3a4b0987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-func-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/input.js new file mode 100644 index 000000000000..ab4fe6e51ff7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/input.js @@ -0,0 +1,2 @@ +declare interface A {} +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/options.json new file mode 100644 index 000000000000..4a1b4e5c5cd4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-interface-declare-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/input.js new file mode 100644 index 000000000000..7e5419c9a6c5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/input.js @@ -0,0 +1,2 @@ +declare var A: number; +declare var A: number; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/output.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/output.json new file mode 100644 index 000000000000..532ca8848c0b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-declare-var/output.json @@ -0,0 +1,159 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareVariable", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 12, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 15, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 21 + } + } + } + } + } + }, + { + "type": "DeclareVariable", + "start": 23, + "end": 45, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 35, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 21 + }, + "identifierName": "A" + }, + "name": "A", + "typeAnnotation": { + "type": "TypeAnnotation", + "start": 36, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 21 + } + }, + "typeAnnotation": { + "type": "NumberTypeAnnotation", + "start": 38, + "end": 44, + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 21 + } + } + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/input.js new file mode 100644 index 000000000000..8e7279314635 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/input.js @@ -0,0 +1,2 @@ +declare var A: number; +let A; diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/options.json new file mode 100644 index 000000000000..b6ff3a4b0987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-declare-var-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/input.js new file mode 100644 index 000000000000..5f780ecff9a5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/input.js @@ -0,0 +1,2 @@ +interface A {} +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/options.json new file mode 100644 index 000000000000..04242bd1565b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-interface-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/input.js new file mode 100644 index 000000000000..61596821e374 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/input.js @@ -0,0 +1,2 @@ +let A = 1; +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/options.json new file mode 100644 index 000000000000..4a1b4e5c5cd4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/input.js new file mode 100644 index 000000000000..97428603f0e4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/input.js @@ -0,0 +1,2 @@ +let A = 1; +declare interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/options.json new file mode 100644 index 000000000000..187fea591b95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-declare-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:18)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/input.js new file mode 100644 index 000000000000..2e575bbc693d --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/input.js @@ -0,0 +1,2 @@ +let A = 1; +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/options.json new file mode 100644 index 000000000000..04242bd1565b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-let-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/input.js new file mode 100644 index 000000000000..38b60058911b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/input.js @@ -0,0 +1,2 @@ +type A = number; +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/options.json new file mode 100644 index 000000000000..04242bd1565b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-type-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/input.js new file mode 100644 index 000000000000..c534e4739b49 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/input.js @@ -0,0 +1,2 @@ +var A = 1; +declare class A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/options.json new file mode 100644 index 000000000000..4a1b4e5c5cd4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-class/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:14)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/input.js new file mode 100644 index 000000000000..07a1fa47aab2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/input.js @@ -0,0 +1,2 @@ +var A = 1; +declare interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/options.json new file mode 100644 index 000000000000..187fea591b95 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-declare-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:18)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/input.js b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/input.js new file mode 100644 index 000000000000..70f7e73cc0ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/input.js @@ -0,0 +1,2 @@ +var A = 1; +interface A {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/options.json b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/options.json new file mode 100644 index 000000000000..04242bd1565b --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/.dupl-decl-var-interface/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/declare-module/input.js b/packages/babel-parser/test/fixtures/flow/scope/declare-module/input.js new file mode 100644 index 000000000000..3b25537ffca6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/declare-module/input.js @@ -0,0 +1,5 @@ +declare module A { + declare class X {} +} + +class X {} diff --git a/packages/babel-parser/test/fixtures/flow/scope/declare-module/output.json b/packages/babel-parser/test/fixtures/flow/scope/declare-module/output.json new file mode 100644 index 000000000000..672f98d0ad8c --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/declare-module/output.json @@ -0,0 +1,190 @@ +{ + "type": "File", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 53, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "DeclareModule", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "A" + }, + "name": "A" + }, + "body": { + "type": "BlockStatement", + "start": 17, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "DeclareClass", + "start": 21, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "id": { + "type": "Identifier", + "start": 35, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 16 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeParameters": null, + "extends": [], + "implements": [], + "mixins": [], + "body": { + "type": "ObjectTypeAnnotation", + "start": 37, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "callProperties": [], + "properties": [], + "indexers": [], + "internalSlots": [], + "exact": false + } + } + ] + }, + "kind": "CommonJS" + }, + { + "type": "ClassDeclaration", + "start": 43, + "end": 53, + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 49, + "end": 50, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + }, + "identifierName": "X" + }, + "name": "X" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 51, + "end": 53, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/input.js new file mode 100644 index 000000000000..22286388e087 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/input.js @@ -0,0 +1,2 @@ +const A = 1; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json new file mode 100644 index 000000000000..81dc2c90799f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/input.js new file mode 100644 index 000000000000..09676cc69535 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/input.js @@ -0,0 +1,2 @@ +const A = 1; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json new file mode 100644 index 000000000000..1eed93f49a0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-const-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/input.js new file mode 100644 index 000000000000..f388a626baa6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/input.js @@ -0,0 +1,2 @@ +let A = 1; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json new file mode 100644 index 000000000000..81dc2c90799f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/input.js new file mode 100644 index 000000000000..acd0aedaa643 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/input.js @@ -0,0 +1,2 @@ +let A = 1; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json new file mode 100644 index 000000000000..1eed93f49a0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-let-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/input.js new file mode 100644 index 000000000000..68252d13d604 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +const A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json new file mode 100644 index 000000000000..336686170eb0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-const/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/input.js new file mode 100644 index 000000000000..cb701d75b873 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +let A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json new file mode 100644 index 000000000000..b6ff3a4b0987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/input.js new file mode 100644 index 000000000000..ea475eaf7548 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json new file mode 100644 index 000000000000..81dc2c90799f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/input.js new file mode 100644 index 000000000000..9f3827951edb --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json new file mode 100644 index 000000000000..1eed93f49a0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/input.js new file mode 100644 index 000000000000..265278011940 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/input.js @@ -0,0 +1,2 @@ +opaque type A = {}; +var A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json new file mode 100644 index 000000000000..b6ff3a4b0987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-opaque-type-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/input.js new file mode 100644 index 000000000000..2b045e915ada --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/input.js @@ -0,0 +1,2 @@ +type A = {}; +const A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json new file mode 100644 index 000000000000..336686170eb0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-const/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:6)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/input.js new file mode 100644 index 000000000000..c827929c6d17 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/input.js @@ -0,0 +1,2 @@ +type A = {}; +let A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json new file mode 100644 index 000000000000..b6ff3a4b0987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-let/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/input.js new file mode 100644 index 000000000000..03d17d1612aa --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/input.js @@ -0,0 +1,2 @@ +type A = {}; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json new file mode 100644 index 000000000000..81dc2c90799f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/input.js new file mode 100644 index 000000000000..72146f415607 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/input.js @@ -0,0 +1,2 @@ +type A = {}; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json new file mode 100644 index 000000000000..1eed93f49a0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/input.js new file mode 100644 index 000000000000..04e932fa9c8a --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/input.js @@ -0,0 +1,2 @@ +type A = {}; +var A = 1; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json new file mode 100644 index 000000000000..b6ff3a4b0987 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-type-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:4)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/input.js new file mode 100644 index 000000000000..e4d5ab41ec30 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/input.js @@ -0,0 +1,2 @@ +var A = 1; +opaque type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json new file mode 100644 index 000000000000..81dc2c90799f --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-opaque-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:12)" +} diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/input.js b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/input.js new file mode 100644 index 000000000000..3427e135d606 --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/input.js @@ -0,0 +1,2 @@ +var A = 1; +type A = {}; diff --git a/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json new file mode 100644 index 000000000000..1eed93f49a0e --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/scope/dupl-decl-var-type/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'A' has already been declared (2:5)" +} diff --git a/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/input.js b/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/input.js index f0afdd16f8e5..cd488659aca6 100644 --- a/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/input.js +++ b/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/input.js @@ -1,2 +1,2 @@ export type Foo = number; -export opaque type Foo = number; +export opaque type Foo2 = number; diff --git a/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/output.json b/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/output.json index fc72d6467694..70d30bbe8a92 100644 --- a/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/output.json +++ b/packages/babel-parser/test/fixtures/flow/sourcetype-script/export-named/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 58, + "end": 59, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 2, - "column": 32 + "column": 33 } }, "program": { "type": "Program", "start": 0, - "end": 58, + "end": 59, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 2, - "column": 32 + "column": 33 } }, "sourceType": "script", @@ -98,7 +98,7 @@ { "type": "ExportNamedDeclaration", "start": 26, - "end": 58, + "end": 59, "loc": { "start": { "line": 2, @@ -106,7 +106,7 @@ }, "end": { "line": 2, - "column": 32 + "column": 33 } }, "specifiers": [], @@ -115,7 +115,7 @@ "declaration": { "type": "OpaqueType", "start": 33, - "end": 58, + "end": 59, "loc": { "start": { "line": 2, @@ -123,13 +123,13 @@ }, "end": { "line": 2, - "column": 32 + "column": 33 } }, "id": { "type": "Identifier", "start": 45, - "end": 48, + "end": 49, "loc": { "start": { "line": 2, @@ -137,26 +137,26 @@ }, "end": { "line": 2, - "column": 22 + "column": 23 }, - "identifierName": "Foo" + "identifierName": "Foo2" }, - "name": "Foo" + "name": "Foo2" }, "typeParameters": null, "supertype": null, "impltype": { "type": "NumberTypeAnnotation", - "start": 51, - "end": 57, + "start": 52, + "end": 58, "loc": { "start": { "line": 2, - "column": 25 + "column": 26 }, "end": { "line": 2, - "column": 31 + "column": 32 } } } diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/input.js b/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/input.js index 777868f31ed8..04fd627b994e 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/input.js +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/input.js @@ -1,16 +1,16 @@ // bounds -type T = any; -type T = mixed; -type T = empty; +type T1 = any; +type T2 = mixed; +type T3 = empty; // builtins -type T = void; -type T = number; -type T = string; -type T = bool; -type T = boolean; +type T4 = void; +type T5 = number; +type T6 = string; +type T7 = bool; +type T8 = boolean; // literal type annotations -type T = null; -type T = ""; -type T = 0; -type T = true; -type T = false; +type T9 = null; +type T10 = ""; +type T11 = 0; +type T12 = true; +type T13 = false; diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/output.json index 379ea71424c4..9b3179172293 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/builtin/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 248, + "end": 265, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 16, - "column": 15 + "column": 17 } }, "program": { "type": "Program", "start": 0, - "end": 248, + "end": 265, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 16, - "column": 15 + "column": 17 } }, "sourceType": "module", @@ -32,7 +32,7 @@ { "type": "TypeAlias", "start": 10, - "end": 23, + "end": 24, "loc": { "start": { "line": 2, @@ -40,13 +40,13 @@ }, "end": { "line": 2, - "column": 13 + "column": 14 } }, "id": { "type": "Identifier", "start": 15, - "end": 16, + "end": 17, "loc": { "start": { "line": 2, @@ -54,25 +54,25 @@ }, "end": { "line": 2, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T1" }, - "name": "T" + "name": "T1" }, "typeParameters": null, "right": { "type": "AnyTypeAnnotation", - "start": 19, - "end": 22, + "start": 20, + "end": 23, "loc": { "start": { "line": 2, - "column": 9 + "column": 10 }, "end": { "line": 2, - "column": 12 + "column": 13 } } }, @@ -97,8 +97,8 @@ }, { "type": "TypeAlias", - "start": 24, - "end": 39, + "start": 25, + "end": 41, "loc": { "start": { "line": 3, @@ -106,13 +106,13 @@ }, "end": { "line": 3, - "column": 15 + "column": 16 } }, "id": { "type": "Identifier", - "start": 29, - "end": 30, + "start": 30, + "end": 32, "loc": { "start": { "line": 3, @@ -120,33 +120,33 @@ }, "end": { "line": 3, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T2" }, - "name": "T" + "name": "T2" }, "typeParameters": null, "right": { "type": "MixedTypeAnnotation", - "start": 33, - "end": 38, + "start": 35, + "end": 40, "loc": { "start": { "line": 3, - "column": 9 + "column": 10 }, "end": { "line": 3, - "column": 14 + "column": 15 } } } }, { "type": "TypeAlias", - "start": 40, - "end": 55, + "start": 42, + "end": 58, "loc": { "start": { "line": 4, @@ -154,13 +154,13 @@ }, "end": { "line": 4, - "column": 15 + "column": 16 } }, "id": { "type": "Identifier", - "start": 45, - "end": 46, + "start": 47, + "end": 49, "loc": { "start": { "line": 4, @@ -168,25 +168,25 @@ }, "end": { "line": 4, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T3" }, - "name": "T" + "name": "T3" }, "typeParameters": null, "right": { "type": "EmptyTypeAnnotation", - "start": 49, - "end": 54, + "start": 52, + "end": 57, "loc": { "start": { "line": 4, - "column": 9 + "column": 10 }, "end": { "line": 4, - "column": 14 + "column": 15 } } }, @@ -194,8 +194,8 @@ { "type": "CommentLine", "value": " builtins", - "start": 56, - "end": 67, + "start": 59, + "end": 70, "loc": { "start": { "line": 5, @@ -211,8 +211,8 @@ }, { "type": "TypeAlias", - "start": 68, - "end": 82, + "start": 71, + "end": 86, "loc": { "start": { "line": 6, @@ -220,13 +220,13 @@ }, "end": { "line": 6, - "column": 14 + "column": 15 } }, "id": { "type": "Identifier", - "start": 73, - "end": 74, + "start": 76, + "end": 78, "loc": { "start": { "line": 6, @@ -234,25 +234,25 @@ }, "end": { "line": 6, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T4" }, - "name": "T" + "name": "T4" }, "typeParameters": null, "right": { "type": "VoidTypeAnnotation", - "start": 77, - "end": 81, + "start": 81, + "end": 85, "loc": { "start": { "line": 6, - "column": 9 + "column": 10 }, "end": { "line": 6, - "column": 13 + "column": 14 } } }, @@ -260,8 +260,8 @@ { "type": "CommentLine", "value": " builtins", - "start": 56, - "end": 67, + "start": 59, + "end": 70, "loc": { "start": { "line": 5, @@ -277,8 +277,8 @@ }, { "type": "TypeAlias", - "start": 83, - "end": 99, + "start": 87, + "end": 104, "loc": { "start": { "line": 7, @@ -286,13 +286,13 @@ }, "end": { "line": 7, - "column": 16 + "column": 17 } }, "id": { "type": "Identifier", - "start": 88, - "end": 89, + "start": 92, + "end": 94, "loc": { "start": { "line": 7, @@ -300,33 +300,33 @@ }, "end": { "line": 7, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T5" }, - "name": "T" + "name": "T5" }, "typeParameters": null, "right": { "type": "NumberTypeAnnotation", - "start": 92, - "end": 98, + "start": 97, + "end": 103, "loc": { "start": { "line": 7, - "column": 9 + "column": 10 }, "end": { "line": 7, - "column": 15 + "column": 16 } } } }, { "type": "TypeAlias", - "start": 100, - "end": 116, + "start": 105, + "end": 122, "loc": { "start": { "line": 8, @@ -334,13 +334,13 @@ }, "end": { "line": 8, - "column": 16 + "column": 17 } }, "id": { "type": "Identifier", - "start": 105, - "end": 106, + "start": 110, + "end": 112, "loc": { "start": { "line": 8, @@ -348,33 +348,33 @@ }, "end": { "line": 8, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T6" }, - "name": "T" + "name": "T6" }, "typeParameters": null, "right": { "type": "StringTypeAnnotation", - "start": 109, - "end": 115, + "start": 115, + "end": 121, "loc": { "start": { "line": 8, - "column": 9 + "column": 10 }, "end": { "line": 8, - "column": 15 + "column": 16 } } } }, { "type": "TypeAlias", - "start": 117, - "end": 131, + "start": 123, + "end": 138, "loc": { "start": { "line": 9, @@ -382,13 +382,13 @@ }, "end": { "line": 9, - "column": 14 + "column": 15 } }, "id": { "type": "Identifier", - "start": 122, - "end": 123, + "start": 128, + "end": 130, "loc": { "start": { "line": 9, @@ -396,33 +396,33 @@ }, "end": { "line": 9, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T7" }, - "name": "T" + "name": "T7" }, "typeParameters": null, "right": { "type": "BooleanTypeAnnotation", - "start": 126, - "end": 130, + "start": 133, + "end": 137, "loc": { "start": { "line": 9, - "column": 9 + "column": 10 }, "end": { "line": 9, - "column": 13 + "column": 14 } } } }, { "type": "TypeAlias", - "start": 132, - "end": 149, + "start": 139, + "end": 157, "loc": { "start": { "line": 10, @@ -430,13 +430,13 @@ }, "end": { "line": 10, - "column": 17 + "column": 18 } }, "id": { "type": "Identifier", - "start": 137, - "end": 138, + "start": 144, + "end": 146, "loc": { "start": { "line": 10, @@ -444,25 +444,25 @@ }, "end": { "line": 10, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T8" }, - "name": "T" + "name": "T8" }, "typeParameters": null, "right": { "type": "BooleanTypeAnnotation", - "start": 141, - "end": 148, + "start": 149, + "end": 156, "loc": { "start": { "line": 10, - "column": 9 + "column": 10 }, "end": { "line": 10, - "column": 16 + "column": 17 } } }, @@ -470,8 +470,8 @@ { "type": "CommentLine", "value": " literal type annotations", - "start": 150, - "end": 177, + "start": 158, + "end": 185, "loc": { "start": { "line": 11, @@ -487,8 +487,8 @@ }, { "type": "TypeAlias", - "start": 178, - "end": 192, + "start": 186, + "end": 201, "loc": { "start": { "line": 12, @@ -496,13 +496,13 @@ }, "end": { "line": 12, - "column": 14 + "column": 15 } }, "id": { "type": "Identifier", - "start": 183, - "end": 184, + "start": 191, + "end": 193, "loc": { "start": { "line": 12, @@ -510,25 +510,25 @@ }, "end": { "line": 12, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T9" }, - "name": "T" + "name": "T9" }, "typeParameters": null, "right": { "type": "NullLiteralTypeAnnotation", - "start": 187, - "end": 191, + "start": 196, + "end": 200, "loc": { "start": { "line": 12, - "column": 9 + "column": 10 }, "end": { "line": 12, - "column": 13 + "column": 14 } } }, @@ -536,8 +536,8 @@ { "type": "CommentLine", "value": " literal type annotations", - "start": 150, - "end": 177, + "start": 158, + "end": 185, "loc": { "start": { "line": 11, @@ -553,8 +553,8 @@ }, { "type": "TypeAlias", - "start": 193, - "end": 205, + "start": 202, + "end": 216, "loc": { "start": { "line": 13, @@ -562,13 +562,13 @@ }, "end": { "line": 13, - "column": 12 + "column": 14 } }, "id": { "type": "Identifier", - "start": 198, - "end": 199, + "start": 207, + "end": 210, "loc": { "start": { "line": 13, @@ -576,25 +576,25 @@ }, "end": { "line": 13, - "column": 6 + "column": 8 }, - "identifierName": "T" + "identifierName": "T10" }, - "name": "T" + "name": "T10" }, "typeParameters": null, "right": { "type": "StringLiteralTypeAnnotation", - "start": 202, - "end": 204, + "start": 213, + "end": 215, "loc": { "start": { "line": 13, - "column": 9 + "column": 11 }, "end": { "line": 13, - "column": 11 + "column": 13 } }, "extra": { @@ -606,8 +606,8 @@ }, { "type": "TypeAlias", - "start": 206, - "end": 217, + "start": 217, + "end": 230, "loc": { "start": { "line": 14, @@ -615,13 +615,13 @@ }, "end": { "line": 14, - "column": 11 + "column": 13 } }, "id": { "type": "Identifier", - "start": 211, - "end": 212, + "start": 222, + "end": 225, "loc": { "start": { "line": 14, @@ -629,25 +629,25 @@ }, "end": { "line": 14, - "column": 6 + "column": 8 }, - "identifierName": "T" + "identifierName": "T11" }, - "name": "T" + "name": "T11" }, "typeParameters": null, "right": { "type": "NumberLiteralTypeAnnotation", - "start": 215, - "end": 216, + "start": 228, + "end": 229, "loc": { "start": { "line": 14, - "column": 9 + "column": 11 }, "end": { "line": 14, - "column": 10 + "column": 12 } }, "extra": { @@ -659,8 +659,8 @@ }, { "type": "TypeAlias", - "start": 218, - "end": 232, + "start": 231, + "end": 247, "loc": { "start": { "line": 15, @@ -668,13 +668,13 @@ }, "end": { "line": 15, - "column": 14 + "column": 16 } }, "id": { "type": "Identifier", - "start": 223, - "end": 224, + "start": 236, + "end": 239, "loc": { "start": { "line": 15, @@ -682,25 +682,25 @@ }, "end": { "line": 15, - "column": 6 + "column": 8 }, - "identifierName": "T" + "identifierName": "T12" }, - "name": "T" + "name": "T12" }, "typeParameters": null, "right": { "type": "BooleanLiteralTypeAnnotation", - "start": 227, - "end": 231, + "start": 242, + "end": 246, "loc": { "start": { "line": 15, - "column": 9 + "column": 11 }, "end": { "line": 15, - "column": 13 + "column": 15 } }, "value": true @@ -708,8 +708,8 @@ }, { "type": "TypeAlias", - "start": 233, - "end": 248, + "start": 248, + "end": 265, "loc": { "start": { "line": 16, @@ -717,13 +717,13 @@ }, "end": { "line": 16, - "column": 15 + "column": 17 } }, "id": { "type": "Identifier", - "start": 238, - "end": 239, + "start": 253, + "end": 256, "loc": { "start": { "line": 16, @@ -731,25 +731,25 @@ }, "end": { "line": 16, - "column": 6 + "column": 8 }, - "identifierName": "T" + "identifierName": "T13" }, - "name": "T" + "name": "T13" }, "typeParameters": null, "right": { "type": "BooleanLiteralTypeAnnotation", - "start": 242, - "end": 247, + "start": 259, + "end": 264, "loc": { "start": { "line": 16, - "column": 9 + "column": 11 }, "end": { "line": 16, - "column": 14 + "column": 16 } }, "value": false @@ -778,8 +778,8 @@ { "type": "CommentLine", "value": " builtins", - "start": 56, - "end": 67, + "start": 59, + "end": 70, "loc": { "start": { "line": 5, @@ -794,8 +794,8 @@ { "type": "CommentLine", "value": " literal type annotations", - "start": 150, - "end": 177, + "start": 158, + "end": 185, "loc": { "start": { "line": 11, diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/input.js b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/input.js index 216a4222b3bb..435219343e08 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/input.js +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/input.js @@ -1,12 +1,12 @@ type T = { a: () => void }; -type T = { a: () => void }; -type T = { a(): void }; -type T = { a(): void }; +type T1 = { a: () => void }; +type T2 = { a(): void }; +type T3 = { a(): void }; -type T = { (): number }; -type T = { (x: T): number; } +type T4 = { (): number }; +type T5 = { (x: T): number; } -declare class T { foo(): number; } -declare class T { static foo(): number; } -declare class T { (): number } -declare class T { static (): number } +declare class T6 { foo(): number; } +declare class T7 { static foo(): number; } +declare class T8 { (): number } +declare class T9 { static (): number } diff --git a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json index f72e8ff175f2..49fb1b3a7b0d 100644 --- a/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-annotations/object-type-method/output.json @@ -1,7 +1,7 @@ { "type": "File", "start": 0, - "end": 314, + "end": 323, "loc": { "start": { "line": 1, @@ -9,13 +9,13 @@ }, "end": { "line": 12, - "column": 37 + "column": 38 } }, "program": { "type": "Program", "start": 0, - "end": 314, + "end": 323, "loc": { "start": { "line": 1, @@ -23,7 +23,7 @@ }, "end": { "line": 12, - "column": 37 + "column": 38 } }, "sourceType": "module", @@ -158,7 +158,7 @@ { "type": "TypeAlias", "start": 28, - "end": 58, + "end": 59, "loc": { "start": { "line": 2, @@ -166,13 +166,13 @@ }, "end": { "line": 2, - "column": 30 + "column": 31 } }, "id": { "type": "Identifier", "start": 33, - "end": 34, + "end": 35, "loc": { "start": { "line": 2, @@ -180,55 +180,55 @@ }, "end": { "line": 2, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T1" }, - "name": "T" + "name": "T1" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 37, - "end": 57, + "start": 38, + "end": 58, "loc": { "start": { "line": 2, - "column": 9 + "column": 10 }, "end": { "line": 2, - "column": 29 + "column": 30 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 39, - "end": 55, + "start": 40, + "end": 56, "loc": { "start": { "line": 2, - "column": 11 + "column": 12 }, "end": { "line": 2, - "column": 27 + "column": 28 } }, "key": { "type": "Identifier", - "start": 39, - "end": 40, + "start": 40, + "end": 41, "loc": { "start": { "line": 2, - "column": 11 + "column": 12 }, "end": { "line": 2, - "column": 12 + "column": 13 }, "identifierName": "a" }, @@ -240,45 +240,45 @@ "method": false, "value": { "type": "FunctionTypeAnnotation", - "start": 42, - "end": 55, + "start": 43, + "end": 56, "loc": { "start": { "line": 2, - "column": 14 + "column": 15 }, "end": { "line": 2, - "column": 27 + "column": 28 } }, "typeParameters": { "type": "TypeParameterDeclaration", - "start": 42, - "end": 45, + "start": 43, + "end": 46, "loc": { "start": { "line": 2, - "column": 14 + "column": 15 }, "end": { "line": 2, - "column": 17 + "column": 18 } }, "params": [ { "type": "TypeParameter", - "start": 43, - "end": 44, + "start": 44, + "end": 45, "loc": { "start": { "line": 2, - "column": 15 + "column": 16 }, "end": { "line": 2, - "column": 16 + "column": 17 } }, "name": "T", @@ -290,16 +290,16 @@ "rest": null, "returnType": { "type": "VoidTypeAnnotation", - "start": 51, - "end": 55, + "start": 52, + "end": 56, "loc": { "start": { "line": 2, - "column": 23 + "column": 24 }, "end": { "line": 2, - "column": 27 + "column": 28 } } } @@ -316,8 +316,8 @@ }, { "type": "TypeAlias", - "start": 59, - "end": 82, + "start": 60, + "end": 84, "loc": { "start": { "line": 3, @@ -325,13 +325,13 @@ }, "end": { "line": 3, - "column": 23 + "column": 24 } }, "id": { "type": "Identifier", - "start": 64, - "end": 65, + "start": 65, + "end": 67, "loc": { "start": { "line": 3, @@ -339,55 +339,55 @@ }, "end": { "line": 3, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T2" }, - "name": "T" + "name": "T2" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 68, - "end": 81, + "start": 70, + "end": 83, "loc": { "start": { "line": 3, - "column": 9 + "column": 10 }, "end": { "line": 3, - "column": 22 + "column": 23 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 70, - "end": 79, + "start": 72, + "end": 81, "loc": { "start": { "line": 3, - "column": 11 + "column": 12 }, "end": { "line": 3, - "column": 20 + "column": 21 } }, "key": { "type": "Identifier", - "start": 70, - "end": 71, + "start": 72, + "end": 73, "loc": { "start": { "line": 3, - "column": 11 + "column": 12 }, "end": { "line": 3, - "column": 12 + "column": 13 }, "identifierName": "a" }, @@ -399,16 +399,16 @@ "method": true, "value": { "type": "FunctionTypeAnnotation", - "start": 70, - "end": 79, + "start": 72, + "end": 81, "loc": { "start": { "line": 3, - "column": 11 + "column": 12 }, "end": { "line": 3, - "column": 20 + "column": 21 } }, "params": [], @@ -416,16 +416,16 @@ "typeParameters": null, "returnType": { "type": "VoidTypeAnnotation", - "start": 75, - "end": 79, + "start": 77, + "end": 81, "loc": { "start": { "line": 3, - "column": 16 + "column": 17 }, "end": { "line": 3, - "column": 20 + "column": 21 } } } @@ -441,8 +441,8 @@ }, { "type": "TypeAlias", - "start": 83, - "end": 109, + "start": 85, + "end": 112, "loc": { "start": { "line": 4, @@ -450,13 +450,13 @@ }, "end": { "line": 4, - "column": 26 + "column": 27 } }, "id": { "type": "Identifier", - "start": 88, - "end": 89, + "start": 90, + "end": 92, "loc": { "start": { "line": 4, @@ -464,55 +464,55 @@ }, "end": { "line": 4, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T3" }, - "name": "T" + "name": "T3" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 92, - "end": 108, + "start": 95, + "end": 111, "loc": { "start": { "line": 4, - "column": 9 + "column": 10 }, "end": { "line": 4, - "column": 25 + "column": 26 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 94, - "end": 106, + "start": 97, + "end": 109, "loc": { "start": { "line": 4, - "column": 11 + "column": 12 }, "end": { "line": 4, - "column": 23 + "column": 24 } }, "key": { "type": "Identifier", - "start": 94, - "end": 95, + "start": 97, + "end": 98, "loc": { "start": { "line": 4, - "column": 11 + "column": 12 }, "end": { "line": 4, - "column": 12 + "column": 13 }, "identifierName": "a" }, @@ -524,47 +524,47 @@ "method": true, "value": { "type": "FunctionTypeAnnotation", - "start": 94, - "end": 106, + "start": 97, + "end": 109, "loc": { "start": { "line": 4, - "column": 11 + "column": 12 }, "end": { "line": 4, - "column": 23 + "column": 24 } }, "params": [], "rest": null, "typeParameters": { "type": "TypeParameterDeclaration", - "start": 95, - "end": 98, + "start": 98, + "end": 101, "loc": { "start": { "line": 4, - "column": 12 + "column": 13 }, "end": { "line": 4, - "column": 15 + "column": 16 } }, "params": [ { "type": "TypeParameter", - "start": 96, - "end": 97, + "start": 99, + "end": 100, "loc": { "start": { "line": 4, - "column": 13 + "column": 14 }, "end": { "line": 4, - "column": 14 + "column": 15 } }, "name": "T", @@ -574,16 +574,16 @@ }, "returnType": { "type": "VoidTypeAnnotation", - "start": 102, - "end": 106, + "start": 105, + "end": 109, "loc": { "start": { "line": 4, - "column": 19 + "column": 20 }, "end": { "line": 4, - "column": 23 + "column": 24 } } } @@ -599,8 +599,8 @@ }, { "type": "TypeAlias", - "start": 111, - "end": 135, + "start": 114, + "end": 139, "loc": { "start": { "line": 6, @@ -608,13 +608,13 @@ }, "end": { "line": 6, - "column": 24 + "column": 25 } }, "id": { "type": "Identifier", - "start": 116, - "end": 117, + "start": 119, + "end": 121, "loc": { "start": { "line": 6, @@ -622,55 +622,55 @@ }, "end": { "line": 6, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T4" }, - "name": "T" + "name": "T4" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 120, - "end": 134, + "start": 124, + "end": 138, "loc": { "start": { "line": 6, - "column": 9 + "column": 10 }, "end": { "line": 6, - "column": 23 + "column": 24 } }, "callProperties": [ { "type": "ObjectTypeCallProperty", - "start": 122, - "end": 132, + "start": 126, + "end": 136, "loc": { "start": { "line": 6, - "column": 11 + "column": 12 }, "end": { "line": 6, - "column": 21 + "column": 22 } }, "static": false, "value": { "type": "FunctionTypeAnnotation", - "start": 122, - "end": 132, + "start": 126, + "end": 136, "loc": { "start": { "line": 6, - "column": 11 + "column": 12 }, "end": { "line": 6, - "column": 21 + "column": 22 } }, "params": [], @@ -678,16 +678,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 126, - "end": 132, + "start": 130, + "end": 136, "loc": { "start": { "line": 6, - "column": 15 + "column": 16 }, "end": { "line": 6, - "column": 21 + "column": 22 } } } @@ -703,8 +703,8 @@ }, { "type": "TypeAlias", - "start": 136, - "end": 167, + "start": 140, + "end": 172, "loc": { "start": { "line": 7, @@ -712,13 +712,13 @@ }, "end": { "line": 7, - "column": 31 + "column": 32 } }, "id": { "type": "Identifier", - "start": 141, - "end": 142, + "start": 145, + "end": 147, "loc": { "start": { "line": 7, @@ -726,84 +726,84 @@ }, "end": { "line": 7, - "column": 6 + "column": 7 }, - "identifierName": "T" + "identifierName": "T5" }, - "name": "T" + "name": "T5" }, "typeParameters": null, "right": { "type": "ObjectTypeAnnotation", - "start": 145, - "end": 167, + "start": 150, + "end": 172, "loc": { "start": { "line": 7, - "column": 9 + "column": 10 }, "end": { "line": 7, - "column": 31 + "column": 32 } }, "callProperties": [ { "type": "ObjectTypeCallProperty", - "start": 147, - "end": 164, + "start": 152, + "end": 169, "loc": { "start": { "line": 7, - "column": 11 + "column": 12 }, "end": { "line": 7, - "column": 28 + "column": 29 } }, "static": false, "value": { "type": "FunctionTypeAnnotation", - "start": 147, - "end": 164, + "start": 152, + "end": 169, "loc": { "start": { "line": 7, - "column": 11 + "column": 12 }, "end": { "line": 7, - "column": 28 + "column": 29 } }, "params": [ { "type": "FunctionTypeParam", - "start": 151, - "end": 155, + "start": 156, + "end": 160, "loc": { "start": { "line": 7, - "column": 15 + "column": 16 }, "end": { "line": 7, - "column": 19 + "column": 20 } }, "name": { "type": "Identifier", - "start": 151, - "end": 152, + "start": 156, + "end": 157, "loc": { "start": { "line": 7, - "column": 15 + "column": 16 }, "end": { "line": 7, - "column": 16 + "column": 17 }, "identifierName": "x" }, @@ -812,31 +812,31 @@ "optional": false, "typeAnnotation": { "type": "GenericTypeAnnotation", - "start": 154, - "end": 155, + "start": 159, + "end": 160, "loc": { "start": { "line": 7, - "column": 18 + "column": 19 }, "end": { "line": 7, - "column": 19 + "column": 20 } }, "typeParameters": null, "id": { "type": "Identifier", - "start": 154, - "end": 155, + "start": 159, + "end": 160, "loc": { "start": { "line": 7, - "column": 18 + "column": 19 }, "end": { "line": 7, - "column": 19 + "column": 20 }, "identifierName": "T" }, @@ -848,31 +848,31 @@ "rest": null, "typeParameters": { "type": "TypeParameterDeclaration", - "start": 147, - "end": 150, + "start": 152, + "end": 155, "loc": { "start": { "line": 7, - "column": 11 + "column": 12 }, "end": { "line": 7, - "column": 14 + "column": 15 } }, "params": [ { "type": "TypeParameter", - "start": 148, - "end": 149, + "start": 153, + "end": 154, "loc": { "start": { "line": 7, - "column": 12 + "column": 13 }, "end": { "line": 7, - "column": 13 + "column": 14 } }, "name": "T", @@ -882,16 +882,16 @@ }, "returnType": { "type": "NumberTypeAnnotation", - "start": 158, - "end": 164, + "start": 163, + "end": 169, "loc": { "start": { "line": 7, - "column": 22 + "column": 23 }, "end": { "line": 7, - "column": 28 + "column": 29 } } } @@ -907,8 +907,8 @@ }, { "type": "DeclareClass", - "start": 169, - "end": 203, + "start": 174, + "end": 209, "loc": { "start": { "line": 9, @@ -916,13 +916,13 @@ }, "end": { "line": 9, - "column": 34 + "column": 35 } }, "id": { "type": "Identifier", - "start": 183, - "end": 184, + "start": 188, + "end": 190, "loc": { "start": { "line": 9, @@ -930,11 +930,11 @@ }, "end": { "line": 9, - "column": 15 + "column": 16 }, - "identifierName": "T" + "identifierName": "T6" }, - "name": "T" + "name": "T6" }, "typeParameters": null, "extends": [], @@ -942,46 +942,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 185, - "end": 203, + "start": 191, + "end": 209, "loc": { "start": { "line": 9, - "column": 16 + "column": 17 }, "end": { "line": 9, - "column": 34 + "column": 35 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 187, - "end": 200, + "start": 193, + "end": 206, "loc": { "start": { "line": 9, - "column": 18 + "column": 19 }, "end": { "line": 9, - "column": 31 + "column": 32 } }, "key": { "type": "Identifier", - "start": 187, - "end": 190, + "start": 193, + "end": 196, "loc": { "start": { "line": 9, - "column": 18 + "column": 19 }, "end": { "line": 9, - "column": 21 + "column": 22 }, "identifierName": "foo" }, @@ -993,16 +993,16 @@ "method": true, "value": { "type": "FunctionTypeAnnotation", - "start": 187, - "end": 200, + "start": 193, + "end": 206, "loc": { "start": { "line": 9, - "column": 18 + "column": 19 }, "end": { "line": 9, - "column": 31 + "column": 32 } }, "params": [], @@ -1010,16 +1010,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 194, - "end": 200, + "start": 200, + "end": 206, "loc": { "start": { "line": 9, - "column": 25 + "column": 26 }, "end": { "line": 9, - "column": 31 + "column": 32 } } } @@ -1034,8 +1034,8 @@ }, { "type": "DeclareClass", - "start": 204, - "end": 245, + "start": 210, + "end": 252, "loc": { "start": { "line": 10, @@ -1043,13 +1043,13 @@ }, "end": { "line": 10, - "column": 41 + "column": 42 } }, "id": { "type": "Identifier", - "start": 218, - "end": 219, + "start": 224, + "end": 226, "loc": { "start": { "line": 10, @@ -1057,11 +1057,11 @@ }, "end": { "line": 10, - "column": 15 + "column": 16 }, - "identifierName": "T" + "identifierName": "T7" }, - "name": "T" + "name": "T7" }, "typeParameters": null, "extends": [], @@ -1069,46 +1069,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 220, - "end": 245, + "start": 227, + "end": 252, "loc": { "start": { "line": 10, - "column": 16 + "column": 17 }, "end": { "line": 10, - "column": 41 + "column": 42 } }, "callProperties": [], "properties": [ { "type": "ObjectTypeProperty", - "start": 222, - "end": 242, + "start": 229, + "end": 249, "loc": { "start": { "line": 10, - "column": 18 + "column": 19 }, "end": { "line": 10, - "column": 38 + "column": 39 } }, "key": { "type": "Identifier", - "start": 229, - "end": 232, + "start": 236, + "end": 239, "loc": { "start": { "line": 10, - "column": 25 + "column": 26 }, "end": { "line": 10, - "column": 28 + "column": 29 }, "identifierName": "foo" }, @@ -1120,16 +1120,16 @@ "method": true, "value": { "type": "FunctionTypeAnnotation", - "start": 222, - "end": 242, + "start": 229, + "end": 249, "loc": { "start": { "line": 10, - "column": 18 + "column": 19 }, "end": { "line": 10, - "column": 38 + "column": 39 } }, "params": [], @@ -1137,16 +1137,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 236, - "end": 242, + "start": 243, + "end": 249, "loc": { "start": { "line": 10, - "column": 32 + "column": 33 }, "end": { "line": 10, - "column": 38 + "column": 39 } } } @@ -1161,8 +1161,8 @@ }, { "type": "DeclareClass", - "start": 246, - "end": 276, + "start": 253, + "end": 284, "loc": { "start": { "line": 11, @@ -1170,13 +1170,13 @@ }, "end": { "line": 11, - "column": 30 + "column": 31 } }, "id": { "type": "Identifier", - "start": 260, - "end": 261, + "start": 267, + "end": 269, "loc": { "start": { "line": 11, @@ -1184,11 +1184,11 @@ }, "end": { "line": 11, - "column": 15 + "column": 16 }, - "identifierName": "T" + "identifierName": "T8" }, - "name": "T" + "name": "T8" }, "typeParameters": null, "extends": [], @@ -1196,46 +1196,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 262, - "end": 276, + "start": 270, + "end": 284, "loc": { "start": { "line": 11, - "column": 16 + "column": 17 }, "end": { "line": 11, - "column": 30 + "column": 31 } }, "callProperties": [ { "type": "ObjectTypeCallProperty", - "start": 264, - "end": 274, + "start": 272, + "end": 282, "loc": { "start": { "line": 11, - "column": 18 + "column": 19 }, "end": { "line": 11, - "column": 28 + "column": 29 } }, "static": false, "value": { "type": "FunctionTypeAnnotation", - "start": 264, - "end": 274, + "start": 272, + "end": 282, "loc": { "start": { "line": 11, - "column": 18 + "column": 19 }, "end": { "line": 11, - "column": 28 + "column": 29 } }, "params": [], @@ -1243,16 +1243,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 268, - "end": 274, + "start": 276, + "end": 282, "loc": { "start": { "line": 11, - "column": 22 + "column": 23 }, "end": { "line": 11, - "column": 28 + "column": 29 } } } @@ -1267,8 +1267,8 @@ }, { "type": "DeclareClass", - "start": 277, - "end": 314, + "start": 285, + "end": 323, "loc": { "start": { "line": 12, @@ -1276,13 +1276,13 @@ }, "end": { "line": 12, - "column": 37 + "column": 38 } }, "id": { "type": "Identifier", - "start": 291, - "end": 292, + "start": 299, + "end": 301, "loc": { "start": { "line": 12, @@ -1290,11 +1290,11 @@ }, "end": { "line": 12, - "column": 15 + "column": 16 }, - "identifierName": "T" + "identifierName": "T9" }, - "name": "T" + "name": "T9" }, "typeParameters": null, "extends": [], @@ -1302,46 +1302,46 @@ "mixins": [], "body": { "type": "ObjectTypeAnnotation", - "start": 293, - "end": 314, + "start": 302, + "end": 323, "loc": { "start": { "line": 12, - "column": 16 + "column": 17 }, "end": { "line": 12, - "column": 37 + "column": 38 } }, "callProperties": [ { "type": "ObjectTypeCallProperty", - "start": 295, - "end": 312, + "start": 304, + "end": 321, "loc": { "start": { "line": 12, - "column": 18 + "column": 19 }, "end": { "line": 12, - "column": 35 + "column": 36 } }, "static": true, "value": { "type": "FunctionTypeAnnotation", - "start": 302, - "end": 312, + "start": 311, + "end": 321, "loc": { "start": { "line": 12, - "column": 25 + "column": 26 }, "end": { "line": 12, - "column": 35 + "column": 36 } }, "params": [], @@ -1349,16 +1349,16 @@ "typeParameters": null, "returnType": { "type": "NumberTypeAnnotation", - "start": 306, - "end": 312, + "start": 315, + "end": 321, "loc": { "start": { "line": 12, - "column": 29 + "column": 30 }, "end": { "line": 12, - "column": 35 + "column": 36 } } } diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/input.js b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/input.js new file mode 100644 index 000000000000..62acca05efa0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/input.js @@ -0,0 +1,2 @@ +const X = ""; +type X = number; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/output.json b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/output.json new file mode 100644 index 000000000000..b51eb30f5c6c --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-const/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "X" + }, + "name": "X" + }, + "init": { + "type": "StringLiteral", + "start": 10, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "const" + }, + { + "type": "TSTypeAliasDeclaration", + "start": 14, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 23, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/input.js b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/input.js new file mode 100644 index 000000000000..fe2809ad6b22 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/input.js @@ -0,0 +1,2 @@ +let X = ""; +type X = number; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/output.json b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/output.json new file mode 100644 index 000000000000..8c157d8a364d --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-let/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "X" + }, + "name": "X" + }, + "init": { + "type": "StringLiteral", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "let" + }, + { + "type": "TSTypeAliasDeclaration", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/input.js b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/input.js new file mode 100644 index 000000000000..856d8ef6f308 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/input.js @@ -0,0 +1,2 @@ +var X = ""; +type X = number; diff --git a/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/output.json b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/output.json new file mode 100644 index 000000000000..6cfc11c09339 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/scope/no-dupl-decl-type-var/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "X" + }, + "name": "X" + }, + "init": { + "type": "StringLiteral", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + } + ], + "kind": "var" + }, + { + "type": "TSTypeAliasDeclaration", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 6 + }, + "identifierName": "X" + }, + "name": "X" + }, + "typeAnnotation": { + "type": "TSNumberKeyword", + "start": 21, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 15 + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-classes/src/transformClass.js b/packages/babel-plugin-transform-classes/src/transformClass.js index b537c00b3a4e..0335e363439a 100644 --- a/packages/babel-plugin-transform-classes/src/transformClass.js +++ b/packages/babel-plugin-transform-classes/src/transformClass.js @@ -19,22 +19,6 @@ function buildConstructor(classRef, constructorBody, node) { return func; } -const verifyConstructorVisitor = traverse.visitors.merge([ - environmentVisitor, - { - Super(path, state) { - if (state.isDerived) return; - - const { node, parentPath } = path; - if (parentPath.isCallExpression({ callee: node })) { - throw path.buildCodeFrameError( - "super() is only allowed in a derived constructor", - ); - } - }, - }, -]); - export default function transformClass( path: NodePath, file: any, @@ -180,13 +164,6 @@ export default function transformClass( if (t.isClassMethod(node)) { const isConstructor = node.kind === "constructor"; - if (isConstructor) { - path.traverse(verifyConstructorVisitor, { - isDerived: classState.isDerived, - file: classState.file, - }); - } - const replaceSupers = new ReplaceSupers({ methodPath: path, objectRef: classState.classRef, diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/input.js b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/input.js deleted file mode 100644 index 036ce36e395c..000000000000 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/input.js +++ /dev/null @@ -1,5 +0,0 @@ -class Foo { - constructor() { - super(); - } -} diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/options.json b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/options.json deleted file mode 100644 index a4e0aa5c67b6..000000000000 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-call-only-allowed-in-derived-constructor/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "throws": "super() is only allowed in a derived constructor", - "plugins": ["transform-classes"] -} diff --git a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-illegal-non-constructor-call/options.json b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-illegal-non-constructor-call/options.json index 2ff7004be5b7..84442f571d97 100644 --- a/packages/babel-plugin-transform-classes/test/fixtures/spec/super-illegal-non-constructor-call/options.json +++ b/packages/babel-plugin-transform-classes/test/fixtures/spec/super-illegal-non-constructor-call/options.json @@ -1,3 +1,3 @@ { - "throws": "super() is only valid inside a class constructor. Make sure the method name is spelled exactly as 'constructor'." + "throws": "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?" } diff --git a/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/input.js b/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/input.js index 53b5bac68e1b..d2cfab8fba1d 100644 --- a/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/input.js +++ b/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/input.js @@ -1,5 +1,5 @@ export type GraphQLFormattedError = number; -export type GraphQLFormattedError = { +export type GraphQLFormattedError2 = { message: string, locations?: Array<{ line: number, @@ -7,4 +7,4 @@ export type GraphQLFormattedError = { }> }; export interface foo { p: number } -export interface foo { p: T } +export interface foo2 { p: T } diff --git a/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/output.js b/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/output.js index 9e64ba75a316..7c4a2cffff69 100644 --- a/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/output.js +++ b/packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/export-type-alias/output.js @@ -1,6 +1,6 @@ /*:: export type GraphQLFormattedError = number;*/ -/*:: export type GraphQLFormattedError = { +/*:: export type GraphQLFormattedError2 = { message: string, locations?: Array<{ line: number, @@ -10,4 +10,4 @@ /*:: export interface foo { p: number }*/ -/*:: export interface foo { p: T }*/ +/*:: export interface foo2 { p: T }*/ diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js index a97695f41813..eb188c5c908a 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js @@ -1,10 +1,10 @@ class C1<+T, -U> {} function f<+T, -U>() {} type T<+T, -U> = {} -type T = { +p: T } -type T = { -p: T } -type T = { +[k:K]: V } -type T = { -[k:K]: V } +type T1 = { +p: T } +type T2 = { -p: T } +type T3 = { +[k:K]: V } +type T4 = { -[k:K]: V } interface I { +p: T } interface I { -p: T } interface I { +[k:K]: V } diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-opaque-type-alias/input.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-opaque-type-alias/input.js index 53dfc2c87440..404f6d84e4c6 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-opaque-type-alias/input.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-opaque-type-alias/input.js @@ -1,6 +1,6 @@ opaque type ID = string; opaque type Foo = Bar -export opaque type Foo = number; +export opaque type Foo1 = number; opaque type union = | {type: "A"} @@ -12,5 +12,5 @@ opaque type overloads = & ((x: number) => string) ; -declare opaque type Foo: Bar; -declare export opaque type Foo: Bar; +declare opaque type Foo2: Bar; +declare export opaque type Fo3: Bar; diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-alias/input.js b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-alias/input.js index 12bfc22fc85e..2718274e2cf6 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-alias/input.js +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-alias/input.js @@ -1,6 +1,6 @@ type FBID = number; type Foo = Bar -export type Foo = number; +export type Foo1 = number; type union = | {type: "A"} diff --git a/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/input.js b/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/input.js deleted file mode 100644 index 47bd62071480..000000000000 --- a/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/input.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; - -const a = () => { - new.target; -}; diff --git a/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/options.json b/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/options.json deleted file mode 100644 index bd1ea4079447..000000000000 --- a/packages/babel-plugin-transform-new-target/test/fixtures/errors/new-target-arrow/options.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": ["transform-new-target"], - "throws": "new.target must be under a (non-arrow) function or a class." -} diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index 5d67387a1eba..cc2903a3aca5 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -284,189 +284,6 @@ built-ins/RegExp/property-escapes/unsupported-property-Line_Break-with-value.js( built-ins/RegExp/property-escapes/unsupported-property-Line_Break-with-value.js(strict mode) built-ins/RegExp/property-escapes/unsupported-property-Line_Break.js(default) built-ins/RegExp/property-escapes/unsupported-property-Line_Break.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/async-function-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/class-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/const-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/fn-scope-var-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration-nested-in-function.js(default) -language/block-scope/syntax/redeclaration/function-declaration-attempt-to-redeclare-with-var-declaration-nested-in-function.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/function-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/generator-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-async-function.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-async-generator.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-class.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-class.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-const.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-const.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-function.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-function.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-generator.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-generator.js(strict mode) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-let.js(default) -language/block-scope/syntax/redeclaration/inner-block-var-redeclaration-attempt-after-let.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-var.js(default) -language/block-scope/syntax/redeclaration/let-name-redeclaration-attempt-with-var.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-async-function.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-async-generator.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-class.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-class.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-const.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-const.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-function.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-function.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.js(strict mode) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-let.js(default) -language/block-scope/syntax/redeclaration/var-name-redeclaration-attempt-with-let.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-async-function.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-async-function.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-async-generator.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-async-generator.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-class.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-class.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-const.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-const.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-function.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-function.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-generator.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-generator.js(strict mode) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-let.js(default) -language/block-scope/syntax/redeclaration/var-redeclaration-attempt-after-let.js(strict mode) language/expressions/assignment/destructuring/obj-prop-__proto__dup.js(default) language/expressions/assignment/destructuring/obj-prop-__proto__dup.js(strict mode) language/expressions/async-arrow-function/await-as-param-ident-nested-arrow-parameter-position.js(default) @@ -479,18 +296,6 @@ language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-de language/expressions/async-arrow-function/early-errors-arrow-await-in-formals-default.js(strict mode) language/expressions/async-arrow-function/early-errors-arrow-await-in-formals.js(default) language/expressions/async-arrow-function/early-errors-arrow-await-in-formals.js(strict mode) -language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate.js(default) -language/expressions/async-arrow-function/early-errors-arrow-formals-body-duplicate.js(strict mode) -language/expressions/async-function/early-errors-expression-formals-body-duplicate.js(default) -language/expressions/async-function/early-errors-expression-formals-body-duplicate.js(strict mode) -language/expressions/async-function/named-dflt-params-duplicates.js(default) -language/expressions/async-function/nameless-dflt-params-duplicates.js(default) -language/expressions/async-generator/dflt-params-duplicates.js(default) -language/expressions/async-generator/early-errors-expression-formals-body-duplicate-const.js(default) -language/expressions/async-generator/early-errors-expression-formals-body-duplicate-const.js(strict mode) -language/expressions/async-generator/early-errors-expression-formals-body-duplicate-let.js(default) -language/expressions/async-generator/early-errors-expression-formals-body-duplicate-let.js(strict mode) -language/expressions/async-generator/named-dflt-params-duplicates.js(default) language/expressions/class/elements/fields-duplicate-privatenames.js(default) language/expressions/class/elements/fields-duplicate-privatenames.js(strict mode) language/expressions/class/elements/fields-literal-name-static-propname-constructor.js(default) @@ -511,8 +316,6 @@ language/expressions/class/elements/private-derived-cls-indirect-eval-err-contai language/expressions/class/elements/private-derived-cls-indirect-eval-err-contains-supercall.js(strict mode) language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js(default) language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js(strict mode) -language/expressions/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js(default) -language/expressions/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js(strict mode) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(default) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(strict mode) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js(default) @@ -591,21 +394,9 @@ language/expressions/class/elements/syntax/early-errors/invalid-names/method-out language/expressions/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(default) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(strict mode) -language/expressions/function/dflt-params-duplicates.js(default) -language/expressions/generators/dflt-params-duplicates.js(default) -language/expressions/object/method-definition/async-gen-meth-dflt-params-duplicates.js(default) -language/expressions/object/method-definition/async-meth-dflt-params-duplicates.js(default) language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(default) language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(strict mode) language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js(default) -language/expressions/object/method-definition/gen-meth-dflt-params-duplicates.js(default) -language/expressions/object/method-definition/generator-param-redecl-const.js(default) -language/expressions/object/method-definition/generator-param-redecl-const.js(strict mode) -language/expressions/object/method-definition/generator-param-redecl-let.js(default) -language/expressions/object/method-definition/generator-param-redecl-let.js(strict mode) -language/expressions/object/method-definition/meth-dflt-params-duplicates.js(default) -language/expressions/object/method-definition/name-param-redecl.js(default) -language/expressions/object/method-definition/name-param-redecl.js(strict mode) language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js(default) language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js(strict mode) language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js(default) @@ -626,12 +417,8 @@ language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js(de language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js(strict mode) language/expressions/template-literal/unicode-escape-nls-err.js(default) language/expressions/template-literal/unicode-escape-nls-err.js(strict mode) -language/global-code/new.target-arrow.js(default) -language/global-code/new.target-arrow.js(strict mode) language/identifiers/unicode-escape-nls-err.js(default) language/identifiers/unicode-escape-nls-err.js(strict mode) -language/import/dup-bound-names.js(default) -language/import/dup-bound-names.js(strict mode) language/line-terminators/invalid-string-ls.js(default) language/line-terminators/invalid-string-ls.js(strict mode) language/line-terminators/invalid-string-ps.js(default) @@ -816,12 +603,6 @@ language/module-code/early-export-global.js(default) language/module-code/early-export-global.js(strict mode) language/module-code/early-export-unresolvable.js(default) language/module-code/early-export-unresolvable.js(strict mode) -language/module-code/early-lex-and-var.js(default) -language/module-code/early-lex-and-var.js(strict mode) -language/module-code/parse-err-hoist-lex-fun.js(default) -language/module-code/parse-err-hoist-lex-fun.js(strict mode) -language/module-code/parse-err-hoist-lex-gen.js(default) -language/module-code/parse-err-hoist-lex-gen.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-1.js(default) language/module-code/privatename-not-valid-earlyerr-module-1.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-2.js(default) @@ -830,10 +611,6 @@ language/module-code/privatename-not-valid-earlyerr-module-3.js(default) language/module-code/privatename-not-valid-earlyerr-module-3.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-4.js(default) language/module-code/privatename-not-valid-earlyerr-module-4.js(strict mode) -language/statements/async-function/dflt-params-duplicates.js(default) -language/statements/async-function/early-errors-declaration-formals-body-duplicate.js(default) -language/statements/async-function/early-errors-declaration-formals-body-duplicate.js(strict mode) -language/statements/async-generator/dflt-params-duplicates.js(default) language/statements/class/async-gen-meth-escaped-async.js(default) language/statements/class/async-gen-meth-escaped-async.js(strict mode) language/statements/class/async-meth-escaped-async.js(default) @@ -866,8 +643,6 @@ language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js(de language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js(strict mode) language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js(default) language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js(strict mode) -language/statements/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js(default) -language/statements/class/elements/syntax/early-errors/grammar-ctor-super-no-heritage.js(strict mode) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(default) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(strict mode) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js(default) @@ -946,174 +721,29 @@ language/statements/class/elements/syntax/early-errors/invalid-names/method-outt language/statements/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode) language/statements/class/elements/syntax/early-errors/super-private-access-invalid.js(default) language/statements/class/elements/syntax/early-errors/super-private-access-invalid.js(strict mode) -language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js(default) -language/statements/class/syntax/early-errors/class-definition-evaluation-block-duplicate-binding.js(strict mode) -language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js(default) -language/statements/class/syntax/early-errors/class-definition-evaluation-scriptbody-duplicate-binding.js(strict mode) -language/statements/const/redeclaration-error-from-within-strict-mode-function-const.js(default) language/statements/for-in/dstr/array-rest-before-elision.js(default) language/statements/for-in/dstr/array-rest-before-elision.js(strict mode) language/statements/for-in/dstr/array-rest-elision-invalid.js(default) language/statements/for-in/dstr/array-rest-elision-invalid.js(strict mode) -language/statements/for-in/head-const-bound-names-dup.js(default) -language/statements/for-in/head-const-bound-names-dup.js(strict mode) language/statements/for-in/head-const-bound-names-in-stmt.js(default) language/statements/for-in/head-const-bound-names-in-stmt.js(strict mode) -language/statements/for-in/head-let-bound-names-dup.js(default) -language/statements/for-in/head-let-bound-names-dup.js(strict mode) language/statements/for-in/head-let-bound-names-in-stmt.js(default) language/statements/for-in/head-let-bound-names-in-stmt.js(strict mode) language/statements/for-of/dstr/array-rest-before-elision.js(default) language/statements/for-of/dstr/array-rest-before-elision.js(strict mode) language/statements/for-of/dstr/array-rest-elision-invalid.js(default) language/statements/for-of/dstr/array-rest-elision-invalid.js(strict mode) -language/statements/for-of/head-const-bound-names-dup.js(default) -language/statements/for-of/head-const-bound-names-dup.js(strict mode) language/statements/for-of/head-const-bound-names-in-stmt.js(default) language/statements/for-of/head-const-bound-names-in-stmt.js(strict mode) language/statements/for-of/head-decl-no-expr.js(default) language/statements/for-of/head-decl-no-expr.js(strict mode) language/statements/for-of/head-expr-no-expr.js(default) language/statements/for-of/head-expr-no-expr.js(strict mode) -language/statements/for-of/head-let-bound-names-dup.js(default) -language/statements/for-of/head-let-bound-names-dup.js(strict mode) language/statements/for-of/head-let-bound-names-in-stmt.js(default) language/statements/for-of/head-let-bound-names-in-stmt.js(strict mode) language/statements/for-of/head-var-no-expr.js(default) language/statements/for-of/head-var-no-expr.js(strict mode) language/statements/for/head-let-bound-names-in-stmt.js(default) language/statements/for/head-let-bound-names-in-stmt.js(strict mode) -language/statements/function/dflt-params-duplicates.js(default) -language/statements/generators/dflt-params-duplicates.js(default) -language/statements/let/redeclaration-error-from-within-strict-mode-function.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/async-function-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/async-generator-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/class-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/const-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/function-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/generator-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-var.js(default) -language/statements/switch/syntax/redeclaration/let-name-redeclaration-attempt-with-var.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-async-function.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-async-function.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-async-generator.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-async-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-class.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-class.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-const.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-const.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-function.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-function.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-generator.js(strict mode) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-let.js(default) -language/statements/switch/syntax/redeclaration/var-name-redeclaration-attempt-with-let.js(strict mode) -language/statements/try/early-catch-function.js(default) -language/statements/try/early-catch-function.js(strict mode) -language/statements/try/early-catch-lex.js(default) -language/statements/try/early-catch-lex.js(strict mode) language/statements/try/early-catch-var.js(default) language/statements/try/early-catch-var.js(strict mode) \ No newline at end of file From 632552f55d4d2b859715f65ecf659bdd524c471d Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Mon, 25 Feb 2019 11:52:40 -0800 Subject: [PATCH 06/58] Minify bundles on circle for repl (#9582) --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 95de88499fc5..c43f8398678e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,7 @@ jobs: - run: yarn --version - run: make test-ci-coverage # Builds babel-standalone with the regular Babel config - - run: make build + - run: IS_PUBLISH=true make build # test-ci-coverage doesn't test babel-standalone, as trying to gather coverage # data for a JS file that's several megabytes large is bound to fail. Here, # we just run the babel-standalone test separately. From 0e3968124c226291ca75a7f06086bafcbdb5d6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 25 Feb 2019 21:51:17 +0100 Subject: [PATCH 07/58] Remove unused file (eslint-local-rules.js) (#9583) --- eslint-local-rules.js | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 eslint-local-rules.js diff --git a/eslint-local-rules.js b/eslint-local-rules.js deleted file mode 100644 index 8b3b7ea4971f..000000000000 --- a/eslint-local-rules.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; - -const noDeprecatedClone = require("./scripts/eslint_rules/no-deprecated-clone"); -const noUndefinedIdentifier = require("./scripts/eslint_rules/no-undefined-identifier"); -const pluginName = require("./scripts/eslint_rules/plugin-name"); - -module.exports = { - "no-deprecated-clone": noDeprecatedClone, - "no-undefined-identifier": noUndefinedIdentifier, - "plugin-name": pluginName, -}; From 434fd32c90909a577ef9b090c4a6972f9537ba50 Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Mon, 25 Feb 2019 16:51:38 -0600 Subject: [PATCH 08/58] Update esm and electron mappings in preset-env (#9573) --- .../data/built-in-modules.json | 2 +- packages/babel-preset-env/data/built-ins.json | 93 ++++++++++--------- packages/babel-preset-env/data/plugins.json | 22 ++--- packages/babel-preset-env/package.json | 6 +- .../babel-preset-env/scripts/build-data.js | 9 +- .../scripts/build-modules-support.js | 13 ++- 6 files changed, 76 insertions(+), 69 deletions(-) diff --git a/packages/babel-preset-env/data/built-in-modules.json b/packages/babel-preset-env/data/built-in-modules.json index 9bd7f2aa0016..e1b1e8a6dc4e 100644 --- a/packages/babel-preset-env/data/built-in-modules.json +++ b/packages/babel-preset-env/data/built-in-modules.json @@ -6,6 +6,6 @@ "safari": "10.1", "opera": "48", "ios_saf": "10.3", - "and_ff": "60" + "and_ff": "64" } } diff --git a/packages/babel-preset-env/data/built-ins.json b/packages/babel-preset-env/data/built-ins.json index 2e6321e2b37c..8e2d2570771f 100644 --- a/packages/babel-preset-env/data/built-ins.json +++ b/packages/babel-preset-env/data/built-ins.json @@ -17,7 +17,7 @@ "safari": "3.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -40,7 +40,7 @@ "safari": "3.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -73,7 +73,7 @@ "safari": "3.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -106,7 +106,7 @@ "safari": "3.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -119,7 +119,7 @@ "safari": "4", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -142,7 +142,7 @@ "safari": "3.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -155,7 +155,7 @@ "safari": "3.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -178,7 +178,7 @@ "safari": "4", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -191,7 +191,7 @@ "safari": "4", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -204,7 +204,7 @@ "safari": "3.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -215,10 +215,10 @@ "edge": "12", "firefox": "5", "safari": "10.1", - "node": "10.0", + "node": "10", "ie": "9", "ios": "10.3", - "electron": "3" + "electron": "3.1" }, "es6.array.species": { "chrome": "51", @@ -238,7 +238,7 @@ "safari": "4", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -251,7 +251,7 @@ "safari": "4", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -264,7 +264,7 @@ "safari": "10", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "10", "electron": "1.1" }, @@ -286,7 +286,7 @@ "safari": "3.1", "node": "0.12", "ie": "10", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -299,9 +299,10 @@ "safari": "5.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "7", - "phantom": "2" + "phantom": "2", + "electron": "5" }, "es6.function.has-instance": { "chrome": "51", @@ -320,7 +321,7 @@ "firefox": "2", "safari": "4", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -624,7 +625,7 @@ "safari": "4", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -637,7 +638,7 @@ "node": "8.10", "ios": "9", "opera": "49", - "electron": "3" + "electron": "3.1" }, "es7.object.define-setter": { "chrome": "62", @@ -647,7 +648,7 @@ "node": "8.10", "ios": "9", "opera": "49", - "electron": "3" + "electron": "3.1" }, "es6.object.define-property": { "chrome": "5", @@ -657,7 +658,7 @@ "safari": "5.1", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -670,7 +671,7 @@ "safari": "4", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -742,7 +743,7 @@ "node": "8.10", "ios": "9", "opera": "49", - "electron": "3" + "electron": "3.1" }, "es7.object.lookup-setter": { "chrome": "62", @@ -751,7 +752,7 @@ "node": "8.10", "ios": "9", "opera": "49", - "electron": "3" + "electron": "3.1" }, "es6.object.prevent-extensions": { "chrome": "44", @@ -859,10 +860,10 @@ "edge": "18", "firefox": "58", "safari": "11.1", - "node": "10.0", + "node": "10", "ios": "11.3", "opera": "50", - "electron": "3" + "electron": "3.1" }, "es6.reflect.apply": { "chrome": "49", @@ -1080,10 +1081,10 @@ "chrome": "63", "firefox": "57", "safari": "12", - "node": "10.0", + "node": "10", "ios": "12", "opera": "50", - "electron": "3" + "electron": "3.1" }, "es6.string.anchor": { "chrome": "5", @@ -1091,7 +1092,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1102,7 +1103,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1113,7 +1114,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1124,7 +1125,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1155,7 +1156,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1166,7 +1167,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1177,7 +1178,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1208,7 +1209,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1229,7 +1230,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1280,7 +1281,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1301,7 +1302,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1312,7 +1313,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1323,7 +1324,7 @@ "firefox": "17", "safari": "6", "node": "0.12", - "android": "4.0", + "android": "4", "ios": "7", "phantom": "2", "electron": "1.1" @@ -1336,7 +1337,7 @@ "safari": "4", "node": "0.10", "ie": "9", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -1359,7 +1360,7 @@ "safari": "5.1", "node": "0.12", "ie": "10", - "android": "4.0", + "android": "4", "ios": "6", "phantom": "2", "electron": "1.1" @@ -1478,7 +1479,7 @@ "chrome": "69", "firefox": "62", "safari": "12", - "node": "11.0", + "node": "11", "ios": "12", "opera": "56", "electron": "4" diff --git a/packages/babel-preset-env/data/plugins.json b/packages/babel-preset-env/data/plugins.json index 37c725885368..cb6301765dc6 100644 --- a/packages/babel-preset-env/data/plugins.json +++ b/packages/babel-preset-env/data/plugins.json @@ -125,7 +125,7 @@ "node": "8.10", "ios": "11.3", "opera": "49", - "electron": "3" + "electron": "3.1" }, "transform-unicode-regex": { "chrome": "50", @@ -231,10 +231,10 @@ "chrome": "63", "firefox": "57", "safari": "12", - "node": "10.0", + "node": "10", "ios": "12", "opera": "50", - "electron": "3" + "electron": "3.1" }, "proposal-object-rest-spread": { "chrome": "60", @@ -248,35 +248,35 @@ "proposal-unicode-property-regex": { "chrome": "64", "safari": "11.1", - "node": "10.0", + "node": "10", "ios": "11.3", "opera": "51", - "electron": "3" + "electron": "3.1" }, "proposal-json-strings": { "chrome": "66", "firefox": "62", "safari": "12", - "node": "10.0", + "node": "10", "ios": "12", "opera": "53", - "electron": "3" + "electron": "3.1" }, "proposal-optional-catch-binding": { "chrome": "66", "firefox": "58", "safari": "11.1", - "node": "10.0", + "node": "10", "ios": "11.3", "opera": "53", - "electron": "3" + "electron": "3.1" }, "transform-named-capturing-groups-regex": { "chrome": "64", "safari": "11.1", - "node": "10.0", + "node": "10", "ios": "11.3", "opera": "51", - "electron": "3" + "electron": "3.1" } } diff --git a/packages/babel-preset-env/package.json b/packages/babel-preset-env/package.json index 234208b68a99..f4b60f0553be 100644 --- a/packages/babel-preset-env/package.json +++ b/packages/babel-preset-env/package.json @@ -53,7 +53,7 @@ "@babel/plugin-transform-template-literals": "^7.2.0", "@babel/plugin-transform-typeof-symbol": "^7.2.0", "@babel/plugin-transform-unicode-regex": "^7.2.0", - "browserslist": "^4.3.4", + "browserslist": "^4.4.2", "invariant": "^2.2.2", "js-levenshtein": "^1.1.3", "semver": "^5.3.0" @@ -66,8 +66,8 @@ "@babel/core": "^7.3.4", "@babel/helper-fixtures": "^7.2.0", "@babel/helper-plugin-test-runner": "^7.0.0", - "caniuse-db": "1.0.30000851", + "caniuse-db": "1.0.30000938", "compat-table": "kangax/compat-table#1e7b377fbdda9243cf9602872fcb493cdbdd565f", - "electron-to-chromium": "1.3.79" + "electron-to-chromium": "1.3.113" } } diff --git a/packages/babel-preset-env/scripts/build-data.js b/packages/babel-preset-env/scripts/build-data.js index 3706d8148ae0..7e1b2289f990 100644 --- a/packages/babel-preset-env/scripts/build-data.js +++ b/packages/babel-preset-env/scripts/build-data.js @@ -254,7 +254,14 @@ const generateData = (environments, features) => { const version = getLowestImplementedVersion(options, env); if (version !== null) { - plugin[env] = version.toString(); + const versionString = version.toString(); + + // NOTE(bng): A number of environments in compat-table changed to + // include a trailing zero (node10 -> node10_0), so for now stripping + // it to be consistent + plugin[env] = versionString.endsWith(".0") + ? versionString.slice(0, -2) + : versionString; } }); diff --git a/packages/babel-preset-env/scripts/build-modules-support.js b/packages/babel-preset-env/scripts/build-modules-support.js index 1ce611078c15..24528bb0ec65 100644 --- a/packages/babel-preset-env/scripts/build-modules-support.js +++ b/packages/babel-preset-env/scripts/build-modules-support.js @@ -3,23 +3,22 @@ const fs = require("fs"); const moduleSupport = require("caniuse-db/features-json/es6-module.json"); -const acceptedWithCaveats = { - safari: true, - ios_saf: true, -}; +const skipList = new Set(["and_chr", "android", "samsung"]); +const acceptedWithCaveats = new Set(["safari", "ios_saf"]); const { stats } = moduleSupport; const allowedBrowsers = {}; Object.keys(stats).forEach(browser => { - if (browser !== "and_chr") { + if (!skipList.has(browser)) { const browserVersions = stats[browser]; const allowedVersions = Object.keys(browserVersions) .filter(value => { - return acceptedWithCaveats[browser] + // Edge 16/17 are marked as "y #6" + return acceptedWithCaveats.has(browser) ? browserVersions[value][0] === "a" - : browserVersions[value] === "y"; + : browserVersions[value].startsWith("y"); }) .sort((a, b) => a - b); From 45c96908e94f044420f2bf01ad9dfa94abdeb970 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Mon, 25 Feb 2019 15:10:48 -0800 Subject: [PATCH 09/58] Update test262 (#9587) * Update test262 * Also remove unrecognized tests from the whitelist --- Makefile | 4 +- .../test262/run_babel_parser_test262_utils.js | 4 +- scripts/tests/test262/test262_whitelist.txt | 54 ++++++++----------- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index 67adb8378d29..0664763b8dd0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ MAKEFLAGS = -j1 FLOW_COMMIT = 2ac56861e3ceff9ca406ae586fbafb3480c6c0b7 -TEST262_COMMIT = 4f1155c566a222238fd86f179c6635ecb4c289bb +TEST262_COMMIT = b4e15b3d5cf63571151dbd02c0987864544c6a56 # Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967 export FORCE_COLOR = true @@ -103,7 +103,7 @@ test-flow-update-whitelist: bootstrap-test262: rm -rf ./build/test262 mkdir -p ./build - git clone --branch=master --single-branch --shallow-since=2010-01-10 https://github.com/tc39/test262.git ./build/test262 + git clone --branch=master --single-branch --shallow-since=2019-01-01 https://github.com/tc39/test262.git ./build/test262 cd build/test262 && git checkout $(TEST262_COMMIT) test-test262: diff --git a/scripts/tests/test262/run_babel_parser_test262_utils.js b/scripts/tests/test262/run_babel_parser_test262_utils.js index 4a0bf1b25756..99c173dab66d 100644 --- a/scripts/tests/test262/run_babel_parser_test262_utils.js +++ b/scripts/tests/test262/run_babel_parser_test262_utils.js @@ -43,6 +43,7 @@ const ignoredFeatures = [ "for-of", "generators", "globalThis", + "hashbang", "Int8Array", "Int32Array", "Intl.ListFormat", @@ -209,7 +210,8 @@ exports.updateWhitelist = function(filename, summary) { .concat(summary.disallowed.failure) .map(function(test) { return test.id; - }); + }) + .concat(summary.unrecognized); const toAdd = summary.disallowed.falsePositive .concat(summary.disallowed.falseNegative) .map(function(test) { diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index cc2903a3aca5..716f19338cdd 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -284,6 +284,23 @@ built-ins/RegExp/property-escapes/unsupported-property-Line_Break-with-value.js( built-ins/RegExp/property-escapes/unsupported-property-Line_Break-with-value.js(strict mode) built-ins/RegExp/property-escapes/unsupported-property-Line_Break.js(default) built-ins/RegExp/property-escapes/unsupported-property-Line_Break.js(strict mode) +language/comments/hashbang/escaped-bang-041.js(default) +language/comments/hashbang/escaped-bang-u0021.js(default) +language/comments/hashbang/escaped-bang-u21.js(default) +language/comments/hashbang/escaped-bang-x21.js(default) +language/comments/hashbang/escaped-hash-043.js(default) +language/comments/hashbang/escaped-hash-u0023.js(default) +language/comments/hashbang/escaped-hash-u23.js(default) +language/comments/hashbang/escaped-hash-x23.js(default) +language/comments/hashbang/escaped-hashbang.js(default) +language/comments/hashbang/multi-line-comment.js(default) +language/comments/hashbang/preceding-directive-prologue-sc.js(default) +language/comments/hashbang/preceding-directive-prologue.js(default) +language/comments/hashbang/preceding-empty-statement.js(default) +language/comments/hashbang/preceding-hashbang.js(default) +language/comments/hashbang/preceding-line-comment.js(default) +language/comments/hashbang/preceding-multi-line-comment.js(default) +language/comments/hashbang/preceding-whitespace.js(default) language/expressions/assignment/destructuring/obj-prop-__proto__dup.js(default) language/expressions/assignment/destructuring/obj-prop-__proto__dup.js(strict mode) language/expressions/async-arrow-function/await-as-param-ident-nested-arrow-parameter-position.js(default) @@ -316,6 +333,8 @@ language/expressions/class/elements/private-derived-cls-indirect-eval-err-contai language/expressions/class/elements/private-derived-cls-indirect-eval-err-contains-supercall.js(strict mode) language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js(default) language/expressions/class/elements/private-methods/prod-private-method-initialize-order.js(strict mode) +language/expressions/class/elements/syntax/early-errors/grammar-private-field-on-object-destructuring.js(default) +language/expressions/class/elements/syntax/early-errors/grammar-private-field-on-object-destructuring.js(strict mode) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(default) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(strict mode) language/expressions/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js(default) @@ -372,14 +391,6 @@ language/expressions/class/elements/syntax/early-errors/invalid-names/method-her language/expressions/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-bad-reference.js(strict mode) language/expressions/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-this.js(default) language/expressions/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-this.js(strict mode) -language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js(default) -language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js(strict mode) -language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js(default) -language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js(strict mode) -language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js(default) -language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js(strict mode) -language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js(default) -language/expressions/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js(strict mode) language/expressions/class/elements/syntax/early-errors/invalid-names/method-member-expression-bad-reference.js(default) language/expressions/class/elements/syntax/early-errors/invalid-names/method-member-expression-bad-reference.js(strict mode) language/expressions/class/elements/syntax/early-errors/invalid-names/method-member-expression-this.js(default) @@ -394,6 +405,7 @@ language/expressions/class/elements/syntax/early-errors/invalid-names/method-out language/expressions/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(default) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(strict mode) +language/expressions/object/method-definition/early-errors-object-async-method-duplicate-parameters.js(default) language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(default) language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(strict mode) language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js(default) @@ -405,24 +417,12 @@ language/expressions/object/method-definition/private-name-early-error-gen-insid language/expressions/object/method-definition/private-name-early-error-gen-inside-class.js(strict mode) language/expressions/object/method-definition/private-name-early-error-method-inside-class.js(default) language/expressions/object/method-definition/private-name-early-error-method-inside-class.js(strict mode) -language/expressions/postfix-decrement/arguments-nostrict.js(default) -language/expressions/postfix-decrement/eval-nostrict.js(default) -language/expressions/postfix-increment/arguments-nostrict.js(default) -language/expressions/postfix-increment/eval-nostrict.js(default) -language/expressions/prefix-decrement/arguments-nostrict.js(default) -language/expressions/prefix-decrement/eval-nostrict.js(default) -language/expressions/prefix-increment/arguments-nostrict.js(default) -language/expressions/prefix-increment/eval-nostrict.js(default) language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js(default) language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js(strict mode) language/expressions/template-literal/unicode-escape-nls-err.js(default) language/expressions/template-literal/unicode-escape-nls-err.js(strict mode) language/identifiers/unicode-escape-nls-err.js(default) language/identifiers/unicode-escape-nls-err.js(strict mode) -language/line-terminators/invalid-string-ls.js(default) -language/line-terminators/invalid-string-ls.js(strict mode) -language/line-terminators/invalid-string-ps.js(default) -language/line-terminators/invalid-string-ps.js(strict mode) language/literals/numeric/numeric-separator-literal-nzd-nsl-dds-leading-zero-err.js(default) language/literals/regexp/early-err-pattern.js(default) language/literals/regexp/early-err-pattern.js(strict mode) @@ -643,6 +643,8 @@ language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js(de language/statements/class/elements/privatename-not-valid-earlyerr-script-3.js(strict mode) language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js(default) language/statements/class/elements/privatename-not-valid-earlyerr-script-4.js(strict mode) +language/statements/class/elements/syntax/early-errors/grammar-private-field-on-object-destructuring.js(default) +language/statements/class/elements/syntax/early-errors/grammar-private-field-on-object-destructuring.js(strict mode) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(default) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-field.js(strict mode) language/statements/class/elements/syntax/early-errors/grammar-privatemeth-duplicate-get-get.js(default) @@ -699,14 +701,6 @@ language/statements/class/elements/syntax/early-errors/invalid-names/method-heri language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-bad-reference.js(strict mode) language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-this.js(default) language/statements/class/elements/syntax/early-errors/invalid-names/method-heritage-member-expression-this.js(strict mode) -language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js(default) -language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-bad-reference.js(strict mode) -language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js(default) -language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-call-expression-this.js(strict mode) -language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js(default) -language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-bad-reference.js(strict mode) -language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js(default) -language/statements/class/elements/syntax/early-errors/invalid-names/method-inner-member-expression-this.js(strict mode) language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-bad-reference.js(default) language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-bad-reference.js(strict mode) language/statements/class/elements/syntax/early-errors/invalid-names/method-member-expression-this.js(default) @@ -744,6 +738,4 @@ language/statements/for-of/head-let-bound-names-in-stmt.js(strict mode) language/statements/for-of/head-var-no-expr.js(default) language/statements/for-of/head-var-no-expr.js(strict mode) language/statements/for/head-let-bound-names-in-stmt.js(default) -language/statements/for/head-let-bound-names-in-stmt.js(strict mode) -language/statements/try/early-catch-var.js(default) -language/statements/try/early-catch-var.js(strict mode) \ No newline at end of file +language/statements/for/head-let-bound-names-in-stmt.js(strict mode) \ No newline at end of file From e6c1065d1987b3f7bdd94d52fafcbc4edb0ad52f Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Mon, 25 Feb 2019 15:20:05 -0800 Subject: [PATCH 10/58] Fix strict mode prescanning with EmptyStatement (#9585) --- packages/babel-parser/src/parser/util.js | 11 +- .../use-strict-with-pre-semi/input.js | 3 + .../use-strict-with-pre-semi/output.json | 252 ++++++++++++++++++ 3 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 packages/babel-parser/test/fixtures/core/regression/use-strict-with-pre-semi/input.js create mode 100644 packages/babel-parser/test/fixtures/core/regression/use-strict-with-pre-semi/output.json diff --git a/packages/babel-parser/src/parser/util.js b/packages/babel-parser/src/parser/util.js index 4c8eb453a8c3..6d5234793b6d 100644 --- a/packages/babel-parser/src/parser/util.js +++ b/packages/babel-parser/src/parser/util.js @@ -5,7 +5,7 @@ import Tokenizer from "../tokenizer"; import type { Node } from "../types"; import { lineBreak, skipWhiteSpace } from "../util/whitespace"; -const literal = /^(?:;|('|")((?:\\?.)*?)\1)/; +const literal = /^('|")((?:\\?.)*?)\1/; // ## Parser utilities @@ -170,6 +170,7 @@ export default class UtilParser extends Tokenizer { strictDirective(start: number): boolean { for (;;) { + // Try to find string literal. skipWhiteSpace.lastIndex = start; // $FlowIgnore start += skipWhiteSpace.exec(this.state.input)[0].length; @@ -177,6 +178,14 @@ export default class UtilParser extends Tokenizer { if (!match) break; if (match[2] === "use strict") return true; start += match[0].length; + + // Skip semicolon, if any. + skipWhiteSpace.lastIndex = start; + // $FlowIgnore + start += skipWhiteSpace.exec(this.state.input)[0].length; + if (this.state.input[start] === ";") { + start++; + } } return false; diff --git a/packages/babel-parser/test/fixtures/core/regression/use-strict-with-pre-semi/input.js b/packages/babel-parser/test/fixtures/core/regression/use-strict-with-pre-semi/input.js new file mode 100644 index 000000000000..b6452ebfc3ad --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/regression/use-strict-with-pre-semi/input.js @@ -0,0 +1,3 @@ +function a ([a] = []) { + ; 'use strict'; with ({}) {} +} diff --git a/packages/babel-parser/test/fixtures/core/regression/use-strict-with-pre-semi/output.json b/packages/babel-parser/test/fixtures/core/regression/use-strict-with-pre-semi/output.json new file mode 100644 index 000000000000..694c18f640d7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/regression/use-strict-with-pre-semi/output.json @@ -0,0 +1,252 @@ +{ + "type": "File", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "a" + }, + "name": "a" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "AssignmentPattern", + "start": 12, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "left": { + "type": "ArrayPattern", + "start": 12, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "elements": [ + { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "a" + }, + "name": "a" + } + ] + }, + "right": { + "type": "ArrayExpression", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "elements": [] + } + } + ], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 55, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "EmptyStatement", + "start": 25, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 2 + } + } + }, + { + "type": "ExpressionStatement", + "start": 27, + "end": 40, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "expression": { + "type": "StringLiteral", + "start": 27, + "end": 39, + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "extra": { + "rawValue": "use strict", + "raw": "'use strict'" + }, + "value": "use strict" + } + }, + { + "type": "WithStatement", + "start": 41, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "object": { + "type": "ObjectExpression", + "start": 47, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "properties": [] + }, + "body": { + "type": "BlockStatement", + "start": 51, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 29 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file From d0e196d210545428c78e8e8177464c0637b28f88 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Mon, 25 Feb 2019 18:30:51 -0800 Subject: [PATCH 11/58] Treat for loop body as part of loop scope (#9586) --- packages/babel-parser/src/parser/statement.js | 4 +- .../test/fixtures/core/scope/for-let/input.js | 3 + .../fixtures/core/scope/for-let/output.json | 191 ++++++++++++++++++ .../test/fixtures/core/scope/for-var/input.js | 3 + .../fixtures/core/scope/for-var/options.json | 3 + scripts/tests/test262/test262_whitelist.txt | 13 +- 6 files changed, 204 insertions(+), 13 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/core/scope/for-let/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/for-let/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/for-var/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/for-var/options.json diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 5e77de8ba31a..0f55802ea0e2 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -901,7 +901,6 @@ export default class StatementParser extends ExpressionParser { node.update = this.match(tt.parenR) ? null : this.parseExpression(); this.expect(tt.parenR); - this.scope.exit(); node.body = // For the smartPipelines plugin: Disable topic references from outer // contexts within the loop body. They are permitted in test expressions, @@ -911,6 +910,7 @@ export default class StatementParser extends ExpressionParser { this.parseStatement("for"), ); + this.scope.exit(); this.state.labels.pop(); return this.finishNode(node, "ForStatement"); @@ -937,7 +937,6 @@ export default class StatementParser extends ExpressionParser { node.right = this.parseExpression(); this.expect(tt.parenR); - this.scope.exit(); node.body = // For the smartPipelines plugin: // Disable topic references from outer contexts within the loop body. @@ -947,6 +946,7 @@ export default class StatementParser extends ExpressionParser { this.parseStatement("for"), ); + this.scope.exit(); this.state.labels.pop(); return this.finishNode(node, type); diff --git a/packages/babel-parser/test/fixtures/core/scope/for-let/input.js b/packages/babel-parser/test/fixtures/core/scope/for-let/input.js new file mode 100644 index 000000000000..a169b4038040 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/for-let/input.js @@ -0,0 +1,3 @@ +for (let i = 0;;) { + let i; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/for-let/output.json b/packages/babel-parser/test/fixtures/core/scope/for-let/output.json new file mode 100644 index 000000000000..8af98b16aa63 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/for-let/output.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ForStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "init": { + "type": "VariableDeclaration", + "start": 5, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "i" + }, + "name": "i" + }, + "init": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + ], + "kind": "let" + }, + "test": null, + "update": null, + "body": { + "type": "BlockStatement", + "start": 18, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + }, + "identifierName": "i" + }, + "name": "i" + }, + "init": null + } + ], + "kind": "let" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/for-var/input.js b/packages/babel-parser/test/fixtures/core/scope/for-var/input.js new file mode 100644 index 000000000000..400b636e5c84 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/for-var/input.js @@ -0,0 +1,3 @@ +for (let i = 0;;) { + var i; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/for-var/options.json b/packages/babel-parser/test/fixtures/core/scope/for-var/options.json new file mode 100644 index 000000000000..10e45adf4560 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/for-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'i' has already been declared (2:8)" +} \ No newline at end of file diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index 716f19338cdd..0c385c9bc7dc 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -1,3 +1,4 @@ + annexB/language/statements/for-in/bare-initializer.js(default) annexB/language/statements/for-in/bare-initializer.js(strict mode) built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_F-negated.js(default) @@ -719,23 +720,13 @@ language/statements/for-in/dstr/array-rest-before-elision.js(default) language/statements/for-in/dstr/array-rest-before-elision.js(strict mode) language/statements/for-in/dstr/array-rest-elision-invalid.js(default) language/statements/for-in/dstr/array-rest-elision-invalid.js(strict mode) -language/statements/for-in/head-const-bound-names-in-stmt.js(default) -language/statements/for-in/head-const-bound-names-in-stmt.js(strict mode) -language/statements/for-in/head-let-bound-names-in-stmt.js(default) -language/statements/for-in/head-let-bound-names-in-stmt.js(strict mode) language/statements/for-of/dstr/array-rest-before-elision.js(default) language/statements/for-of/dstr/array-rest-before-elision.js(strict mode) language/statements/for-of/dstr/array-rest-elision-invalid.js(default) language/statements/for-of/dstr/array-rest-elision-invalid.js(strict mode) -language/statements/for-of/head-const-bound-names-in-stmt.js(default) -language/statements/for-of/head-const-bound-names-in-stmt.js(strict mode) language/statements/for-of/head-decl-no-expr.js(default) language/statements/for-of/head-decl-no-expr.js(strict mode) language/statements/for-of/head-expr-no-expr.js(default) language/statements/for-of/head-expr-no-expr.js(strict mode) -language/statements/for-of/head-let-bound-names-in-stmt.js(default) -language/statements/for-of/head-let-bound-names-in-stmt.js(strict mode) language/statements/for-of/head-var-no-expr.js(default) -language/statements/for-of/head-var-no-expr.js(strict mode) -language/statements/for/head-let-bound-names-in-stmt.js(default) -language/statements/for/head-let-bound-names-in-stmt.js(strict mode) \ No newline at end of file +language/statements/for-of/head-var-no-expr.js(strict mode) \ No newline at end of file From 8f26f6df8355540dd8f351e9f71f7bf056838e2c Mon Sep 17 00:00:00 2001 From: Florian Adonis Date: Tue, 26 Feb 2019 16:05:43 +0100 Subject: [PATCH 12/58] change var name for coherence (#9579) --- packages/babel-generator/src/printer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-generator/src/printer.js b/packages/babel-generator/src/printer.js index 1d0b2077a160..fb4715d491c5 100644 --- a/packages/babel-generator/src/printer.js +++ b/packages/babel-generator/src/printer.js @@ -367,7 +367,7 @@ export default class Printer { const loc = t.isProgram(node) || t.isFile(node) ? null : node.loc; this.withSource("start", loc, () => { - this[node.type](node, parent); + printMethod.call(this, node, parent); }); this._printTrailingComments(node); From f1ab6120d2617e25d1dbf1eec6c7d74c61ad329b Mon Sep 17 00:00:00 2001 From: Brian Ng Date: Tue, 26 Feb 2019 11:21:00 -0600 Subject: [PATCH 13/58] Bump Babel deps (#9590) --- babel.config.js | 8 +- package.json | 10 +- yarn.lock | 461 +++++++++++++++++++++++------------------------- 3 files changed, 232 insertions(+), 247 deletions(-) diff --git a/babel.config.js b/babel.config.js index 12f4bb16ca83..cb8f2fbf003b 100644 --- a/babel.config.js +++ b/babel.config.js @@ -115,9 +115,11 @@ module.exports = function(api) { "packages/babel-runtime", /[\\/]node_modules[\\/](?:@babel\/runtime|babel-runtime|core-js)[\\/]/, ], - plugins: [includeRuntime ? "@babel/transform-runtime" : null].filter( - Boolean - ), + plugins: [ + includeRuntime + ? ["@babel/transform-runtime", { version: "7.3.4" }] + : null, + ].filter(Boolean), }, ].filter(Boolean), }; diff --git a/package.json b/package.json index d682ce4540bf..109bc6a97be9 100644 --- a/package.json +++ b/package.json @@ -10,17 +10,17 @@ }, "devDependencies": { "@babel/cli": "^7.2.3", - "@babel/core": "^7.2.2", + "@babel/core": "^7.3.4", "@babel/eslint-plugin-development": "^1.0.1", - "@babel/plugin-proposal-class-properties": "^7.3.0", + "@babel/plugin-proposal-class-properties": "^7.3.4", "@babel/plugin-proposal-export-namespace-from": "^7.2.0", "@babel/plugin-proposal-numeric-separator": "^7.2.0", "@babel/plugin-transform-modules-commonjs": "^7.2.0", - "@babel/plugin-transform-runtime": "^7.2.0", - "@babel/preset-env": "^7.3.1", + "@babel/plugin-transform-runtime": "^7.3.4", + "@babel/preset-env": "^7.3.4", "@babel/preset-flow": "^7.0.0", "@babel/register": "^7.0.0", - "@babel/runtime": "^7.3.1", + "@babel/runtime": "^7.3.4", "babel-eslint": "^11.0.0-beta.0", "babel-jest": "^24.0.0", "babel-loader": "^8.0.5", diff --git a/yarn.lock b/yarn.lock index e0f7d90ff7d3..ab1eecdd3c33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,6 +5,7 @@ "@babel/cli@^7.2.3": version "7.2.3" resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.2.3.tgz#1b262e42a3e959d28ab3d205ba2718e1923cfee6" + integrity sha512-bfna97nmJV6nDJhXNPeEfxyMjWnt6+IjUAaDPiYRTBlm8L41n8nvw6UAqUCbvpFfU246gHPxW7sfWwqtF4FcYA== dependencies: commander "^2.8.1" convert-source-map "^1.1.0" @@ -21,24 +22,26 @@ "@babel/code-frame@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0.tgz#06e2ab19bdb535385559aabb5ba59729482800f8" + integrity sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA== dependencies: "@babel/highlight" "^7.0.0" -"@babel/core@^7.1.0", "@babel/core@^7.2.2": - version "7.2.2" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.2.2.tgz#07adba6dde27bb5ad8d8672f15fde3e08184a687" +"@babel/core@^7.1.0", "@babel/core@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.3.4.tgz#921a5a13746c21e32445bf0798680e9d11a6530b" + integrity sha512-jRsuseXBo9pN197KnDwhhaaBzyZr2oIcLHHTt2oDdQrej5Qp57dCCJafWx5ivU8/alEYDpssYqv1MUqcxwQlrA== dependencies: "@babel/code-frame" "^7.0.0" - "@babel/generator" "^7.2.2" + "@babel/generator" "^7.3.4" "@babel/helpers" "^7.2.0" - "@babel/parser" "^7.2.2" + "@babel/parser" "^7.3.4" "@babel/template" "^7.2.2" - "@babel/traverse" "^7.2.2" - "@babel/types" "^7.2.2" + "@babel/traverse" "^7.3.4" + "@babel/types" "^7.3.4" convert-source-map "^1.1.0" debug "^4.1.0" json5 "^2.1.0" - lodash "^4.17.10" + lodash "^4.17.11" resolve "^1.3.2" semver "^5.4.1" source-map "^0.5.0" @@ -46,36 +49,30 @@ "@babel/eslint-plugin-development@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@babel/eslint-plugin-development/-/eslint-plugin-development-1.0.1.tgz#1f5206ae95795db09b65e7dbc2b158d66497a44c" + integrity sha512-ioEhN8HgKr4Yx8ef+XryNpKN4FimSFceb0qVVxvoUzpFn3xyq17MlY5AquEqtXObE7Nu7WKq7QL9INzjCrugyw== -"@babel/generator@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0.tgz#1efd58bffa951dc846449e58ce3a1d7f02d393aa" - dependencies: - "@babel/types" "^7.0.0" - jsesc "^2.5.1" - lodash "^4.17.10" - source-map "^0.5.0" - trim-right "^1.0.1" - -"@babel/generator@^7.2.2": - version "7.3.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.3.0.tgz#f663838cd7b542366de3aa608a657b8ccb2a99eb" +"@babel/generator@^7.0.0", "@babel/generator@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.3.4.tgz#9aa48c1989257877a9d971296e5b73bfe72e446e" + integrity sha512-8EXhHRFqlVVWXPezBW5keTiQi/rJMQTg/Y9uVCEZ0CAF3PKtCCaVRnp64Ii1ujhkoDhhF1fVsImoN4yJ2uz4Wg== dependencies: - "@babel/types" "^7.3.0" + "@babel/types" "^7.3.4" jsesc "^2.5.1" - lodash "^4.17.10" + lodash "^4.17.11" source-map "^0.5.0" trim-right "^1.0.1" "@babel/helper-annotate-as-pure@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32" + integrity sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q== dependencies: "@babel/types" "^7.0.0" "@babel/helper-builder-binary-assignment-operator-visitor@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.1.0.tgz#6b69628dfe4087798e0c4ed98e3d4a6b2fbd2f5f" + integrity sha512-qNSR4jrmJ8M1VMM9tibvyRAHXQs2PmaksQF7c1CGJNipfe3D8p+wgNwgso/P2A2r2mdgBWAXljNWR0QRZAMW8w== dependencies: "@babel/helper-explode-assignable-expression" "^7.1.0" "@babel/types" "^7.0.0" @@ -83,24 +80,28 @@ "@babel/helper-call-delegate@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-call-delegate/-/helper-call-delegate-7.1.0.tgz#6a957f105f37755e8645343d3038a22e1449cc4a" + integrity sha512-YEtYZrw3GUK6emQHKthltKNZwszBcHK58Ygcis+gVUrF4/FmTVr5CCqQNSfmvg2y+YDEANyYoaLz/SHsnusCwQ== dependencies: "@babel/helper-hoist-variables" "^7.0.0" "@babel/traverse" "^7.1.0" "@babel/types" "^7.0.0" -"@babel/helper-create-class-features-plugin@^7.3.0": - version "7.3.0" - resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.3.0.tgz#2b01a81b3adc2b1287f9ee193688ef8dc71e718f" +"@babel/helper-create-class-features-plugin@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.3.4.tgz#092711a7a3ad8ea34de3e541644c2ce6af1f6f0c" + integrity sha512-uFpzw6L2omjibjxa8VGZsJUPL5wJH0zzGKpoz0ccBkzIa6C8kWNUbiBmQ0rgOKWlHJ6qzmfa6lTiGchiV8SC+g== dependencies: "@babel/helper-function-name" "^7.1.0" "@babel/helper-member-expression-to-functions" "^7.0.0" "@babel/helper-optimise-call-expression" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-replace-supers" "^7.2.3" + "@babel/helper-replace-supers" "^7.3.4" + "@babel/helper-split-export-declaration" "^7.0.0" "@babel/helper-define-map@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-define-map/-/helper-define-map-7.1.0.tgz#3b74caec329b3c80c116290887c0dd9ae468c20c" + integrity sha512-yPPcW8dc3gZLN+U1mhYV91QU3n5uTbx7DUdf8NnPbjS0RMwBuHi9Xt2MUgppmNz7CJxTBWsGczTiEp1CSOTPRg== dependencies: "@babel/helper-function-name" "^7.1.0" "@babel/types" "^7.0.0" @@ -109,6 +110,7 @@ "@babel/helper-explode-assignable-expression@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.1.0.tgz#537fa13f6f1674df745b0c00ec8fe4e99681c8f6" + integrity sha512-NRQpfHrJ1msCHtKjbzs9YcMmJZOg6mQMmGRB+hbamEdG5PNpaSm95275VD92DvJKuyl0s2sFiDmMZ+EnnvufqA== dependencies: "@babel/traverse" "^7.1.0" "@babel/types" "^7.0.0" @@ -116,6 +118,7 @@ "@babel/helper-function-name@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz#a0ceb01685f73355d4360c1247f582bfafc8ff53" + integrity sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw== dependencies: "@babel/helper-get-function-arity" "^7.0.0" "@babel/template" "^7.1.0" @@ -124,24 +127,28 @@ "@babel/helper-get-function-arity@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz#83572d4320e2a4657263734113c42868b64e49c3" + integrity sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ== dependencies: "@babel/types" "^7.0.0" "@babel/helper-hoist-variables@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.0.0.tgz#46adc4c5e758645ae7a45deb92bab0918c23bb88" + integrity sha512-Ggv5sldXUeSKsuzLkddtyhyHe2YantsxWKNi7A+7LeD12ExRDWTRk29JCXpaHPAbMaIPZSil7n+lq78WY2VY7w== dependencies: "@babel/types" "^7.0.0" "@babel/helper-member-expression-to-functions@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.0.0.tgz#8cd14b0a0df7ff00f009e7d7a436945f47c7a16f" + integrity sha512-avo+lm/QmZlv27Zsi0xEor2fKcqWG56D5ae9dzklpIaY7cQMK5N8VSpaNVPPagiqmy7LrEjK1IWdGMOqPu5csg== dependencies: "@babel/types" "^7.0.0" "@babel/helper-module-imports@7.0.0-beta.35": version "7.0.0-beta.35" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0-beta.35.tgz#308e350e731752cdb4d0f058df1d704925c64e0a" + integrity sha512-vaC1KyIZSuyWb3Lj277fX0pxivyHwuDU4xZsofqgYAbkDxNieMg2vuhzP5AgMweMY7fCQUMTi+BgPqTLjkxXFg== dependencies: "@babel/types" "7.0.0-beta.35" lodash "^4.2.0" @@ -149,39 +156,45 @@ "@babel/helper-module-imports@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz#96081b7111e486da4d2cd971ad1a4fe216cc2e3d" + integrity sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A== dependencies: "@babel/types" "^7.0.0" "@babel/helper-module-transforms@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.1.0.tgz#470d4f9676d9fad50b324cdcce5fbabbc3da5787" + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.2.2.tgz#ab2f8e8d231409f8370c883d20c335190284b963" + integrity sha512-YRD7I6Wsv+IHuTPkAmAS4HhY0dkPobgLftHp0cRGZSdrRvmZY8rFvae/GVu3bD00qscuvK3WPHB3YdNpBXUqrA== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/helper-simple-access" "^7.1.0" "@babel/helper-split-export-declaration" "^7.0.0" - "@babel/template" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/template" "^7.2.2" + "@babel/types" "^7.2.2" lodash "^4.17.10" "@babel/helper-optimise-call-expression@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.0.0.tgz#a2920c5702b073c15de51106200aa8cad20497d5" + integrity sha512-u8nd9NQePYNQV8iPWu/pLLYBqZBa4ZaY1YWRFMuxrid94wKI1QNt67NEZ7GAe5Kc/0LLScbim05xZFWkAdrj9g== dependencies: "@babel/types" "^7.0.0" "@babel/helper-plugin-utils@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250" + integrity sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA== "@babel/helper-regex@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-regex/-/helper-regex-7.0.0.tgz#2c1718923b57f9bbe64705ffe5640ac64d9bdb27" + integrity sha512-TR0/N0NDCcUIUEbqV6dCO+LptmmSQFQ7q70lfcEB4URsjD0E1HzicrwUH+ap6BAQ2jhCX9Q4UqZy4wilujWlkg== dependencies: lodash "^4.17.10" "@babel/helper-remap-async-to-generator@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz#361d80821b6f38da75bd3f0785ece20a88c5fe7f" + integrity sha512-3fOK0L+Fdlg8S5al8u/hWE6vhufGSn0bN09xm2LXMy//REAF8kDCrYoOBKYmA8m5Nom+sV9LyLCwrFynA8/slg== dependencies: "@babel/helper-annotate-as-pure" "^7.0.0" "@babel/helper-wrap-function" "^7.1.0" @@ -189,18 +202,20 @@ "@babel/traverse" "^7.1.0" "@babel/types" "^7.0.0" -"@babel/helper-replace-supers@^7.1.0", "@babel/helper-replace-supers@^7.2.3": - version "7.2.3" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.2.3.tgz#19970020cf22677d62b3a689561dbd9644d8c5e5" +"@babel/helper-replace-supers@^7.1.0", "@babel/helper-replace-supers@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.3.4.tgz#a795208e9b911a6eeb08e5891faacf06e7013e13" + integrity sha512-pvObL9WVf2ADs+ePg0jrqlhHoxRXlOa+SHRHzAXIz2xkYuOHfGl+fKxPMaS4Fq+uje8JQPobnertBBvyrWnQ1A== dependencies: "@babel/helper-member-expression-to-functions" "^7.0.0" "@babel/helper-optimise-call-expression" "^7.0.0" - "@babel/traverse" "^7.2.3" - "@babel/types" "^7.0.0" + "@babel/traverse" "^7.3.4" + "@babel/types" "^7.3.4" "@babel/helper-simple-access@^7.1.0": version "7.1.0" resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz#65eeb954c8c245beaa4e859da6188f39d71e585c" + integrity sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w== dependencies: "@babel/template" "^7.1.0" "@babel/types" "^7.0.0" @@ -208,56 +223,64 @@ "@babel/helper-split-export-declaration@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz#3aae285c0311c2ab095d997b8c9a94cad547d813" + integrity sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag== dependencies: "@babel/types" "^7.0.0" "@babel/helper-wrap-function@^7.1.0": - version "7.1.0" - resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.1.0.tgz#8cf54e9190706067f016af8f75cb3df829cc8c66" + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.2.0.tgz#c4e0012445769e2815b55296ead43a958549f6fa" + integrity sha512-o9fP1BZLLSrYlxYEYyl2aS+Flun5gtjTIG8iln+XuEzQTs0PLagAGSXUcqruJwD5fM48jzIEggCKpIfWTcR7pQ== dependencies: "@babel/helper-function-name" "^7.1.0" "@babel/template" "^7.1.0" "@babel/traverse" "^7.1.0" - "@babel/types" "^7.0.0" + "@babel/types" "^7.2.0" "@babel/helpers@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.2.0.tgz#8335f3140f3144270dc63c4732a4f8b0a50b7a21" + version "7.3.1" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.3.1.tgz#949eec9ea4b45d3210feb7dc1c22db664c9e44b9" + integrity sha512-Q82R3jKsVpUV99mgX50gOPCWwco9Ec5Iln/8Vyu4osNIOQgSrd9RFrQeUvmvddFNoLwMyOUWU+5ckioEKpDoGA== dependencies: "@babel/template" "^7.1.2" "@babel/traverse" "^7.1.5" - "@babel/types" "^7.2.0" + "@babel/types" "^7.3.0" "@babel/highlight@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0.tgz#f710c38c8d458e6dd9a201afb637fcb781ce99e4" + integrity sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw== dependencies: chalk "^2.0.0" esutils "^2.0.2" js-tokens "^4.0.0" -"@babel/parser@^7.0.0", "@babel/parser@^7.2.2", "@babel/parser@^7.2.3": - version "7.3.1" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.1.tgz#8f4ffd45f779e6132780835ffa7a215fa0b2d181" +"@babel/parser@^7.0.0", "@babel/parser@^7.2.2", "@babel/parser@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.4.tgz#a43357e4bbf4b92a437fb9e465c192848287f27c" + integrity sha512-tXZCqWtlOOP4wgCp6RjRvLmfuhnqTLy9VHwRochJBCP2nDm27JnnuFEnXFASVyQNHk36jD1tAammsCEEqgscIQ== "@babel/plugin-proposal-async-generator-functions@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz#b289b306669dce4ad20b0252889a15768c9d417e" + integrity sha512-+Dfo/SCQqrwx48ptLVGLdE39YtWRuKc/Y9I5Fy0P1DDBB9lsAHpjcEJQt+4IifuSOSTLBKJObJqMvaO1pIE8LQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-remap-async-to-generator" "^7.1.0" "@babel/plugin-syntax-async-generators" "^7.2.0" -"@babel/plugin-proposal-class-properties@^7.3.0": - version "7.3.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.3.0.tgz#272636bc0fa19a0bc46e601ec78136a173ea36cd" +"@babel/plugin-proposal-class-properties@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.3.4.tgz#410f5173b3dc45939f9ab30ca26684d72901405e" + integrity sha512-lUf8D3HLs4yYlAo8zjuneLvfxN7qfKv1Yzbj5vjqaqMJxgJA3Ipwp4VUJ+OrOdz53Wbww6ahwB8UhB2HQyLotA== dependencies: - "@babel/helper-create-class-features-plugin" "^7.3.0" + "@babel/helper-create-class-features-plugin" "^7.3.4" "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-proposal-export-namespace-from@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.2.0.tgz#308fd4d04ff257fc3e4be090550840eeabad5dd9" + integrity sha512-DZUxbHYxQ5fUFIkMEnh75ogEdBLPfL+mQUqrO2hNY2LGm+tqFnxE924+mhAcCOh/8za8AaZsWHbq6bBoS3TAzA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-export-namespace-from" "^7.2.0" @@ -265,6 +288,7 @@ "@babel/plugin-proposal-json-strings@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.2.0.tgz#568ecc446c6148ae6b267f02551130891e29f317" + integrity sha512-MAFV1CA/YVmYwZG0fBQyXhmj0BHCB5egZHCKWIFVv/XCxAeVGIHfos3SwDck4LvCllENIAg7xMKOG5kH0dzyUg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-json-strings" "^7.2.0" @@ -272,13 +296,15 @@ "@babel/plugin-proposal-numeric-separator@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.2.0.tgz#646854daf4cd22fd6733f6076013a936310443ac" + integrity sha512-DohMOGDrZiMKS7LthjUZNNcWl8TAf5BZDwZAH4wpm55FuJTHgfqPGdibg7rZDmont/8Yg0zA03IgT6XLeP+4sg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-numeric-separator" "^7.2.0" -"@babel/plugin-proposal-object-rest-spread@^7.3.1": - version "7.3.1" - resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.3.1.tgz#f69fb6a1ea6a4e1c503994a91d9cf76f3c4b36e8" +"@babel/plugin-proposal-object-rest-spread@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.3.4.tgz#47f73cf7f2a721aad5c0261205405c642e424654" + integrity sha512-j7VQmbbkA+qrzNqbKHrBsW3ddFnOeva6wzSe/zB7T+xaxGc+RCpwo44wCmRixAIGRoIpmVgvzFzNJqQcO3/9RA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-object-rest-spread" "^7.2.0" @@ -286,6 +312,7 @@ "@babel/plugin-proposal-optional-catch-binding@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.2.0.tgz#135d81edb68a081e55e56ec48541ece8065c38f5" + integrity sha512-mgYj3jCcxug6KUcX4OBoOJz3CMrwRfQELPQ5560F70YQUBZB7uac9fqaWamKR1iWUzGiK2t0ygzjTScZnVz75g== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" @@ -293,6 +320,7 @@ "@babel/plugin-proposal-unicode-property-regex@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.2.0.tgz#abe7281fe46c95ddc143a65e5358647792039520" + integrity sha512-LvRVYb7kikuOtIoUeWTkOxQEV1kYvL5B6U3iWEGCzPNRus1MzJweFqORTj+0jkxozkTSYNJozPOddxmqdqsRpw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-regex" "^7.0.0" @@ -301,54 +329,63 @@ "@babel/plugin-syntax-async-generators@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.2.0.tgz#69e1f0db34c6f5a0cf7e2b3323bf159a76c8cb7f" + integrity sha512-1ZrIRBv2t0GSlcwVoQ6VgSLpLgiN/FVQUzt9znxo7v2Ov4jJrs8RY8tv0wvDmFN3qIdMKWrmMMW6yZ0G19MfGg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-export-namespace-from@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.2.0.tgz#8d257838c6b3b779db52c0224443459bd27fb039" + integrity sha512-1zGA3UNch6A+A11nIzBVEaE3DDJbjfB+eLIcf0GGOh/BJr/8NxL3546MGhV/r0RhH4xADFIEso39TKCfEMlsGA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-syntax-flow@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.0.0.tgz#70638aeaad9ee426bc532e51523cff8ff02f6f17" +"@babel/plugin-syntax-flow@^7.2.0": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.2.0.tgz#a765f061f803bc48f240c26f8747faf97c26bf7c" + integrity sha512-r6YMuZDWLtLlu0kqIim5o/3TNRAlWb073HwT3e2nKf9I8IIvOggPrnILYPsrrKilmn/mYEMCf/Z07w3yQJF6dg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-json-strings@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.2.0.tgz#72bd13f6ffe1d25938129d2a186b11fd62951470" + integrity sha512-5UGYnMSLRE1dqqZwug+1LISpA403HzlSfsg6P9VXU6TBjcSHeNlw4DxDx7LgpF+iKZoOG/+uzqoRHTdcUpiZNg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-numeric-separator@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.2.0.tgz#7470fe070c2944469a756752a69a6963135018be" + integrity sha512-DroeVNkO/BnGpL2R7+ZNZqW+E24aR/4YWxP3Qb15d6lPU8KDzF8HlIUIRCOJRn4X77/oyW4mJY+7FHfY82NLtQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-object-rest-spread@^7.0.0", "@babel/plugin-syntax-object-rest-spread@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz#3b7a3e733510c57e820b9142a6579ac8b0dfad2e" + integrity sha512-t0JKGgqk2We+9may3t0xDdmneaXmyxq0xieYcKHxIsrJO64n1OiMWNUtc5gQK1PA0NpdCRrtZp4z+IUaKugrSA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-syntax-optional-catch-binding@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.2.0.tgz#a94013d6eda8908dfe6a477e7f9eda85656ecf5c" + integrity sha512-bDe4xKNhb0LI7IvZHiA13kff0KEfaGX/Hv4lMA9+7TEc63hMNvfKo6ZFpXhKuEp+II/q35Gc4NoMeDZyaUbj9w== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-arrow-functions@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.2.0.tgz#9aeafbe4d6ffc6563bf8f8372091628f00779550" + integrity sha512-ER77Cax1+8/8jCB9fo4Ud161OZzWN5qawi4GusDuRLcDbDG+bIGYY20zb2dfAFdTRGzrfq2xZPvF0R64EHnimg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-async-to-generator@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.2.0.tgz#68b8a438663e88519e65b776f8938f3445b1a2ff" +"@babel/plugin-transform-async-to-generator@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.3.4.tgz#4e45408d3c3da231c0e7b823f407a53a7eb3048c" + integrity sha512-Y7nCzv2fw/jEZ9f678MuKdMo99MFDJMT/PvD9LisrR5JDFcJH6vYeH6RnjVt3p5tceyGRvTtEN0VOlU+rgHZjA== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -357,44 +394,50 @@ "@babel/plugin-transform-block-scoped-functions@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.2.0.tgz#5d3cc11e8d5ddd752aa64c9148d0db6cb79fd190" + integrity sha512-ntQPR6q1/NKuphly49+QiQiTN0O63uOwjdD6dhIjSWBI5xlrbUFh720TIpzBhpnrLfv2tNH/BXvLIab1+BAI0w== dependencies: "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-block-scoping@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.2.0.tgz#f17c49d91eedbcdf5dd50597d16f5f2f770132d4" +"@babel/plugin-transform-block-scoping@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.3.4.tgz#5c22c339de234076eee96c8783b2fed61202c5c4" + integrity sha512-blRr2O8IOZLAOJklXLV4WhcEzpYafYQKSGT3+R26lWG41u/FODJuBggehtOwilVAcFu393v3OFj+HmaE6tVjhA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" - lodash "^4.17.10" + lodash "^4.17.11" -"@babel/plugin-transform-classes@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.2.0.tgz#374f8876075d7d21fea55aeb5c53561259163f96" +"@babel/plugin-transform-classes@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-classes/-/plugin-transform-classes-7.3.4.tgz#dc173cb999c6c5297e0b5f2277fdaaec3739d0cc" + integrity sha512-J9fAvCFBkXEvBimgYxCjvaVDzL6thk0j0dBvCeZmIUDBwyt+nv6HfbImsSrWsYXfDNDivyANgJlFXDUWRTZBuA== dependencies: "@babel/helper-annotate-as-pure" "^7.0.0" "@babel/helper-define-map" "^7.1.0" "@babel/helper-function-name" "^7.1.0" "@babel/helper-optimise-call-expression" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" - "@babel/helper-replace-supers" "^7.1.0" + "@babel/helper-replace-supers" "^7.3.4" "@babel/helper-split-export-declaration" "^7.0.0" globals "^11.1.0" "@babel/plugin-transform-computed-properties@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.2.0.tgz#83a7df6a658865b1c8f641d510c6f3af220216da" + integrity sha512-kP/drqTxY6Xt3NNpKiMomfgkNn4o7+vKxK2DDKcBG9sHj51vHqMBGy8wbDS/J4lMxnqs153/T3+DmCEAkC5cpA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-destructuring@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.2.0.tgz#e75269b4b7889ec3a332cd0d0c8cff8fed0dc6f3" + version "7.3.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.3.2.tgz#f2f5520be055ba1c38c41c0e094d8a461dd78f2d" + integrity sha512-Lrj/u53Ufqxl/sGxyjsJ2XNtNuEjDyjpqdhMNh5aZ+XFOdThL46KBj27Uem4ggoezSYBxKWAil6Hu8HtwqesYw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-dotall-regex@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.2.0.tgz#f0aabb93d120a8ac61e925ea0ba440812dbe0e49" + integrity sha512-sKxnyHfizweTgKZf7XsXu/CNupKhzijptfTM+bozonIuyVrLWVUvYjE2bhuSBML8VQeMxq4Mm63Q9qvcvUcciQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-regex" "^7.0.0" @@ -403,32 +446,37 @@ "@babel/plugin-transform-duplicate-keys@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.2.0.tgz#d952c4930f312a4dbfff18f0b2914e60c35530b3" + integrity sha512-q+yuxW4DsTjNceUiTzK0L+AfQ0zD9rWaTLiUqHA8p0gxx7lu1EylenfzjeIWNkPy6e/0VG/Wjw9uf9LueQwLOw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-exponentiation-operator@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.2.0.tgz#a63868289e5b4007f7054d46491af51435766008" + integrity sha512-umh4hR6N7mu4Elq9GG8TOu9M0bakvlsREEC+ialrQN6ABS4oDQ69qJv1VtR3uxlKMCQMCvzk7vr17RHKcjx68A== dependencies: "@babel/helper-builder-binary-assignment-operator-visitor" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-flow-strip-types@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.0.0.tgz#c40ced34c2783985d90d9f9ac77a13e6fb396a01" + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.3.4.tgz#00156236defb7dedddc2d3c9477dcc01a4494327" + integrity sha512-PmQC9R7DwpBFA+7ATKMyzViz3zCaMNouzZMPZN2K5PnbBbtL3AXFYTkDk+Hey5crQq2A90UG5Uthz0mel+XZrA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" - "@babel/plugin-syntax-flow" "^7.0.0" + "@babel/plugin-syntax-flow" "^7.2.0" "@babel/plugin-transform-for-of@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.2.0.tgz#ab7468befa80f764bb03d3cb5eef8cc998e1cad9" + integrity sha512-Kz7Mt0SsV2tQk6jG5bBv5phVbkd0gd27SgYD4hH1aLMJRchM0dzHaXvrWhVZ+WxAlDoAKZ7Uy3jVTW2mKXQ1WQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-function-name@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.2.0.tgz#f7930362829ff99a3174c39f0afcc024ef59731a" + integrity sha512-kWgksow9lHdvBC2Z4mxTsvc7YdY7w/V6B2vy9cTIPtLEE9NhwoWivaxdNM/S37elu5bqlLP/qOY906LukO9lkQ== dependencies: "@babel/helper-function-name" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -436,12 +484,14 @@ "@babel/plugin-transform-literals@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-literals/-/plugin-transform-literals-7.2.0.tgz#690353e81f9267dad4fd8cfd77eafa86aba53ea1" + integrity sha512-2ThDhm4lI4oV7fVQ6pNNK+sx+c/GM5/SaML0w/r4ZB7sAneD/piDJtwdKlNckXeyGK7wlwg2E2w33C/Hh+VFCg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-modules-amd@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.2.0.tgz#82a9bce45b95441f617a24011dc89d12da7f4ee6" + integrity sha512-mK2A8ucqz1qhrdqjS9VMIDfIvvT2thrEsIQzbaTdc5QFzhDjQv2CkJJ5f6BXIkgbmaoax3zBr2RyvV/8zeoUZw== dependencies: "@babel/helper-module-transforms" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -449,14 +499,16 @@ "@babel/plugin-transform-modules-commonjs@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.2.0.tgz#c4f1933f5991d5145e9cfad1dfd848ea1727f404" + integrity sha512-V6y0uaUQrQPXUrmj+hgnks8va2L0zcZymeU7TtWEgdRLNkceafKXEduv7QzgQAE4lT+suwooG9dC7LFhdRAbVQ== dependencies: "@babel/helper-module-transforms" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-simple-access" "^7.1.0" -"@babel/plugin-transform-modules-systemjs@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.2.0.tgz#912bfe9e5ff982924c81d0937c92d24994bb9068" +"@babel/plugin-transform-modules-systemjs@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.3.4.tgz#813b34cd9acb6ba70a84939f3680be0eb2e58861" + integrity sha512-VZ4+jlGOF36S7TjKs8g4ojp4MEI+ebCQZdswWb/T9I4X84j8OtFAyjXjt/M16iIm5RIZn0UMQgg/VgIwo/87vw== dependencies: "@babel/helper-hoist-variables" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -464,6 +516,7 @@ "@babel/plugin-transform-modules-umd@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.2.0.tgz#7678ce75169f0877b8eb2235538c074268dd01ae" + integrity sha512-BV3bw6MyUH1iIsGhXlOK6sXhmSarZjtJ/vMiD9dNmpY8QXFFQTj+6v92pcfy1iqa8DeAfJFwoxcrS/TUZda6sw== dependencies: "@babel/helper-module-transforms" "^7.1.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -471,39 +524,45 @@ "@babel/plugin-transform-named-capturing-groups-regex@^7.3.0": version "7.3.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.3.0.tgz#140b52985b2d6ef0cb092ef3b29502b990f9cd50" + integrity sha512-NxIoNVhk9ZxS+9lSoAQ/LM0V2UEvARLttEHUrRDGKFaAxOYQcrkN/nLRE+BbbicCAvZPl7wMP0X60HsHE5DtQw== dependencies: regexp-tree "^0.1.0" "@babel/plugin-transform-new-target@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.0.0.tgz#ae8fbd89517fa7892d20e6564e641e8770c3aa4a" + integrity sha512-yin069FYjah+LbqfGeTfzIBODex/e++Yfa0rH0fpfam9uTbuEeEOx5GLGr210ggOV77mVRNoeqSYqeuaqSzVSw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-object-super@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.2.0.tgz#b35d4c10f56bab5d650047dad0f1d8e8814b6598" + integrity sha512-VMyhPYZISFZAqAPVkiYb7dUe2AsVi2/wCT5+wZdsNO31FojQJa9ns40hzZ6U9f50Jlq4w6qwzdBB2uwqZ00ebg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-replace-supers" "^7.1.0" "@babel/plugin-transform-parameters@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.2.0.tgz#0d5ad15dc805e2ea866df4dd6682bfe76d1408c2" + version "7.3.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.3.3.tgz#3a873e07114e1a5bee17d04815662c8317f10e30" + integrity sha512-IrIP25VvXWu/VlBWTpsjGptpomtIkYrN/3aDp4UKm7xK6UxZY88kcJ1UwETbzHAlwN21MnNfwlar0u8y3KpiXw== dependencies: "@babel/helper-call-delegate" "^7.1.0" "@babel/helper-get-function-arity" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" -"@babel/plugin-transform-regenerator@^7.0.0": - version "7.0.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.0.0.tgz#5b41686b4ed40bef874d7ed6a84bdd849c13e0c1" +"@babel/plugin-transform-regenerator@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.3.4.tgz#1601655c362f5b38eead6a52631f5106b29fa46a" + integrity sha512-hvJg8EReQvXT6G9H2MvNPXkv9zK36Vxa1+csAVTpE1J3j0zlHplw76uudEbJxgvqZzAq9Yh45FLD4pk5mKRFQA== dependencies: - regenerator-transform "^0.13.3" + regenerator-transform "^0.13.4" -"@babel/plugin-transform-runtime@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.2.0.tgz#566bc43f7d0aedc880eaddbd29168d0f248966ea" +"@babel/plugin-transform-runtime@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.3.4.tgz#57805ac8c1798d102ecd75c03b024a5b3ea9b431" + integrity sha512-PaoARuztAdd5MgeVjAxnIDAIUet5KpogqaefQvPOmPYCxYoaPhautxDh3aO8a4xHsKgT/b9gSxR0BKK1MIewPA== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -513,18 +572,21 @@ "@babel/plugin-transform-shorthand-properties@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.2.0.tgz#6333aee2f8d6ee7e28615457298934a3b46198f0" + integrity sha512-QP4eUM83ha9zmYtpbnyjTLAGKQritA5XW/iG9cjtuOI8s1RuL/3V6a3DeSHfKutJQ+ayUfeZJPcnCYEQzaPQqg== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-spread@^7.2.0": - version "7.2.0" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.2.0.tgz#0c76c12a3b5826130078ee8ec84a7a8e4afd79c4" + version "7.2.2" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.2.2.tgz#3103a9abe22f742b6d406ecd3cd49b774919b406" + integrity sha512-KWfky/58vubwtS0hLqEnrWJjsMGaOeSBn90Ezn5Jeg9Z8KKHmELbP1yGylMlm5N6TPKeY9A2+UaSYLdxahg01w== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-sticky-regex@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.2.0.tgz#a1e454b5995560a9c1e0d537dfc15061fd2687e1" + integrity sha512-KKYCoGaRAf+ckH8gEL3JHUaFVyNHKe3ASNsZ+AlktgHevvxGigoIttrEJb8iKN03Q7Eazlv1s6cx2B2cQ3Jabw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-regex" "^7.0.0" @@ -532,6 +594,7 @@ "@babel/plugin-transform-template-literals@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.2.0.tgz#d87ed01b8eaac7a92473f608c97c089de2ba1e5b" + integrity sha512-FkPix00J9A/XWXv4VoKJBMeSkyY9x/TqIh76wzcdfl57RJJcf8CehQ08uwfhCDNtRQYtHQKBTwKZDEyjE13Lwg== dependencies: "@babel/helper-annotate-as-pure" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" @@ -539,26 +602,29 @@ "@babel/plugin-transform-typeof-symbol@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.2.0.tgz#117d2bcec2fbf64b4b59d1f9819894682d29f2b2" + integrity sha512-2LNhETWYxiYysBtrBTqL8+La0jIoQQnIScUJc74OYvUGRmkskNY4EzLCnjHBzdmb38wqtTaixpo1NctEcvMDZw== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-unicode-regex@^7.2.0": version "7.2.0" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.2.0.tgz#4eb8db16f972f8abb5062c161b8b115546ade08b" + integrity sha512-m48Y0lMhrbXEJnVUaYly29jRXbQ3ksxPrS1Tg8t+MHqzXhtBYAvI51euOBaoAlZLPHsieY9XPVMf80a5x0cPcA== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/helper-regex" "^7.0.0" regexpu-core "^4.1.3" -"@babel/preset-env@^7.3.1": - version "7.3.1" - resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.3.1.tgz#389e8ca6b17ae67aaf9a2111665030be923515db" +"@babel/preset-env@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.3.4.tgz#887cf38b6d23c82f19b5135298bdb160062e33e1" + integrity sha512-2mwqfYMK8weA0g0uBKOt4FE3iEodiHy9/CW0b+nWXcbL+pGzLx8ESYc+j9IIxr6LTDHWKgPm71i9smo02bw+gA== dependencies: "@babel/helper-module-imports" "^7.0.0" "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-proposal-async-generator-functions" "^7.2.0" "@babel/plugin-proposal-json-strings" "^7.2.0" - "@babel/plugin-proposal-object-rest-spread" "^7.3.1" + "@babel/plugin-proposal-object-rest-spread" "^7.3.4" "@babel/plugin-proposal-optional-catch-binding" "^7.2.0" "@babel/plugin-proposal-unicode-property-regex" "^7.2.0" "@babel/plugin-syntax-async-generators" "^7.2.0" @@ -566,10 +632,10 @@ "@babel/plugin-syntax-object-rest-spread" "^7.2.0" "@babel/plugin-syntax-optional-catch-binding" "^7.2.0" "@babel/plugin-transform-arrow-functions" "^7.2.0" - "@babel/plugin-transform-async-to-generator" "^7.2.0" + "@babel/plugin-transform-async-to-generator" "^7.3.4" "@babel/plugin-transform-block-scoped-functions" "^7.2.0" - "@babel/plugin-transform-block-scoping" "^7.2.0" - "@babel/plugin-transform-classes" "^7.2.0" + "@babel/plugin-transform-block-scoping" "^7.3.4" + "@babel/plugin-transform-classes" "^7.3.4" "@babel/plugin-transform-computed-properties" "^7.2.0" "@babel/plugin-transform-destructuring" "^7.2.0" "@babel/plugin-transform-dotall-regex" "^7.2.0" @@ -580,13 +646,13 @@ "@babel/plugin-transform-literals" "^7.2.0" "@babel/plugin-transform-modules-amd" "^7.2.0" "@babel/plugin-transform-modules-commonjs" "^7.2.0" - "@babel/plugin-transform-modules-systemjs" "^7.2.0" + "@babel/plugin-transform-modules-systemjs" "^7.3.4" "@babel/plugin-transform-modules-umd" "^7.2.0" "@babel/plugin-transform-named-capturing-groups-regex" "^7.3.0" "@babel/plugin-transform-new-target" "^7.0.0" "@babel/plugin-transform-object-super" "^7.2.0" "@babel/plugin-transform-parameters" "^7.2.0" - "@babel/plugin-transform-regenerator" "^7.0.0" + "@babel/plugin-transform-regenerator" "^7.3.4" "@babel/plugin-transform-shorthand-properties" "^7.2.0" "@babel/plugin-transform-spread" "^7.2.0" "@babel/plugin-transform-sticky-regex" "^7.2.0" @@ -601,6 +667,7 @@ "@babel/preset-flow@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.0.0.tgz#afd764835d9535ec63d8c7d4caf1c06457263da2" + integrity sha512-bJOHrYOPqJZCkPVbG1Lot2r5OSsB+iUOaxiHdlOeB1yPWS6evswVHwvkDLZ54WTaTRIk89ds0iHmGZSnxlPejQ== dependencies: "@babel/helper-plugin-utils" "^7.0.0" "@babel/plugin-transform-flow-strip-types" "^7.0.0" @@ -608,6 +675,7 @@ "@babel/register@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.0.0.tgz#fa634bae1bfa429f60615b754fc1f1d745edd827" + integrity sha512-f/+CRmaCe7rVEvcvPvxeA8j5aJhHC3aJie7YuqcMDhUOuyWLA7J/aNrTaHIzoWPEhpHA54mec4Mm8fv8KBlv3g== dependencies: core-js "^2.5.7" find-cache-dir "^1.0.0" @@ -617,48 +685,53 @@ pirates "^4.0.0" source-map-support "^0.5.9" -"@babel/runtime@^7.3.1": - version "7.3.1" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.1.tgz#574b03e8e8a9898eaf4a872a92ea20b7846f6f2a" +"@babel/runtime@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.4.tgz#73d12ba819e365fcf7fd152aed56d6df97d21c83" + integrity sha512-IvfvnMdSaLBateu0jfsYIpZTxAc2cKEXEMiezGGN75QcBcecDUKd3PgLAncT0oOgxKy8dd8hrJKj9MfzgfZd6g== dependencies: regenerator-runtime "^0.12.0" "@babel/template@^7.0.0", "@babel/template@^7.1.0", "@babel/template@^7.1.2", "@babel/template@^7.2.2": version "7.2.2" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.2.2.tgz#005b3fdf0ed96e88041330379e0da9a708eb2907" + integrity sha512-zRL0IMM02AUDwghf5LMSSDEz7sBCO2YnNmpg3uWTZj/v1rcG2BmQUvaGU8GhU8BvfMh1k2KIAYZ7Ji9KXPUg7g== dependencies: "@babel/code-frame" "^7.0.0" "@babel/parser" "^7.2.2" "@babel/types" "^7.2.2" -"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.1.5", "@babel/traverse@^7.2.2", "@babel/traverse@^7.2.3": - version "7.2.3" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.2.3.tgz#7ff50cefa9c7c0bd2d81231fdac122f3957748d8" +"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.1.5", "@babel/traverse@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.3.4.tgz#1330aab72234f8dea091b08c4f8b9d05c7119e06" + integrity sha512-TvTHKp6471OYEcE/91uWmhR6PrrYywQntCHSaZ8CM8Vmp+pjAusal4nGB2WCCQd0rvI7nOMKn9GnbcvTUz3/ZQ== dependencies: "@babel/code-frame" "^7.0.0" - "@babel/generator" "^7.2.2" + "@babel/generator" "^7.3.4" "@babel/helper-function-name" "^7.1.0" "@babel/helper-split-export-declaration" "^7.0.0" - "@babel/parser" "^7.2.3" - "@babel/types" "^7.2.2" + "@babel/parser" "^7.3.4" + "@babel/types" "^7.3.4" debug "^4.1.0" globals "^11.1.0" - lodash "^4.17.10" + lodash "^4.17.11" "@babel/types@7.0.0-beta.35": version "7.0.0-beta.35" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.35.tgz#cf933a9a9a38484ca724b335b88d83726d5ab960" + integrity sha512-y9XT11CozHDgjWcTdxmhSj13rJVXpa5ZXwjjOiTedjaM0ba5ItqdS02t31EhPl7HtOWxsZkYCCUNrSfrOisA6w== dependencies: esutils "^2.0.2" lodash "^4.2.0" to-fast-properties "^2.0.0" -"@babel/types@^7.0.0", "@babel/types@^7.2.0", "@babel/types@^7.2.2", "@babel/types@^7.3.0": - version "7.3.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.3.0.tgz#61dc0b336a93badc02bf5f69c4cd8e1353f2ffc0" +"@babel/types@^7.0.0", "@babel/types@^7.2.0", "@babel/types@^7.2.2", "@babel/types@^7.3.0", "@babel/types@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.3.4.tgz#bf482eaeaffb367a28abbf9357a94963235d90ed" + integrity sha512-WEkp8MsLftM7O/ty580wAmZzN1nDmCACc5+jFzUt+GUFNNIi3LdRlueYz0YIlmJhlZx1QYDMZL5vdWCL0fNjFQ== dependencies: esutils "^2.0.2" - lodash "^4.17.10" + lodash "^4.17.11" to-fast-properties "^2.0.0" "@iamstarkov/listr-update-renderer@0.4.1": @@ -1899,15 +1972,10 @@ browser-process-hrtime@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz#425d68a58d3447f02a04aa894187fce8af8b7b8e" -browser-resolve@^1.11.0, browser-resolve@^1.7.0: - version "1.11.2" - resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.2.tgz#8ff09b0a2c421718a1051c260b32e48f442938ce" - dependencies: - resolve "1.1.7" - -browser-resolve@^1.11.3: +browser-resolve@^1.11.0, browser-resolve@^1.11.3, browser-resolve@^1.7.0: version "1.11.3" resolved "https://registry.yarnpkg.com/browser-resolve/-/browser-resolve-1.11.3.tgz#9b7cbb3d0f510e4cb86bdbd796124d28b5890af6" + integrity sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ== dependencies: resolve "1.1.7" @@ -3978,16 +4046,10 @@ fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" -fsevents@^1.2.2: - version "1.2.4" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.4.tgz#f41dcb1af2582af3692da36fc55cbd8e1041c426" - dependencies: - nan "^2.9.2" - node-pre-gyp "^0.10.0" - -fsevents@^1.2.3: +fsevents@^1.2.2, fsevents@^1.2.3: version "1.2.7" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.7.tgz#4851b664a3783e52003b3c66eb0eee1074933aa4" + integrity sha512-Pxm6sI2MeBD7RdD12RYsqaP0nMiwx8eZBXCa6z2L+mRHm2DYrOYwihmhjpkdjUHwQhslWQjRpEgNq4XvBmaAuw== dependencies: nan "^2.9.2" node-pre-gyp "^0.10.0" @@ -4175,20 +4237,10 @@ glob-watcher@^5.0.0: just-debounce "^1.0.0" object.defaults "^1.1.0" -glob@^7.0.0, glob@^7.0.3, glob@^7.1.0, glob@^7.1.1, glob@^7.1.2: - version "7.1.2" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" - dependencies: - fs.realpath "^1.0.0" - inflight "^1.0.4" - inherits "2" - minimatch "^3.0.4" - once "^1.3.0" - path-is-absolute "^1.0.0" - -glob@^7.1.3: +glob@^7.0.0, glob@^7.0.3, glob@^7.1.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3: version "7.1.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" + integrity sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -4215,13 +4267,10 @@ global-prefix@^1.0.1: is-windows "^1.0.1" which "^1.2.14" -globals@^11.1.0: - version "11.3.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.3.0.tgz#e04fdb7b9796d8adac9c8f64c14837b2313378b0" - -globals@^11.7.0: - version "11.7.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673" +globals@^11.1.0, globals@^11.7.0: + version "11.11.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.11.0.tgz#dcf93757fa2de5486fbeed7118538adf789e9c2e" + integrity sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw== globby@^5.0.0: version "5.0.0" @@ -4262,13 +4311,10 @@ glogg@^1.0.0: dependencies: sparkles "^1.0.0" -graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: - version "4.1.11" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" - -graceful-fs@^4.1.15: +graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.15" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" + integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== growly@^1.3.0: version "1.3.0" @@ -6104,17 +6150,10 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "~3.0.0" -lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1: - version "4.17.5" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" - -lodash@^4.17.10, lodash@^4.17.5: - version "4.17.10" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" - -lodash@^4.17.11: +lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" + integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== log-symbols@^1.0.2: version "1.0.2" @@ -6157,29 +6196,18 @@ lower-case@^1.1.1: version "1.1.4" resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac" -lru-cache@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55" - dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" - -lru-cache@^4.1.2, lru-cache@^4.1.3: +lru-cache@^4.0.1, lru-cache@^4.1.2, lru-cache@^4.1.3: version "4.1.5" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" + integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== dependencies: pseudomap "^1.0.2" yallist "^2.1.2" -make-dir@^1.0.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.2.0.tgz#6d6a49eead4aae296c53bbf3a1a008bd6c89469b" - dependencies: - pify "^3.0.0" - -make-dir@^1.3.0: +make-dir@^1.0.0, make-dir@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" + integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== dependencies: pify "^3.0.0" @@ -6349,27 +6377,10 @@ micromatch@^2.1.5, micromatch@^2.3.11: parse-glob "^3.0.4" regex-cache "^0.4.2" -micromatch@^3.0.4, micromatch@^3.1.4: - version "3.1.9" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.9.tgz#15dc93175ae39e52e93087847096effc73efcf89" - dependencies: - arr-diff "^4.0.0" - array-unique "^0.3.2" - braces "^2.3.1" - define-property "^2.0.2" - extend-shallow "^3.0.2" - extglob "^2.0.4" - fragment-cache "^0.2.1" - kind-of "^6.0.2" - nanomatch "^1.2.9" - object.pick "^1.3.0" - regex-not "^1.0.0" - snapdragon "^0.8.1" - to-regex "^3.0.1" - -micromatch@^3.1.10, micromatch@^3.1.8: +micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.8: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== dependencies: arr-diff "^4.0.0" array-unique "^0.3.2" @@ -6392,25 +6403,17 @@ miller-rabin@^4.0.0: bn.js "^4.0.0" brorand "^1.0.1" -mime-db@~1.33.0: - version "1.33.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" - -mime-db@~1.37.0: - version "1.37.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.37.0.tgz#0b6a0ce6fdbe9576e25f1f2d2fde8830dc0ad0d8" +mime-db@~1.38.0: + version "1.38.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.38.0.tgz#1a2aab16da9eb167b49c6e4df2d9c68d63d8e2ad" + integrity sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg== -mime-types@^2.1.12: - version "2.1.18" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" +mime-types@^2.1.12, mime-types@~2.1.19: + version "2.1.22" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.22.tgz#fe6b355a190926ab7698c9a0556a11199b2199bd" + integrity sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog== dependencies: - mime-db "~1.33.0" - -mime-types@~2.1.19: - version "2.1.21" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.21.tgz#28995aa1ecb770742fe6ae7e58f9181c744b3f96" - dependencies: - mime-db "~1.37.0" + mime-db "~1.38.0" mimic-fn@^1.0.0: version "1.2.0" @@ -7783,9 +7786,10 @@ regenerator-runtime@^0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.0.tgz#8052ac952d85b10f3425192cd0c53f45cf65c6cb" -regenerator-transform@^0.13.3: - version "0.13.3" - resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.13.3.tgz#264bd9ff38a8ce24b06e0636496b2c856b57bcbb" +regenerator-transform@^0.13.4: + version "0.13.4" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.13.4.tgz#18f6763cf1382c69c36df76c6ce122cc694284fb" + integrity sha512-T0QMBjK3J0MtxjPmdIMXm72Wvj2Abb0Bd4HADdfijwMdoIsyQZ6fWC7kDFhk2YinBBEMZDL7Y7wh0J1sGx3S4A== dependencies: private "^0.1.6" @@ -9092,13 +9096,10 @@ util@0.10.3, util@^0.10.3, util@~0.10.1: dependencies: inherits "2.0.1" -uuid@^3.0.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" - -uuid@^3.3.2: +uuid@^3.0.1, uuid@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" + integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== v8flags@^3.0.1: version "3.0.2" @@ -9106,16 +9107,10 @@ v8flags@^3.0.1: dependencies: homedir-polyfill "^1.0.1" -validate-npm-package-license@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz#81643bcbef1bdfecd4623793dc4648948ba98338" - dependencies: - spdx-correct "^3.0.0" - spdx-expression-parse "^3.0.0" - -validate-npm-package-license@^3.0.3: +validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" + integrity sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew== dependencies: spdx-correct "^3.0.0" spdx-expression-parse "^3.0.0" @@ -9371,15 +9366,10 @@ which-module@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" -which@1, which@^1.3.1: +which@1, which@^1.2.10, which@^1.2.12, which@^1.2.14, which@^1.2.9, which@^1.3.0, which@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" - dependencies: - isexe "^2.0.0" - -which@^1.2.10, which@^1.2.12, which@^1.2.14, which@^1.2.9, which@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== dependencies: isexe "^2.0.0" @@ -9423,17 +9413,10 @@ wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" -write-file-atomic@^2.0.0, write-file-atomic@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" - dependencies: - graceful-fs "^4.1.11" - imurmurhash "^0.1.4" - signal-exit "^3.0.2" - -write-file-atomic@^2.4.2: +write-file-atomic@^2.0.0, write-file-atomic@^2.3.0, write-file-atomic@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.2.tgz#a7181706dfba17855d221140a9c06e15fcdd87b9" + integrity sha512-s0b6vB3xIVRLWywa6X9TOMA7k9zio0TMOsl9ZnDkliA/cfJlpHXAscj0gbHVJiTdIuAYpIyqS5GW91fqm6gG5g== dependencies: graceful-fs "^4.1.11" imurmurhash "^0.1.4" From 0345c1bc1ded6af8d66f8605e6fdbeeb9b70c5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 26 Feb 2019 20:09:02 +0100 Subject: [PATCH 14/58] Use `for..of Object.keys` instead of `for..in` (#9518) In https://github.com/babel/babel/issues/9511 (and #9495 is another symptom), @PavelKastornyy reported a node crash becaue the JavaScript heap run out of memory. The problem was that their code was adding enumerable properties to `Object.prototype`: it is something that shouldn't be done, but Babel shouldn't make node crash if someone adds them. I reduced down the problem to `for...in` loops in `@babel/traverse` that grew the memory consumption exponentially because of that unexpected properties. --- .eslintrc.json | 3 ++- packages/babel-helper-define-map/src/index.js | 2 +- .../babel-helper-hoist-variables/src/index.js | 2 +- packages/babel-parser/src/options.js | 2 +- .../test/helpers/runFixtureTests.js | 4 ++-- .../src/index.js | 2 +- .../src/index.js | 20 +++++++++---------- .../src/tdz.js | 2 +- .../src/index.js | 2 +- .../src/index.js | 8 +++++--- packages/babel-traverse/src/path/context.js | 2 +- packages/babel-traverse/src/path/index.js | 2 +- .../babel-traverse/src/path/lib/hoister.js | 6 +++--- .../babel-traverse/src/path/replacement.js | 2 +- packages/babel-traverse/src/scope/index.js | 13 ++++++------ packages/babel-traverse/src/visitors.js | 20 +++++++++---------- packages/babel-types/src/builders/builder.js | 2 +- .../converters/gatherSequenceExpressions.js | 2 +- .../babel-types/src/converters/valueToNode.js | 2 +- packages/babel-types/src/definitions/utils.js | 2 +- .../flow/removeTypeDuplicates.js | 4 ++-- .../babel-types/src/modifications/inherits.js | 2 +- .../src/modifications/removeProperties.js | 2 +- .../src/validators/isNodesEquivalent.js | 7 ++++++- 24 files changed, 60 insertions(+), 55 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8a8366b60be9..a59dc0d9e2dd 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -14,7 +14,8 @@ "rules": { "@babel/development/no-undefined-identifier": "error", "@babel/development/no-deprecated-clone": "error", - "import/no-extraneous-dependencies": "error" + "import/no-extraneous-dependencies": "error", + "guard-for-in": "error" } }, { diff --git a/packages/babel-helper-define-map/src/index.js b/packages/babel-helper-define-map/src/index.js index ff588c1ce380..da81b3a43bd7 100644 --- a/packages/babel-helper-define-map/src/index.js +++ b/packages/babel-helper-define-map/src/index.js @@ -98,7 +98,7 @@ export function push( } export function hasComputed(mutatorMap: Object): boolean { - for (const key in mutatorMap) { + for (const key of Object.keys(mutatorMap)) { if (mutatorMap[key]._computed) { return true; } diff --git a/packages/babel-helper-hoist-variables/src/index.js b/packages/babel-helper-hoist-variables/src/index.js index 4f9c6d938bd7..6b8bb4cf3b03 100644 --- a/packages/babel-helper-hoist-variables/src/index.js +++ b/packages/babel-helper-hoist-variables/src/index.js @@ -28,7 +28,7 @@ const visitor = { ); } - for (const name in declar.getBindingIdentifiers()) { + for (const name of Object.keys(declar.getBindingIdentifiers())) { state.emit(t.identifier(name), name, declar.node.init !== null); } } diff --git a/packages/babel-parser/src/options.js b/packages/babel-parser/src/options.js index 3bab7c04a287..c11dd55cca99 100755 --- a/packages/babel-parser/src/options.js +++ b/packages/babel-parser/src/options.js @@ -61,7 +61,7 @@ export const defaultOptions: Options = { export function getOptions(opts: ?Options): Options { const options: any = {}; - for (const key in defaultOptions) { + for (const key of Object.keys(defaultOptions)) { options[key] = opts && opts[key] != null ? opts[key] : defaultOptions[key]; } return options; diff --git a/packages/babel-parser/test/helpers/runFixtureTests.js b/packages/babel-parser/test/helpers/runFixtureTests.js index be42014fd7d3..a3915587f4e7 100644 --- a/packages/babel-parser/test/helpers/runFixtureTests.js +++ b/packages/babel-parser/test/helpers/runFixtureTests.js @@ -195,12 +195,12 @@ function misMatch(exp, act) { return ppJSON(exp) + " !== " + ppJSON(act); } } else { - for (const prop in exp) { + for (const prop of Object.keys(exp)) { const mis = misMatch(exp[prop], act[prop]); if (mis) return addPath(mis, prop); } - for (const prop in act) { + for (const prop of Object.keys(act)) { if (typeof act[prop] === "function") { continue; } diff --git a/packages/babel-plugin-proposal-object-rest-spread/src/index.js b/packages/babel-plugin-proposal-object-rest-spread/src/index.js index 8506c21db77e..c4738f0c6730 100644 --- a/packages/babel-plugin-proposal-object-rest-spread/src/index.js +++ b/packages/babel-plugin-proposal-object-rest-spread/src/index.js @@ -302,7 +302,7 @@ export default declare((api, opts) => { const specifiers = []; - for (const name in path.getOuterBindingIdentifiers(path)) { + for (const name of Object.keys(path.getOuterBindingIdentifiers(path))) { specifiers.push( t.exportSpecifier(t.identifier(name), t.identifier(name)), ); diff --git a/packages/babel-plugin-transform-block-scoping/src/index.js b/packages/babel-plugin-transform-block-scoping/src/index.js index ef91aa55b959..cc63c554ddcd 100644 --- a/packages/babel-plugin-transform-block-scoping/src/index.js +++ b/packages/babel-plugin-transform-block-scoping/src/index.js @@ -153,8 +153,7 @@ function convertBlockScopedToVar( // Move bindings from current block scope to function scope. if (moveBindingsToParent) { const parentScope = scope.getFunctionParent() || scope.getProgramParent(); - const ids = path.getBindingIdentifiers(); - for (const name in ids) { + for (const name of Object.keys(path.getBindingIdentifiers())) { const binding = scope.getOwnBinding(name); if (binding) binding.kind = "var"; scope.moveBindingTo(name, parentScope); @@ -245,8 +244,7 @@ const loopLabelVisitor = { const continuationVisitor = { enter(path, state) { if (path.isAssignmentExpression() || path.isUpdateExpression()) { - const bindings = path.getBindingIdentifiers(); - for (const name in bindings) { + for (const name of Object.keys(path.getBindingIdentifiers())) { if ( state.outsideReferences[name] !== path.scope.getBindingIdentifier(name) @@ -410,7 +408,7 @@ class BlockScoping { const scope = this.scope; const state = this.state; - for (const name in scope.bindings) { + for (const name of Object.keys(scope.bindings)) { const binding = scope.bindings[name]; if (binding.kind !== "const") continue; @@ -444,7 +442,7 @@ class BlockScoping { const parentScope = scope.getFunctionParent() || scope.getProgramParent(); const letRefs = this.letReferences; - for (const key in letRefs) { + for (const key of Object.keys(letRefs)) { const ref = letRefs[key]; const binding = scope.getBinding(ref.name); if (!binding) continue; @@ -471,7 +469,7 @@ class BlockScoping { // those in upper scopes and then if they do, generate a uid // for them and replace all references with it - for (const key in letRefs) { + for (const key of Object.keys(letRefs)) { // just an Identifier node we collected in `getLetReferences` // this is the defining identifier of a declaration const ref = letRefs[key]; @@ -491,7 +489,7 @@ class BlockScoping { } } - for (const key in outsideLetRefs) { + for (const key of Object.keys(outsideLetRefs)) { const ref = letRefs[key]; // check for collisions with a for loop's init variable and the enclosing scope's bindings // https://github.com/babel/babel/issues/8498 @@ -514,7 +512,7 @@ class BlockScoping { // remap loop heads with colliding variables if (this.loop) { - for (const name in outsideRefs) { + for (const name of Object.keys(outsideRefs)) { const id = outsideRefs[name]; if ( @@ -814,7 +812,7 @@ class BlockScoping { pushDeclar(node: { type: "VariableDeclaration" }): Array { const declars = []; const names = t.getBindingIdentifiers(node); - for (const name in names) { + for (const name of Object.keys(names)) { declars.push(t.variableDeclarator(names[name])); } @@ -852,7 +850,7 @@ class BlockScoping { } if (has.hasBreakContinue) { - for (const key in has.map) { + for (const key of Object.keys(has.map)) { cases.push(t.switchCase(t.stringLiteral(key), [has.map[key]])); } diff --git a/packages/babel-plugin-transform-block-scoping/src/tdz.js b/packages/babel-plugin-transform-block-scoping/src/tdz.js index e1423513489e..9612b8deb210 100644 --- a/packages/babel-plugin-transform-block-scoping/src/tdz.js +++ b/packages/babel-plugin-transform-block-scoping/src/tdz.js @@ -83,7 +83,7 @@ export const visitor = { const nodes = []; const ids = path.getBindingIdentifiers(); - for (const name in ids) { + for (const name of Object.keys(ids)) { const id = ids[name]; if (isReference(id, path.scope, state)) { diff --git a/packages/babel-plugin-transform-destructuring/src/index.js b/packages/babel-plugin-transform-destructuring/src/index.js index 52a76928e19f..de2b9ff4ba16 100644 --- a/packages/babel-plugin-transform-destructuring/src/index.js +++ b/packages/babel-plugin-transform-destructuring/src/index.js @@ -421,7 +421,7 @@ export default declare((api, options) => { const specifiers = []; - for (const name in path.getOuterBindingIdentifiers(path)) { + for (const name of Object.keys(path.getOuterBindingIdentifiers(path))) { specifiers.push( t.exportSpecifier(t.identifier(name), t.identifier(name)), ); diff --git a/packages/babel-plugin-transform-modules-systemjs/src/index.js b/packages/babel-plugin-transform-modules-systemjs/src/index.js index f43fc7a34f53..0159e2257f30 100644 --- a/packages/babel-plugin-transform-modules-systemjs/src/index.js +++ b/packages/babel-plugin-transform-modules-systemjs/src/index.js @@ -113,7 +113,7 @@ export default declare((api, options) => { if (arg.isObjectPattern() || arg.isArrayPattern()) { const exprs = [path.node]; - for (const name in arg.getBindingIdentifiers()) { + for (const name of Object.keys(arg.getBindingIdentifiers())) { if (this.scope.getBinding(name) !== path.scope.getBinding(name)) { return; } @@ -266,7 +266,7 @@ export default declare((api, options) => { } else if (path.isImportDeclaration()) { const source = path.node.source.value; pushModule(source, "imports", path.node.specifiers); - for (const name in path.getBindingIdentifiers()) { + for (const name of Object.keys(path.getBindingIdentifiers())) { path.scope.removeBinding(name); variableIds.push(t.identifier(name)); } @@ -320,7 +320,9 @@ export default declare((api, options) => { addExportName(name, name); path.insertAfter([buildExportCall(name, t.identifier(name))]); } else { - for (const name in declar.getBindingIdentifiers()) { + for (const name of Object.keys( + declar.getBindingIdentifiers(), + )) { addExportName(name, name); } } diff --git a/packages/babel-traverse/src/path/context.js b/packages/babel-traverse/src/path/context.js index a97045e10f16..0057b1694d3f 100644 --- a/packages/babel-traverse/src/path/context.js +++ b/packages/babel-traverse/src/path/context.js @@ -169,7 +169,7 @@ export function _resyncKey() { } } } else { - for (const key in this.container) { + for (const key of Object.keys(this.container)) { if (this.container[key] === this.node) { return this.setKey(key); } diff --git a/packages/babel-traverse/src/path/index.js b/packages/babel-traverse/src/path/index.js index 506a25e95ded..f76ba1ec5ece 100644 --- a/packages/babel-traverse/src/path/index.js +++ b/packages/babel-traverse/src/path/index.js @@ -183,7 +183,7 @@ for (const type of (t.TYPES: Array)) { }; } -for (const type in virtualTypes) { +for (const type of Object.keys(virtualTypes)) { if (type[0] === "_") continue; if (t.TYPES.indexOf(type) < 0) t.TYPES.push(type); diff --git a/packages/babel-traverse/src/path/lib/hoister.js b/packages/babel-traverse/src/path/lib/hoister.js index edd27385105d..2fd8339eaa7d 100644 --- a/packages/babel-traverse/src/path/lib/hoister.js +++ b/packages/babel-traverse/src/path/lib/hoister.js @@ -58,7 +58,7 @@ export default class PathHoister { // A scope is compatible if all required bindings are reachable. isCompatibleScope(scope) { - for (const key in this.bindings) { + for (const key of Object.keys(this.bindings)) { const binding = this.bindings[key]; if (!scope.bindingIdentifierEquals(key, binding.identifier)) { return false; @@ -98,7 +98,7 @@ export default class PathHoister { // avoid hoisting to a scope that contains bindings that are executed after our attachment path if (targetScope.path.isProgram() || targetScope.path.isFunction()) { - for (const name in this.bindings) { + for (const name of Object.keys(this.bindings)) { // check binding is a direct child of this paths scope if (!targetScope.hasOwnBinding(name)) continue; @@ -182,7 +182,7 @@ export default class PathHoister { // Returns true if a scope has param bindings. hasOwnParamBindings(scope) { - for (const name in this.bindings) { + for (const name of Object.keys(this.bindings)) { if (!scope.hasOwnBinding(name)) continue; const binding = this.bindings[name]; diff --git a/packages/babel-traverse/src/path/replacement.js b/packages/babel-traverse/src/path/replacement.js index 07691853345e..0c411cb40163 100644 --- a/packages/babel-traverse/src/path/replacement.js +++ b/packages/babel-traverse/src/path/replacement.js @@ -15,7 +15,7 @@ const hoistVariablesVisitor = { if (path.node.kind !== "var") return; const bindings = path.getBindingIdentifiers(); - for (const key in bindings) { + for (const key of Object.keys(bindings)) { path.scope.push({ id: bindings[key] }); } diff --git a/packages/babel-traverse/src/scope/index.js b/packages/babel-traverse/src/scope/index.js index 88383fa66cf7..2976cff173f6 100644 --- a/packages/babel-traverse/src/scope/index.js +++ b/packages/babel-traverse/src/scope/index.js @@ -97,8 +97,7 @@ const collectorVisitor = { if (binding) binding.reference(path); } else if (t.isVariableDeclaration(declar)) { for (const decl of (declar.declarations: Array)) { - const ids = t.getBindingIdentifiers(decl); - for (const name in ids) { + for (const name of Object.keys(t.getBindingIdentifiers(decl))) { const binding = scope.getBinding(name); if (binding) binding.reference(path); } @@ -388,7 +387,7 @@ export default class Scope { let scope = this; do { console.log("#", scope.block.type); - for (const name in scope.bindings) { + for (const name of Object.keys(scope.bindings)) { const binding = scope.bindings[name]; console.log(" -", name, { constant: binding.constant, @@ -501,7 +500,7 @@ export default class Scope { registerConstantViolation(path: NodePath) { const ids = path.getBindingIdentifiers(); - for (const name in ids) { + for (const name of Object.keys(ids)) { const binding = this.getBinding(name); if (binding) binding.reassign(path); } @@ -521,7 +520,7 @@ export default class Scope { const parent = this.getProgramParent(); const ids = path.getBindingIdentifiers(true); - for (const name in ids) { + for (const name of Object.keys(ids)) { for (const id of (ids[name]: Array)) { const local = this.getOwnBinding(name); @@ -746,7 +745,7 @@ export default class Scope { // register undeclared bindings as globals const ids = path.getBindingIdentifiers(); let programParent; - for (const name in ids) { + for (const name of Object.keys(ids)) { if (path.scope.getBinding(name)) continue; programParent = programParent || path.scope.getProgramParent(); @@ -886,7 +885,7 @@ export default class Scope { for (const kind of (arguments: Array)) { let scope = this; do { - for (const name in scope.bindings) { + for (const name of Object.keys(scope.bindings)) { const binding = scope.bindings[name]; if (binding.kind === kind) ids[name] = binding; } diff --git a/packages/babel-traverse/src/visitors.js b/packages/babel-traverse/src/visitors.js index fd8a8ece29bd..77c1488d5d55 100644 --- a/packages/babel-traverse/src/visitors.js +++ b/packages/babel-traverse/src/visitors.js @@ -23,7 +23,7 @@ export function explode(visitor) { visitor._exploded = true; // normalise pipes - for (const nodeType in visitor) { + for (const nodeType of Object.keys(visitor)) { if (shouldIgnoreKey(nodeType)) continue; const parts: Array = nodeType.split("|"); @@ -59,7 +59,7 @@ export function explode(visitor) { // wrap all the functions const fns = visitor[nodeType]; - for (const type in fns) { + for (const type of Object.keys(fns)) { fns[type] = wrapCheck(wrapper, fns[type]); } @@ -81,7 +81,7 @@ export function explode(visitor) { } // add aliases - for (const nodeType in visitor) { + for (const nodeType of Object.keys(visitor)) { if (shouldIgnoreKey(nodeType)) continue; const fns = visitor[nodeType]; @@ -111,7 +111,7 @@ export function explode(visitor) { } } - for (const nodeType in visitor) { + for (const nodeType of Object.keys(visitor)) { if (shouldIgnoreKey(nodeType)) continue; ensureCallbackArrays(visitor[nodeType]); @@ -130,7 +130,7 @@ export function verify(visitor) { ); } - for (const nodeType in visitor) { + for (const nodeType of Object.keys(visitor)) { if (nodeType === "enter" || nodeType === "exit") { validateVisitorMethods(nodeType, visitor[nodeType]); } @@ -145,7 +145,7 @@ export function verify(visitor) { const visitors = visitor[nodeType]; if (typeof visitors === "object") { - for (const visitorKey in visitors) { + for (const visitorKey of Object.keys(visitors)) { if (visitorKey === "enter" || visitorKey === "exit") { // verify that it just contains functions validateVisitorMethods( @@ -189,7 +189,7 @@ export function merge( explode(visitor); - for (const type in visitor) { + for (const type of Object.keys(visitor)) { let visitorType = visitor[type]; // if we have state or wrapper then overload the callbacks to take it @@ -208,7 +208,7 @@ export function merge( function wrapWithStateOrWrapper(oldVisitor, state, wrapper: ?Function) { const newVisitor = {}; - for (const key in oldVisitor) { + for (const key of Object.keys(oldVisitor)) { let fns = oldVisitor[key]; // not an enter/exit array of callbacks @@ -237,7 +237,7 @@ function wrapWithStateOrWrapper(oldVisitor, state, wrapper: ?Function) { } function ensureEntranceObjects(obj) { - for (const key in obj) { + for (const key of Object.keys(obj)) { if (shouldIgnoreKey(key)) continue; const fns = obj[key]; @@ -278,7 +278,7 @@ function shouldIgnoreKey(key) { } function mergePair(dest, src) { - for (const key in src) { + for (const key of Object.keys(src)) { dest[key] = [].concat(dest[key] || [], src[key]); } } diff --git a/packages/babel-types/src/builders/builder.js b/packages/babel-types/src/builders/builder.js index 7458eb1c92be..e01cf9fd97d6 100644 --- a/packages/babel-types/src/builders/builder.js +++ b/packages/babel-types/src/builders/builder.js @@ -28,7 +28,7 @@ export default function builder(type: string, ...args: Array): Object { i++; }); - for (const key in node) { + for (const key of Object.keys(node)) { validate(node, key, node[key]); } diff --git a/packages/babel-types/src/converters/gatherSequenceExpressions.js b/packages/babel-types/src/converters/gatherSequenceExpressions.js index 4b526767e224..e9808e6ed3ad 100644 --- a/packages/babel-types/src/converters/gatherSequenceExpressions.js +++ b/packages/babel-types/src/converters/gatherSequenceExpressions.js @@ -36,7 +36,7 @@ export default function gatherSequenceExpressions( for (const declar of (node.declarations: Array)) { const bindings = getBindingIdentifiers(declar); - for (const key in bindings) { + for (const key of Object.keys(bindings)) { declars.push({ kind: node.kind, id: cloneNode(bindings[key]), diff --git a/packages/babel-types/src/converters/valueToNode.js b/packages/babel-types/src/converters/valueToNode.js index a4f195765cfd..56bb7ff06be8 100644 --- a/packages/babel-types/src/converters/valueToNode.js +++ b/packages/babel-types/src/converters/valueToNode.js @@ -77,7 +77,7 @@ export default function valueToNode(value: any): Object { // object if (isPlainObject(value)) { const props = []; - for (const key in value) { + for (const key of Object.keys(value)) { let nodeKey; if (isValidIdentifier(key)) { nodeKey = identifier(key); diff --git a/packages/babel-types/src/definitions/utils.js b/packages/babel-types/src/definitions/utils.js index 45cf72b297fa..c1d2ce762daa 100644 --- a/packages/babel-types/src/definitions/utils.js +++ b/packages/babel-types/src/definitions/utils.js @@ -201,7 +201,7 @@ export default function defineType( fields[key] = fields[key] || {}; } - for (const key in fields) { + for (const key of Object.keys(fields)) { const field = fields[key]; if (builder.indexOf(key) === -1) { diff --git a/packages/babel-types/src/modifications/flow/removeTypeDuplicates.js b/packages/babel-types/src/modifications/flow/removeTypeDuplicates.js index d27a8d257140..629c265ff55a 100644 --- a/packages/babel-types/src/modifications/flow/removeTypeDuplicates.js +++ b/packages/babel-types/src/modifications/flow/removeTypeDuplicates.js @@ -73,12 +73,12 @@ export default function removeTypeDuplicates( } // add back in bases - for (const type in bases) { + for (const type of Object.keys(bases)) { types.push(bases[type]); } // add back in generics - for (const name in generics) { + for (const name of Object.keys(generics)) { types.push(generics[name]); } diff --git a/packages/babel-types/src/modifications/inherits.js b/packages/babel-types/src/modifications/inherits.js index dba679c050c6..a8021828593a 100644 --- a/packages/babel-types/src/modifications/inherits.js +++ b/packages/babel-types/src/modifications/inherits.js @@ -16,7 +16,7 @@ export default function inherits(child: T, parent: Object): T { } // force inherit "private" properties - for (const key in parent) { + for (const key of Object.keys(parent)) { if (key[0] === "_" && key !== "__clone") child[key] = parent[key]; } diff --git a/packages/babel-types/src/modifications/removeProperties.js b/packages/babel-types/src/modifications/removeProperties.js index 2f81d9cd7e06..e0f2af6c1a5e 100644 --- a/packages/babel-types/src/modifications/removeProperties.js +++ b/packages/babel-types/src/modifications/removeProperties.js @@ -20,7 +20,7 @@ export default function removeProperties( if (node[key] != null) node[key] = undefined; } - for (const key in node) { + for (const key of Object.keys(node)) { if (key[0] === "_" && node[key] != null) node[key] = undefined; } diff --git a/packages/babel-types/src/validators/isNodesEquivalent.js b/packages/babel-types/src/validators/isNodesEquivalent.js index 68672ff96475..26d61a122f7a 100644 --- a/packages/babel-types/src/validators/isNodesEquivalent.js +++ b/packages/babel-types/src/validators/isNodesEquivalent.js @@ -25,6 +25,11 @@ export default function isNodesEquivalent(a: any, b: any): boolean { if (typeof a[field] !== typeof b[field]) { return false; } + if (a[field] == null && b[field] == null) { + continue; + } else if (a[field] == null || b[field] == null) { + return false; + } if (Array.isArray(a[field])) { if (!Array.isArray(b[field])) { @@ -46,7 +51,7 @@ export default function isNodesEquivalent(a: any, b: any): boolean { typeof a[field] === "object" && (!visitorKeys || !visitorKeys.includes(field)) ) { - for (const key in a[field]) { + for (const key of Object.keys(a[field])) { if (a[field][key] !== b[field][key]) { return false; } From e1ff4c47b94e3e0444867d96be9737eb7aa57ac4 Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Tue, 26 Feb 2019 14:11:49 -0500 Subject: [PATCH 15/58] preset-env: Sort versions before determining lowest (#9595) Likely because of implicit `equals` (ie, Safari 12 support implies iOS Safari 12), the versions in the `res` hash are not always sorted in version order. Doing a semver sort reveals some builtins have actually been supported a little longer than we thought! --- packages/babel-preset-env/data/built-ins.json | 34 ++++----- .../babel-preset-env/scripts/build-data.js | 70 +++++++++++-------- 2 files changed, 59 insertions(+), 45 deletions(-) diff --git a/packages/babel-preset-env/data/built-ins.json b/packages/babel-preset-env/data/built-ins.json index 8e2d2570771f..990d1e0d6031 100644 --- a/packages/babel-preset-env/data/built-ins.json +++ b/packages/babel-preset-env/data/built-ins.json @@ -284,7 +284,7 @@ "edge": "12", "firefox": "2", "safari": "3.1", - "node": "0.12", + "node": "0.10", "ie": "10", "android": "4", "ios": "6", @@ -300,7 +300,7 @@ "node": "0.10", "ie": "9", "android": "4", - "ios": "7", + "ios": "6", "phantom": "2", "electron": "5" }, @@ -320,7 +320,7 @@ "edge": "12", "firefox": "2", "safari": "4", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "6", "phantom": "2", @@ -1091,7 +1091,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1102,7 +1102,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1113,7 +1113,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1124,7 +1124,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1155,7 +1155,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1166,7 +1166,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1177,7 +1177,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1208,7 +1208,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1229,7 +1229,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1280,7 +1280,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1301,7 +1301,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1312,7 +1312,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1323,7 +1323,7 @@ "edge": "12", "firefox": "17", "safari": "6", - "node": "0.12", + "node": "0.10", "android": "4", "ios": "7", "phantom": "2", @@ -1358,7 +1358,7 @@ "edge": "12", "firefox": "15", "safari": "5.1", - "node": "0.12", + "node": "0.10", "ie": "10", "android": "4", "ios": "6", diff --git a/packages/babel-preset-env/scripts/build-data.js b/packages/babel-preset-env/scripts/build-data.js index 7e1b2289f990..cea4a0d5cc61 100644 --- a/packages/babel-preset-env/scripts/build-data.js +++ b/packages/babel-preset-env/scripts/build-data.js @@ -193,27 +193,40 @@ const getLowestImplementedVersion = ({ features }, env) => { // // NOTE: when/if compat-table adds a babel7 key, we'll want to update this if (!test.babel6corejs2 && isBuiltIn) { - return "-1"; + return { + version: "0.0.0", + semver: "0.0.0", + implements: true, + }; } - return ( - Object.keys(test) - .filter(t => t.startsWith(env)) - // Babel assumes strict mode - .filter( - test => tests[i].res[test] === true || tests[i].res[test] === "strict" - ) - // normalize some keys and get version from full string. - .map(test => { - return test.replace("_", ".").replace(env, ""); - }) - // version must be label from the unreleasedLabels (like tp) or number. - .filter( - version => - unreleasedLabelForEnv === version || !isNaN(parseFloat(version)) - ) - .shift() - ); + const reportedVersions = Object.keys(test) + .filter(t => t.startsWith(env)) + .map(t => { + const version = t.replace("_", ".").replace(env, ""); + return { + version, + semver: semver.coerce(version) || version, + // Babel assumes strict mode + implements: tests[i].res[t] === true || tests[i].res[t] === "strict", + }; + }) + // version must be label from the unreleasedLabels (like tp) or number. + .filter( + version => + unreleasedLabelForEnv === version.version || + !isNaN(parseFloat(version.version)) + ) + // Sort in asc order, with unreleasedLabelForEnv coming last. + .sort(({ semver: av }, { semver: bv }) => { + if (av === unreleasedLabelForEnv) return 1; + if (bv === unreleasedLabelForEnv) return -1; + if (semver.gt(av, bv)) return 1; + if (semver.gt(bv, av)) return -1; + return 0; + }); + + return reportedVersions.find(version => version.implements); }); const envFiltered = envTests.filter(t => t); @@ -229,15 +242,16 @@ const getLowestImplementedVersion = ({ features }, env) => { return null; } - return envTests - .map(str => str.replace(env, "")) - .reduce((a, b) => { - if (a === unreleasedLabelForEnv || b === unreleasedLabelForEnv) { - return unreleasedLabelForEnv; - } + return envFiltered.reduce((a, b) => { + if ( + a.semver === unreleasedLabelForEnv || + b.semver === unreleasedLabelForEnv + ) { + return unreleasedLabelForEnv; + } - return semver.lt(semver.coerce(a), semver.coerce(b)) ? b : a; - }); + return semver.lt(a.semver, b.semver) ? b : a; + }); }; const generateData = (environments, features) => { @@ -254,7 +268,7 @@ const generateData = (environments, features) => { const version = getLowestImplementedVersion(options, env); if (version !== null) { - const versionString = version.toString(); + const versionString = version.version; // NOTE(bng): A number of environments in compat-table changed to // include a trailing zero (node10 -> node10_0), so for now stripping From 244e4580e9b89e0c94549a3149f9b5b75a244d6f Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Tue, 26 Feb 2019 11:15:34 -0800 Subject: [PATCH 16/58] Remove always false param allowExpressionBody (#9591) --- packages/babel-parser/src/parser/expression.js | 5 ++--- packages/babel-parser/src/parser/statement.js | 4 ---- packages/babel-parser/src/plugins/flow.js | 6 ++---- packages/babel-parser/src/plugins/typescript.js | 6 ++---- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index f2bcfb19d3ad..df72050b7f4d 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -881,7 +881,7 @@ export default class ExpressionParser extends LValParser { !this.canInsertSemicolon() ) { this.next(); - return this.parseFunction(node, undefined, false, true); + return this.parseFunction(node, undefined, true); } else if ( canBeArrow && id.name === "async" && @@ -1804,10 +1804,9 @@ export default class ExpressionParser extends LValParser { parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, - allowExpressionBody?: boolean, ): void { // $FlowIgnore (node is not bodiless if we get here) - this.parseFunctionBody(node, allowExpressionBody); + this.parseFunctionBody(node); this.finishNode(node, type); } diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 0f55802ea0e2..2d98842c8b25 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -548,7 +548,6 @@ export default class StatementParser extends ExpressionParser { return this.parseFunction( node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), - false, isAsync, ); } @@ -1013,7 +1012,6 @@ export default class StatementParser extends ExpressionParser { parseFunction( node: T, statement?: number = FUNC_NO_FLAGS, - allowExpressionBody?: boolean = false, isAsync?: boolean = false, ): T { const isStatement = statement & FUNC_STATEMENT; @@ -1074,7 +1072,6 @@ export default class StatementParser extends ExpressionParser { this.parseFunctionBodyAndFinish( node, isStatement ? "FunctionDeclaration" : "FunctionExpression", - allowExpressionBody, ); }); @@ -1753,7 +1750,6 @@ export default class StatementParser extends ExpressionParser { return this.parseFunction( expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, - false, isAsync, ); } else if (this.match(tt._class)) { diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index af151c317dfe..f76f043c4b1a 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -1557,10 +1557,8 @@ export default (superClass: Class): Class => parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, - allowExpressionBody?: boolean, ): void { - // For arrow functions, `parseArrow` handles the return type itself. - if (!allowExpressionBody && this.match(tt.colon)) { + if (this.match(tt.colon)) { const typeNode = this.startNode(); [ @@ -1575,7 +1573,7 @@ export default (superClass: Class): Class => : null; } - super.parseFunctionBodyAndFinish(node, type, allowExpressionBody); + super.parseFunctionBodyAndFinish(node, type); } // interfaces diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 7418fd7221ea..343975243a11 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -1481,10 +1481,8 @@ export default (superClass: Class): Class => parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, - allowExpressionBody?: boolean, ): void { - // For arrow functions, `parseArrow` handles the return type itself. - if (!allowExpressionBody && this.match(tt.colon)) { + if (this.match(tt.colon)) { node.returnType = this.tsParseTypeOrTypePredicateAnnotation(tt.colon); } @@ -1499,7 +1497,7 @@ export default (superClass: Class): Class => return; } - super.parseFunctionBodyAndFinish(node, type, allowExpressionBody); + super.parseFunctionBodyAndFinish(node, type); } parseSubscript( From a029071b8faf8bceccb4fc2a2a805870f7672015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 26 Feb 2019 20:35:18 +0100 Subject: [PATCH 17/58] [TS] Correctly forget `await`s after parsing async arrows with type args (#9593) --- .../babel-parser/src/plugins/typescript.js | 21 +- .../async-await-null/output.json | 1 - .../arrow-function/async-generic/output.json | 1 - .../async-arrow-generic-9560/input.js | 8 + .../async-arrow-generic-9560/options.json | 3 + .../async-arrow-generic-9560/output.json | 342 ++++++++++++++++++ 6 files changed, 359 insertions(+), 17 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/output.json diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 343975243a11..4973d1f6be4f 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -6,13 +6,7 @@ import { types as ct } from "../tokenizer/context"; import * as N from "../types"; import type { Pos, Position } from "../util/location"; import Parser from "../parser"; -import { - type BindingTypes, - functionFlags, - BIND_NONE, - SCOPE_ARROW, - SCOPE_OTHER, -} from "../util/scopeflags"; +import { type BindingTypes, BIND_NONE, SCOPE_OTHER } from "../util/scopeflags"; type TsModifier = | "readonly" @@ -1381,14 +1375,11 @@ export default (superClass: Class): Class => return undefined; } - this.scope.enter(functionFlags(true, false) | SCOPE_ARROW); - - res.id = null; - res.generator = false; - res.expression = true; // May be set again by parseFunctionBody. - res.async = true; - this.parseFunctionBody(res, true); - return this.finishNode(res, "ArrowFunctionExpression"); + return this.parseArrowExpression( + res, + /* params are already set */ null, + /* async */ true, + ); } tsParseTypeArguments(): N.TsTypeParameterInstantiation { diff --git a/packages/babel-parser/test/fixtures/typescript/arrow-function/async-await-null/output.json b/packages/babel-parser/test/fixtures/typescript/arrow-function/async-await-null/output.json index b8ff07769c78..8af1eae03c46 100644 --- a/packages/babel-parser/test/fixtures/typescript/arrow-function/async-await-null/output.json +++ b/packages/babel-parser/test/fixtures/typescript/arrow-function/async-await-null/output.json @@ -93,7 +93,6 @@ "params": [], "id": null, "generator": false, - "expression": true, "async": true, "body": { "type": "AwaitExpression", diff --git a/packages/babel-parser/test/fixtures/typescript/arrow-function/async-generic/output.json b/packages/babel-parser/test/fixtures/typescript/arrow-function/async-generic/output.json index cad181eb8702..89af25ded2c0 100644 --- a/packages/babel-parser/test/fixtures/typescript/arrow-function/async-generic/output.json +++ b/packages/babel-parser/test/fixtures/typescript/arrow-function/async-generic/output.json @@ -205,7 +205,6 @@ }, "id": null, "generator": false, - "expression": true, "async": true, "body": { "type": "Identifier", diff --git a/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/input.js b/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/input.js new file mode 100644 index 000000000000..2f1c5ce9190a --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/input.js @@ -0,0 +1,8 @@ +class Cl { + a = async() => { + await 0; + }; + + b = async() => { + }; +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/options.json b/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/options.json new file mode 100644 index 000000000000..fb92dc3bde16 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["typescript", "classProperties"] +} diff --git a/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/output.json b/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/output.json new file mode 100644 index 000000000000..8cbb94861b92 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/regression/async-arrow-generic-9560/output.json @@ -0,0 +1,342 @@ +{ + "type": "File", + "start": 0, + "end": 80, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 80, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 80, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "Cl" + }, + "name": "Cl" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 9, + "end": 80, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 8, + "column": 1 + } + }, + "body": [ + { + "type": "ClassProperty", + "start": 13, + "end": 50, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "a" + }, + "name": "a" + }, + "computed": false, + "value": { + "type": "ArrowFunctionExpression", + "start": 17, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start": 22, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "name": "T" + } + ] + }, + "params": [], + "id": null, + "generator": false, + "async": true, + "body": { + "type": "BlockStatement", + "start": 31, + "end": 49, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 4, + "column": 3 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 37, + "end": 45, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "expression": { + "type": "AwaitExpression", + "start": 37, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "argument": { + "type": "NumericLiteral", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } + } + }, + { + "type": "ClassProperty", + "start": 54, + "end": 78, + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 54, + "end": 55, + "loc": { + "start": { + "line": 6, + "column": 2 + }, + "end": { + "line": 6, + "column": 3 + }, + "identifierName": "b" + }, + "name": "b" + }, + "computed": false, + "value": { + "type": "ArrowFunctionExpression", + "start": 58, + "end": 77, + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "typeParameters": { + "type": "TSTypeParameterDeclaration", + "start": 63, + "end": 66, + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "params": [ + { + "type": "TSTypeParameter", + "start": 64, + "end": 65, + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "name": "T" + } + ] + }, + "params": [], + "id": null, + "generator": false, + "async": true, + "body": { + "type": "BlockStatement", + "start": 72, + "end": 77, + "loc": { + "start": { + "line": 6, + "column": 20 + }, + "end": { + "line": 7, + "column": 3 + } + }, + "body": [], + "directives": [] + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file From 039a74a8b97407c48b7f5a76515b66d85d887e9a Mon Sep 17 00:00:00 2001 From: Justin Ridgewell Date: Tue, 26 Feb 2019 15:18:52 -0500 Subject: [PATCH 18/58] preset-env: minimally supporting version (#9596) * preset-env: minimally supporting version This changes the "does browser support X" algorithm to "lowest version such that all higher versions support it". Eg, given `{ chrome70: true, chrome60: false, chrome50: true }`, the lowest version is chrome70, not chrome50. This is done to remove Tagged Template Literal support from Safari, which introduced a bug in Safari 12 but correctly implemented the feature in Safari 11-9. * Add tests * Fix tests * Fix comment --- packages/babel-preset-env/data/built-ins.json | 8 +++---- packages/babel-preset-env/data/plugins.json | 2 -- packages/babel-preset-env/package.json | 2 +- .../babel-preset-env/scripts/build-data.js | 24 +++++++++++++------ .../specific-targets/stdout.txt | 4 ++-- .../safari-tagged-template-literals/input.js | 1 + .../options.json | 13 ++++++++++ .../safari-tagged-template-literals/output.js | 13 ++++++++++ 8 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/input.js create mode 100644 packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/options.json create mode 100644 packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/output.js diff --git a/packages/babel-preset-env/data/built-ins.json b/packages/babel-preset-env/data/built-ins.json index 990d1e0d6031..d584df33679c 100644 --- a/packages/babel-preset-env/data/built-ins.json +++ b/packages/babel-preset-env/data/built-ins.json @@ -214,10 +214,10 @@ "opera": "50", "edge": "12", "firefox": "5", - "safari": "10.1", + "safari": "12", "node": "10", "ie": "9", - "ios": "10.3", + "ios": "12", "electron": "3.1" }, "es6.array.species": { @@ -317,7 +317,7 @@ "es6.function.name": { "chrome": "5", "opera": "10.50", - "edge": "12", + "edge": "14", "firefox": "2", "safari": "4", "node": "0.10", @@ -729,7 +729,7 @@ "es6.object.get-prototype-of": { "chrome": "44", "edge": "12", - "firefox": "3.5", + "firefox": "35", "safari": "9", "node": "4", "ios": "9", diff --git a/packages/babel-preset-env/data/plugins.json b/packages/babel-preset-env/data/plugins.json index cb6301765dc6..a869f0bd2111 100644 --- a/packages/babel-preset-env/data/plugins.json +++ b/packages/babel-preset-env/data/plugins.json @@ -3,9 +3,7 @@ "chrome": "41", "edge": "13", "firefox": "34", - "safari": "9", "node": "4", - "ios": "9", "opera": "28", "electron": "0.24" }, diff --git a/packages/babel-preset-env/package.json b/packages/babel-preset-env/package.json index f4b60f0553be..d32592e328da 100644 --- a/packages/babel-preset-env/package.json +++ b/packages/babel-preset-env/package.json @@ -67,7 +67,7 @@ "@babel/helper-fixtures": "^7.2.0", "@babel/helper-plugin-test-runner": "^7.0.0", "caniuse-db": "1.0.30000938", - "compat-table": "kangax/compat-table#1e7b377fbdda9243cf9602872fcb493cdbdd565f", + "compat-table": "kangax/compat-table#6d012ba020fa7415e8a2d29e87924bab79b128a3", "electron-to-chromium": "1.3.113" } } diff --git a/packages/babel-preset-env/scripts/build-data.js b/packages/babel-preset-env/scripts/build-data.js index cea4a0d5cc61..28e80b1031f1 100644 --- a/packages/babel-preset-env/scripts/build-data.js +++ b/packages/babel-preset-env/scripts/build-data.js @@ -203,7 +203,7 @@ const getLowestImplementedVersion = ({ features }, env) => { const reportedVersions = Object.keys(test) .filter(t => t.startsWith(env)) .map(t => { - const version = t.replace("_", ".").replace(env, ""); + const version = t.replace(/_/g, ".").replace(env, ""); return { version, semver: semver.coerce(version) || version, @@ -217,16 +217,26 @@ const getLowestImplementedVersion = ({ features }, env) => { unreleasedLabelForEnv === version.version || !isNaN(parseFloat(version.version)) ) - // Sort in asc order, with unreleasedLabelForEnv coming last. + // Sort in desc order, with unreleasedLabelForEnv coming last. .sort(({ semver: av }, { semver: bv }) => { - if (av === unreleasedLabelForEnv) return 1; - if (bv === unreleasedLabelForEnv) return -1; - if (semver.gt(av, bv)) return 1; - if (semver.gt(bv, av)) return -1; + if (av === unreleasedLabelForEnv) return -1; + if (bv === unreleasedLabelForEnv) return 1; + if (semver.gt(av, bv)) return -1; + if (semver.gt(bv, av)) return 1; return 0; }); - return reportedVersions.find(version => version.implements); + // Find the lowest version such that all higher versions implement it. + // Eg, given { chrome70: true, chrome60: false, chrome50: true }, the + // lowest version is chrome70, not chrome50. + let lowest = null; + for (const version of reportedVersions) { + if (!version.implements) { + break; + } + lowest = version; + } + return lowest; }); const envFiltered = envTests.filter(t => t); diff --git a/packages/babel-preset-env/test/debug-fixtures/specific-targets/stdout.txt b/packages/babel-preset-env/test/debug-fixtures/specific-targets/stdout.txt index e27e601607e9..c1caa5390a37 100644 --- a/packages/babel-preset-env/test/debug-fixtures/specific-targets/stdout.txt +++ b/packages/babel-preset-env/test/debug-fixtures/specific-targets/stdout.txt @@ -13,7 +13,7 @@ Using targets: Using modules transform: auto Using plugins: - transform-template-literals { "ie":"10", "safari":"7" } + transform-template-literals { "ie":"10", "ios":"9", "safari":"7" } transform-literals { "firefox":"49", "ie":"10", "safari":"7" } transform-function-name { "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } transform-arrow-functions { "ie":"10", "ios":"9", "safari":"7" } @@ -59,7 +59,7 @@ Using polyfills with `entry` option: es6.date.to-json { "ios":"9", "safari":"7" } es6.date.to-primitive { "edge":"13", "ie":"10", "ios":"9", "safari":"7" } es6.function.has-instance { "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } - es6.function.name { "ie":"10" } + es6.function.name { "edge":"13", "ie":"10" } es6.map { "edge":"13", "firefox":"49", "ie":"10", "ios":"9", "safari":"7" } es6.math.acosh { "ie":"10", "safari":"7" } es6.math.asinh { "ie":"10", "safari":"7" } diff --git a/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/input.js b/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/input.js new file mode 100644 index 000000000000..4d45d4de3a41 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/input.js @@ -0,0 +1 @@ +tag`Safari 12 borked`; diff --git a/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/options.json b/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/options.json new file mode 100644 index 000000000000..97a5889f7656 --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/options.json @@ -0,0 +1,13 @@ +{ + "presets": [ + [ + "../../../../lib", + { + "targets": { + "browsers": "safari 9" + }, + "shippedProposals": true + } + ] + ] +} diff --git a/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/output.js b/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/output.js new file mode 100644 index 000000000000..bbeb47d3ed6e --- /dev/null +++ b/packages/babel-preset-env/test/fixtures/preset-options/safari-tagged-template-literals/output.js @@ -0,0 +1,13 @@ +function _templateObject() { + var data = _taggedTemplateLiteral(["Safari 12 borked"]); + + _templateObject = function _templateObject() { + return data; + }; + + return data; +} + +function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); } + +tag(_templateObject()); From c1e51e08d31bb47c8b6b04fb223310d36b093706 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Tue, 26 Feb 2019 12:29:10 -0800 Subject: [PATCH 19/58] Update charcodes --- packages/babel-parser/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-parser/package.json b/packages/babel-parser/package.json index cf31022a2ccc..bdd0b80da331 100644 --- a/packages/babel-parser/package.json +++ b/packages/babel-parser/package.json @@ -30,7 +30,7 @@ "devDependencies": { "@babel/code-frame": "^7.0.0", "@babel/helper-fixtures": "^7.2.0", - "charcodes": "0.1.0", + "charcodes": "^0.2.0", "unicode-11.0.0": "^0.7.8" }, "bin": { From 43eed1ac922400cb486bfe6af74883c48ac1d3ed Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Tue, 26 Feb 2019 13:28:10 -0800 Subject: [PATCH 20/58] Check exported bindings are defined (#9589) * Check exported bindings are defined * Add tests * Update flow whitelist * Add tests for builtins --- .../fixtures/edgecase/unary-op/options.json | 3 + .../fixtures/flow/declare-exports/input.js | 1 + .../fixtures/flow/declare-exports/output.js | 1 + .../fixtures/flow/type-annotations/input.js | 2 +- .../fixtures/flow/type-annotations/output.js | 4 +- .../harmony-edgecase/exports/input.js | 1 + .../harmony-edgecase/exports/output.js | 1 + .../fixtures/types/ExportSpecifier11/input.js | 1 + .../types/ExportSpecifier11/output.js | 3 +- .../fixtures/types/ExportSpecifier12/input.js | 1 + .../types/ExportSpecifier12/output.js | 3 +- .../fixtures/types/ExportSpecifier13/input.js | 1 + .../types/ExportSpecifier13/output.js | 3 +- .../fixtures/types/ExportSpecifier14/input.js | 1 + .../types/ExportSpecifier14/output.js | 3 +- .../fixtures/types/ExportSpecifier15/input.js | 1 + .../types/ExportSpecifier15/output.js | 3 +- .../types/UnaryExpression/options.json | 3 + .../fixtures/types/WithStatement/options.json | 3 + packages/babel-generator/test/index.js | 2 +- packages/babel-parser/src/parser/statement.js | 18 +- packages/babel-parser/src/types.js | 1 + packages/babel-parser/src/util/scope.js | 19 ++ .../scope/undecl-export-as-default/input.js | 1 + .../undecl-export-as-default/options.json | 4 + .../core/scope/undecl-export-as/input.js | 2 + .../core/scope/undecl-export-as/options.json | 4 + .../core/scope/undecl-export-block/input.js | 4 + .../scope/undecl-export-block/options.json | 4 + .../scope/undecl-export-builtin-as/input.js | 1 + .../undecl-export-builtin-as/options.json | 4 + .../core/scope/undecl-export-builtin/input.js | 1 + .../scope/undecl-export-builtin/options.json | 4 + .../core/scope/undecl-export-if/input.js | 2 + .../core/scope/undecl-export-if/options.json | 4 + .../core/scope/undecl-export-var/input.js | 4 + .../core/scope/undecl-export-var/options.json | 3 + .../core/scope/undecl-export-var/output.json | 172 ++++++++++++++++++ .../core/scope/undecl-export/input.js | 1 + .../core/scope/undecl-export/options.json | 4 + .../duplicate-named-export-builtin/input.js | 2 + .../output.json | 110 +++++++++-- .../fixtures/es2015/uncategorised/86/input.js | 3 +- .../es2015/uncategorised/86/output.json | 68 ++++++- .../fixtures/es2015/uncategorised/87/input.js | 4 +- .../es2015/uncategorised/87/output.json | 165 +++++++++++++---- .../fixtures/es2015/uncategorised/88/input.js | 3 +- .../es2015/uncategorised/88/output.json | 109 +++++++++-- .../fixtures/es2015/uncategorised/89/input.js | 4 +- .../es2015/uncategorised/89/output.json | 165 +++++++++++++---- .../export-named-as-default/input.js | 1 + .../export-named-as-default/output.json | 67 ++++++- .../export-named-as-specifier/input.js | 1 + .../export-named-as-specifier/output.json | 124 +++++++++++-- .../export-named-as-specifiers/input.js | 1 + .../export-named-as-specifiers/output.json | 100 +++++++++- .../export-named-specifier/input.js | 1 + .../export-named-specifier/output.json | 91 +++++++-- .../export-named-specifiers-comma/input.js | 2 + .../export-named-specifiers-comma/output.json | 170 +++++++++++++---- .../export-named-specifiers/input.js | 2 + .../export-named-specifiers/output.json | 170 +++++++++++++---- .../export-named-pattern/input.js | 1 + .../export-named-pattern/output.json | 65 ++++++- .../flow/type-exports/specifier/input.js | 1 + .../flow/type-exports/specifier/output.json | 87 +++++++-- .../strip-type-annotations/input.mjs | 2 +- .../systemjs/export-named-2/input.mjs | 1 + .../systemjs/export-named-2/output.mjs | 13 +- .../systemjs/export-named-3/input.mjs | 1 + .../systemjs/export-named-3/output.mjs | 8 +- .../systemjs/export-named-4/input.mjs | 1 + .../systemjs/export-named-4/output.mjs | 8 +- .../systemjs/export-named-5/input.mjs | 1 + .../systemjs/export-named-5/output.mjs | 13 +- .../fixtures/systemjs/export-named/input.mjs | 1 + .../fixtures/systemjs/export-named/output.mjs | 8 +- .../test/fixtures/systemjs/overview/input.mjs | 4 +- .../fixtures/systemjs/overview/output.mjs | 4 +- scripts/tests/flow/flow_tests_whitelist.txt | 3 + scripts/tests/test262/test262_whitelist.txt | 4 - 81 files changed, 1583 insertions(+), 304 deletions(-) create mode 100644 packages/babel-generator/test/fixtures/edgecase/unary-op/options.json create mode 100644 packages/babel-generator/test/fixtures/types/UnaryExpression/options.json create mode 100644 packages/babel-generator/test/fixtures/types/WithStatement/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-as/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-as/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-block/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-block/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-if/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-if/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-var/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-var/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export-var/output.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/undecl-export/options.json diff --git a/packages/babel-generator/test/fixtures/edgecase/unary-op/options.json b/packages/babel-generator/test/fixtures/edgecase/unary-op/options.json new file mode 100644 index 000000000000..a2e80d9ec294 --- /dev/null +++ b/packages/babel-generator/test/fixtures/edgecase/unary-op/options.json @@ -0,0 +1,3 @@ +{ + "strictMode": false +} diff --git a/packages/babel-generator/test/fixtures/flow/declare-exports/input.js b/packages/babel-generator/test/fixtures/flow/declare-exports/input.js index 279e6ab4f9f9..97544d82b930 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-exports/input.js +++ b/packages/babel-generator/test/fixtures/flow/declare-exports/input.js @@ -17,6 +17,7 @@ declare export * from 'asd'; declare export { a, b }; declare export {}; declare export { c, d } from 'bar'; +var a, b; declare module B { declare export type B = {}; diff --git a/packages/babel-generator/test/fixtures/flow/declare-exports/output.js b/packages/babel-generator/test/fixtures/flow/declare-exports/output.js index 877c43099415..59f3a4c56856 100644 --- a/packages/babel-generator/test/fixtures/flow/declare-exports/output.js +++ b/packages/babel-generator/test/fixtures/flow/declare-exports/output.js @@ -26,6 +26,7 @@ declare export * from 'asd'; declare export { a, b }; declare export {}; declare export { c, d } from 'bar'; +var a, b; declare module B { declare export type B = {}; declare export interface Moon {} diff --git a/packages/babel-generator/test/fixtures/flow/type-annotations/input.js b/packages/babel-generator/test/fixtures/flow/type-annotations/input.js index 76be1b446fac..e7335c30b72a 100644 --- a/packages/babel-generator/test/fixtures/flow/type-annotations/input.js +++ b/packages/babel-generator/test/fixtures/flow/type-annotations/input.js @@ -107,7 +107,7 @@ import { type Foo12 } from "bar"; import { typeof Foo13 } from "bar"; import { type Foo as Bar1 } from "bar"; import { typeof Foo as Bar2 } from "bar"; -export type { foo }; +export type { foo1 }; export type { bar } from "bar"; export interface baz { p: number } export interface qux { p: T } diff --git a/packages/babel-generator/test/fixtures/flow/type-annotations/output.js b/packages/babel-generator/test/fixtures/flow/type-annotations/output.js index cd69710614a1..6465359f336d 100644 --- a/packages/babel-generator/test/fixtures/flow/type-annotations/output.js +++ b/packages/babel-generator/test/fixtures/flow/type-annotations/output.js @@ -231,7 +231,7 @@ import { type Foo12 } from "bar"; import { typeof Foo13 } from "bar"; import { type Foo as Bar1 } from "bar"; import { typeof Foo as Bar2 } from "bar"; -export type { foo }; +export type { foo1 }; export type { bar } from "bar"; export interface baz { p: number @@ -293,4 +293,4 @@ function foo27(numVal: number = 2) {} function foo28(numVal?: number = 2) {} -export type * from "foo"; +export type * from "foo"; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/harmony-edgecase/exports/input.js b/packages/babel-generator/test/fixtures/harmony-edgecase/exports/input.js index ec680f05ac1d..540245d565b3 100644 --- a/packages/babel-generator/test/fixtures/harmony-edgecase/exports/input.js +++ b/packages/babel-generator/test/fixtures/harmony-edgecase/exports/input.js @@ -1,3 +1,4 @@ +var a, c; export * from "OK" export { name } from "OK" export { a as b, c as d } from "hello" diff --git a/packages/babel-generator/test/fixtures/harmony-edgecase/exports/output.js b/packages/babel-generator/test/fixtures/harmony-edgecase/exports/output.js index 5482292b19a7..84c968fe12a3 100644 --- a/packages/babel-generator/test/fixtures/harmony-edgecase/exports/output.js +++ b/packages/babel-generator/test/fixtures/harmony-edgecase/exports/output.js @@ -1,3 +1,4 @@ +var a, c; export * from "OK"; export { name } from "OK"; export { a as b, c as d } from "hello"; diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier11/input.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier11/input.js index f40ac5c3434e..701c971b8991 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier11/input.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier11/input.js @@ -1 +1,2 @@ export { foo }; +var foo; diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier11/output.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier11/output.js index f604032cb6d6..520c0fb1dda1 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier11/output.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier11/output.js @@ -1 +1,2 @@ -export { foo }; \ No newline at end of file +export { foo }; +var foo; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier12/input.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier12/input.js index 9dfa348be312..5e6c6606032a 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier12/input.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier12/input.js @@ -1 +1,2 @@ export { foo, bar }; +var foo, bar; diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier12/output.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier12/output.js index 4cb44a4b2592..be6d973b815d 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier12/output.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier12/output.js @@ -1 +1,2 @@ -export { foo, bar }; \ No newline at end of file +export { foo, bar }; +var foo, bar; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier13/input.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier13/input.js index e4cca384daec..dd1cfea6d77d 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier13/input.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier13/input.js @@ -1 +1,2 @@ export { foo as bar }; +var foo; diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier13/output.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier13/output.js index 5d4569c099d2..d6e7ac50254e 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier13/output.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier13/output.js @@ -1 +1,2 @@ -export { foo as bar }; \ No newline at end of file +export { foo as bar }; +var foo; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier14/input.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier14/input.js index 95daad9d9676..5e840fff920b 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier14/input.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier14/input.js @@ -1 +1,2 @@ export { foo as default }; +var foo; diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier14/output.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier14/output.js index f96da82b3b2c..4a3a9fe44ea7 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier14/output.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier14/output.js @@ -1 +1,2 @@ -export { foo as default }; \ No newline at end of file +export { foo as default }; +var foo; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier15/input.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier15/input.js index ebd14b2d969e..022457fd87a6 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier15/input.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier15/input.js @@ -1 +1,2 @@ export { foo as default, bar }; +var foo, bar; diff --git a/packages/babel-generator/test/fixtures/types/ExportSpecifier15/output.js b/packages/babel-generator/test/fixtures/types/ExportSpecifier15/output.js index 2ef73817d596..974c22ae14f2 100644 --- a/packages/babel-generator/test/fixtures/types/ExportSpecifier15/output.js +++ b/packages/babel-generator/test/fixtures/types/ExportSpecifier15/output.js @@ -1 +1,2 @@ -export { foo as default, bar }; \ No newline at end of file +export { foo as default, bar }; +var foo, bar; \ No newline at end of file diff --git a/packages/babel-generator/test/fixtures/types/UnaryExpression/options.json b/packages/babel-generator/test/fixtures/types/UnaryExpression/options.json new file mode 100644 index 000000000000..a2e80d9ec294 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/UnaryExpression/options.json @@ -0,0 +1,3 @@ +{ + "strictMode": false +} diff --git a/packages/babel-generator/test/fixtures/types/WithStatement/options.json b/packages/babel-generator/test/fixtures/types/WithStatement/options.json new file mode 100644 index 000000000000..a2e80d9ec294 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/WithStatement/options.json @@ -0,0 +1,3 @@ +{ + "strictMode": false +} diff --git a/packages/babel-generator/test/index.js b/packages/babel-generator/test/index.js index c8b60b4051db..057452885063 100644 --- a/packages/babel-generator/test/index.js +++ b/packages/babel-generator/test/index.js @@ -489,7 +489,7 @@ suites.forEach(function(testSuite) { const actualAst = parse(actualCode, { filename: actual.loc, plugins: task.options.plugins || [], - strictMode: false, + strictMode: task.options.strictMode === false ? false : true, sourceType: "module", sourceMaps: !!task.sourceMap, }); diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 2d98842c8b25..d2981c24006a 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -49,6 +49,14 @@ export default class StatementParser extends ExpressionParser { this.parseBlockBody(program, true, true, tt.eof); + if (this.inModule && this.scope.undefinedExports.size > 0) { + for (const [name] of Array.from(this.scope.undefinedExports)) { + const pos = this.scope.undefinedExports.get(name); + // $FlowIssue + this.raise(pos, `Export '${name}' is not defined`); + } + } + file.program = this.finishNode(program, "Program"); file.comments = this.state.comments; @@ -1631,7 +1639,7 @@ export default class StatementParser extends ExpressionParser { } if (isFromRequired || hasSpecifiers || hasDeclaration) { - this.checkExport(node, true); + this.checkExport(node, true, false, !!node.source); return this.finishNode(node, "ExportNamedDeclaration"); } @@ -1845,8 +1853,9 @@ export default class StatementParser extends ExpressionParser { checkExport( node: N.ExportNamedDeclaration, - checkNames: ?boolean, + checkNames?: boolean, isDefault?: boolean, + isFrom?: boolean, ): void { if (checkNames) { // Check for duplicate exports @@ -1857,6 +1866,11 @@ export default class StatementParser extends ExpressionParser { // Named exports for (const specifier of node.specifiers) { this.checkDuplicateExports(specifier, specifier.exported.name); + // check if export is defined + // $FlowIgnore + if (!isFrom && specifier.local) { + this.scope.checkLocalExport(specifier.local); + } } } else if (node.declaration) { // Exported declarations diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 06e5a03a71d8..696589b3e650 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -831,6 +831,7 @@ export type ExportNamedDeclaration = NodeBase & { export type ExportSpecifier = NodeBase & { type: "ExportSpecifier", exported: Identifier, + local: Identifier, }; export type ExportDefaultSpecifier = NodeBase & { diff --git a/packages/babel-parser/src/util/scope.js b/packages/babel-parser/src/util/scope.js index 496814cd96b0..8d9e08b1a816 100644 --- a/packages/babel-parser/src/util/scope.js +++ b/packages/babel-parser/src/util/scope.js @@ -16,6 +16,7 @@ import { type BindingTypes, SCOPE_CLASS, } from "./scopeflags"; +import * as N from "../types"; // Start an AST node, attaching a start offset. class Scope { @@ -40,6 +41,7 @@ export default class ScopeHandler { scopeStack: Array = []; raise: raiseFunction; inModule: boolean; + undefinedExports: Map = new Map(); constructor(raise: raiseFunction, inModule: boolean) { this.raise = raise; @@ -95,6 +97,9 @@ export default class ScopeHandler { scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1; scope.lexical.push(name); + if (this.inModule && scope.flags & SCOPE_PROGRAM) { + this.undefinedExports.delete(name); + } } else if (bindingType === BIND_SIMPLE_CATCH) { const scope = this.currentScope(); scope.lexical.push(name); @@ -122,6 +127,10 @@ export default class ScopeHandler { } scope.var.push(name); + if (this.inModule && scope.flags & SCOPE_PROGRAM) { + this.undefinedExports.delete(name); + } + if (scope.flags & SCOPE_VAR) break; } } @@ -130,6 +139,16 @@ export default class ScopeHandler { } } + checkLocalExport(id: N.Identifier) { + // scope.functions must be empty as Module code is always strict. + if ( + this.scopeStack[0].lexical.indexOf(id.name) === -1 && + this.scopeStack[0].var.indexOf(id.name) === -1 + ) { + this.undefinedExports.set(id.name, id.start); + } + } + currentScope(): Scope { return this.scopeStack[this.scopeStack.length - 1]; } diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/input.js b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/input.js new file mode 100644 index 000000000000..df3d92761397 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/input.js @@ -0,0 +1 @@ +export { encrypt as default }; diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/options.json new file mode 100644 index 000000000000..8448889cf253 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as-default/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Export 'encrypt' is not defined (1:9)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/input.js b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/input.js new file mode 100644 index 000000000000..f14dc079868b --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/input.js @@ -0,0 +1,2 @@ +export { encrypt as decrypt }; +function decrypt() {} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/options.json new file mode 100644 index 000000000000..8448889cf253 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-as/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Export 'encrypt' is not defined (1:9)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/input.js b/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/input.js new file mode 100644 index 000000000000..1e993e373a01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/input.js @@ -0,0 +1,4 @@ +{ + function encrypt() {} +} +export { encrypt } diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/options.json new file mode 100644 index 000000000000..0844d3e80e68 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-block/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Export 'encrypt' is not defined (4:9)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/input.js b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/input.js new file mode 100644 index 000000000000..2ab393fc2343 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/input.js @@ -0,0 +1 @@ +export { Object as Obj }; diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/options.json new file mode 100644 index 000000000000..cbab70613300 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin-as/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Export 'Object' is not defined (1:9)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/input.js b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/input.js new file mode 100644 index 000000000000..8ddd96dff319 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/input.js @@ -0,0 +1 @@ +export { Object }; diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/options.json new file mode 100644 index 000000000000..cbab70613300 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-builtin/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Export 'Object' is not defined (1:9)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/input.js b/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/input.js new file mode 100644 index 000000000000..6d6c87fb7a38 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/input.js @@ -0,0 +1,2 @@ +export { encrypt }; +if (true) function encrypt() {} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/options.json new file mode 100644 index 000000000000..2c97b3ce5a78 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-if/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "In strict mode code, functions can only be declared at top level or inside a block (2:10)" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/input.js b/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/input.js new file mode 100644 index 000000000000..b8a0b5223551 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/input.js @@ -0,0 +1,4 @@ +{ + var encrypt +} +export { encrypt } diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/options.json new file mode 100644 index 000000000000..2104ca43283f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/output.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/output.json new file mode 100644 index 000000000000..91e34252dbc5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export-var/output.json @@ -0,0 +1,172 @@ +{ + "type": "File", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "BlockStatement", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 4, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "id": { + "type": "Identifier", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "init": null + } + ], + "kind": "var" + } + ], + "directives": [] + }, + { + "type": "ExportNamedDeclaration", + "start": 18, + "end": 36, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 18 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 27, + "end": 34, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "local": { + "type": "Identifier", + "start": 27, + "end": 34, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "exported": { + "type": "Identifier", + "start": 27, + "end": 34, + "loc": { + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export/input.js b/packages/babel-parser/test/fixtures/core/scope/undecl-export/input.js new file mode 100644 index 000000000000..7ec871cd2f99 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export/input.js @@ -0,0 +1 @@ +export { encrypt }; diff --git a/packages/babel-parser/test/fixtures/core/scope/undecl-export/options.json b/packages/babel-parser/test/fixtures/core/scope/undecl-export/options.json new file mode 100644 index 000000000000..8448889cf253 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/undecl-export/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Export 'encrypt' is not defined (1:9)" +} diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-builtin/input.js b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-builtin/input.js index 01d2b22e0b82..30c0f0d29bb5 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-builtin/input.js +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-builtin/input.js @@ -1 +1,3 @@ +const toString = 1; + export { toString }; diff --git a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-builtin/output.json b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-builtin/output.json index 190e09b28697..7d37c8dcb67b 100644 --- a/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-builtin/output.json +++ b/packages/babel-parser/test/fixtures/es2015/modules/duplicate-named-export-builtin/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 20, + "end": 41, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 3, "column": 20 } }, "program": { "type": "Program", "start": 0, - "end": 20, + "end": 41, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 3, "column": 20 } }, @@ -30,9 +30,9 @@ "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "VariableDeclaration", "start": 0, - "end": 20, + "end": 19, "loc": { "start": { "line": 1, @@ -40,36 +40,105 @@ }, "end": { "line": 1, + "column": 19 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "toString" + }, + "name": "toString" + }, + "init": { + "type": "NumericLiteral", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "extra": { + "rawValue": 1, + "raw": "1" + }, + "value": 1 + } + } + ], + "kind": "const" + }, + { + "type": "ExportNamedDeclaration", + "start": 21, + "end": 41, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, "column": 20 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "start": 9, - "end": 17, + "start": 30, + "end": 38, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 17 } }, "local": { "type": "Identifier", - "start": 9, - "end": 17, + "start": 30, + "end": 38, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 17 }, "identifierName": "toString" @@ -78,15 +147,15 @@ }, "exported": { "type": "Identifier", - "start": 9, - "end": 17, + "start": 30, + "end": 38, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 17 }, "identifierName": "toString" @@ -95,7 +164,8 @@ } } ], - "source": null + "source": null, + "declaration": null } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/86/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/86/input.js index ebdd242449e5..bc9adbfd19cc 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/86/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/86/input.js @@ -1 +1,2 @@ -export { encrypt } \ No newline at end of file +export { encrypt } +function encrypt () {} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/86/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/86/output.json index 6f2e67893ccb..7e4ade49890c 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/86/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/86/output.json @@ -1,29 +1,29 @@ { "type": "File", "start": 0, - "end": 18, + "end": 41, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 18 + "line": 2, + "column": 22 } }, "program": { "type": "Program", "start": 0, - "end": 18, + "end": 41, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 18 + "line": 2, + "column": 22 } }, "sourceType": "module", @@ -43,7 +43,6 @@ "column": 18 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", @@ -95,7 +94,60 @@ } } ], - "source": null + "source": null, + "declaration": null + }, + { + "type": "FunctionDeclaration", + "start": 19, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 2, + "column": 20 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "body": [], + "directives": [] + } } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/87/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/87/input.js index 04615d4b6f31..9e82122a4077 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/87/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/87/input.js @@ -1 +1,3 @@ -export { encrypt, decrypt } \ No newline at end of file +function encrypt () {} +class decrypt{} +export { encrypt, decrypt } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/87/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/87/output.json index f7a0baef7991..28e7320743b9 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/87/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/87/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 27, + "end": 66, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 3, "column": 27 } }, "program": { "type": "Program", "start": 0, - "end": 27, + "end": 66, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 3, "column": 27 } }, @@ -30,9 +30,9 @@ "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "FunctionDeclaration", "start": 0, - "end": 27, + "end": 22, "loc": { "start": { "line": 1, @@ -40,36 +40,136 @@ }, "end": { "line": 1, + "column": 22 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "ClassDeclaration", + "start": 23, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 36, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "decrypt" + }, + "name": "decrypt" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "body": [] + } + }, + { + "type": "ExportNamedDeclaration", + "start": 39, + "end": 66, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, "column": 27 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "start": 9, - "end": 16, + "start": 48, + "end": 55, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 16 } }, "local": { "type": "Identifier", - "start": 9, - "end": 16, + "start": 48, + "end": 55, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 16 }, "identifierName": "encrypt" @@ -78,15 +178,15 @@ }, "exported": { "type": "Identifier", - "start": 9, - "end": 16, + "start": 48, + "end": 55, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 16 }, "identifierName": "encrypt" @@ -96,29 +196,29 @@ }, { "type": "ExportSpecifier", - "start": 18, - "end": 25, + "start": 57, + "end": 64, "loc": { "start": { - "line": 1, + "line": 3, "column": 18 }, "end": { - "line": 1, + "line": 3, "column": 25 } }, "local": { "type": "Identifier", - "start": 18, - "end": 25, + "start": 57, + "end": 64, "loc": { "start": { - "line": 1, + "line": 3, "column": 18 }, "end": { - "line": 1, + "line": 3, "column": 25 }, "identifierName": "decrypt" @@ -127,15 +227,15 @@ }, "exported": { "type": "Identifier", - "start": 18, - "end": 25, + "start": 57, + "end": 64, "loc": { "start": { - "line": 1, + "line": 3, "column": 18 }, "end": { - "line": 1, + "line": 3, "column": 25 }, "identifierName": "decrypt" @@ -144,7 +244,8 @@ } } ], - "source": null + "source": null, + "declaration": null } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/88/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/88/input.js index 9f663623f952..1f9f9289b167 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/88/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/88/input.js @@ -1 +1,2 @@ -export { encrypt as default } \ No newline at end of file +import encrypt from ""; +export { encrypt as default } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/88/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/88/output.json index 425419eb9509..25b0fd97418a 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/88/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/88/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 29, + "end": 53, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 2, "column": 29 } }, "program": { "type": "Program", "start": 0, - "end": 29, + "end": 53, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 2, "column": 29 } }, @@ -30,9 +30,9 @@ "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "ImportDeclaration", "start": 0, - "end": 29, + "end": 23, "loc": { "start": { "line": 1, @@ -40,36 +40,104 @@ }, "end": { "line": 1, + "column": 23 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "local": { + "type": "Identifier", + "start": 7, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 20, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "extra": { + "rawValue": "", + "raw": "\"\"" + }, + "value": "" + } + }, + { + "type": "ExportNamedDeclaration", + "start": 24, + "end": 53, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, "column": 29 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "start": 9, - "end": 27, + "start": 33, + "end": 51, "loc": { "start": { - "line": 1, + "line": 2, "column": 9 }, "end": { - "line": 1, + "line": 2, "column": 27 } }, "local": { "type": "Identifier", - "start": 9, - "end": 16, + "start": 33, + "end": 40, "loc": { "start": { - "line": 1, + "line": 2, "column": 9 }, "end": { - "line": 1, + "line": 2, "column": 16 }, "identifierName": "encrypt" @@ -78,15 +146,15 @@ }, "exported": { "type": "Identifier", - "start": 20, - "end": 27, + "start": 44, + "end": 51, "loc": { "start": { - "line": 1, + "line": 2, "column": 20 }, "end": { - "line": 1, + "line": 2, "column": 27 }, "identifierName": "default" @@ -95,7 +163,8 @@ } } ], - "source": null + "source": null, + "declaration": null } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/89/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/89/input.js index fec65aa2e838..f1526616e3f4 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/89/input.js +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/89/input.js @@ -1 +1,3 @@ -export { encrypt, decrypt as dec } \ No newline at end of file +function encrypt() {} +class decrypt {} +export { encrypt, decrypt as dec } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/89/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/89/output.json index 7f1186d778ed..6e52c6fd4d1f 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/89/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/89/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 34, + "end": 73, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 3, "column": 34 } }, "program": { "type": "Program", "start": 0, - "end": 34, + "end": 73, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 3, "column": 34 } }, @@ -30,9 +30,9 @@ "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "FunctionDeclaration", "start": 0, - "end": 34, + "end": 21, "loc": { "start": { "line": 1, @@ -40,36 +40,136 @@ }, "end": { "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "encrypt" + }, + "name": "encrypt" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "body": [], + "directives": [] + } + }, + { + "type": "ClassDeclaration", + "start": 22, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "id": { + "type": "Identifier", + "start": 28, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 13 + }, + "identifierName": "decrypt" + }, + "name": "decrypt" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 36, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "body": [] + } + }, + { + "type": "ExportNamedDeclaration", + "start": 39, + "end": 73, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, "column": 34 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "start": 9, - "end": 16, + "start": 48, + "end": 55, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 16 } }, "local": { "type": "Identifier", - "start": 9, - "end": 16, + "start": 48, + "end": 55, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 16 }, "identifierName": "encrypt" @@ -78,15 +178,15 @@ }, "exported": { "type": "Identifier", - "start": 9, - "end": 16, + "start": 48, + "end": 55, "loc": { "start": { - "line": 1, + "line": 3, "column": 9 }, "end": { - "line": 1, + "line": 3, "column": 16 }, "identifierName": "encrypt" @@ -96,29 +196,29 @@ }, { "type": "ExportSpecifier", - "start": 18, - "end": 32, + "start": 57, + "end": 71, "loc": { "start": { - "line": 1, + "line": 3, "column": 18 }, "end": { - "line": 1, + "line": 3, "column": 32 } }, "local": { "type": "Identifier", - "start": 18, - "end": 25, + "start": 57, + "end": 64, "loc": { "start": { - "line": 1, + "line": 3, "column": 18 }, "end": { - "line": 1, + "line": 3, "column": 25 }, "identifierName": "decrypt" @@ -127,15 +227,15 @@ }, "exported": { "type": "Identifier", - "start": 29, - "end": 32, + "start": 68, + "end": 71, "loc": { "start": { - "line": 1, + "line": 3, "column": 29 }, "end": { - "line": 1, + "line": 3, "column": 32 }, "identifierName": "dec" @@ -144,7 +244,8 @@ } } ], - "source": null + "source": null, + "declaration": null } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-default/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-default/input.js index 5d32a24de0a9..974ab55e4371 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-default/input.js +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-default/input.js @@ -1 +1,2 @@ export {foo as default}; +var foo; diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-default/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-default/output.json index c3d6819265c2..ab9dd47bd5f1 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-default/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-default/output.json @@ -1,29 +1,29 @@ { "type": "File", "start": 0, - "end": 24, + "end": 33, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 24 + "line": 2, + "column": 8 } }, "program": { "type": "Program", "start": 0, - "end": 24, + "end": 33, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 24 + "line": 2, + "column": 8 } }, "sourceType": "module", @@ -43,7 +43,6 @@ "column": 24 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", @@ -95,7 +94,59 @@ } } ], - "source": null + "source": null, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start": 25, + "end": 33, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 29, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifier/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifier/input.js index e7820a6f027c..1d873bf86024 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifier/input.js +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifier/input.js @@ -1 +1,2 @@ +var foo, bar; export {foo as bar}; diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifier/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifier/output.json index e1652693b14f..0b8670ce2ef3 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifier/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifier/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 20, + "end": 34, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 2, "column": 20 } }, "program": { "type": "Program", "start": 0, - "end": 20, + "end": 34, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 2, "column": 20 } }, @@ -30,9 +30,9 @@ "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "VariableDeclaration", "start": 0, - "end": 20, + "end": 13, "loc": { "start": { "line": 1, @@ -40,36 +40,119 @@ }, "end": { "line": 1, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ExportNamedDeclaration", + "start": 14, + "end": 34, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, "column": 20 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "start": 8, - "end": 18, + "start": 22, + "end": 32, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 18 } }, "local": { "type": "Identifier", - "start": 8, - "end": 11, + "start": 22, + "end": 25, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 }, "identifierName": "foo" @@ -78,15 +161,15 @@ }, "exported": { "type": "Identifier", - "start": 15, - "end": 18, + "start": 29, + "end": 32, "loc": { "start": { - "line": 1, + "line": 2, "column": 15 }, "end": { - "line": 1, + "line": 2, "column": 18 }, "identifierName": "bar" @@ -95,7 +178,8 @@ } } ], - "source": null + "source": null, + "declaration": null } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifiers/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifiers/input.js index ff57927839e8..f0218dfca8ab 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifiers/input.js +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifiers/input.js @@ -1 +1,2 @@ export {foo as default, bar}; +var foo, bar; diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifiers/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifiers/output.json index 8114c32e2924..2a876f042ed1 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifiers/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-as-specifiers/output.json @@ -1,29 +1,29 @@ { "type": "File", "start": 0, - "end": 29, + "end": 43, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 29 + "line": 2, + "column": 13 } }, "program": { "type": "Program", "start": 0, - "end": 29, + "end": 43, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 29 + "line": 2, + "column": 13 } }, "sourceType": "module", @@ -43,7 +43,6 @@ "column": 29 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", @@ -144,7 +143,92 @@ } } ], - "source": null + "source": null, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start": 30, + "end": 43, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 34, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + }, + { + "type": "VariableDeclarator", + "start": 39, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "id": { + "type": "Identifier", + "start": 39, + "end": 42, + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 12 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": null + } + ], + "kind": "var" } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifier/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifier/input.js index df5f5e609e93..1c36f4346199 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifier/input.js +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifier/input.js @@ -1 +1,2 @@ +let foo; export {foo}; diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifier/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifier/output.json index 49c37926ad3c..4faa60a28feb 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifier/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifier/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 13, + "end": 22, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 2, "column": 13 } }, "program": { "type": "Program", "start": 0, - "end": 13, + "end": 22, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 2, "column": 13 } }, @@ -30,9 +30,9 @@ "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "VariableDeclaration", "start": 0, - "end": 13, + "end": 8, "loc": { "start": { "line": 1, @@ -40,36 +40,86 @@ }, "end": { "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "ExportNamedDeclaration", + "start": 9, + "end": 22, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, "column": 13 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 } }, "local": { "type": "Identifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 }, "identifierName": "foo" @@ -78,15 +128,15 @@ }, "exported": { "type": "Identifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 }, "identifierName": "foo" @@ -95,7 +145,8 @@ } } ], - "source": null + "source": null, + "declaration": null } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers-comma/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers-comma/input.js index 61bc40fd77ea..12c55903d5e5 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers-comma/input.js +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers-comma/input.js @@ -1 +1,3 @@ +var bar; export {foo, bar,}; +var foo; diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers-comma/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers-comma/output.json index 0c439126a9ac..3616570c157d 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers-comma/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers-comma/output.json @@ -1,38 +1,38 @@ { "type": "File", "start": 0, - "end": 19, + "end": 37, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 19 + "line": 3, + "column": 8 } }, "program": { "type": "Program", "start": 0, - "end": 19, + "end": 37, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 19 + "line": 3, + "column": 8 } }, "sourceType": "module", "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "VariableDeclaration", "start": 0, - "end": 19, + "end": 8, "loc": { "start": { "line": 1, @@ -40,36 +40,86 @@ }, "end": { "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ExportNamedDeclaration", + "start": 9, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, "column": 19 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 } }, "local": { "type": "Identifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 }, "identifierName": "foo" @@ -78,15 +128,15 @@ }, "exported": { "type": "Identifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 }, "identifierName": "foo" @@ -96,29 +146,29 @@ }, { "type": "ExportSpecifier", - "start": 13, - "end": 16, + "start": 22, + "end": 25, "loc": { "start": { - "line": 1, + "line": 2, "column": 13 }, "end": { - "line": 1, + "line": 2, "column": 16 } }, "local": { "type": "Identifier", - "start": 13, - "end": 16, + "start": 22, + "end": 25, "loc": { "start": { - "line": 1, + "line": 2, "column": 13 }, "end": { - "line": 1, + "line": 2, "column": 16 }, "identifierName": "bar" @@ -127,15 +177,15 @@ }, "exported": { "type": "Identifier", - "start": 13, - "end": 16, + "start": 22, + "end": 25, "loc": { "start": { - "line": 1, + "line": 2, "column": 13 }, "end": { - "line": 1, + "line": 2, "column": 16 }, "identifierName": "bar" @@ -144,7 +194,59 @@ } } ], - "source": null + "source": null, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 33, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers/input.js index fdbc94275097..8e2977a9e757 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers/input.js +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers/input.js @@ -1 +1,3 @@ +var foo; export {foo, bar}; +var bar; diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers/output.json index b28aaf0d65e4..51d2d56a1f4d 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/export-named-specifiers/output.json @@ -1,38 +1,38 @@ { "type": "File", "start": 0, - "end": 18, + "end": 36, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 18 + "line": 3, + "column": 8 } }, "program": { "type": "Program", "start": 0, - "end": 18, + "end": 36, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 18 + "line": 3, + "column": 8 } }, "sourceType": "module", "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "VariableDeclaration", "start": 0, - "end": 18, + "end": 8, "loc": { "start": { "line": 1, @@ -40,36 +40,86 @@ }, "end": { "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "var" + }, + { + "type": "ExportNamedDeclaration", + "start": 9, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, "column": 18 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 } }, "local": { "type": "Identifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 }, "identifierName": "foo" @@ -78,15 +128,15 @@ }, "exported": { "type": "Identifier", - "start": 8, - "end": 11, + "start": 17, + "end": 20, "loc": { "start": { - "line": 1, + "line": 2, "column": 8 }, "end": { - "line": 1, + "line": 2, "column": 11 }, "identifierName": "foo" @@ -96,29 +146,29 @@ }, { "type": "ExportSpecifier", - "start": 13, - "end": 16, + "start": 22, + "end": 25, "loc": { "start": { - "line": 1, + "line": 2, "column": 13 }, "end": { - "line": 1, + "line": 2, "column": 16 } }, "local": { "type": "Identifier", - "start": 13, - "end": 16, + "start": 22, + "end": 25, "loc": { "start": { - "line": 1, + "line": 2, "column": 13 }, "end": { - "line": 1, + "line": 2, "column": 16 }, "identifierName": "bar" @@ -127,15 +177,15 @@ }, "exported": { "type": "Identifier", - "start": 13, - "end": 16, + "start": 22, + "end": 25, "loc": { "start": { - "line": 1, + "line": 2, "column": 13 }, "end": { - "line": 1, + "line": 2, "column": 16 }, "identifierName": "bar" @@ -144,7 +194,59 @@ } } ], - "source": null + "source": null, + "declaration": null + }, + { + "type": "VariableDeclaration", + "start": 28, + "end": 36, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 32, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "init": null + } + ], + "kind": "var" } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/flow/declare-export/export-named-pattern/input.js b/packages/babel-parser/test/fixtures/flow/declare-export/export-named-pattern/input.js index 6a25a1836566..9c00baefd079 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-export/export-named-pattern/input.js +++ b/packages/babel-parser/test/fixtures/flow/declare-export/export-named-pattern/input.js @@ -1 +1,2 @@ declare module "foo" { declare export {a,}; } +var a; diff --git a/packages/babel-parser/test/fixtures/flow/declare-export/export-named-pattern/output.json b/packages/babel-parser/test/fixtures/flow/declare-export/export-named-pattern/output.json index dda5b894d12c..c3b63e8c2365 100644 --- a/packages/babel-parser/test/fixtures/flow/declare-export/export-named-pattern/output.json +++ b/packages/babel-parser/test/fixtures/flow/declare-export/export-named-pattern/output.json @@ -1,29 +1,29 @@ { "type": "File", "start": 0, - "end": 45, + "end": 52, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 45 + "line": 2, + "column": 6 } }, "program": { "type": "Program", "start": 0, - "end": 45, + "end": 52, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, - "column": 45 + "line": 2, + "column": 6 } }, "sourceType": "module", @@ -92,7 +92,6 @@ "column": 43 } }, - "declaration": null, "specifiers": [ { "type": "ExportSpecifier", @@ -145,11 +144,63 @@ } ], "source": null, + "declaration": null, "default": false } ] }, "kind": "ES" + }, + { + "type": "VariableDeclaration", + "start": 46, + "end": 52, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 50, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "id": { + "type": "Identifier", + "start": 50, + "end": 51, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "a" + }, + "name": "a" + }, + "init": null + } + ], + "kind": "var" } ], "directives": [] diff --git a/packages/babel-parser/test/fixtures/flow/type-exports/specifier/input.js b/packages/babel-parser/test/fixtures/flow/type-exports/specifier/input.js index e34ea63759dc..168e2cff4a3e 100644 --- a/packages/babel-parser/test/fixtures/flow/type-exports/specifier/input.js +++ b/packages/babel-parser/test/fixtures/flow/type-exports/specifier/input.js @@ -1 +1,2 @@ +let foo; export type { foo }; diff --git a/packages/babel-parser/test/fixtures/flow/type-exports/specifier/output.json b/packages/babel-parser/test/fixtures/flow/type-exports/specifier/output.json index 4481726d786b..f4d18be8251b 100644 --- a/packages/babel-parser/test/fixtures/flow/type-exports/specifier/output.json +++ b/packages/babel-parser/test/fixtures/flow/type-exports/specifier/output.json @@ -1,28 +1,28 @@ { "type": "File", "start": 0, - "end": 20, + "end": 29, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 2, "column": 20 } }, "program": { "type": "Program", "start": 0, - "end": 20, + "end": 29, "loc": { "start": { "line": 1, "column": 0 }, "end": { - "line": 1, + "line": 2, "column": 20 } }, @@ -30,9 +30,9 @@ "interpreter": null, "body": [ { - "type": "ExportNamedDeclaration", + "type": "VariableDeclaration", "start": 0, - "end": 20, + "end": 8, "loc": { "start": { "line": 1, @@ -40,35 +40,86 @@ }, "end": { "line": 1, + "column": 8 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "init": null + } + ], + "kind": "let" + }, + { + "type": "ExportNamedDeclaration", + "start": 9, + "end": 29, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, "column": 20 } }, "specifiers": [ { "type": "ExportSpecifier", - "start": 14, - "end": 17, + "start": 23, + "end": 26, "loc": { "start": { - "line": 1, + "line": 2, "column": 14 }, "end": { - "line": 1, + "line": 2, "column": 17 } }, "local": { "type": "Identifier", - "start": 14, - "end": 17, + "start": 23, + "end": 26, "loc": { "start": { - "line": 1, + "line": 2, "column": 14 }, "end": { - "line": 1, + "line": 2, "column": 17 }, "identifierName": "foo" @@ -77,15 +128,15 @@ }, "exported": { "type": "Identifier", - "start": 14, - "end": 17, + "start": 23, + "end": 26, "loc": { "start": { - "line": 1, + "line": 2, "column": 14 }, "end": { - "line": 1, + "line": 2, "column": 17 }, "identifierName": "foo" diff --git a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/input.mjs b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/input.mjs index 4be37364cf10..8fdbffd7f814 100644 --- a/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/input.mjs +++ b/packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-type-annotations/input.mjs @@ -99,7 +99,7 @@ import type { imp2, imp3 } from "baz"; import type { foo as imp4 } from "baz"; import type from "foo"; import typeof * as namespace from "bar"; -export type { foo }; +export type { foo1 }; export type { foo2 } from "bar"; import {type T} from "foo"; import {type T2, V1} from "foo"; diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-2/input.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-2/input.mjs index fdbc94275097..97b218259d14 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-2/input.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-2/input.mjs @@ -1 +1,2 @@ export {foo, bar}; +var foo, bar; diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-2/output.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-2/output.mjs index ab82079a7c68..bed82c28410d 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-2/output.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-2/output.mjs @@ -1,12 +1,15 @@ System.register([], function (_export, _context) { "use strict"; + var foo, bar; + + _export({ + foo: void 0, + bar: void 0 + }); + return { setters: [], - execute: function () { - _export("foo", foo); - - _export("bar", bar); - } + execute: function () {} }; }); diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-3/input.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-3/input.mjs index e7820a6f027c..2ad49c002c36 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-3/input.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-3/input.mjs @@ -1 +1,2 @@ export {foo as bar}; +var foo; diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-3/output.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-3/output.mjs index 418e0cea9532..d613ff78b938 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-3/output.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-3/output.mjs @@ -1,10 +1,12 @@ System.register([], function (_export, _context) { "use strict"; + var foo; + + _export("foo", void 0); + return { setters: [], - execute: function () { - _export("bar", foo); - } + execute: function () {} }; }); diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-4/input.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-4/input.mjs index 5d32a24de0a9..974ab55e4371 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-4/input.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-4/input.mjs @@ -1 +1,2 @@ export {foo as default}; +var foo; diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-4/output.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-4/output.mjs index 25834444d127..d613ff78b938 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-4/output.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-4/output.mjs @@ -1,10 +1,12 @@ System.register([], function (_export, _context) { "use strict"; + var foo; + + _export("foo", void 0); + return { setters: [], - execute: function () { - _export("default", foo); - } + execute: function () {} }; }); diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-5/input.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-5/input.mjs index ff57927839e8..f0218dfca8ab 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-5/input.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-5/input.mjs @@ -1 +1,2 @@ export {foo as default, bar}; +var foo, bar; diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-5/output.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-5/output.mjs index bc1c7593c0d4..bed82c28410d 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-5/output.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named-5/output.mjs @@ -1,12 +1,15 @@ System.register([], function (_export, _context) { "use strict"; + var foo, bar; + + _export({ + foo: void 0, + bar: void 0 + }); + return { setters: [], - execute: function () { - _export("default", foo); - - _export("bar", bar); - } + execute: function () {} }; }); diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named/input.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named/input.mjs index df5f5e609e93..ff265b20ef19 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named/input.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named/input.mjs @@ -1 +1,2 @@ export {foo}; +var foo; diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named/output.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named/output.mjs index 0981d53ba56a..d613ff78b938 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named/output.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/export-named/output.mjs @@ -1,10 +1,12 @@ System.register([], function (_export, _context) { "use strict"; + var foo; + + _export("foo", void 0); + return { setters: [], - execute: function () { - _export("foo", foo); - } + execute: function () {} }; }); diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/overview/input.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/overview/input.mjs index 1623f8b61e3a..3e062136f23f 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/overview/input.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/overview/input.mjs @@ -6,7 +6,7 @@ import * as foo2 from "foo"; import {bar} from "foo"; import {foo as bar2} from "foo"; -export {test}; +export {foo}; export var test2 = 5; -export default test; +export default foo; diff --git a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/overview/output.mjs b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/overview/output.mjs index 97f9581aa131..e84b007dcd43 100644 --- a/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/overview/output.mjs +++ b/packages/babel-plugin-transform-modules-systemjs/test/fixtures/systemjs/overview/output.mjs @@ -10,11 +10,11 @@ System.register(["foo", "foo-bar", "./directory/foo-bar"], function (_export, _c bar2 = _foo.foo; }, function (_fooBar) {}, function (_directoryFooBar) {}], execute: function () { - _export("test", test); + _export("foo", foo); _export("test2", test2 = 5); - _export("default", test); + _export("default", foo); } }; }); diff --git a/scripts/tests/flow/flow_tests_whitelist.txt b/scripts/tests/flow/flow_tests_whitelist.txt index c5a154762bb3..4c850ac5271a 100644 --- a/scripts/tests/flow/flow_tests_whitelist.txt +++ b/scripts/tests/flow/flow_tests_whitelist.txt @@ -35,3 +35,6 @@ numbers/underscored_float_whole.js numbers/underscored_hex.js numbers/underscored_number.js numbers/underscored_oct.js +ES6/modules/migrated_0020.js +export_import_reserved_words/migrated_0003.js +export_statements/export_trailing_comma.js diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index 0c385c9bc7dc..ea959b580202 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -600,10 +600,6 @@ language/literals/string/unicode-escape-nls-err-double.js(default) language/literals/string/unicode-escape-nls-err-double.js(strict mode) language/literals/string/unicode-escape-nls-err-single.js(default) language/literals/string/unicode-escape-nls-err-single.js(strict mode) -language/module-code/early-export-global.js(default) -language/module-code/early-export-global.js(strict mode) -language/module-code/early-export-unresolvable.js(default) -language/module-code/early-export-unresolvable.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-1.js(default) language/module-code/privatename-not-valid-earlyerr-module-1.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-2.js(default) From 5c8cc0d536d2fb074d903d56857823935dd84a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 27 Feb 2019 00:17:11 +0100 Subject: [PATCH 21/58] =?UTF-8?q?Mark=20FOO=20in=20"var=20{=20x:=20FOO=20}?= =?UTF-8?q?=CB=9D=20as=20a=20binding,=20not=20as=20a=20reference=20(#9492)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/index.js | 13 ++++++- .../misc/import-const-throw/output.js | 24 ++++++++----- .../src/path/lib/virtual-types.js | 11 +++--- .../babel-types/src/validators/isBinding.js | 17 +++++++++- .../src/validators/isReferenced.js | 12 +++++-- packages/babel-types/test/validators.js | 34 +++++++++++++++++++ 6 files changed, 95 insertions(+), 16 deletions(-) diff --git a/packages/babel-plugin-proposal-object-rest-spread/src/index.js b/packages/babel-plugin-proposal-object-rest-spread/src/index.js index c4738f0c6730..1eb8e7b70f90 100644 --- a/packages/babel-plugin-proposal-object-rest-spread/src/index.js +++ b/packages/babel-plugin-proposal-object-rest-spread/src/index.js @@ -2,6 +2,17 @@ import { declare } from "@babel/helper-plugin-utils"; import syntaxObjectRestSpread from "@babel/plugin-syntax-object-rest-spread"; import { types as t } from "@babel/core"; +// TODO: Remove in Babel 8 +// @babel/types <=7.3.3 counts FOO as referenced in var { x: FOO }. +// We need to detect this bug to know if "unused" means 0 or 1 references. +const ZERO_REFS = (() => { + const node = t.identifier("a"); + const property = t.objectProperty(t.identifier("key"), node); + const pattern = t.objectPattern([property]); + + return t.isReferenced(node, property, pattern) ? 1 : 0; +})(); + export default declare((api, opts) => { api.assertVersion(7); @@ -98,7 +109,7 @@ export default declare((api, opts) => { Object.keys(bindings).forEach(bindingName => { const bindingParentPath = bindings[bindingName].parentPath; if ( - path.scope.getBinding(bindingName).references > 1 || + path.scope.getBinding(bindingName).references > ZERO_REFS || !bindingParentPath.isObjectProperty() ) { return; diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-const-throw/output.js b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-const-throw/output.js index 7b05f0c82458..01984ae47f96 100644 --- a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-const-throw/output.js +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/misc/import-const-throw/output.js @@ -18,24 +18,32 @@ _baz.Baz = (44, function () { throw new Error('"' + "Baz" + '" is read-only.'); }()); ({ - Foo: _foo.default -} = {}); + Foo +} = ({}, function () { + throw new Error('"' + "Foo" + '" is read-only.'); +}())); ({ Bar } = ({}, function () { throw new Error('"' + "Bar" + '" is read-only.'); }())); ({ - Baz: _baz.Baz -} = {}); + Baz +} = ({}, function () { + throw new Error('"' + "Baz" + '" is read-only.'); +}())); ({ - prop: _foo.default -} = {}); + prop: Foo +} = ({}, function () { + throw new Error('"' + "Foo" + '" is read-only.'); +}())); ({ prop: Bar } = ({}, function () { throw new Error('"' + "Bar" + '" is read-only.'); }())); ({ - prop: _baz.Baz -} = {}); + prop: Baz +} = ({}, function () { + throw new Error('"' + "Baz" + '" is read-only.'); +}())); diff --git a/packages/babel-traverse/src/path/lib/virtual-types.js b/packages/babel-traverse/src/path/lib/virtual-types.js index 35319f6ee894..97cec0e3af99 100644 --- a/packages/babel-traverse/src/path/lib/virtual-types.js +++ b/packages/babel-traverse/src/path/lib/virtual-types.js @@ -4,7 +4,8 @@ import * as t from "@babel/types"; export const ReferencedIdentifier = { types: ["Identifier", "JSXIdentifier"], - checkPath({ node, parent }: NodePath, opts?: Object): boolean { + checkPath(path: NodePath, opts?: Object): boolean { + const { node, parent } = path; if (!t.isIdentifier(node, opts) && !t.isJSXMemberExpression(parent, opts)) { if (t.isJSXIdentifier(node, opts)) { if (react.isCompatTag(node.name)) return false; @@ -15,7 +16,7 @@ export const ReferencedIdentifier = { } // check if node is referenced - return t.isReferenced(node, parent); + return t.isReferenced(node, parent, path.parentPath.parent); }, }; @@ -28,8 +29,10 @@ export const ReferencedMemberExpression = { export const BindingIdentifier = { types: ["Identifier"], - checkPath({ node, parent }: NodePath): boolean { - return t.isIdentifier(node) && t.isBinding(node, parent); + checkPath(path: NodePath): boolean { + const { node, parent } = path; + const grandparent = path.parentPath.parent; + return t.isIdentifier(node) && t.isBinding(node, parent, grandparent); }, }; diff --git a/packages/babel-types/src/validators/isBinding.js b/packages/babel-types/src/validators/isBinding.js index b1719a3b3802..234da4f6ec33 100644 --- a/packages/babel-types/src/validators/isBinding.js +++ b/packages/babel-types/src/validators/isBinding.js @@ -3,7 +3,22 @@ import getBindingIdentifiers from "../retrievers/getBindingIdentifiers"; /** * Check if the input `node` is a binding identifier. */ -export default function isBinding(node: Object, parent: Object): boolean { +export default function isBinding( + node: Object, + parent: Object, + grandparent?: Object, +): boolean { + if ( + grandparent && + node.type === "Identifier" && + parent.type === "ObjectProperty" && + grandparent.type === "ObjectExpression" + ) { + // We need to special-case this, because getBindingIdentifiers + // has an ObjectProperty->value entry for destructuring patterns. + return false; + } + const keys = getBindingIdentifiers.keys[parent.type]; if (keys) { for (let i = 0; i < keys.length; i++) { diff --git a/packages/babel-types/src/validators/isReferenced.js b/packages/babel-types/src/validators/isReferenced.js index b629e625ee4d..6a5a3ebc8ed3 100644 --- a/packages/babel-types/src/validators/isReferenced.js +++ b/packages/babel-types/src/validators/isReferenced.js @@ -2,7 +2,11 @@ /** * Check if the input `node` is a reference to a bound variable. */ -export default function isReferenced(node: Object, parent: Object): boolean { +export default function isReferenced( + node: Object, + parent: Object, + grandparent?: Object, +): boolean { switch (parent.type) { // yes: PARENT[NODE] // yes: NODE.child @@ -37,6 +41,7 @@ export default function isReferenced(node: Object, parent: Object): boolean { // yes: { [NODE]: "" } // no: { NODE: "" } // depends: { NODE } + // depends: { key: NODE } case "ObjectProperty": // no: class { NODE = value; } // yes: class { [NODE] = value; } @@ -51,7 +56,10 @@ export default function isReferenced(node: Object, parent: Object): boolean { if (parent.key === node) { return !!parent.computed; } - return parent.value === node; + if (parent.value === node) { + return !grandparent || grandparent.type !== "ObjectPattern"; + } + return true; // no: class NODE {} // yes: class Foo extends NODE {} diff --git a/packages/babel-types/test/validators.js b/packages/babel-types/test/validators.js index ce4740288105..8e1f18e11545 100644 --- a/packages/babel-types/test/validators.js +++ b/packages/babel-types/test/validators.js @@ -121,6 +121,40 @@ describe("validators", function() { expect(t.isReferenced(node, parent)).toBe(true); }); + + it("returns true if node id a value of ObjectProperty of an expression", function() { + const node = t.identifier("a"); + const parent = t.objectProperty(t.identifier("key"), node); + const grandparent = t.objectExpression([parent]); + + expect(t.isReferenced(node, parent, grandparent)).toBe(true); + }); + + it("returns false if node id a value of ObjectProperty of a pattern", function() { + const node = t.identifier("a"); + const parent = t.objectProperty(t.identifier("key"), node); + const grandparent = t.objectPattern([parent]); + + expect(t.isReferenced(node, parent, grandparent)).toBe(false); + }); + }); + + describe("isBinding", function() { + it("returns false if node id a value of ObjectProperty of an expression", function() { + const node = t.identifier("a"); + const parent = t.objectProperty(t.identifier("key"), node); + const grandparent = t.objectExpression([parent]); + + expect(t.isBinding(node, parent, grandparent)).toBe(false); + }); + + it("returns true if node id a value of ObjectProperty of a pattern", function() { + const node = t.identifier("a"); + const parent = t.objectProperty(t.identifier("key"), node); + const grandparent = t.objectPattern([parent]); + + expect(t.isBinding(node, parent, grandparent)).toBe(true); + }); }); describe("isType", function() { From 9aec606c69b04a4617eb85242b9ffb7229d7379a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 28 Feb 2019 00:34:48 +0100 Subject: [PATCH 22/58] Don't loose "this" in helper-call-delegate (#9601) --- .../babel-helper-call-delegate/src/index.js | 2 +- .../parameters/iife-this-9385/input.mjs | 6 ++++ .../parameters/iife-this-9385/options.json | 4 +++ .../parameters/iife-this-9385/output.js | 35 +++++++++++++++++++ .../fixtures/parameters/iife-this/input.js | 8 +++++ .../fixtures/parameters/iife-this/output.js | 23 ++++++++++++ 6 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/input.mjs create mode 100644 packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/options.json create mode 100644 packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/output.js create mode 100644 packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this/input.js create mode 100644 packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this/output.js diff --git a/packages/babel-helper-call-delegate/src/index.js b/packages/babel-helper-call-delegate/src/index.js index 8aee0276132c..d4bf041d0131 100644 --- a/packages/babel-helper-call-delegate/src/index.js +++ b/packages/babel-helper-call-delegate/src/index.js @@ -41,7 +41,7 @@ export default function(path: NodePath, scope = path.scope) { path.traverse(visitor, state); - if (state.foundArguments) { + if (state.foundArguments || state.foundThis) { callee = t.memberExpression(container, t.identifier("apply")); args = []; diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/input.mjs b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/input.mjs new file mode 100644 index 000000000000..971a693e6b72 --- /dev/null +++ b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/input.mjs @@ -0,0 +1,6 @@ +export class Test { + invite(options: { privacy: string } = {}) { + const privacy = options.privacy || "Private" + console.log(this) + } +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/options.json b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/options.json new file mode 100644 index 000000000000..cc760c8a6ca5 --- /dev/null +++ b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["transform-typescript"], + "presets": ["env"] +} diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/output.js b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/output.js new file mode 100644 index 000000000000..0268eef274c1 --- /dev/null +++ b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/output.js @@ -0,0 +1,35 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Test = void 0; + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +var Test = +/*#__PURE__*/ +function () { + function Test() { + _classCallCheck(this, Test); + } + + _createClass(Test, [{ + key: "invite", + value: function invite() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + return function () { + var privacy = options.privacy || "Private"; + console.log(this); + }.apply(this); + } + }]); + + return Test; +}(); + +exports.Test = Test; diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this/input.js b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this/input.js new file mode 100644 index 000000000000..b25022747087 --- /dev/null +++ b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this/input.js @@ -0,0 +1,8 @@ +var a; + +class Test { + invite(p = a) { + let a; + this; + } +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this/output.js b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this/output.js new file mode 100644 index 000000000000..d199a0d7866f --- /dev/null +++ b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this/output.js @@ -0,0 +1,23 @@ +var a; + +var Test = +/*#__PURE__*/ +function () { + "use strict"; + + function Test() { + babelHelpers.classCallCheck(this, Test); + } + + babelHelpers.createClass(Test, [{ + key: "invite", + value: function invite() { + var p = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : a; + return function () { + var a; + this; + }.apply(this); + } + }]); + return Test; +}(); From 5cb280f986bdbb56f09adc89bc59422880d79352 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 27 Feb 2019 15:53:28 -0800 Subject: [PATCH 23/58] Fix scope check for 2nd+ lexical bindings (#9600) --- packages/babel-parser/src/util/scope.js | 3 +-- .../core/scope/dupl-bind-2nd-lvl-lex-nested/input.js | 5 +++++ .../core/scope/dupl-bind-2nd-lvl-lex-nested/options.json | 3 +++ .../test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/input.js | 3 +++ .../fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json | 3 +++ .../core/scope/dupl-bind-2nd-lvl-var-nested/input.js | 5 +++++ .../core/scope/dupl-bind-2nd-lvl-var-nested/options.json | 3 +++ .../test/fixtures/core/scope/dupl-bind-2nd-lvl-var/input.js | 3 +++ .../fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json | 3 +++ 9 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/input.js create mode 100644 packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json diff --git a/packages/babel-parser/src/util/scope.js b/packages/babel-parser/src/util/scope.js index 8d9e08b1a816..a9cf9d89edea 100644 --- a/packages/babel-parser/src/util/scope.js +++ b/packages/babel-parser/src/util/scope.js @@ -117,8 +117,7 @@ export default class ScopeHandler { const scope = this.scopeStack[i]; if ( (scope.lexical.indexOf(name) > -1 && - !(scope.flags & SCOPE_SIMPLE_CATCH) && - scope.lexical[0] === name) || + !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)) || (!this.treatFunctionsAsVarInScope(scope) && scope.functions.indexOf(name) > -1) ) { diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/input.js new file mode 100644 index 000000000000..9c289f87c3ee --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/input.js @@ -0,0 +1,5 @@ +{ + let bar; + var foo = 1; + let foo = 1; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json new file mode 100644 index 000000000000..b09098cda9c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex-nested/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (4:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/input.js new file mode 100644 index 000000000000..512f6888653d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/input.js @@ -0,0 +1,3 @@ +let bar; +var foo = 1; +let foo = 1; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json new file mode 100644 index 000000000000..37dd7bff7207 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-lex/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:4)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/input.js new file mode 100644 index 000000000000..59ae63e301b7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/input.js @@ -0,0 +1,5 @@ +{ + let bar; + let foo = 1; + var foo = 1; +} diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json new file mode 100644 index 000000000000..b09098cda9c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var-nested/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (4:6)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/input.js b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/input.js new file mode 100644 index 000000000000..aebd03c05710 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/input.js @@ -0,0 +1,3 @@ +let bar; +let foo = 1; +var foo = 1; diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json new file mode 100644 index 000000000000..37dd7bff7207 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-2nd-lvl-var/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Identifier 'foo' has already been declared (3:4)" +} \ No newline at end of file From 208195f42576a70798cedf1abe4d9f1d86979fcc Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 27 Feb 2019 15:54:07 -0800 Subject: [PATCH 24/58] Disallow duplicate params in methods (#9599) * Disallow duplicate params in methods * Fix plugins --- packages/babel-parser/src/parser/expression.js | 13 +++++++++---- packages/babel-parser/src/plugins/estree.js | 8 ++++++-- packages/babel-parser/src/plugins/flow.js | 13 +++++++++---- packages/babel-parser/src/plugins/typescript.js | 3 ++- .../disallow-duplicate-method-params/input.js | 3 +++ .../disallow-duplicate-method-params/options.json | 3 +++ .../disallow-duplicate-method-params/input.js | 3 +++ .../disallow-duplicate-method-params/options.json | 3 +++ scripts/tests/test262/test262_whitelist.txt | 2 -- 9 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/options.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index df72050b7f4d..63c5cbe0bb2a 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1740,7 +1740,7 @@ export default class ExpressionParser extends LValParser { ); this.parseFunctionParams((node: any), allowModifiers); this.checkYieldAwaitInDefaultParams(); - this.parseFunctionBodyAndFinish(node, type); + this.parseFunctionBodyAndFinish(node, type, true); this.state.yieldPos = oldYieldPos; this.state.awaitPos = oldAwaitPos; @@ -1804,14 +1804,19 @@ export default class ExpressionParser extends LValParser { parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, + isMethod?: boolean = false, ): void { // $FlowIgnore (node is not bodiless if we get here) - this.parseFunctionBody(node); + this.parseFunctionBody(node, false, isMethod); this.finishNode(node, type); } // Parse function body and check parameters. - parseFunctionBody(node: N.Function, allowExpression: ?boolean): void { + parseFunctionBody( + node: N.Function, + allowExpression: ?boolean, + isMethod?: boolean = false, + ): void { const isExpression = allowExpression && !this.match(tt.braceL); const oldStrict = this.state.strict; let useStrict = false; @@ -1853,7 +1858,7 @@ export default class ExpressionParser extends LValParser { // if a let/const declaration in the function clashes with one of the params. this.checkParams( node, - !oldStrict && !useStrict && !allowExpression && !nonSimple, + !oldStrict && !useStrict && !allowExpression && !isMethod && !nonSimple, allowExpression, ); node.body = this.parseBlock(true, false); diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index 0a5a276a2bf0..07891f3086ae 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -259,8 +259,12 @@ export default (superClass: Class): Class => return node; } - parseFunctionBody(node: N.Function, allowExpression: ?boolean): void { - super.parseFunctionBody(node, allowExpression); + parseFunctionBody( + node: N.Function, + allowExpression: ?boolean, + isMethod?: boolean = false, + ): void { + super.parseFunctionBody(node, allowExpression, isMethod); node.expression = node.body.type !== "BlockStatement"; } diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index f76f043c4b1a..80961e09380b 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -1544,19 +1544,24 @@ export default (superClass: Class): Class => // Overrides // ================================== - parseFunctionBody(node: N.Function, allowExpressionBody: ?boolean): void { + parseFunctionBody( + node: N.Function, + allowExpressionBody: ?boolean, + isMethod?: boolean = false, + ): void { if (allowExpressionBody) { return this.forwardNoArrowParamsConversionAt(node, () => - super.parseFunctionBody(node, true), + super.parseFunctionBody(node, true, isMethod), ); } - return super.parseFunctionBody(node, false); + return super.parseFunctionBody(node, false, isMethod); } parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, + isMethod?: boolean = false, ): void { if (this.match(tt.colon)) { const typeNode = this.startNode(); @@ -1573,7 +1578,7 @@ export default (superClass: Class): Class => : null; } - super.parseFunctionBodyAndFinish(node, type); + super.parseFunctionBodyAndFinish(node, type, isMethod); } // interfaces diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 4973d1f6be4f..c51153661358 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -1472,6 +1472,7 @@ export default (superClass: Class): Class => parseFunctionBodyAndFinish( node: N.BodilessFunctionOrMethodBase, type: string, + isMethod?: boolean = false, ): void { if (this.match(tt.colon)) { node.returnType = this.tsParseTypeOrTypePredicateAnnotation(tt.colon); @@ -1488,7 +1489,7 @@ export default (superClass: Class): Class => return; } - super.parseFunctionBodyAndFinish(node, type); + super.parseFunctionBodyAndFinish(node, type, isMethod); } parseSubscript( diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/input.js b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/input.js new file mode 100644 index 000000000000..101e2b77cc79 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/input.js @@ -0,0 +1,3 @@ +class Foo { + bar(a, a) {} +} diff --git a/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/options.json b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/options.json new file mode 100644 index 000000000000..c7a2c3ba50a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class-methods/disallow-duplicate-method-params/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Argument name clash (2:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/input.js b/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/input.js new file mode 100644 index 000000000000..b916cd4df9b4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/input.js @@ -0,0 +1,3 @@ +({ + bar(a, a) {} +}) diff --git a/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/options.json b/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/options.json new file mode 100644 index 000000000000..c7a2c3ba50a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/object/disallow-duplicate-method-params/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Argument name clash (2:11)" +} \ No newline at end of file diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index ea959b580202..2dc847d203a6 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -406,10 +406,8 @@ language/expressions/class/elements/syntax/early-errors/invalid-names/method-out language/expressions/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(default) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(strict mode) -language/expressions/object/method-definition/early-errors-object-async-method-duplicate-parameters.js(default) language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(default) language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(strict mode) -language/expressions/object/method-definition/early-errors-object-method-duplicate-parameters.js(default) language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js(default) language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js(strict mode) language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js(default) From 98ab1b6428e797088bb6245f81963dae174be2f5 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 28 Feb 2019 11:42:12 -0800 Subject: [PATCH 25/58] Refactor parsing object members (#9607) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Refactor parsing object members * Ensure decorators on rest don’t swallow decorators silently * Use hasPrecedingLineBreak * Add test for async with linebreak * Update flow whitelist --- .../babel-parser/src/parser/expression.js | 201 ++++++++++-------- packages/babel-parser/src/parser/lval.js | 35 +-- packages/babel-parser/src/plugins/estree.js | 14 +- .../babel-parser/src/plugins/typescript.js | 2 +- .../core/uncategorised/396/options.json | 2 +- .../core/uncategorised/555/options.json | 2 +- .../comma-after-rest/options.json | 2 +- .../invalid-location/options.json | 2 +- .../comma-after-rest-param/options.json | 2 +- .../invalid-rest-in-params/options.json | 2 +- .../object/async-method-linebreak/input.js | 4 + .../async-method-linebreak/options.json | 3 + .../es2015/uncategorised/277/options.json | 2 +- .../es2015/uncategorised/283/options.json | 2 +- .../es2015/uncategorised/353/input.js | 1 - .../es2015/uncategorised/353/options.json | 3 - .../options.json | 2 +- .../es2018/object-rest-spread/16/options.json | 2 +- .../es2018/object-rest-spread/17/options.json | 2 +- .../es2018/object-rest-spread/19/options.json | 2 +- .../es2018/object-rest-spread/20/options.json | 2 +- .../es2018/object-rest-spread/22/options.json | 2 +- .../es2018/object-rest-spread/23/options.json | 2 +- .../es2018/object-rest-spread/25/options.json | 2 +- .../es2018/object-rest-spread/26/options.json | 2 +- .../es2018/object-rest-spread/7/options.json | 2 +- .../es2018/object-rest-spread/8/options.json | 2 +- .../es2018/object-rest-spread/9/options.json | 2 +- .../comma-after-rest/options.json | 2 +- .../options.json | 2 +- .../arrow-with-multiple-rest/options.json | 2 +- .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../invalid-proto-shorthands/options.json | 3 - .../input.js | 0 .../proto-identifier-shorthand/output.json | 176 +++++++++++++++ .../input.js | 0 .../proto-literal-shorthand/output.json | 179 ++++++++++++++++ .../input.js | 0 .../proto-shorthand-identifier/output.json | 176 +++++++++++++++ .../input.js | 0 .../proto-shorthand-literal/output.json | 179 ++++++++++++++++ .../input.js | 0 .../proto-shorthands/output.json | 181 ++++++++++++++++ .../invalid-syntax/migrated_0258/options.json | 2 +- .../types/tuple-rest-invalid/options.json | 2 +- scripts/tests/flow/flow_tests_whitelist.txt | 1 - .../test262/run_babel_parser_test262_utils.js | 2 +- scripts/tests/test262/test262_whitelist.txt | 5 - 51 files changed, 1054 insertions(+), 173 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/options.json delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/353/input.js delete mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/353/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/options.json delete mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/options.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-identifier-shorthand => proto-identifier-shorthand}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/output.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-literal-shorthand => proto-literal-shorthand}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/output.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-shorthand-identifier => proto-shorthand-identifier}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/output.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-shorthand-literal => proto-shorthand-literal}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/output.json rename packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/{invalid-proto-shorthands => proto-shorthands}/input.js (100%) create mode 100644 packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/output.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 63c5cbe0bb2a..9b05a76d560f 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -67,10 +67,18 @@ export default class ExpressionParser extends LValParser { // strict mode, init properties are also not allowed to be repeated. checkPropClash( - prop: N.ObjectMember, + prop: N.ObjectMember | N.SpreadElement, propHash: { [key: string]: boolean }, ): void { - if (prop.computed || prop.kind) return; + if ( + prop.type === "SpreadElement" || + prop.computed || + prop.kind || + // $FlowIgnore + prop.shorthand + ) { + return; + } const key = prop.key; // It is either an Identifier or a String/NumericLiteral @@ -197,13 +205,10 @@ export default class ExpressionParser extends LValParser { this.checkLVal(left, undefined, undefined, "assignment expression"); let patternErrorMsg; - let elementName; if (left.type === "ObjectPattern") { patternErrorMsg = "`({a}) = 0` use `({a} = 0)`"; - elementName = "property"; } else if (left.type === "ArrayPattern") { patternErrorMsg = "`([a]) = 0` use `([a] = 0)`"; - elementName = "element"; } if (patternErrorMsg && left.extra && left.extra.parenthesized) { @@ -213,7 +218,7 @@ export default class ExpressionParser extends LValParser { ); } - if (elementName) this.checkCommaAfterRestFromSpread(elementName); + if (patternErrorMsg) this.checkCommaAfterRestFromSpread(); this.state.commaAfterSpreadAt = oldCommaAfterSpreadAt; this.next(); @@ -639,7 +644,7 @@ export default class ExpressionParser extends LValParser { if (possibleAsync && this.shouldParseAsyncArrow()) { state.stop = true; - this.checkCommaAfterRestFromSpread("parameter"); + this.checkCommaAfterRestFromSpread(); node = this.parseAsyncArrowFromCallExpression( this.startNodeAt(startPos, startLoc), @@ -1207,13 +1212,13 @@ export default class ExpressionParser extends LValParser { spreadStart = this.state.start; exprList.push( this.parseParenItem( - this.parseRest(), + this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc, ), ); - this.checkCommaAfterRest(tt.parenR, "parameter"); + this.checkCommaAfterRest(); break; } else { @@ -1409,7 +1414,6 @@ export default class ExpressionParser extends LValParser { isPattern: boolean, refShorthandDefaultPos?: ?Pos, ): T { - let decorators = []; const propHash: any = Object.create(null); let first = true; const node = this.startNode(); @@ -1425,108 +1429,117 @@ export default class ExpressionParser extends LValParser { if (this.eat(tt.braceR)) break; } - if (this.match(tt.at)) { - if (this.hasPlugin("decorators")) { - this.raise( - this.state.start, - "Stage 2 decorators disallow object literal property decorators", - ); - } else { - // we needn't check if decorators (stage 0) plugin is enabled since it's checked by - // the call to this.parseDecorator - while (this.match(tt.at)) { - decorators.push(this.parseDecorator()); - } - } - } + const prop = this.parseObjectMember(isPattern, refShorthandDefaultPos); + // $FlowIgnore RestElement will never be returned if !isPattern + if (!isPattern) this.checkPropClash(prop, propHash); - let prop = this.startNode(), - isGenerator = false, - isAsync = false, - startPos, - startLoc; - if (decorators.length) { - prop.decorators = decorators; - decorators = []; - } - - if (this.match(tt.ellipsis)) { - prop = this.parseSpread(isPattern ? { start: 0 } : undefined); - node.properties.push(prop); - if (isPattern) { - this.toAssignable(prop, true, "object pattern"); - this.checkCommaAfterRest(tt.braceR, "property"); - this.expect(tt.braceR); - break; - } - continue; - } - - prop.method = false; - - if (isPattern || refShorthandDefaultPos) { - startPos = this.state.start; - startLoc = this.state.startLoc; + // $FlowIgnore + if (prop.shorthand) { + this.addExtra(prop, "shorthand", true); } - if (!isPattern) { - isGenerator = this.eat(tt.star); - } + node.properties.push(prop); + } - const containsEsc = this.state.containsEsc; + return this.finishNode( + node, + isPattern ? "ObjectPattern" : "ObjectExpression", + ); + } - if (!isPattern && this.isContextual("async")) { - if (isGenerator) this.unexpected(); + isAsyncProp(prop: N.ObjectProperty): boolean { + return ( + !prop.computed && + prop.key.type === "Identifier" && + prop.key.name === "async" && + (this.match(tt.name) || + this.match(tt.num) || + this.match(tt.string) || + this.match(tt.bracketL) || + this.state.type.keyword || + this.match(tt.star)) && + !this.hasPrecedingLineBreak() + ); + } - const asyncId = this.parseIdentifier(); - if ( - this.match(tt.colon) || - this.match(tt.parenL) || - this.match(tt.braceR) || - this.match(tt.eq) || - this.match(tt.comma) - ) { - prop.key = asyncId; - prop.computed = false; - } else { - isAsync = true; - isGenerator = this.eat(tt.star); - this.parsePropertyName(prop); - } + parseObjectMember( + isPattern: boolean, + refShorthandDefaultPos: ?Pos, + ): N.ObjectMember | N.SpreadElement | N.RestElement { + let decorators = []; + if (this.match(tt.at)) { + if (this.hasPlugin("decorators")) { + this.raise( + this.state.start, + "Stage 2 decorators disallow object literal property decorators", + ); } else { - this.parsePropertyName(prop); + // we needn't check if decorators (stage 0) plugin is enabled since it's checked by + // the call to this.parseDecorator + while (this.match(tt.at)) { + decorators.push(this.parseDecorator()); + } } + } - this.parseObjPropValue( - prop, - startPos, - startLoc, - isGenerator, - isAsync, - isPattern, - refShorthandDefaultPos, - containsEsc, - ); - this.checkPropClash(prop, propHash); + const prop = this.startNode(); + let isGenerator = false; + let isAsync = false; + let startPos; + let startLoc; - if (prop.shorthand) { - this.addExtra(prop, "shorthand", true); + if (this.match(tt.ellipsis)) { + if (decorators.length) this.unexpected(); + if (isPattern) { + this.next(); + // Don't use parseRestBinding() as we only allow Identifier here. + prop.argument = this.parseIdentifier(); + this.checkCommaAfterRest(); + return this.finishNode(prop, "RestElement"); } - node.properties.push(prop); + return this.parseSpread(); } if (decorators.length) { - this.raise( - this.state.start, - "You have trailing decorators with no property", - ); + prop.decorators = decorators; + decorators = []; } - return this.finishNode( - node, - isPattern ? "ObjectPattern" : "ObjectExpression", + prop.method = false; + + if (isPattern || refShorthandDefaultPos) { + startPos = this.state.start; + startLoc = this.state.startLoc; + } + + if (!isPattern) { + isGenerator = this.eat(tt.star); + } + + const containsEsc = this.state.containsEsc; + this.parsePropertyName(prop); + + if (!isPattern && !containsEsc && !isGenerator && this.isAsyncProp(prop)) { + isAsync = true; + isGenerator = this.eat(tt.star); + this.parsePropertyName(prop); + } else { + isAsync = false; + } + + this.parseObjPropValue( + prop, + startPos, + startLoc, + isGenerator, + isAsync, + isPattern, + refShorthandDefaultPos, + containsEsc, ); + + return prop; } isGetterOrSetterMethod(prop: N.ObjectMethod, isPattern: boolean): boolean { diff --git a/packages/babel-parser/src/parser/lval.js b/packages/babel-parser/src/parser/lval.js index 1711b7ae7d81..dd02c8c97441 100644 --- a/packages/babel-parser/src/parser/lval.js +++ b/packages/babel-parser/src/parser/lval.js @@ -122,7 +122,7 @@ export default class LValParser extends NodeUtils { this.raise(prop.key.start, error); } else if (prop.type === "SpreadElement" && !isLast) { - this.raiseRestNotLast(prop.start, "property"); + this.raiseRestNotLast(prop.start); } else { this.toAssignable(prop, isBinding, "object destructuring pattern"); } @@ -160,7 +160,7 @@ export default class LValParser extends NodeUtils { if (elt) { this.toAssignable(elt, isBinding, contextDescription); if (elt.type === "RestElement") { - this.raiseRestNotLast(elt.start, "element"); + this.raiseRestNotLast(elt.start); } } } @@ -213,7 +213,7 @@ export default class LValParser extends NodeUtils { return this.finishNode(node, "SpreadElement"); } - parseRest(): RestElement { + parseRestBinding(): RestElement { const node = this.startNode(); this.next(); node.argument = this.parseBindingAtom(); @@ -260,13 +260,8 @@ export default class LValParser extends NodeUtils { } else if (this.eat(close)) { break; } else if (this.match(tt.ellipsis)) { - elts.push(this.parseAssignableListItemTypes(this.parseRest())); - this.checkCommaAfterRest( - close, - this.scope.inFunction && this.state.inParameters - ? "parameter" - : "element", - ); + elts.push(this.parseAssignableListItemTypes(this.parseRestBinding())); + this.checkCommaAfterRest(); this.expect(close); break; } else { @@ -441,27 +436,19 @@ export default class LValParser extends NodeUtils { } } - checkCommaAfterRest(close: TokenType, kind: string): void { + checkCommaAfterRest(): void { if (this.match(tt.comma)) { - if (this.lookahead().type === close) { - this.raiseCommaAfterRest(this.state.start, kind); - } else { - this.raiseRestNotLast(this.state.start, kind); - } + this.raiseRestNotLast(this.state.start); } } - checkCommaAfterRestFromSpread(kind: string): void { + checkCommaAfterRestFromSpread(): void { if (this.state.commaAfterSpreadAt > -1) { - this.raiseCommaAfterRest(this.state.commaAfterSpreadAt, kind); + this.raiseRestNotLast(this.state.commaAfterSpreadAt); } } - raiseCommaAfterRest(pos: number, kind: string) { - this.raise(pos, `A trailing comma is not permitted after the rest ${kind}`); - } - - raiseRestNotLast(pos: number, kind: string) { - this.raise(pos, `The rest ${kind} must be the last ${kind}`); + raiseRestNotLast(pos: number) { + this.raise(pos, `Rest element must be last element`); } } diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index 07891f3086ae..38e7e2e01cdd 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -126,16 +126,24 @@ export default (superClass: Class): Class => } checkPropClash( - prop: N.ObjectMember, + prop: N.ObjectMember | N.SpreadElement, propHash: { [key: string]: boolean }, ): void { - if (prop.computed || !isSimpleProperty(prop)) return; + if ( + prop.type === "SpreadElement" || + prop.computed || + prop.method || + // $FlowIgnore + prop.shorthand + ) { + return; + } const key = prop.key; // It is either an Identifier or a String/NumericLiteral const name = key.type === "Identifier" ? key.name : String(key.value); - if (name === "__proto__") { + if (name === "__proto__" && prop.kind === "init") { if (propHash.proto) { this.raise(key.start, "Redefinition of __proto__ property"); } diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index c51153661358..7bc3623d78fe 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -570,7 +570,7 @@ export default (superClass: Class): Class => const restNode: N.TsRestType = this.startNode(); this.next(); // skips ellipsis restNode.typeAnnotation = this.tsParseType(); - this.checkCommaAfterRest(tt.bracketR, "type"); + this.checkCommaAfterRest(); return this.finishNode(restNode, "TSRestType"); } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json index 029befcedaa1..2e1b1cc3aa43 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/396/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:18)" + "throws": "Rest element must be last element (1:18)" } diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json index baad06556ff8..c1c6450ba3c0 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/555/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (3:13)" + "throws": "Rest element must be last element (3:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json index a85e470aeb8b..daa827f45cc4 100644 --- a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json +++ b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/comma-after-rest/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest element (1:5)" + "throws": "Rest element must be last element (1:5)" } diff --git a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json index 083dcaaa2cb0..0dac59b7a808 100644 --- a/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json +++ b/packages/babel-parser/test/fixtures/es2015/array-rest-spread/invalid-location/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest element must be the last element (1:1)" + "throws": "Rest element must be last element (1:1)" } diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json index d866b41af70c..65ed8c638978 100644 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/comma-after-rest-param/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest parameter (1:8)" + "throws": "Rest element must be last element (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json index baad06556ff8..c1c6450ba3c0 100644 --- a/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/invalid-rest-in-params/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (3:13)" + "throws": "Rest element must be last element (3:13)" } diff --git a/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/input.js b/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/input.js new file mode 100644 index 000000000000..f50ae43d068a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/input.js @@ -0,0 +1,4 @@ +({ + async + foo() {} +}) diff --git a/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/options.json b/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/options.json new file mode 100644 index 000000000000..978486d6a57c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/object/async-method-linebreak/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \",\" (3:4)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json index 029befcedaa1..2e1b1cc3aa43 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/277/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:18)" + "throws": "Rest element must be last element (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json index 3ead3a4299f8..daa827f45cc4 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/283/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:5)" + "throws": "Rest element must be last element (1:5)" } diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/353/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/353/input.js deleted file mode 100644 index 727c567cc1bd..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/353/input.js +++ /dev/null @@ -1 +0,0 @@ -({ __proto__, __proto__: 2 }) \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/353/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/353/options.json deleted file mode 100644 index a8b5ad2f5b20..000000000000 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/353/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json index 231d5fccd5ff..f686fb60b45e 100644 --- a/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/params-invalid-rest-trailing-comma/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest parameter (1:11)" + "throws": "Rest element must be last element (1:11)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/16/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/16/options.json index f65c23001ff1..9ce9658f7dfa 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/16/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/16/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:8)" + "throws": "Unexpected token (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/17/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/17/options.json index bf0116a7b09f..2a28555f76db 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/17/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/17/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:9)" + "throws": "Unexpected token (1:9)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/19/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/19/options.json index 6a9895dd9d8c..b8b06c3a03ba 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/19/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/19/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:18)" + "throws": "Unexpected token (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/20/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/20/options.json index 6a9895dd9d8c..b8b06c3a03ba 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/20/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/20/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:18)" + "throws": "Unexpected token (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/22/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/22/options.json index f65c23001ff1..08b79c43d6cd 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/22/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/22/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:8)" + "throws": "Unexpected token, expected \",\" (1:10)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/23/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/23/options.json index 6a9895dd9d8c..81e7a97e3f7e 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/23/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/23/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:18)" + "throws": "Unexpected token, expected \",\" (1:20)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/25/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/25/options.json index f65c23001ff1..9ce9658f7dfa 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/25/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/25/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:8)" + "throws": "Unexpected token (1:8)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/26/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/26/options.json index 6a9895dd9d8c..b8b06c3a03ba 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/26/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/26/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid rest operator's argument (1:18)" + "throws": "Unexpected token (1:18)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json index 253a786581de..b86f80dc4a72 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/7/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest property must be the last property (1:10)" + "throws": "Rest element must be last element (1:10)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json index e5efb196646c..c49db16e2821 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/8/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest property (1:16)" + "throws": "Rest element must be last element (1:16)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json index e1bf843ed1c1..e9effa60cb30 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/9/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest property must be the last property (1:13)" + "throws": "Rest element must be last element (1:13)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json index a19bb078b172..935d087d7ee5 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/comma-after-rest/options.json @@ -1,3 +1,3 @@ { - "throws": "A trailing comma is not permitted after the rest property (1:6)" + "throws": "Rest element must be last element (1:6)" } diff --git a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json index 015adf82cda0..b708967fd223 100644 --- a/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json +++ b/packages/babel-parser/test/fixtures/es2018/object-rest-spread/expression-rest-not-last-invalid/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest property must be the last property (1:2)" + "throws": "Rest element must be last element (1:2)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json index 3ead3a4299f8..daa827f45cc4 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-arrow-function/arrow-with-multiple-rest/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:5)" + "throws": "Rest element must be last element (1:5)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/options.json deleted file mode 100644 index 5c966843f4fa..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:20)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/options.json deleted file mode 100644 index e19950ad14df..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:22)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/options.json deleted file mode 100644 index a8b5ad2f5b20..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/options.json deleted file mode 100644 index a8b5ad2f5b20..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/options.json deleted file mode 100644 index a8b5ad2f5b20..000000000000 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Redefinition of __proto__ property (1:14)" -} diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-identifier-shorthand/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/output.json new file mode 100644 index 000000000000..20867c4f1d25 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-identifier-shorthand/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-literal-shorthand/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/output.json new file mode 100644 index 000000000000..43f28e81ab32 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-literal-shorthand/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 3, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + } + } + } + }, + { + "type": "ObjectProperty", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-identifier/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/output.json new file mode 100644 index 000000000000..28fc9127cd03 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-identifier/output.json @@ -0,0 +1,176 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 14, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 25, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 29 + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthand-literal/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/output.json new file mode 100644 index 000000000000..5bfefd1a3925 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthand-literal/output.json @@ -0,0 +1,179 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 14, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "method": false, + "key": { + "type": "StringLiteral", + "start": 14, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "extra": { + "rawValue": "__proto__", + "raw": "\"__proto__\"" + }, + "value": "__proto__" + }, + "computed": false, + "shorthand": false, + "value": { + "type": "NullLiteral", + "start": 27, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 31 + } + } + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/input.js b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/input.js similarity index 100% rename from packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/invalid-proto-shorthands/input.js rename to packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/input.js diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/output.json new file mode 100644 index 000000000000..23f3d43707e1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-initialiser/proto-shorthands/output.json @@ -0,0 +1,181 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "ObjectExpression", + "start": 1, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 3, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + }, + { + "type": "ObjectProperty", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "__proto__" + }, + "name": "__proto__" + }, + "extra": { + "shorthand": true + } + } + ], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json index 029befcedaa1..2e1b1cc3aa43 100644 --- a/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json +++ b/packages/babel-parser/test/fixtures/esprima/invalid-syntax/migrated_0258/options.json @@ -1,3 +1,3 @@ { - "throws": "The rest parameter must be the last parameter (1:18)" + "throws": "Rest element must be last element (1:18)" } diff --git a/packages/babel-parser/test/fixtures/typescript/types/tuple-rest-invalid/options.json b/packages/babel-parser/test/fixtures/typescript/types/tuple-rest-invalid/options.json index a500c245e78f..82b4f09fc940 100644 --- a/packages/babel-parser/test/fixtures/typescript/types/tuple-rest-invalid/options.json +++ b/packages/babel-parser/test/fixtures/typescript/types/tuple-rest-invalid/options.json @@ -1,5 +1,5 @@ { "sourceType": "module", "plugins": ["typescript"], - "throws": "The rest type must be the last type (1:19)" + "throws": "Rest element must be last element (1:19)" } diff --git a/scripts/tests/flow/flow_tests_whitelist.txt b/scripts/tests/flow/flow_tests_whitelist.txt index 4c850ac5271a..60ee5e0e6e98 100644 --- a/scripts/tests/flow/flow_tests_whitelist.txt +++ b/scripts/tests/flow/flow_tests_whitelist.txt @@ -10,7 +10,6 @@ JSX_invalid/migrated_0000.js arrow_function_invalid/migrated_0002.js -async_await/async_generic_method.js async_await/migrated_0007.js async_await/migrated_0020.js async_await/migrated_0024.js diff --git a/scripts/tests/test262/run_babel_parser_test262_utils.js b/scripts/tests/test262/run_babel_parser_test262_utils.js index 99c173dab66d..974e4a88e795 100644 --- a/scripts/tests/test262/run_babel_parser_test262_utils.js +++ b/scripts/tests/test262/run_babel_parser_test262_utils.js @@ -229,7 +229,7 @@ exports.updateWhitelist = function(filename, summary) { return line; }) .filter(function(line) { - return line !== null; + return line !== null && line !== ""; }) .concat(toAdd) .sort() diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index 2dc847d203a6..03e75b2222f7 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -1,4 +1,3 @@ - annexB/language/statements/for-in/bare-initializer.js(default) annexB/language/statements/for-in/bare-initializer.js(strict mode) built-ins/RegExp/property-escapes/binary-property-with-value-ASCII_-_F-negated.js(default) @@ -406,10 +405,6 @@ language/expressions/class/elements/syntax/early-errors/invalid-names/method-out language/expressions/class/elements/syntax/early-errors/invalid-names/method-outter-member-expression-this.js(strict mode) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(default) language/expressions/class/elements/syntax/early-errors/super-private-access-invalid.js(strict mode) -language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(default) -language/expressions/object/method-definition/early-errors-object-method-async-lineterminator.js(strict mode) -language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js(default) -language/expressions/object/method-definition/private-name-early-error-async-fn-inside-class.js(strict mode) language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js(default) language/expressions/object/method-definition/private-name-early-error-async-gen-inside-class.js(strict mode) language/expressions/object/method-definition/private-name-early-error-gen-inside-class.js(default) From d72f3aa7585cfb41c05a7aeb4714b86913a2d749 Mon Sep 17 00:00:00 2001 From: Evan Henley Date: Thu, 28 Feb 2019 15:03:12 -0600 Subject: [PATCH 26/58] [plugin-transform-typescript] Strip type imports used in Enums and object types (#9605) * fix: strip type imports used in Enums and object types * chore: update failing snapshot * docs: correct TSPropertySignature comment * fix: enum value should be considered a reference * chore: add tests for TSPropertySignature and TSEnumMember --- .../parameters/iife-this-9385/output.js | 6 +-- .../test/fixtures/imports/enum-id/input.mjs | 2 + .../test/fixtures/imports/enum-id/output.mjs | 7 +++ .../fixtures/imports/enum-value/input.mjs | 2 + .../fixtures/imports/enum-value/output.mjs | 8 ++++ .../imports/property-signature/input.mjs | 2 + .../imports/property-signature/output.mjs | 3 ++ .../src/validators/isReferenced.js | 14 ++++++ packages/babel-types/test/validators.js | 46 ++++++++++++++++++- 9 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-id/input.mjs create mode 100644 packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-id/output.mjs create mode 100644 packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-value/input.mjs create mode 100644 packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-value/output.mjs create mode 100644 packages/babel-plugin-transform-typescript/test/fixtures/imports/property-signature/input.mjs create mode 100644 packages/babel-plugin-transform-typescript/test/fixtures/imports/property-signature/output.mjs diff --git a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/output.js b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/output.js index 0268eef274c1..5e502c2384f7 100644 --- a/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/output.js +++ b/packages/babel-plugin-transform-parameters/test/fixtures/parameters/iife-this-9385/output.js @@ -22,10 +22,8 @@ function () { key: "invite", value: function invite() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - return function () { - var privacy = options.privacy || "Private"; - console.log(this); - }.apply(this); + var privacy = options.privacy || "Private"; + console.log(this); } }]); diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-id/input.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-id/input.mjs new file mode 100644 index 000000000000..f46a82c360a2 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-id/input.mjs @@ -0,0 +1,2 @@ +import { A } from 'lib' +enum Enum { A }; \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-id/output.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-id/output.mjs new file mode 100644 index 000000000000..628c6ba0ff86 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-id/output.mjs @@ -0,0 +1,7 @@ +var Enum; + +(function (Enum) { + Enum[Enum["A"] = 0] = "A"; +})(Enum || (Enum = {})); + +; diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-value/input.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-value/input.mjs new file mode 100644 index 000000000000..727760d0ed26 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-value/input.mjs @@ -0,0 +1,2 @@ +import { A } from 'lib' +enum Enum { id = A }; \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-value/output.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-value/output.mjs new file mode 100644 index 000000000000..88a2cffb8392 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/enum-value/output.mjs @@ -0,0 +1,8 @@ +import { A } from 'lib'; +var Enum; + +(function (Enum) { + Enum[Enum["id"] = A] = "id"; +})(Enum || (Enum = {})); + +; diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/property-signature/input.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/property-signature/input.mjs new file mode 100644 index 000000000000..7e242846479e --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/property-signature/input.mjs @@ -0,0 +1,2 @@ +import { A } from 'lib' +const obj: { A: A } = { A: 'foo' }; \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/imports/property-signature/output.mjs b/packages/babel-plugin-transform-typescript/test/fixtures/imports/property-signature/output.mjs new file mode 100644 index 000000000000..cba06b741a87 --- /dev/null +++ b/packages/babel-plugin-transform-typescript/test/fixtures/imports/property-signature/output.mjs @@ -0,0 +1,3 @@ +const obj = { + A: 'foo' +}; diff --git a/packages/babel-types/src/validators/isReferenced.js b/packages/babel-types/src/validators/isReferenced.js index 6a5a3ebc8ed3..f83c7956c493 100644 --- a/packages/babel-types/src/validators/isReferenced.js +++ b/packages/babel-types/src/validators/isReferenced.js @@ -134,6 +134,20 @@ export default function isReferenced( // no: type X = { NODE: OtherType } case "ObjectTypeProperty": return parent.key !== node; + + // yes: enum X { Foo = NODE } + // no: enum X { NODE } + case "TSEnumMember": + return parent.id !== node; + + // yes: { [NODE]: value } + // no: { NODE: value } + case "TSPropertySignature": + if (parent.key === node) { + return !!parent.computed; + } + + return true; } return true; diff --git a/packages/babel-types/test/validators.js b/packages/babel-types/test/validators.js index 8e1f18e11545..3b4ec0d93349 100644 --- a/packages/babel-types/test/validators.js +++ b/packages/babel-types/test/validators.js @@ -122,7 +122,7 @@ describe("validators", function() { expect(t.isReferenced(node, parent)).toBe(true); }); - it("returns true if node id a value of ObjectProperty of an expression", function() { + it("returns true if node is a value of ObjectProperty of an expression", function() { const node = t.identifier("a"); const parent = t.objectProperty(t.identifier("key"), node); const grandparent = t.objectExpression([parent]); @@ -130,13 +130,55 @@ describe("validators", function() { expect(t.isReferenced(node, parent, grandparent)).toBe(true); }); - it("returns false if node id a value of ObjectProperty of a pattern", function() { + it("returns false if node is a value of ObjectProperty of a pattern", function() { const node = t.identifier("a"); const parent = t.objectProperty(t.identifier("key"), node); const grandparent = t.objectPattern([parent]); expect(t.isReferenced(node, parent, grandparent)).toBe(false); }); + + describe("TSPropertySignature", function() { + it("returns false if node is a key", function() { + // { A: string } + const node = t.identifier("A"); + const parent = t.tsPropertySignature( + node, + t.tsTypeAnnotation(t.tsStringKeyword()), + ); + + expect(t.isReferenced(node, parent)).toBe(false); + }); + + it("returns true if node is a value", function() { + // { someKey: A } + const node = t.identifier("A"); + const parent = t.tsPropertySignature( + t.identifier("someKey"), + t.tsTypeAnnotation(t.tsTypeReference(node)), + ); + + expect(t.isReferenced(node, parent)).toBe(true); + }); + }); + + describe("TSEnumMember", function() { + it("returns false if node is an id", function() { + // enum X = { A }; + const node = t.identifier("A"); + const parent = t.tsEnumMember(node); + + expect(t.isReferenced(node, parent)).toBe(false); + }); + + it("returns true if node is a value", function() { + // enum X = { Foo = A } + const node = t.identifier("A"); + const parent = t.tsEnumMember(t.identifier("Foo"), node); + + expect(t.isReferenced(node, parent)).toBe(true); + }); + }); }); describe("isBinding", function() { From f13f4adcbb73bba964ba98bdc9541d4c73f0b2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 28 Feb 2019 23:58:27 +0100 Subject: [PATCH 27/58] [TS] Disallow type casts in arrow parameters (#9612) --- packages/babel-parser/src/plugins/typescript.js | 14 ++++++++++++-- .../cast/arrow-async-parameter-as/input.js | 1 + .../cast/arrow-async-parameter-as/options.json | 3 +++ .../cast/arrow-async-parameter-assertion/input.js | 1 + .../arrow-async-parameter-assertion/options.json | 3 +++ .../typescript/cast/arrow-parameter-as/input.js | 1 + .../cast/arrow-parameter-as/options.json | 3 +++ .../cast/arrow-parameter-assertion/input.js | 1 + .../cast/arrow-parameter-assertion/options.json | 3 +++ 9 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/options.json create mode 100644 packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/options.json diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 7bc3623d78fe..7d1f81d1b8a7 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -2268,8 +2268,18 @@ export default (superClass: Class): Class => ): $ReadOnlyArray { for (let i = 0; i < exprList.length; i++) { const expr = exprList[i]; - if (expr && expr.type === "TSTypeCastExpression") { - exprList[i] = this.typeCastToParameter(expr); + if (!expr) continue; + switch (expr.type) { + case "TSTypeCastExpression": + exprList[i] = this.typeCastToParameter(expr); + break; + case "TSAsExpression": + case "TSTypeAssertion": + this.raise( + expr.start, + "Unexpected type cast in parameter position.", + ); + break; } } return super.toAssignableList(exprList, isBinding, contextDescription); diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/input.js b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/input.js new file mode 100644 index 000000000000..746078a226a0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/input.js @@ -0,0 +1 @@ +async (a as T) => {}; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/options.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/options.json new file mode 100644 index 000000000000..69d91502496d --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-as/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected type cast in parameter position. (1:7)" +} diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/input.js b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/input.js new file mode 100644 index 000000000000..5e3f1481d6e7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/input.js @@ -0,0 +1 @@ +async ( a) => {}; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/options.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/options.json new file mode 100644 index 000000000000..69d91502496d --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-async-parameter-assertion/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected type cast in parameter position. (1:7)" +} diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/input.js b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/input.js new file mode 100644 index 000000000000..dc2282c6bdc8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/input.js @@ -0,0 +1 @@ +(a as T) => {}; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/options.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/options.json new file mode 100644 index 000000000000..b5bdba868c9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-as/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected type cast in parameter position. (1:1)" +} diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/input.js b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/input.js new file mode 100644 index 000000000000..39dae7d0cf4a --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/input.js @@ -0,0 +1 @@ +( a) => {}; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/options.json b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/options.json new file mode 100644 index 000000000000..b5bdba868c9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/cast/arrow-parameter-assertion/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected type cast in parameter position. (1:1)" +} From 17f4195bcc2e2024b9d8ec19ae225e6e074bafc0 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 28 Feb 2019 15:07:20 -0800 Subject: [PATCH 28/58] Allow any reserved word in `export {} from` specifiers (#9616) --- packages/babel-parser/src/parser/statement.js | 21 ++- .../export-from-valid-reserved-word/input.js | 1 + .../output.json | 122 ++++++++++++++++++ .../invalid-export-default-token/options.json | 5 +- .../invalid-export-named-default/options.json | 5 +- 5 files changed, 139 insertions(+), 15 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/es2015/modules/export-from-valid-reserved-word/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/modules/export-from-valid-reserved-word/output.json diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index d2981c24006a..22cc9b24a001 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -1866,9 +1866,17 @@ export default class StatementParser extends ExpressionParser { // Named exports for (const specifier of node.specifiers) { this.checkDuplicateExports(specifier, specifier.exported.name); - // check if export is defined // $FlowIgnore if (!isFrom && specifier.local) { + // check for keywords used as local names + this.checkReservedWord( + specifier.local.name, + specifier.local.start, + true, + false, + ); + // check if export is defined + // $FlowIgnore this.scope.checkLocalExport(specifier.local); } } @@ -1954,7 +1962,6 @@ export default class StatementParser extends ExpressionParser { parseExportSpecifiers(): Array { const nodes = []; let first = true; - let needsFrom; // export { x, y as z } [from '...'] this.expect(tt.braceL); @@ -1967,22 +1974,14 @@ export default class StatementParser extends ExpressionParser { if (this.eat(tt.braceR)) break; } - const isDefault = this.match(tt._default); - if (isDefault && !needsFrom) needsFrom = true; - const node = this.startNode(); - node.local = this.parseIdentifier(isDefault); + node.local = this.parseIdentifier(true); node.exported = this.eatContextual("as") ? this.parseIdentifier(true) : node.local.__clone(); nodes.push(this.finishNode(node, "ExportSpecifier")); } - // https://github.com/ember-cli/ember-cli/pull/3739 - if (needsFrom && !this.isContextual("from")) { - this.unexpected(); - } - return nodes; } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/export-from-valid-reserved-word/input.js b/packages/babel-parser/test/fixtures/es2015/modules/export-from-valid-reserved-word/input.js new file mode 100644 index 000000000000..0248bf7b6bd9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/export-from-valid-reserved-word/input.js @@ -0,0 +1 @@ +export { if } from 'foo' diff --git a/packages/babel-parser/test/fixtures/es2015/modules/export-from-valid-reserved-word/output.json b/packages/babel-parser/test/fixtures/es2015/modules/export-from-valid-reserved-word/output.json new file mode 100644 index 000000000000..5455a5287944 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/export-from-valid-reserved-word/output.json @@ -0,0 +1,122 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "if" + }, + "name": "if" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "if" + }, + "name": "if" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "extra": { + "rawValue": "foo", + "raw": "'foo'" + }, + "value": "foo" + }, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default-token/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default-token/options.json index e806dd7b3a52..b6ce2c43af87 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default-token/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default-token/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:17)" -} + "sourceType": "module", + "throws": "Unexpected token, expected \";\" (1:17)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/options.json index 4c07f39d1731..e03d273fdcd5 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-named-default/options.json @@ -1,3 +1,4 @@ { - "throws": "Unexpected token (1:16)" -} + "sourceType": "module", + "throws": "Unexpected keyword 'default' (1:8)" +} \ No newline at end of file From f195daa092ae2cbdf3d5c31c99fc50653f6e275e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 1 Mar 2019 00:09:49 +0100 Subject: [PATCH 29/58] Don't add params of anonymous exported function decls to the outer scope (#9613) * Don't add params of anonymous exported function decls to the outer scope * Test --- .../src/index.js | 5 +---- .../test/fixtures/regression/issue-9611/input.mjs | 3 +++ .../test/fixtures/regression/issue-9611/options.json | 3 +++ .../test/fixtures/regression/issue-9611/output.js | 12 ++++++++++++ packages/babel-traverse/src/scope/index.js | 2 +- 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/input.mjs create mode 100644 packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/options.json create mode 100644 packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/output.js diff --git a/packages/babel-helper-split-export-declaration/src/index.js b/packages/babel-helper-split-export-declaration/src/index.js index ffbf52243a05..c591f8746396 100644 --- a/packages/babel-helper-split-export-declaration/src/index.js +++ b/packages/babel-helper-split-export-declaration/src/index.js @@ -49,10 +49,7 @@ export default function splitExportDeclaration(exportDeclaration) { exportDeclaration.replaceWith(updatedDeclaration); if (needBindingRegistration) { - scope.registerBinding( - isClassDeclaration ? "let" : "var", - exportDeclaration, - ); + scope.registerDeclaration(exportDeclaration); } return exportDeclaration; diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/input.mjs b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/input.mjs new file mode 100644 index 000000000000..cdc221254f38 --- /dev/null +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/input.mjs @@ -0,0 +1,3 @@ +import x from './x'; + +export default function(x) {} \ No newline at end of file diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/options.json b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/options.json new file mode 100644 index 000000000000..81e5ce12436d --- /dev/null +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["transform-modules-commonjs"] +} diff --git a/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/output.js b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/output.js new file mode 100644 index 000000000000..d1b46e901e14 --- /dev/null +++ b/packages/babel-plugin-transform-modules-commonjs/test/fixtures/regression/issue-9611/output.js @@ -0,0 +1,12 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = _default; + +var _x = _interopRequireDefault(require("./x")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _default(x) {} diff --git a/packages/babel-traverse/src/scope/index.js b/packages/babel-traverse/src/scope/index.js index 2976cff173f6..375d5827b970 100644 --- a/packages/babel-traverse/src/scope/index.js +++ b/packages/babel-traverse/src/scope/index.js @@ -518,7 +518,7 @@ export default class Scope { } const parent = this.getProgramParent(); - const ids = path.getBindingIdentifiers(true); + const ids = path.getOuterBindingIdentifiers(true); for (const name of Object.keys(ids)) { for (const id of (ids[name]: Array)) { From 38ef4b74677d7ec5d07c7c33094f4503d3b58b87 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Mon, 4 Mar 2019 14:26:22 -0800 Subject: [PATCH 30/58] Add editorconfig for Makefile (#9623) --- .editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.editorconfig b/.editorconfig index ba48528bbf4b..d38c249a7aa9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,5 +10,8 @@ end_of_line = lf indent_style = space indent_size = 2 +[Makefile] +indent_style = tab + [*.{md,markdown}] trim_trailing_whitespace = false From 37a427f692d073ff9e067671b3f297514779eeb5 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Mon, 4 Mar 2019 14:26:39 -0800 Subject: [PATCH 31/58] Update dependencies (#9624) --- package.json | 4 +- yarn.lock | 759 ++++++++++++++++++++------------------------------- 2 files changed, 295 insertions(+), 468 deletions(-) diff --git a/package.json b/package.json index 109bc6a97be9..642b2c72f5d8 100644 --- a/package.json +++ b/package.json @@ -33,12 +33,12 @@ "duplicate-package-checker-webpack-plugin": "^2.1.0", "enhanced-resolve": "^3.0.0", "eslint": "^5.12.1", - "eslint-config-babel": "^8.0.2", + "eslint-config-babel": "^9.0.0", "eslint-plugin-flowtype": "^3.2.1", "eslint-plugin-import": "^2.16.0", "eslint-plugin-prettier": "^3.0.1", "fancy-log": "^1.3.3", - "flow-bin": "^0.92.1", + "flow-bin": "^0.94.0", "graceful-fs": "^4.1.15", "gulp": "^4.0.0", "gulp-babel": "^8.0.0", diff --git a/yarn.lock b/yarn.lock index ab1eecdd3c33..1a41a9418210 100644 --- a/yarn.lock +++ b/yarn.lock @@ -685,6 +685,13 @@ pirates "^4.0.0" source-map-support "^0.5.9" +"@babel/runtime@7.0.0": + version "7.0.0" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0.tgz#adeb78fedfc855aa05bc041640f3f6f98e85424c" + integrity sha512-7hGhzlcmg01CvH1EHdSPVXYX1aJ8KCEyz6I9xYIi/asDtzBPMyMhVibhM/K6g/5qnKBwjZtp10bNZIEFTRW1MA== + dependencies: + regenerator-runtime "^0.12.0" + "@babel/runtime@^7.3.4": version "7.3.4" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.4.tgz#73d12ba819e365fcf7fd152aed56d6df97d21c83" @@ -734,19 +741,6 @@ lodash "^4.17.11" to-fast-properties "^2.0.0" -"@iamstarkov/listr-update-renderer@0.4.1": - version "0.4.1" - resolved "https://registry.yarnpkg.com/@iamstarkov/listr-update-renderer/-/listr-update-renderer-0.4.1.tgz#d7c48092a2dcf90fd672b6c8b458649cb350c77e" - dependencies: - chalk "^1.1.3" - cli-truncate "^0.2.1" - elegant-spinner "^1.0.1" - figures "^1.7.0" - indent-string "^3.0.0" - log-symbols "^1.0.2" - log-update "^2.3.0" - strip-ansi "^3.0.1" - "@lerna/add@^3.6.0": version "3.6.0" resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.6.0.tgz#eea53efff0b3237774ddac6eaa84957140e89238" @@ -1343,14 +1337,7 @@ "@types/uglify-js" "*" source-map "^0.6.0" -JSONStream@^1.0.3, JSONStream@^1.0.4: - version "1.3.2" - resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.2.tgz#c102371b6ec3a7cf3b847ca00c20bb0fce4c6dea" - dependencies: - jsonparse "^1.2.0" - through ">=2.2.7 <3" - -JSONStream@^1.3.4: +JSONStream@^1.0.3, JSONStream@^1.0.4, JSONStream@^1.3.4: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" dependencies: @@ -1406,9 +1393,10 @@ acorn@^5.0.0, acorn@^5.0.3, acorn@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.5.0.tgz#1abb587fbf051f94e3de20e6b26ef910b1828298" -acorn@^6.0.2: - version "6.0.5" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.0.5.tgz#81730c0815f3f3b34d8efa95cb7430965f4d887a" +acorn@^6.0.2, acorn@^6.0.7: + version "6.1.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.1.1.tgz#7d25ae05bb8ad1f9b699108e1094ecd7884adc1f" + integrity sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA== agent-base@4, agent-base@^4.1.0, agent-base@~4.2.0: version "4.2.1" @@ -1426,9 +1414,10 @@ ajv-keywords@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.1.0.tgz#ac2b27939c543e95d2c06e7f7f5c27be4aa543be" -ajv@^6.1.0, ajv@^6.5.3, ajv@^6.5.5: - version "6.7.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.7.0.tgz#e3ce7bb372d6577bb1839f1dfdfcbf5ad2948d96" +ajv@^6.1.0, ajv@^6.5.5, ajv@^6.9.1: + version "6.9.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.9.2.tgz#4927adb83e7f48e5a32b45729744c71ec39c9c7b" + integrity sha512-4UFy0/LgDo7Oa/+wOAlj44tp9K78u38E5/359eSrqEp1Z5PdVfimCcs7SluXMP755RUQu6d2b4AvF0R1C9RZjg== dependencies: fast-deep-equal "^2.0.1" fast-json-stable-stringify "^2.0.0" @@ -1459,9 +1448,10 @@ ansi-cyan@^0.1.1: dependencies: ansi-wrap "0.1.0" -ansi-escapes@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" +ansi-escapes@^3.0.0, ansi-escapes@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz#8780b98ff9dbf5638152d1f1fe5c1d7b4442976b" + integrity sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ== ansi-gray@^0.1.1: version "0.1.1" @@ -1747,17 +1737,7 @@ async-settle@^1.0.0: dependencies: async-done "^1.2.2" -async@^1.4.0: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - -async@^2.1.2: - version "2.6.0" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.0.tgz#61a29abb6fcc026fea77e56d1c6ec53a795951f4" - dependencies: - lodash "^4.14.0" - -async@^2.5.0, async@^2.6.1: +async@^2.1.2, async@^2.5.0, async@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610" dependencies: @@ -1787,12 +1767,15 @@ babel-eslint@^11.0.0-beta.0: eslint-visitor-keys "^1.0.0" semver "^5.6.0" -babel-jest@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.0.0.tgz#8a0c767f03f4a595fb921afdab13ff126edd00da" +babel-jest@^24.0.0, babel-jest@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.1.0.tgz#441e23ef75ded3bd547e300ac3194cef87b55190" + integrity sha512-MLcagnVrO9ybQGLEfZUqnOzv36iQzU7Bj4elm39vCukumLVSfoX+tRy3/jW7lUKc7XdpRmB/jech6L/UCsSZjw== dependencies: babel-plugin-istanbul "^5.1.0" - babel-preset-jest "^24.0.0" + babel-preset-jest "^24.1.0" + chalk "^2.4.2" + slash "^2.0.0" babel-loader@^8.0.5: version "8.0.5" @@ -1811,9 +1794,10 @@ babel-plugin-istanbul@^5.1.0: istanbul-lib-instrument "^3.0.0" test-exclude "^5.0.0" -babel-plugin-jest-hoist@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.0.0.tgz#3adf030b6fd67e4311479a54b24077bdfc226ec9" +babel-plugin-jest-hoist@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.1.0.tgz#dfecc491fb15e2668abbd690a697a8fd1411a7f8" + integrity sha512-gljYrZz8w1b6fJzKcsfKsipSru2DU2DmQ39aB6nV3xQ0DDv3zpIzKGortA5gknrhNnPN8DweaEgrnZdmbGmhnw== babel-plugin-transform-charcodes@^0.2.0: version "0.2.0" @@ -1822,12 +1806,13 @@ babel-plugin-transform-charcodes@^0.2.0: "@babel/parser" "^7.0.0" "@babel/traverse" "^7.0.0" -babel-preset-jest@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.0.0.tgz#d23782e5e036cff517859640a80960bd628bd82b" +babel-preset-jest@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.1.0.tgz#83bc564fdcd4903641af65ec63f2f5de6b04132e" + integrity sha512-FfNLDxFWsNX9lUmtwY7NheGlANnagvxq8LZdl5PKnVG3umP+S/g0XbVBfwtA4Ai3Ri/IMkWabBz3Tyk9wdspcw== dependencies: "@babel/plugin-syntax-object-rest-spread" "^7.0.0" - babel-plugin-jest-hoist "^24.0.0" + babel-plugin-jest-hoist "^24.1.0" bach@^1.0.0: version "1.2.0" @@ -2299,15 +2284,7 @@ chalk@^1.0.0, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.2.tgz#250dc96b07491bfd601e648d66ddf5f60c7a5c65" - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - -chalk@^2.3.0: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.3.2, chalk@^2.4.1, chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== @@ -2316,14 +2293,6 @@ chalk@^2.3.0: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^2.3.1, chalk@^2.4.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" - dependencies: - ansi-styles "^3.2.1" - escape-string-regexp "^1.0.5" - supports-color "^5.3.0" - charcodes@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/charcodes/-/charcodes-0.2.0.tgz#5208d327e6cc05f99eb80ffc814707572d1f14e4" @@ -2362,11 +2331,7 @@ chokidar@^2.0.0, chokidar@^2.0.2, chokidar@^2.0.3: optionalDependencies: fsevents "^1.2.2" -chownr@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" - -chownr@^1.1.1: +chownr@^1.0.1, chownr@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.1.tgz#54726b8b8fff4df053c42187e801fb4412df1494" @@ -2385,10 +2350,6 @@ cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: inherits "^2.0.1" safe-buffer "^5.0.1" -circular-json@^0.3.1: - version "0.3.3" - resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" - class-utils@^0.3.5: version "0.3.6" resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" @@ -2570,11 +2531,11 @@ combined-stream@^1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@2.14.x, commander@^2.8.1, commander@^2.9.0, commander@~2.14.1: +commander@2.14.x, commander@~2.14.1: version "2.14.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.1.tgz#2235123e37af8ca3c65df45b026dbd357b01b9aa" -commander@^2.14.1: +commander@^2.14.1, commander@^2.8.1, commander@^2.9.0: version "2.18.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" @@ -2605,10 +2566,11 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.4.6, concat-stream@^1.5.0, concat-stream@^1.6.0: - version "1.6.1" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.1.tgz#261b8f518301f1d834e36342b9fea095d2620a26" +concat-stream@^1.4.6, concat-stream@^1.5.0, concat-stream@^1.6.0, concat-stream@~1.6.0: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" dependencies: + buffer-from "^1.0.0" inherits "^2.0.3" readable-stream "^2.2.2" typedarray "^0.0.6" @@ -2621,15 +2583,6 @@ concat-stream@~1.5.1: readable-stream "~2.0.0" typedarray "~0.0.5" -concat-stream@~1.6.0: - version "1.6.2" - resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" - dependencies: - buffer-from "^1.0.0" - inherits "^2.0.3" - readable-stream "^2.2.2" - typedarray "^0.0.6" - config-chain@^1.1.11: version "1.1.12" resolved "https://registry.yarnpkg.com/config-chain/-/config-chain-1.1.12.tgz#0fde8d091200eb5e808caf25fe618c02f48e4efa" @@ -2774,14 +2727,6 @@ core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" -cosmiconfig@5.0.6: - version "5.0.6" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.6.tgz#dca6cf680a0bd03589aff684700858c81abeeb39" - dependencies: - is-directory "^0.3.1" - js-yaml "^3.9.0" - parse-json "^4.0.0" - cosmiconfig@^5.0.2, cosmiconfig@^5.0.7: version "5.0.7" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-5.0.7.tgz#39826b292ee0d78eda137dfa3173bd1c21a43b04" @@ -2927,13 +2872,7 @@ debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: dependencies: ms "2.0.0" -debug@^4.0.1, debug@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.0.tgz#373687bffa678b38b1cd91f861b63850035ddc87" - dependencies: - ms "^2.1.1" - -debug@^4.1.1: +debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" dependencies: @@ -3022,18 +2961,6 @@ defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" -del@^2.0.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8" - dependencies: - globby "^5.0.0" - is-path-cwd "^1.0.0" - is-path-in-cwd "^1.0.0" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - rimraf "^2.2.8" - del@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/del/-/del-3.0.0.tgz#53ecf699ffcbcb39637691ab13baf160819766e5" @@ -3137,9 +3064,10 @@ doctrine@1.5.0: esutils "^2.0.2" isarray "^1.0.0" -doctrine@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" +doctrine@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" + integrity sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w== dependencies: esutils "^2.0.2" @@ -3262,6 +3190,11 @@ elliptic@^6.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.0" +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" @@ -3418,9 +3351,10 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-config-babel@^8.0.2: - version "8.0.2" - resolved "https://registry.yarnpkg.com/eslint-config-babel/-/eslint-config-babel-8.0.2.tgz#01f4b430148078522a4c69ab76944c672092d143" +eslint-config-babel@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-babel/-/eslint-config-babel-9.0.0.tgz#bcfb9e9a1892aff29b8773cb9d2c76639de83c07" + integrity sha512-J7l2KdDKi2y9QifMqXdSIkghrVXr6fcpxegj+803C+4xBfpp0h2LcY9X5N+ivJMBoX6G2PJ/TBTM1Kro0MELBA== eslint-import-resolver-node@^0.3.2: version "0.3.2" @@ -3439,10 +3373,11 @@ eslint-module-utils@^2.3.0: pkg-dir "^2.0.0" eslint-plugin-flowtype@^3.2.1: - version "3.2.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-3.2.1.tgz#45e032aee54e695dfc41a891e92b7afedfc62c77" + version "3.4.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-3.4.2.tgz#55475e10b05fd714d60bceebbbed596cb8706b16" + integrity sha512-sv6O6fiN3dIwhU4qRxfcyIpbKGVvsxwIQ6vgBLudpQKjH1rEyEFEOjGzGEUBTQP9J8LdTZm37OjiqZ0ZeFOa6g== dependencies: - lodash "^4.17.10" + lodash "^4.17.11" eslint-plugin-import@^2.16.0: version "2.16.0" @@ -3473,9 +3408,10 @@ eslint-scope@3.7.1: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-scope@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.0.tgz#50bf3071e9338bcdc43331794a0cb533f0136172" +eslint-scope@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.2.tgz#5f10cd6cabb1965bf479fa65745673439e21cb0e" + integrity sha512-5q1+B/ogmHl8+paxtOKx38Z8LtWkVGuNt3+GQNErqwLl6ViNp/gdJGMCjZNxZ8j/VYjDNZ2Fo+eQc1TAVPIzbg== dependencies: esrecurse "^4.1.0" estraverse "^4.1.1" @@ -3489,52 +3425,53 @@ eslint-visitor-keys@^1.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" eslint@^5.12.1: - version "5.12.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.12.1.tgz#5ca9931fb9029d04e7be92b03ce3b58edfac7e3b" + version "5.15.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.15.0.tgz#f313a2f7c7628d39adeefdba4a9c41f842012c9e" + integrity sha512-xwG7SS5JLeqkiR3iOmVgtF8Y6xPdtr6AAsN6ph7Q6R/fv+3UlKYoika8SmNzmb35qdRF+RfTY35kMEdtbi+9wg== dependencies: "@babel/code-frame" "^7.0.0" - ajv "^6.5.3" + ajv "^6.9.1" chalk "^2.1.0" cross-spawn "^6.0.5" debug "^4.0.1" - doctrine "^2.1.0" - eslint-scope "^4.0.0" + doctrine "^3.0.0" + eslint-scope "^4.0.2" eslint-utils "^1.3.1" eslint-visitor-keys "^1.0.0" - espree "^5.0.0" + espree "^5.0.1" esquery "^1.0.1" esutils "^2.0.2" - file-entry-cache "^2.0.0" + file-entry-cache "^5.0.1" functional-red-black-tree "^1.0.1" glob "^7.1.2" globals "^11.7.0" ignore "^4.0.6" import-fresh "^3.0.0" imurmurhash "^0.1.4" - inquirer "^6.1.0" + inquirer "^6.2.2" js-yaml "^3.12.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.3.0" - lodash "^4.17.5" + lodash "^4.17.11" minimatch "^3.0.4" mkdirp "^0.5.1" natural-compare "^1.4.0" optionator "^0.8.2" path-is-inside "^1.0.2" - pluralize "^7.0.0" progress "^2.0.0" regexpp "^2.0.1" semver "^5.5.1" strip-ansi "^4.0.0" strip-json-comments "^2.0.1" - table "^5.0.2" + table "^5.2.3" text-table "^0.2.0" -espree@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.0.tgz#fc7f984b62b36a0f543b13fb9cd7b9f4a7f5b65c" +espree@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.1.tgz#5d6526fa4fc7f0788a5cf75b15f30323e2f81f7a" + integrity sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A== dependencies: - acorn "^6.0.2" + acorn "^6.0.7" acorn-jsx "^5.0.0" eslint-visitor-keys "^1.0.0" @@ -3668,9 +3605,10 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" -expect@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/expect/-/expect-24.0.0.tgz#71f71d88a4202746fc79849bb4c6498008b5ef03" +expect@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/expect/-/expect-24.1.0.tgz#88e73301c4c785cde5f16da130ab407bdaf8c0f2" + integrity sha512-lVcAPhaYkQcIyMS+F8RVwzbm1jro20IG8OkvxQ6f1JfqhVZyyudCwYogQ7wnktlf14iF3ii7ArIUO/mqvrW9Gw== dependencies: ansi-styles "^3.2.0" jest-get-type "^24.0.0" @@ -3697,15 +3635,11 @@ extend-shallow@^3.0.0, extend-shallow@^3.0.2: assign-symbols "^1.0.0" is-extendable "^1.0.1" -extend@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" - -extend@~3.0.2: +extend@^3.0.0, extend@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" -external-editor@^3.0.0: +external-editor@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-3.0.3.tgz#5866db29a97826dbe4bf3afd24070ead9ea43a27" dependencies: @@ -3749,7 +3683,7 @@ falafel@^2.1.0: isarray "0.0.1" object-keys "^1.0.6" -fancy-log@1.3.2, fancy-log@^1.3.2: +fancy-log@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.2.tgz#f41125e3d84f2e7d89a43d06d958c8f78be16be1" dependencies: @@ -3757,7 +3691,7 @@ fancy-log@1.3.2, fancy-log@^1.3.2: color-support "^1.1.3" time-stamp "^1.0.0" -fancy-log@^1.3.3: +fancy-log@^1.3.2, fancy-log@^1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.3.3.tgz#dbc19154f558690150a23953a0adbd035be45fc7" dependencies: @@ -3820,12 +3754,12 @@ figures@^2.0.0: dependencies: escape-string-regexp "^1.0.5" -file-entry-cache@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" +file-entry-cache@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-5.0.1.tgz#ca0f6efa6dd3d561333fb14515065c2fafdf439c" + integrity sha512-bCg29ictuBaKUwwArK4ouCaqDgLZcysCFLmM/Yn/FDoqndh/9vNuQfXRDvTuXKLxfD/JtZQGKFT8MGcJBK644g== dependencies: - flat-cache "^1.2.1" - object-assign "^4.0.1" + flat-cache "^2.0.1" filename-regex@^2.0.0: version "2.0.1" @@ -3934,19 +3868,24 @@ flagged-respawn@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-1.0.0.tgz#4e79ae9b2eb38bf86b3bb56bf3e0a56aa5fcabd7" -flat-cache@^1.2.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481" +flat-cache@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0" + integrity sha512-LoQe6yDuUMDzQAEH8sgmh4Md6oZnc/7PjtwjNFSzveXqSHt6ka9fPBuso7IGf9Rz4uqnSnWiFH2B/zj24a5ReA== dependencies: - circular-json "^0.3.1" - del "^2.0.2" - graceful-fs "^4.1.2" - write "^0.2.1" + flatted "^2.0.0" + rimraf "2.6.3" + write "1.0.3" + +flatted@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.0.tgz#55122b6536ea496b4b44893ee2608141d10d9916" + integrity sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg== -flow-bin@^0.92.1: - version "0.92.1" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.92.1.tgz#32c136c07235f30c42dc0549a0790f370fad4070" - integrity sha512-F5kC5oQOR2FXROAeybJHFqgZP+moKV9fa/53QK4Q4WayTQHdA0KSl48KD1gP0A9mioRLiKUegTva/7I15cX3Iw== +flow-bin@^0.94.0: + version "0.94.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.94.0.tgz#b5d58fe7559705b73a18229f97edfc3ab6ffffcb" + integrity sha512-DYF7r9CJ/AksfmmB4+q+TyLMoeQPRnqtF1Pk7KY3zgfkB/nVuA3nXyzqgsIPIvnMSiFEXQcFK4z+iPxSLckZhQ== flush-write-stream@^1.0.0, flush-write-stream@^1.0.2: version "1.0.3" @@ -3955,6 +3894,11 @@ flush-write-stream@^1.0.0, flush-write-stream@^1.0.2: inherits "^2.0.1" readable-stream "^2.0.4" +fn-name@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7" + integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc= + for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -4272,17 +4216,6 @@ globals@^11.1.0, globals@^11.7.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.11.0.tgz#dcf93757fa2de5486fbeed7118538adf789e9c2e" integrity sha512-WHq43gS+6ufNOEqlrDBxVEbb8ntfXrfAUU2ZOpCxrBdGKW3gyv8mCxAfIBD0DroPKGrJ2eSsXsLtY9MPntsyTw== -globby@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" - dependencies: - array-union "^1.0.1" - arrify "^1.0.0" - glob "^7.0.3" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" @@ -4426,7 +4359,7 @@ gulplog@^1.0.0: dependencies: glogg "^1.0.0" -handlebars@^4.0.11: +handlebars@^4.0.11, handlebars@^4.0.2: version "4.0.12" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.12.tgz#2c15c8a96d46da5e266700518ba8cb8d919d5bc5" dependencies: @@ -4436,16 +4369,6 @@ handlebars@^4.0.11: optionalDependencies: uglify-js "^3.1.4" -handlebars@^4.0.2: - version "4.0.11" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" - dependencies: - async "^1.4.0" - optimist "^0.6.1" - source-map "^0.4.4" - optionalDependencies: - uglify-js "^2.6" - har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" @@ -4512,13 +4435,7 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" -has@^1.0.0, has@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" - dependencies: - function-bind "^1.0.2" - -has@^1.0.3: +has@^1.0.0, has@^1.0.1, has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== @@ -4567,11 +4484,7 @@ homedir-polyfill@^1.0.1: dependencies: parse-passwd "^1.0.0" -hosted-git-info@^2.1.4: - version "2.5.0" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c" - -hosted-git-info@^2.6.0: +hosted-git-info@^2.1.4, hosted-git-info@^2.6.0: version "2.7.1" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" @@ -4670,22 +4583,16 @@ husky@^1.3.1: run-node "^1.0.0" slash "^2.0.0" -iconv-lite@0.4.19, iconv-lite@~0.4.13: +iconv-lite@0.4.19: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" -iconv-lite@^0.4.24: +iconv-lite@^0.4.24, iconv-lite@^0.4.4, iconv-lite@~0.4.13: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" dependencies: safer-buffer ">= 2.1.2 < 3" -iconv-lite@^0.4.4: - version "0.4.21" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.21.tgz#c47f8733d02171189ebc4a400f3218d348094798" - dependencies: - safer-buffer "^2.1.0" - ieee754@^1.1.4: version "1.1.8" resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.8.tgz#be33d40ac10ef1926701f6f08a2d86fbfd1ad3e4" @@ -4798,38 +4705,21 @@ inline-source-map@~0.6.0: dependencies: source-map "~0.5.3" -inquirer@^6.1.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.2.0.tgz#51adcd776f661369dc1e894859c2560a224abdd8" +inquirer@^6.2.0, inquirer@^6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.2.2.tgz#46941176f65c9eb20804627149b743a218f25406" + integrity sha512-Z2rREiXA6cHRR9KBOarR3WuLlFzlIfAEIiB45ll5SSadMg7WqOh1MKEjjndfuH5ewXdixWCxqnVfGOQzPeiztA== dependencies: - ansi-escapes "^3.0.0" - chalk "^2.0.0" + ansi-escapes "^3.2.0" + chalk "^2.4.2" cli-cursor "^2.1.0" cli-width "^2.0.0" - external-editor "^3.0.0" + external-editor "^3.0.3" figures "^2.0.0" - lodash "^4.17.10" - mute-stream "0.0.7" - run-async "^2.2.0" - rxjs "^6.1.0" - string-width "^2.1.0" - strip-ansi "^4.0.0" - through "^2.3.6" - -inquirer@^6.2.0: - version "6.2.1" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-6.2.1.tgz#9943fc4882161bdb0b0c9276769c75b32dbfcd52" - dependencies: - ansi-escapes "^3.0.0" - chalk "^2.0.0" - cli-cursor "^2.1.0" - cli-width "^2.0.0" - external-editor "^3.0.0" - figures "^2.0.0" - lodash "^4.17.10" + lodash "^4.17.11" mute-stream "0.0.7" run-async "^2.2.0" - rxjs "^6.1.0" + rxjs "^6.4.0" string-width "^2.1.0" strip-ansi "^5.0.0" through "^2.3.6" @@ -4851,13 +4741,7 @@ interpret@^1.0.0, interpret@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" -invariant@^2.2.2: - version "2.2.3" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.3.tgz#1a827dfde7dcbd7c323f0ca826be8fa7c5e9d688" - dependencies: - loose-envify "^1.0.0" - -invariant@^2.2.4: +invariant@^2.2.2, invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" dependencies: @@ -5210,10 +5094,6 @@ istanbul-api@^2.0.8: minimatch "^3.0.4" once "^1.4.0" -istanbul-lib-coverage@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#2aee0e073ad8c5f6a0b00e0dfbf52b4667472eda" - istanbul-lib-coverage@^2.0.2, istanbul-lib-coverage@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz#0b891e5ad42312c2b9488554f603795f9a2211ba" @@ -5224,19 +5104,7 @@ istanbul-lib-hook@^2.0.3: dependencies: append-transform "^1.0.0" -istanbul-lib-instrument@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.0.0.tgz#b5f066b2a161f75788be17a9d556f40a0cf2afc9" - dependencies: - "@babel/generator" "^7.0.0" - "@babel/parser" "^7.0.0" - "@babel/template" "^7.0.0" - "@babel/traverse" "^7.0.0" - "@babel/types" "^7.0.0" - istanbul-lib-coverage "^2.0.1" - semver "^5.5.0" - -istanbul-lib-instrument@^3.0.1, istanbul-lib-instrument@^3.1.0: +istanbul-lib-instrument@^3.0.0, istanbul-lib-instrument@^3.0.1, istanbul-lib-instrument@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.1.0.tgz#a2b5484a7d445f1f311e93190813fa56dfb62971" dependencies: @@ -5279,9 +5147,10 @@ jest-changed-files@^24.0.0: execa "^1.0.0" throat "^4.0.0" -jest-cli@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-24.0.0.tgz#691fd4f7bce2574c1865db6844a43b56e60ce2a4" +jest-cli@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-24.1.0.tgz#f7cc98995f36e7210cce3cbb12974cbf60940843" + integrity sha512-U/iyWPwOI0T1CIxVLtk/2uviOTJ/OiSWJSe8qt6X1VkbbgP+nrtLJlmT9lPBe4lK78VNFJtrJ7pttcNv/s7yCw== dependencies: ansi-escapes "^3.0.0" chalk "^2.0.1" @@ -5295,16 +5164,16 @@ jest-cli@^24.0.0: istanbul-lib-instrument "^3.0.1" istanbul-lib-source-maps "^3.0.1" jest-changed-files "^24.0.0" - jest-config "^24.0.0" + jest-config "^24.1.0" jest-environment-jsdom "^24.0.0" jest-get-type "^24.0.0" jest-haste-map "^24.0.0" jest-message-util "^24.0.0" jest-regex-util "^24.0.0" - jest-resolve-dependencies "^24.0.0" - jest-runner "^24.0.0" - jest-runtime "^24.0.0" - jest-snapshot "^24.0.0" + jest-resolve-dependencies "^24.1.0" + jest-runner "^24.1.0" + jest-runtime "^24.1.0" + jest-snapshot "^24.1.0" jest-util "^24.0.0" jest-validate "^24.0.0" jest-watcher "^24.0.0" @@ -5322,26 +5191,26 @@ jest-cli@^24.0.0: which "^1.2.12" yargs "^12.0.2" -jest-config@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-24.0.0.tgz#878abe03c060c74a0ec30d3cd5dd1897873e030e" +jest-config@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-24.1.0.tgz#6ea6881cfdd299bc86cc144ee36d937c97c3850c" + integrity sha512-FbbRzRqtFC6eGjG5VwsbW4E5dW3zqJKLWYiZWhB0/4E5fgsMw8GODLbGSrY5t17kKOtCWb/Z7nsIThRoDpuVyg== dependencies: "@babel/core" "^7.1.0" - babel-jest "^24.0.0" + babel-jest "^24.1.0" chalk "^2.0.1" glob "^7.1.1" jest-environment-jsdom "^24.0.0" jest-environment-node "^24.0.0" jest-get-type "^24.0.0" - jest-jasmine2 "^24.0.0" + jest-jasmine2 "^24.1.0" jest-regex-util "^24.0.0" - jest-resolve "^24.0.0" + jest-resolve "^24.1.0" jest-util "^24.0.0" jest-validate "^24.0.0" micromatch "^3.1.10" pretty-format "^24.0.0" realpath-native "^1.0.2" - uuid "^3.3.2" jest-diff@^24.0.0: version "24.0.0" @@ -5382,10 +5251,6 @@ jest-environment-node@^24.0.0: jest-mock "^24.0.0" jest-util "^24.0.0" -jest-get-type@^22.1.0: - version "22.1.0" - resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.1.0.tgz#4e90af298ed6181edc85d2da500dbd2753e0d5a9" - jest-get-type@^24.0.0: version "24.0.0" resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-24.0.0.tgz#36e72930b78e33da59a4f63d44d332188278940b" @@ -5403,21 +5268,23 @@ jest-haste-map@^24.0.0: micromatch "^3.1.10" sane "^3.0.0" -jest-jasmine2@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-24.0.0.tgz#7d87be9d8b32d34ac5980ad646b7ae7f99e33a19" +jest-jasmine2@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-24.1.0.tgz#8377324b967037c440f0a549ee0bbd9912055db6" + integrity sha512-H+o76SdSNyCh9fM5K8upK45YTo/DiFx5w2YAzblQebSQmukDcoVBVeXynyr7DDnxh+0NTHYRCLwJVf3tC518wg== dependencies: "@babel/traverse" "^7.1.0" chalk "^2.0.1" co "^4.6.0" - expect "^24.0.0" + expect "^24.1.0" is-generator-fn "^2.0.0" jest-each "^24.0.0" jest-matcher-utils "^24.0.0" jest-message-util "^24.0.0" - jest-snapshot "^24.0.0" + jest-snapshot "^24.1.0" jest-util "^24.0.0" pretty-format "^24.0.0" + throat "^4.0.0" jest-leak-detector@^24.0.0: version "24.0.0" @@ -5452,42 +5319,47 @@ jest-regex-util@^24.0.0: version "24.0.0" resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-24.0.0.tgz#4feee8ec4a358f5bee0a654e94eb26163cb9089a" -jest-resolve-dependencies@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-24.0.0.tgz#86540611d660bdcaab8b87d069247d3832811d94" +jest-resolve-dependencies@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-24.1.0.tgz#78f738a2ec59ff4d00751d9da56f176e3f589f6c" + integrity sha512-2VwPsjd3kRPu7qe2cpytAgowCObk5AKeizfXuuiwgm1a9sijJDZe8Kh1sFj6FKvSaNEfCPlBVkZEJa2482m/Uw== dependencies: jest-regex-util "^24.0.0" - jest-snapshot "^24.0.0" + jest-snapshot "^24.1.0" -jest-resolve@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-24.0.0.tgz#0206cfe842324f8796b01f706f4075309bf7b405" +jest-resolve@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-24.1.0.tgz#42ff0169b0ea47bfdbd0c52a0067ca7d022c7688" + integrity sha512-TPiAIVp3TG6zAxH28u/6eogbwrvZjBMWroSLBDkwkHKrqxB/RIdwkWDye4uqPlZIXWIaHtifY3L0/eO5Z0f2wg== dependencies: browser-resolve "^1.11.3" chalk "^2.0.1" realpath-native "^1.0.0" -jest-runner@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-24.0.0.tgz#00b280d52d23286111a8ed0362ed958283f7f0e3" +jest-runner@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-24.1.0.tgz#3686a2bb89ce62800da23d7fdc3da2c32792943b" + integrity sha512-CDGOkT3AIFl16BLL/OdbtYgYvbAprwJ+ExKuLZmGSCSldwsuU2dEGauqkpvd9nphVdAnJUcP12e/EIlnTX0QXg== dependencies: + chalk "^2.4.2" exit "^0.1.2" graceful-fs "^4.1.15" - jest-config "^24.0.0" + jest-config "^24.1.0" jest-docblock "^24.0.0" jest-haste-map "^24.0.0" - jest-jasmine2 "^24.0.0" + jest-jasmine2 "^24.1.0" jest-leak-detector "^24.0.0" jest-message-util "^24.0.0" - jest-runtime "^24.0.0" + jest-runtime "^24.1.0" jest-util "^24.0.0" jest-worker "^24.0.0" source-map-support "^0.5.6" throat "^4.0.0" -jest-runtime@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-24.0.0.tgz#bc80756f5458c2c8e4db86f44b687ff692026c13" +jest-runtime@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-24.1.0.tgz#7c157a2e776609e8cf552f956a5a19ec9c985214" + integrity sha512-59/BY6OCuTXxGeDhEMU7+N33dpMQyXq7MLK07cNSIY/QYt2QZgJ7Tjx+rykBI0skAoigFl0A5tmT8UdwX92YuQ== dependencies: "@babel/core" "^7.1.0" babel-plugin-istanbul "^5.1.0" @@ -5497,35 +5369,36 @@ jest-runtime@^24.0.0: fast-json-stable-stringify "^2.0.0" glob "^7.1.3" graceful-fs "^4.1.15" - jest-config "^24.0.0" + jest-config "^24.1.0" jest-haste-map "^24.0.0" jest-message-util "^24.0.0" jest-regex-util "^24.0.0" - jest-resolve "^24.0.0" - jest-snapshot "^24.0.0" + jest-resolve "^24.1.0" + jest-snapshot "^24.1.0" jest-util "^24.0.0" jest-validate "^24.0.0" micromatch "^3.1.10" realpath-native "^1.0.0" slash "^2.0.0" - strip-bom "3.0.0" - write-file-atomic "^2.4.2" + strip-bom "^3.0.0" + write-file-atomic "2.4.1" yargs "^12.0.2" jest-serializer@^24.0.0: version "24.0.0" resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-24.0.0.tgz#522c44a332cdd194d8c0531eb06a1ee5afb4256b" -jest-snapshot@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-24.0.0.tgz#fb447a753a3271660b3d89d068698014eb14c414" +jest-snapshot@^24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-24.1.0.tgz#85e22f810357aa5994ab61f236617dc2205f2f5b" + integrity sha512-th6TDfFqEmXvuViacU1ikD7xFb7lQsPn2rJl7OEmnfIVpnrx3QNY2t3PE88meeg0u/mQ0nkyvmC05PBqO4USFA== dependencies: "@babel/types" "^7.0.0" chalk "^2.0.1" jest-diff "^24.0.0" jest-matcher-utils "^24.0.0" jest-message-util "^24.0.0" - jest-resolve "^24.0.0" + jest-resolve "^24.1.0" mkdirp "^0.5.1" natural-compare "^1.4.0" pretty-format "^24.0.0" @@ -5544,15 +5417,6 @@ jest-util@^24.0.0: slash "^2.0.0" source-map "^0.6.0" -jest-validate@^23.5.0: - version "23.6.0" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-23.6.0.tgz#36761f99d1ed33fcd425b4e4c5595d62b6597474" - dependencies: - chalk "^2.0.1" - jest-get-type "^22.1.0" - leven "^2.1.0" - pretty-format "^23.6.0" - jest-validate@^24.0.0: version "24.0.0" resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-24.0.0.tgz#aa8571a46983a6538328fef20406b4a496b6c020" @@ -5580,11 +5444,12 @@ jest-worker@^24.0.0: supports-color "^6.1.0" jest@^24.0.0: - version "24.0.0" - resolved "https://registry.yarnpkg.com/jest/-/jest-24.0.0.tgz#b8e2c8e6274e1092c7f56e57762a1fdc7800201e" + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest/-/jest-24.1.0.tgz#b1e1135caefcf2397950ecf7f90e395fde866fd2" + integrity sha512-+q91L65kypqklvlRFfXfdzUKyngQLOcwGhXQaLmVHv+d09LkNXuBuGxlofTFW42XMzu3giIcChchTsCNUjQ78A== dependencies: import-local "^2.0.0" - jest-cli "^24.0.0" + jest-cli "^24.1.0" js-levenshtein@^1.1.3: version "1.1.3" @@ -5598,20 +5463,13 @@ js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" -js-yaml@^3.12.0: +js-yaml@^3.12.0, js-yaml@^3.2.1, js-yaml@^3.9.0: version "3.12.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" dependencies: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@^3.2.1, js-yaml@^3.9.0: - version "3.11.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef" - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -5659,14 +5517,10 @@ json-loader@^0.5.4: version "0.5.7" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.7.tgz#dca14a70235ff82f0ac9a3abeb60d337a365185d" -json-parse-better-errors@^1.0.0: +json-parse-better-errors@^1.0.0, json-parse-better-errors@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" -json-parse-better-errors@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.1.tgz#50183cd1b2d25275de069e9e71b467ac9eab973a" - json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -5979,13 +5833,13 @@ liftoff@^2.5.0: resolve "^1.1.7" lint-staged@^8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-8.1.0.tgz#dbc3ae2565366d8f20efb9f9799d076da64863f2" + version "8.1.5" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-8.1.5.tgz#372476fe1a58b8834eb562ed4c99126bd60bdd79" + integrity sha512-e5ZavfnSLcBJE1BTzRTqw6ly8OkqVyO3GL2M6teSmTBYQ/2BuueD5GIt2RPsP31u/vjKdexUyDCxSyK75q4BDA== dependencies: - "@iamstarkov/listr-update-renderer" "0.4.1" chalk "^2.3.1" commander "^2.14.1" - cosmiconfig "5.0.6" + cosmiconfig "^5.0.2" debug "^3.1.0" dedent "^0.7.0" del "^3.0.0" @@ -5994,9 +5848,9 @@ lint-staged@^8.1.0: g-status "^2.0.2" is-glob "^4.0.0" is-windows "^1.0.2" - jest-validate "^23.5.0" listr "^0.14.2" - lodash "^4.17.5" + listr-update-renderer "^0.5.0" + lodash "^4.17.11" log-symbols "^2.2.0" micromatch "^3.1.8" npm-which "^3.0.1" @@ -6007,6 +5861,7 @@ lint-staged@^8.1.0: staged-git-files "1.1.2" string-argv "^0.0.2" stringify-object "^3.2.2" + yup "^0.26.10" listr-silent-renderer@^1.1.1: version "1.1.1" @@ -6150,7 +6005,7 @@ lodash.templatesettings@^4.0.0: dependencies: lodash._reinterpolate "~3.0.0" -lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1: +lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.2.1: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== @@ -6452,26 +6307,13 @@ minimist@~0.0.1: version "0.0.10" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" -minipass@^2.2.1, minipass@^2.2.4: - version "2.2.4" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.2.4.tgz#03c824d84551ec38a8d1bb5bc350a5a30a354a40" - dependencies: - safe-buffer "^5.1.1" - yallist "^3.0.0" - -minipass@^2.3.4, minipass@^2.3.5: +minipass@^2.2.1, minipass@^2.3.4, minipass@^2.3.5: version "2.3.5" resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.3.5.tgz#cacebe492022497f656b0f0f51e2682a9ed2d848" dependencies: safe-buffer "^5.1.2" yallist "^3.0.0" -minizlib@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.1.0.tgz#11e13658ce46bc3a70a267aac58359d1e0c29ceb" - dependencies: - minipass "^2.2.1" - minizlib@^1.1.1: version "1.2.1" resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.2.1.tgz#dd27ea6136243c7c880684e8672bb3a45fd9b614" @@ -6781,20 +6623,13 @@ npm-logical-tree@^1.2.1: semver "^5.5.0" validate-npm-package-name "^3.0.0" -npm-packlist@^1.1.12: +npm-packlist@^1.1.12, npm-packlist@^1.1.6: version "1.1.12" resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.1.12.tgz#22bde2ebc12e72ca482abd67afc51eb49377243a" dependencies: ignore-walk "^3.0.1" npm-bundled "^1.0.1" -npm-packlist@^1.1.6: - version "1.1.10" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.1.10.tgz#1039db9e985727e464df066f4cf0ab6ef85c398a" - dependencies: - ignore-walk "^3.0.1" - npm-bundled "^1.0.1" - npm-path@^2.0.2: version "2.0.4" resolved "https://registry.yarnpkg.com/npm-path/-/npm-path-2.0.4.tgz#c641347a5ff9d6a09e4d9bce5580c4f505278e64" @@ -7377,10 +7212,6 @@ plugin-error@^0.1.2: arr-union "^2.0.1" extend-shallow "^1.1.2" -pluralize@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" - pn@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" @@ -7404,15 +7235,9 @@ prettier-linter-helpers@^1.0.0: fast-diff "^1.1.2" prettier@^1.16.1: - version "1.16.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.1.tgz#534c2c9d7853f8845e5e078384e71973bd74089f" - -pretty-format@^23.6.0: - version "23.6.0" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-23.6.0.tgz#5eaac8eeb6b33b987b7fe6097ea6a8a146ab5760" - dependencies: - ansi-regex "^3.0.0" - ansi-styles "^3.2.0" + version "1.16.4" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717" + integrity sha512-ZzWuos7TI5CKUeQAtFd6Zhm2s6EpAD/ZLApIhsF9pRvRtM1RFo61dM/4MSRUA0SuLugA/zgrZD8m0BaY46Og7g== pretty-format@^24.0.0: version "24.0.0" @@ -7473,6 +7298,11 @@ promzard@^0.3.0: dependencies: read "1" +property-expr@^1.5.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/property-expr/-/property-expr-1.5.1.tgz#22e8706894a0c8e28d58735804f6ba3a3673314f" + integrity sha512-CGuc0VUTGthpJXL36ydB6jnbyOf/rAHFvmVrJlH+Rg0DqqLFQGAP6hIaxD/G0OAmBJPhXDHuEJigrp0e0wFV6g== + proto-list@~1.2.1: version "1.2.4" resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" @@ -8001,7 +7831,7 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3: +rimraf@2, rimraf@2.6.3, rimraf@^2.2.8, rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.2, rimraf@^2.6.3: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" dependencies: @@ -8066,23 +7896,14 @@ run-queue@^1.0.0, run-queue@^1.0.3: dependencies: aproba "^1.1.1" -rxjs@^6.1.0: - version "6.3.2" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.2.tgz#6a688b16c4e6e980e62ea805ec30648e1c60907f" - dependencies: - tslib "^1.9.0" - -rxjs@^6.3.3: - version "6.3.3" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.3.3.tgz#3c6a7fa420e844a81390fb1158a9ec614f4bad55" +rxjs@^6.3.3, rxjs@^6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.4.0.tgz#f3bb0fe7bda7fb69deac0c16f17b50b0b8790504" + integrity sha512-Z9Yfa11F6B9Sg/BK9MnqnQ+aQYicPLtilXBp2yUtDt2JRCE0h26d33EnfO3ZxoNxG0T92OUucP3Ct7cpfkdFfw== dependencies: tslib "^1.9.0" -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" - -safe-buffer@^5.1.2: +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" @@ -8092,7 +7913,7 @@ safe-regex@^1.1.0: dependencies: ret "~0.1.10" -"safer-buffer@>= 2.1.2 < 3", safer-buffer@^2.1.0: +"safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -8126,18 +7947,10 @@ semver-greatest-satisfied-range@^1.1.0: dependencies: sver-compat "^1.5.0" -"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" - -"semver@2.x || 3.x || 4 || 5", semver@^5.6.0: +"semver@2 || 3 || 4 || 5", "semver@2.x || 3.x || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.5.1, semver@^5.6.0: version "5.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004" -semver@^5.5.1: - version "5.5.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.1.tgz#7dfdd8814bdb7cabc7be0fb1d734cfb66c940477" - semver@~5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" @@ -8241,10 +8054,13 @@ slice-ansi@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" -slice-ansi@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" +slice-ansi@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-2.1.0.tgz#cacd7693461a637a5788d92a7dd4fba068e81636" + integrity sha512-Qu+VC3EwYLldKa1fCxuuvULvSJOKEgk9pi8dZeCVK7TqBfUNTH4sFkk4joj8afVSfAYgJoSOetjx9QWOJ5mYoQ== dependencies: + ansi-styles "^3.2.0" + astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" slide@^1.1.6: @@ -8316,14 +8132,7 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@^0.5.6: - version "0.5.6" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.6.tgz#4435cee46b1aab62b8e8610ce60f788091c51c13" - dependencies: - buffer-from "^1.0.0" - source-map "^0.6.0" - -source-map-support@^0.5.9: +source-map-support@^0.5.6, source-map-support@^0.5.9: version "0.5.9" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.9.tgz#41bc953b2534267ea2d605bccfa7bfa3111ced5f" dependencies: @@ -8338,16 +8147,16 @@ source-map@0.5.x, source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, sourc version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" -source-map@^0.4.4, source-map@~0.4.0, source-map@~0.4.2: +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + +source-map@~0.4.0, source-map@~0.4.2: version "0.4.4" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.4.4.tgz#eba4f5da9c0dc999de68032d8b4f76173652036b" dependencies: amdefine ">=0.0.4" -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: - version "0.6.1" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" - sparkles@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" @@ -8517,6 +8326,15 @@ string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" +string-width@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.0.0.tgz#5a1690a57cc78211fffd9bf24bbe24d090604eb1" + integrity sha512-rr8CUxBbvOZDUvc5lNIJ+OC1nPVpz+Siw9VBtUjB9b6jZehZLFt0JMCZzShFHIsI8cbhm0EsNIfWJMFV3cu3Ew== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.0.0" + string.prototype.padend@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz#f3aaef7c1719f170c5eab1c32bf780d96e21f2f0" @@ -8525,13 +8343,7 @@ string.prototype.padend@^3.0.0: es-abstract "^1.4.3" function-bind "^1.0.2" -string_decoder@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" - dependencies: - safe-buffer "~5.1.0" - -string_decoder@^1.1.1, string_decoder@~1.1.1: +string_decoder@^1.0.0, string_decoder@^1.1.1, string_decoder@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" dependencies: @@ -8578,16 +8390,16 @@ strip-bom-stream@^2.0.0: first-chunk-stream "^2.0.0" strip-bom "^2.0.0" -strip-bom@3.0.0, strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - strip-bom@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" dependencies: is-utf8 "^0.2.0" +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" @@ -8657,20 +8469,26 @@ symbol-tree@^3.2.2: version "3.2.2" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6" +synchronous-promise@^2.0.5: + version "2.0.6" + resolved "https://registry.yarnpkg.com/synchronous-promise/-/synchronous-promise-2.0.6.tgz#de76e0ea2b3558c1e673942e47e714a930fa64aa" + integrity sha512-TyOuWLwkmtPL49LHCX1caIwHjRzcVd62+GF6h8W/jHOeZUFHpnd2XJDVuUlaTaLPH1nuu2M69mfHr5XbQJnf/g== + syntax-error@^1.1.1: version "1.4.0" resolved "https://registry.yarnpkg.com/syntax-error/-/syntax-error-1.4.0.tgz#2d9d4ff5c064acb711594a3e3b95054ad51d907c" dependencies: acorn-node "^1.2.0" -table@^5.0.2: - version "5.1.0" - resolved "https://registry.yarnpkg.com/table/-/table-5.1.0.tgz#69a54644f6f01ad1628f8178715b408dc6bf11f7" +table@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/table/-/table-5.2.3.tgz#cde0cc6eb06751c009efab27e8c820ca5b67b7f2" + integrity sha512-N2RsDAMvDLvYwFcwbPyF3VmVSSkuF+G1e+8inhBLtHpvwXGw4QRPEZhihQNeEN0i1up6/f6ObCJXNdlRG3YVyQ== dependencies: - ajv "^6.5.3" - lodash "^4.17.10" - slice-ansi "1.0.0" - string-width "^2.1.1" + ajv "^6.9.1" + lodash "^4.17.11" + slice-ansi "^2.1.0" + string-width "^3.0.0" tapable@^0.2.7: version "0.2.8" @@ -8684,19 +8502,7 @@ tar@^2.0.0: fstream "^1.0.2" inherits "2" -tar@^4: - version "4.4.1" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.1.tgz#b25d5a8470c976fd7a9a8a350f42c59e9fa81749" - dependencies: - chownr "^1.0.1" - fs-minipass "^1.2.5" - minipass "^2.2.4" - minizlib "^1.1.0" - mkdirp "^0.5.0" - safe-buffer "^5.1.1" - yallist "^3.0.2" - -tar@^4.4.6: +tar@^4, tar@^4.4.6: version "4.4.8" resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.8.tgz#b19eec3fde2a96e64666df9fdb40c5ca1bc3747d" dependencies: @@ -8852,13 +8658,12 @@ to-through@^2.0.0: dependencies: through2 "^2.0.3" -tough-cookie@>=2.3.3, tough-cookie@^2.3.3: - version "2.3.4" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" - dependencies: - punycode "^1.4.1" +toposort@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/toposort/-/toposort-2.0.2.tgz#ae21768175d1559d48bef35420b2f4962f09c330" + integrity sha1-riF2gXXRVZ1IvvNUILL0li8JwzA= -tough-cookie@~2.4.3: +tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@~2.4.3: version "2.4.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.4.3.tgz#53f36da3f47783b0925afa06ff9f3b165280f781" dependencies: @@ -8919,14 +8724,14 @@ typedarray@^0.0.6, typedarray@~0.0.5: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" -uglify-js@3.3.x, uglify-js@^3.0.5: +uglify-js@3.3.x: version "3.3.13" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.3.13.tgz#8a1a89eeb16e2d6a66b0db2b04cb871af3c669cf" dependencies: commander "~2.14.1" source-map "~0.6.1" -uglify-js@^2.6, uglify-js@^2.8.29: +uglify-js@^2.8.29: version "2.8.29" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd" dependencies: @@ -8935,7 +8740,7 @@ uglify-js@^2.6, uglify-js@^2.8.29: optionalDependencies: uglify-to-browserify "~1.0.0" -uglify-js@^3.1.4: +uglify-js@^3.0.5, uglify-js@^3.1.4: version "3.4.9" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3" dependencies: @@ -9413,7 +9218,16 @@ wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" -write-file-atomic@^2.0.0, write-file-atomic@^2.3.0, write-file-atomic@^2.4.2: +write-file-atomic@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.1.tgz#d0b05463c188ae804396fd5ab2a370062af87529" + integrity sha512-TGHFeZEZMnv+gBFRfjAcxL5bPHrsGKtnb4qsFAws7/vlh+QfwAaySIw4AXP9ZskTTh5GWu3FLuJhsWVdiJPGvg== + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" + +write-file-atomic@^2.0.0, write-file-atomic@^2.3.0: version "2.4.2" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.2.tgz#a7181706dfba17855d221140a9c06e15fcdd87b9" integrity sha512-s0b6vB3xIVRLWywa6X9TOMA7k9zio0TMOsl9ZnDkliA/cfJlpHXAscj0gbHVJiTdIuAYpIyqS5GW91fqm6gG5g== @@ -9440,9 +9254,10 @@ write-pkg@^3.1.0: sort-keys "^2.0.0" write-json-file "^2.2.0" -write@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757" +write@1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/write/-/write-1.0.3.tgz#0800e14523b923a387e415123c865616aae0f5c3" + integrity sha512-/lg70HAjtkUgWPVZhZcm+T4hkL8Zbtp1nFNOn3lRrxnlv50SRBv7cR7RqR+GMsd3hUXy9hWBo4CHTbFTcOYwig== dependencies: mkdirp "^0.5.1" @@ -9608,3 +9423,15 @@ yargs@~3.10.0: cliui "^2.1.0" decamelize "^1.0.0" window-size "0.1.0" + +yup@^0.26.10: + version "0.26.10" + resolved "https://registry.yarnpkg.com/yup/-/yup-0.26.10.tgz#3545839663289038faf25facfc07e11fd67c0cb1" + integrity sha512-keuNEbNSnsOTOuGCt3UJW69jDE3O4P+UHAakO7vSeFMnjaitcmlbij/a3oNb9g1Y1KvSKH/7O1R2PQ4m4TRylw== + dependencies: + "@babel/runtime" "7.0.0" + fn-name "~2.0.1" + lodash "^4.17.10" + property-expr "^1.5.0" + synchronous-promise "^2.0.5" + toposort "^2.0.2" From c60c4dd375a137ae3926679622a496fce1d13bcb Mon Sep 17 00:00:00 2001 From: Behrang Yarahmadi Date: Mon, 14 Jan 2019 17:54:21 +0100 Subject: [PATCH 32/58] Partial Application Syntax: Stage 1 (#9343) * add partial application syntax and some tests * remove unnecessary error message and hasPartial function from parseNewArguments * add types for PartialExpression * Update the tests * rename PartialExpression to Partial * move Partial from expressions to types and rename to ArgumentPlaceholder * add tests for ArgumentPlaceholder in babel-generator * rename Partial to ArgumentPlaceholder * update the tests * remove alias from the type and undo changes in generated folder * adds a nice error message * better definition for the type * auto-generated files * update the conditional for allowPlaceholder message and tests * update CallExpression definition to accept ArgumentPlaceholder * change description * clean up * indent ArgumentPlaceholder entry and revert unwanted changes --- .../babel-generator/src/generators/types.js | 4 + .../types/ArgumentPlaceholder/input.js | 12 + .../types/ArgumentPlaceholder/options.json | 1 + .../types/ArgumentPlaceholder/output.js | 14 + packages/babel-parser/ast/spec.md | 9 + .../babel-parser/src/parser/expression.js | 13 +- packages/babel-parser/src/types.js | 2 + .../partial-application/call-expr/input.js | 1 + .../call-expr/options.json | 3 + .../partial-application/call-expr/output.json | 99 ++++++ .../call-on-SuperProperty/input.js | 5 + .../call-on-SuperProperty/options.json | 3 + .../call-on-SuperProperty/output.json | 305 ++++++++++++++++++ .../partial-application/for-any-arg/input.js | 3 + .../for-any-arg/options.json | 3 + .../for-any-arg/output.json | 260 +++++++++++++++ .../partial-application/from-left/input.js | 3 + .../from-left/options.json | 3 + .../partial-application/from-left/output.json | 230 +++++++++++++ .../partial-application/from-right/input.js | 3 + .../from-right/options.json | 3 + .../from-right/output.json | 230 +++++++++++++ .../partial-application/in-SuperCall/input.js | 6 + .../in-SuperCall/options.json | 4 + .../partial-application/in-new/input.js | 1 + .../partial-application/in-new/options.json | 4 + .../input.js | 1 + .../options.json | 4 + .../top-level-argument-method-call/input.js | 1 + .../options.json | 4 + .../.npmignore | 3 + .../README.md | 19 ++ .../package.json | 23 ++ .../src/index.js | 13 + .../src/asserts/generated/index.js | 6 + .../src/builders/generated/index.js | 4 + packages/babel-types/src/definitions/core.js | 7 +- .../src/definitions/experimental.js | 2 + .../src/validators/generated/index.js | 14 + 39 files changed, 1323 insertions(+), 2 deletions(-) create mode 100644 packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/input.js create mode 100644 packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/options.json create mode 100644 packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/output.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/from-left/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/from-left/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/from-left/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/from-right/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/from-right/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/from-right/output.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/in-new/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-binary-expression/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-binary-expression/options.json create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-method-call/input.js create mode 100644 packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-method-call/options.json create mode 100644 packages/babel-plugin-syntax-partial-application/.npmignore create mode 100644 packages/babel-plugin-syntax-partial-application/README.md create mode 100644 packages/babel-plugin-syntax-partial-application/package.json create mode 100644 packages/babel-plugin-syntax-partial-application/src/index.js diff --git a/packages/babel-generator/src/generators/types.js b/packages/babel-generator/src/generators/types.js index 491ae7513828..fdd090dd4113 100644 --- a/packages/babel-generator/src/generators/types.js +++ b/packages/babel-generator/src/generators/types.js @@ -7,6 +7,10 @@ export function Identifier(node: Object) { }); } +export function ArgumentPlaceholder() { + this.token("?"); +} + export function RestElement(node: Object) { this.token("..."); this.print(node.argument, node); diff --git a/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/input.js b/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/input.js new file mode 100644 index 000000000000..29e9b90f83e0 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/input.js @@ -0,0 +1,12 @@ +foo(?); +foo(?, x); +foo(x, ?); +foo(?, x, ?); +obj.foo(x, ?); +obj.foo(?, x); +obj.foo(?, x, ?); +class foo { + constructor() { + baz(this, () => super.bar(?)); + } +} diff --git a/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/options.json b/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/options.json new file mode 100644 index 000000000000..eff064512269 --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/options.json @@ -0,0 +1 @@ +{ "plugins": ["partialApplication"] } diff --git a/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/output.js b/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/output.js new file mode 100644 index 000000000000..7cb1b16bd55e --- /dev/null +++ b/packages/babel-generator/test/fixtures/types/ArgumentPlaceholder/output.js @@ -0,0 +1,14 @@ +foo(?); +foo(?, x); +foo(x, ?); +foo(?, x, ?); +obj.foo(x, ?); +obj.foo(?, x); +obj.foo(?, x, ?); + +class foo { + constructor() { + baz(this, () => super.bar(?)); + } + +} \ No newline at end of file diff --git a/packages/babel-parser/ast/spec.md b/packages/babel-parser/ast/spec.md index 716097280327..b4f5372cb440 100644 --- a/packages/babel-parser/ast/spec.md +++ b/packages/babel-parser/ast/spec.md @@ -72,6 +72,7 @@ These are the core @babel/parser (babylon) AST node types. - [LogicalExpression](#logicalexpression) - [LogicalOperator](#logicaloperator) - [SpreadElement](#spreadelement) + - [ArgumentPlaceholder](#argumentplaceholder) - [MemberExpression](#memberexpression) - [BindExpression](#bindexpression) - [ConditionalExpression](#conditionalexpression) @@ -862,6 +863,14 @@ interface SpreadElement <: Node { } ``` +### ArgumentPlaceholder + +```js +interface ArgumentPlaceholder <: Node { + type: "ArgumentPlaceholder"; +} +``` + ### MemberExpression ```js diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 9b05a76d560f..516aba3aa2db 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -323,7 +323,6 @@ export default class ExpressionParser extends LValParser { const operator = this.state.value; node.left = left; node.operator = operator; - if ( operator === "**" && left.type === "UnaryExpression" && @@ -634,6 +633,7 @@ export default class ExpressionParser extends LValParser { tt.parenR, possibleAsync, base.type === "Import", + base.type !== "Super", ); if (!state.optionalChainMember) { this.finishCallExpression(node); @@ -744,6 +744,7 @@ export default class ExpressionParser extends LValParser { close: TokenType, possibleAsyncArrow: boolean, dynamicImport?: boolean, + allowPlaceholder?: boolean, ): $ReadOnlyArray { const elts = []; let innerParenStart; @@ -776,6 +777,7 @@ export default class ExpressionParser extends LValParser { false, possibleAsyncArrow ? { start: 0 } : undefined, possibleAsyncArrow ? { start: 0 } : undefined, + allowPlaceholder, ), ); } @@ -1945,6 +1947,7 @@ export default class ExpressionParser extends LValParser { allowEmpty: ?boolean, refShorthandDefaultPos: ?Pos, refNeedsArrowPos: ?Pos, + allowPlaceholder: ?boolean, ): ?N.Expression { let elt; if (allowEmpty && this.match(tt.comma)) { @@ -1957,6 +1960,14 @@ export default class ExpressionParser extends LValParser { spreadNodeStartPos, spreadNodeStartLoc, ); + } else if (this.match(tt.question)) { + this.expectPlugin("partialApplication"); + if (!allowPlaceholder) { + this.raise(this.state.start, "Unexpected argument placeholder"); + } + const node = this.startNode(); + this.next(); + elt = this.finishNode(node, "ArgumentPlaceholder"); } else { elt = this.parseMaybeAssign( false, diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 696589b3e650..35d79c9ce925 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -340,6 +340,8 @@ export type VariableDeclarator = NodeBase & { // Misc +export type ArgumentPlaceholder = NodeBase & { type: "ArgumentPlaceholder" }; + export type Decorator = NodeBase & { type: "Decorator", expression: Expression, diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/input.js new file mode 100644 index 000000000000..74512f8aace5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/input.js @@ -0,0 +1 @@ +foo(?) diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/options.json new file mode 100644 index 000000000000..87414aef43de --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["partialApplication"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/output.json b/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/output.json new file mode 100644 index 000000000000..1846d675488a --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/call-expr/output.json @@ -0,0 +1,99 @@ +{ + "type": "File", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [ + { + "type": "ArgumentPlaceholder", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/input.js new file mode 100644 index 000000000000..ed9915fb3ccb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/input.js @@ -0,0 +1,5 @@ +class foo { + constructor() { + baz(this, () => super.bar(?)); + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/options.json new file mode 100644 index 000000000000..87414aef43de --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["partialApplication"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/output.json b/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/output.json new file mode 100644 index 000000000000..185313af1242 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/call-on-SuperProperty/output.json @@ -0,0 +1,305 @@ +{ + "type": "File", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 10, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "body": [ + { + "type": "ClassMethod", + "start": 16, + "end": 76, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "static": false, + "key": { + "type": "Identifier", + "start": 16, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "constructor" + }, + "name": "constructor" + }, + "computed": false, + "kind": "constructor", + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 76, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "body": [ + { + "type": "ExpressionStatement", + "start": 40, + "end": 70, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 38 + } + }, + "expression": { + "type": "CallExpression", + "start": 40, + "end": 69, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 37 + } + }, + "callee": { + "type": "Identifier", + "start": 40, + "end": 43, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "baz" + }, + "name": "baz" + }, + "arguments": [ + { + "type": "ThisExpression", + "start": 44, + "end": 48, + "loc": { + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 16 + } + } + }, + { + "type": "ArrowFunctionExpression", + "start": 50, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 18 + }, + "end": { + "line": 3, + "column": 36 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "CallExpression", + "start": 56, + "end": 68, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 36 + } + }, + "callee": { + "type": "MemberExpression", + "start": 56, + "end": 65, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 33 + } + }, + "object": { + "type": "Super", + "start": 56, + "end": 61, + "loc": { + "start": { + "line": 3, + "column": 24 + }, + "end": { + "line": 3, + "column": 29 + } + } + }, + "property": { + "type": "Identifier", + "start": 62, + "end": 65, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 33 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "computed": false + }, + "arguments": [ + { + "type": "ArgumentPlaceholder", + "start": 66, + "end": 67, + "loc": { + "start": { + "line": 3, + "column": 34 + }, + "end": { + "line": 3, + "column": 35 + } + } + } + ] + } + } + ] + } + } + ], + "directives": [] + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/input.js new file mode 100644 index 000000000000..58db6e91a913 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/input.js @@ -0,0 +1,3 @@ +foo(?,x,?) + +bar.foo(?, x, ?) diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/options.json new file mode 100644 index 000000000000..87414aef43de --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["partialApplication"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/output.json b/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/output.json new file mode 100644 index 000000000000..29f5266444a5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/for-any-arg/output.json @@ -0,0 +1,260 @@ +{ + "type": "File", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [ + { + "type": "ArgumentPlaceholder", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "ArgumentPlaceholder", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 9 + } + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "expression": { + "type": "CallExpression", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "callee": { + "type": "MemberExpression", + "start": 12, + "end": 19, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "object": { + "type": "Identifier", + "start": 12, + "end": 15, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "property": { + "type": "Identifier", + "start": 16, + "end": 19, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false + }, + "arguments": [ + { + "type": "ArgumentPlaceholder", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 3, + "column": 12 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "ArgumentPlaceholder", + "start": 26, + "end": 27, + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 15 + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/input.js new file mode 100644 index 000000000000..c689537246d2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/input.js @@ -0,0 +1,3 @@ +foo(x,?) + +bar.foo(x,?) diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/options.json new file mode 100644 index 000000000000..87414aef43de --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["partialApplication"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/output.json b/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/output.json new file mode 100644 index 000000000000..d90ab651eebf --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/from-left/output.json @@ -0,0 +1,230 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [ + { + "type": "Identifier", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "ArgumentPlaceholder", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + } + } + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 10, + "end": 22, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "expression": { + "type": "CallExpression", + "start": 10, + "end": 22, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "callee": { + "type": "MemberExpression", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "object": { + "type": "Identifier", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "property": { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false + }, + "arguments": [ + { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "x" + }, + "name": "x" + }, + { + "type": "ArgumentPlaceholder", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + } + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/input.js new file mode 100644 index 000000000000..b566c1df5b1b --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/input.js @@ -0,0 +1,3 @@ +foo(?,x) + +bar.foo(?,x) diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/options.json new file mode 100644 index 000000000000..87414aef43de --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["partialApplication"] +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/output.json b/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/output.json new file mode 100644 index 000000000000..ec82545ec334 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/from-right/output.json @@ -0,0 +1,230 @@ +{ + "type": "File", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "expression": { + "type": "CallExpression", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "callee": { + "type": "Identifier", + "start": 0, + "end": 3, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 3 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "arguments": [ + { + "type": "ArgumentPlaceholder", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + } + }, + { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + } + }, + { + "type": "ExpressionStatement", + "start": 10, + "end": 22, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "expression": { + "type": "CallExpression", + "start": 10, + "end": 22, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "callee": { + "type": "MemberExpression", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "object": { + "type": "Identifier", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 3 + }, + "identifierName": "bar" + }, + "name": "bar" + }, + "property": { + "type": "Identifier", + "start": 14, + "end": 17, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + }, + "identifierName": "foo" + }, + "name": "foo" + }, + "computed": false + }, + "arguments": [ + { + "type": "ArgumentPlaceholder", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 9 + } + } + }, + { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "x" + }, + "name": "x" + } + ] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/input.js new file mode 100644 index 000000000000..eac2ab9cb775 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/input.js @@ -0,0 +1,6 @@ +class Foo extends Bar { + constructor(x){ + super(x, 1, ?, ?); + this.x = x; + } +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/options.json new file mode 100644 index 000000000000..58192a87fd99 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/in-SuperCall/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["partialApplication"], + "throws": "Unexpected argument placeholder (3:16)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/input.js new file mode 100644 index 000000000000..36314ea52964 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/input.js @@ -0,0 +1 @@ +new bar(x, ?, 2, ?) diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json new file mode 100644 index 000000000000..3b09c84c03eb --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/in-new/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["partialApplication"], + "throws": "Unexpected argument placeholder (1:11)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-binary-expression/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-binary-expression/input.js new file mode 100644 index 000000000000..a511c8bf7d89 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-binary-expression/input.js @@ -0,0 +1 @@ +? + x diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-binary-expression/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-binary-expression/options.json new file mode 100644 index 000000000000..8abbd078986f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-binary-expression/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["partialApplication"], + "throws": "Unexpected token (1:0)" +} diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-method-call/input.js b/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-method-call/input.js new file mode 100644 index 000000000000..3308d8780855 --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-method-call/input.js @@ -0,0 +1 @@ +?.f() diff --git a/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-method-call/options.json b/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-method-call/options.json new file mode 100644 index 000000000000..8abbd078986f --- /dev/null +++ b/packages/babel-parser/test/fixtures/experimental/partial-application/top-level-argument-method-call/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["partialApplication"], + "throws": "Unexpected token (1:0)" +} diff --git a/packages/babel-plugin-syntax-partial-application/.npmignore b/packages/babel-plugin-syntax-partial-application/.npmignore new file mode 100644 index 000000000000..f9806945836e --- /dev/null +++ b/packages/babel-plugin-syntax-partial-application/.npmignore @@ -0,0 +1,3 @@ +src +test +*.log diff --git a/packages/babel-plugin-syntax-partial-application/README.md b/packages/babel-plugin-syntax-partial-application/README.md new file mode 100644 index 000000000000..d50284617998 --- /dev/null +++ b/packages/babel-plugin-syntax-partial-application/README.md @@ -0,0 +1,19 @@ +# @babel/plugin-syntax-partial-application + +> Allow parsing of optional properties + +See our website [@babel/plugin-syntax-partial-application](https://babeljs.io/docs/en/next/babel-plugin-syntax-partial-application.html) for more information. + +## Install + +Using npm: + +```sh +npm install --save-dev @babel/plugin-syntax-partial-application +``` + +or using yarn: + +```sh +yarn add @babel/plugin-syntax-partial-application --dev +``` diff --git a/packages/babel-plugin-syntax-partial-application/package.json b/packages/babel-plugin-syntax-partial-application/package.json new file mode 100644 index 000000000000..603cc408c815 --- /dev/null +++ b/packages/babel-plugin-syntax-partial-application/package.json @@ -0,0 +1,23 @@ +{ + "name": "@babel/plugin-syntax-partial-application", + "version": "7.2.0", + "description": "Allow parsing of partial application syntax", + "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-partial-application", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "main": "lib/index.js", + "keywords": [ + "babel-plugin" + ], + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + }, + "devDependencies": { + "@babel/core": "^7.2.0" + } +} diff --git a/packages/babel-plugin-syntax-partial-application/src/index.js b/packages/babel-plugin-syntax-partial-application/src/index.js new file mode 100644 index 000000000000..aafcfc315e2a --- /dev/null +++ b/packages/babel-plugin-syntax-partial-application/src/index.js @@ -0,0 +1,13 @@ +import { declare } from "@babel/helper-plugin-utils"; + +export default declare(api => { + api.assertVersion(7); + + return { + name: "syntax-partial-application", + + manipulateOptions(opts, parserOpts) { + parserOpts.plugins.push("partialApplication"); + }, + }; +}); diff --git a/packages/babel-types/src/asserts/generated/index.js b/packages/babel-types/src/asserts/generated/index.js index 890e3d6e8d3d..34a6a125a252 100644 --- a/packages/babel-types/src/asserts/generated/index.js +++ b/packages/babel-types/src/asserts/generated/index.js @@ -660,6 +660,12 @@ export function assertParenthesizedExpression( ): void { assert("ParenthesizedExpression", node, opts); } +export function assertArgumentPlaceholder( + node: Object, + opts?: Object = {}, +): void { + assert("ArgumentPlaceholder", node, opts); +} export function assertAwaitExpression(node: Object, opts?: Object = {}): void { assert("AwaitExpression", node, opts); } diff --git a/packages/babel-types/src/builders/generated/index.js b/packages/babel-types/src/builders/generated/index.js index a77b43cbb613..6b787e0bb3f8 100644 --- a/packages/babel-types/src/builders/generated/index.js +++ b/packages/babel-types/src/builders/generated/index.js @@ -596,6 +596,10 @@ export function ParenthesizedExpression(...args: Array): Object { return builder("ParenthesizedExpression", ...args); } export { ParenthesizedExpression as parenthesizedExpression }; +export function ArgumentPlaceholder(...args: Array): Object { + return builder("ArgumentPlaceholder", ...args); +} +export { ArgumentPlaceholder as argumentPlaceholder }; export function AwaitExpression(...args: Array): Object { return builder("AwaitExpression", ...args); } diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index a92e8d2725b8..214fa6ccd451 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -138,7 +138,12 @@ defineType("CallExpression", { validate: chain( assertValueType("array"), assertEach( - assertNodeType("Expression", "SpreadElement", "JSXNamespacedName"), + assertNodeType( + "Expression", + "SpreadElement", + "JSXNamespacedName", + "ArgumentPlaceholder", + ), ), ), }, diff --git a/packages/babel-types/src/definitions/experimental.js b/packages/babel-types/src/definitions/experimental.js index 6498e9c329e3..ed088af74bd6 100644 --- a/packages/babel-types/src/definitions/experimental.js +++ b/packages/babel-types/src/definitions/experimental.js @@ -10,6 +10,8 @@ import { classMethodOrDeclareMethodCommon, } from "./es2015"; +defineType("ArgumentPlaceholder", {}); + defineType("AwaitExpression", { builder: ["argument"], visitor: ["argument"], diff --git a/packages/babel-types/src/validators/generated/index.js b/packages/babel-types/src/validators/generated/index.js index ab746105189c..c23ddcf11d97 100644 --- a/packages/babel-types/src/validators/generated/index.js +++ b/packages/babel-types/src/validators/generated/index.js @@ -2093,6 +2093,20 @@ export function isParenthesizedExpression( return false; } +export function isArgumentPlaceholder(node: ?Object, opts?: Object): boolean { + if (!node) return false; + + const nodeType = node.type; + if (nodeType === "ArgumentPlaceholder") { + if (typeof opts === "undefined") { + return true; + } else { + return shallowEqual(node, opts); + } + } + + return false; +} export function isAwaitExpression(node: ?Object, opts?: Object): boolean { if (!node) return false; From d832c0f434f1c272ad7af3a333b306e6227aa720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 5 Mar 2019 00:45:42 +0100 Subject: [PATCH 33/58] Add parser support for placeholders (#9364) --- .../babel-parser/src/parser/expression.js | 13 +- packages/babel-parser/src/parser/statement.js | 45 +-- packages/babel-parser/src/parser/util.js | 7 + packages/babel-parser/src/plugin-utils.js | 9 +- .../babel-parser/src/plugins/placeholders.js | 315 ++++++++++++++++++ packages/babel-parser/src/types.js | 17 + .../failure-spaces/options.json | 2 +- .../failure-spaces/options.json | 2 +- .../placeholders/_errors/no-plugin/input.js | 1 + .../_errors/no-plugin/options.json | 4 + .../placeholders/_errors/space-after/input.js | 1 + .../_errors/space-after/options.json | 4 + .../_errors/space-before/input.js | 1 + .../_errors/space-before/options.json | 4 + .../arrow/async-parenless/input.js | 1 + .../arrow/async-parenless/options.json | 4 + .../placeholders/arrow/async/input.js | 1 + .../placeholders/arrow/async/output.json | 136 ++++++++ .../arrow/sync-parenless/input.js | 1 + .../arrow/sync-parenless/options.json | 4 + .../fixtures/placeholders/arrow/sync/input.js | 1 + .../placeholders/arrow/sync/output.json | 136 ++++++++ .../class/body_expression/input.js | 1 + .../class/body_expression/output.json | 116 +++++++ .../class/body_statement/input.js | 1 + .../class/body_statement/output.json | 101 ++++++ .../placeholders/class/decorators/input.js | 2 + .../class/decorators/options.json | 6 + .../placeholders/class/decorators/output.json | 134 ++++++++ .../placeholders/class/id-body/input.js | 1 + .../placeholders/class/id-body/output.json | 117 +++++++ .../placeholders/class/id-super-body/input.js | 1 + .../class/id-super-body/output.json | 149 +++++++++ .../placeholders/class/id-super/input.js | 1 + .../placeholders/class/id-super/output.json | 132 ++++++++ .../placeholders/class/id_expression/input.js | 1 + .../class/id_expression/output.json | 132 ++++++++ .../placeholders/class/id_statement/input.js | 1 + .../class/id_statement/output.json | 100 ++++++ .../placeholders/class/super/input.js | 1 + .../placeholders/class/super/output.json | 116 +++++++ .../placeholders/export/declaration/input.js | 1 + .../export/declaration/output.json | 100 ++++++ .../export/default-default-from/input.js | 1 + .../export/default-default-from/options.json | 7 + .../export/default-named-from-2/input.js | 1 + .../export/default-named-from-2/options.json | 7 + .../export/default-named-from-3/input.js | 1 + .../export/default-named-from-3/options.json | 7 + .../export/default-named-from/input.js | 1 + .../export/default-named-from/options.json | 7 + .../export/named-alias-2/input.js | 1 + .../export/named-alias-2/output.json | 119 +++++++ .../export/named-alias-3/input.js | 1 + .../export/named-alias-3/output.json | 135 ++++++++ .../placeholders/export/named-alias/input.js | 1 + .../export/named-alias/output.json | 119 +++++++ .../placeholders/export/named-from-2/input.js | 1 + .../export/named-from-2/output.json | 135 ++++++++ .../placeholders/export/named-from-3/input.js | 1 + .../export/named-from-3/output.json | 167 ++++++++++ .../export/named-from-alias-2/input.js | 1 + .../export/named-from-alias-2/output.json | 138 ++++++++ .../export/named-from-alias-3/input.js | 1 + .../export/named-from-alias-3/output.json | 154 +++++++++ .../export/named-from-alias/input.js | 1 + .../export/named-from-alias/output.json | 138 ++++++++ .../placeholders/export/named-from/input.js | 1 + .../export/named-from/output.json | 154 +++++++++ .../placeholders/export/named/input.js | 1 + .../placeholders/export/named/output.json | 135 ++++++++ .../fixtures/placeholders/export/options.json | 4 + .../placeholders/export/star-from-2/input.js | 1 + .../export/star-from-2/options.json | 7 + .../placeholders/export/star-from-3/input.js | 1 + .../export/star-from-3/options.json | 7 + .../placeholders/export/star-from/input.js | 1 + .../placeholders/export/star-from/output.json | 83 +++++ .../placeholders/expression/01/input.js | 1 + .../placeholders/expression/01/output.json | 182 ++++++++++ .../placeholders/expression/options.json | 3 + .../placeholders/function/body/input.js | 1 + .../placeholders/function/body/output.json | 103 ++++++ .../function/id-params-body/input.js | 1 + .../function/id-params-body/output.json | 186 +++++++++++ .../function/id_declaration/input.js | 1 + .../function/id_declaration/output.json | 103 ++++++ .../function/id_expression/input.js | 1 + .../function/id_expression/output.json | 135 ++++++++ .../placeholders/function/param/input.js | 1 + .../placeholders/function/param/output.json | 121 +++++++ .../import/default-file/input.mjs | 1 + .../import/default-file/output.json | 133 ++++++++ .../import/default-named-2/input.mjs | 1 + .../import/default-named-2/output.json | 169 ++++++++++ .../import/default-named-3/input.mjs | 1 + .../import/default-named-3/output.json | 201 +++++++++++ .../import/default-named/input.mjs | 1 + .../import/default-named/output.json | 185 ++++++++++ .../import/default-star-2/input.mjs | 1 + .../import/default-star-2/output.json | 152 +++++++++ .../import/default-star-3/input.mjs | 1 + .../import/default-star-3/output.json | 168 ++++++++++ .../import/default-star/input.mjs | 1 + .../import/default-star/output.json | 152 +++++++++ .../placeholders/import/default/input.mjs | 1 + .../placeholders/import/default/output.json | 120 +++++++ .../placeholders/import/file-empty/input.mjs | 1 + .../import/file-empty/output.json | 84 +++++ .../placeholders/import/file/input.mjs | 1 + .../placeholders/import/file/output.json | 84 +++++ .../import/named-alias-2/input.mjs | 1 + .../import/named-alias-2/output.json | 137 ++++++++ .../import/named-alias-3/input.mjs | 1 + .../import/named-alias-3/output.json | 153 +++++++++ .../placeholders/import/named-alias/input.mjs | 1 + .../import/named-alias/output.json | 137 ++++++++ .../placeholders/import/named/input.mjs | 1 + .../placeholders/import/named/output.json | 153 +++++++++ .../fixtures/placeholders/import/options.json | 4 + .../placeholders/import/star/input.mjs | 1 + .../placeholders/import/star/output.json | 120 +++++++ .../fixtures/placeholders/labels/asi/input.js | 4 + .../placeholders/labels/asi/output.json | 169 ++++++++++ .../placeholders/labels/break/input.js | 3 + .../placeholders/labels/break/output.json | 133 ++++++++ .../placeholders/labels/continue/input.js | 3 + .../placeholders/labels/continue/output.json | 168 ++++++++++ .../labels/labeled-statement/input.js | 1 + .../labels/labeled-statement/output.json | 118 +++++++ .../test/fixtures/placeholders/options.json | 3 + .../placeholders/statement/asi/input.js | 2 + .../placeholders/statement/asi/output.json | 101 ++++++ .../placeholders/statement/nested/input.js | 1 + .../placeholders/statement/nested/output.json | 104 ++++++ .../placeholders/statement/top-level/input.js | 1 + .../statement/top-level/output.json | 68 ++++ .../try/try-catch-finally/input.js | 1 + .../try/try-catch-finally/output.json | 166 +++++++++ .../try/with-catch-param/input.js | 1 + .../try/with-catch-param/output.json | 150 +++++++++ 141 files changed, 7630 insertions(+), 36 deletions(-) create mode 100644 packages/babel-parser/src/plugins/placeholders.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/_errors/space-after/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/_errors/space-before/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/arrow/async/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/arrow/async/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/arrow/sync/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/arrow/sync/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/body_expression/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/body_expression/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/body_statement/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/body_statement/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/decorators/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/decorators/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/decorators/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id-body/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id-body/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id-super-body/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id-super-body/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id-super/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id-super/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id_expression/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id_expression/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id_statement/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/id_statement/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/super/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/class/super/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/declaration/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/declaration/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/default-default-from/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/default-named-from/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-alias/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-alias/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-2/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-2/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-3/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-3/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named-from/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/named/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/star-from-2/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/star-from-3/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/star-from/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/export/star-from/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/expression/01/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/expression/01/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/expression/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/body/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/body/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/id-params-body/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/id-params-body/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/id_declaration/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/id_declaration/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/id_expression/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/id_expression/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/param/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/function/param/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-file/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-file/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-named-2/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-named-2/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-named-3/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-named-3/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-named/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-named/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-star-2/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-star-2/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-star-3/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-star-3/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-star/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default-star/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/default/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/file-empty/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/file-empty/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/file/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/file/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/named-alias-2/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/named-alias-2/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/named-alias-3/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/named-alias-3/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/named-alias/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/named-alias/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/named/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/named/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/star/input.mjs create mode 100644 packages/babel-parser/test/fixtures/placeholders/import/star/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/labels/asi/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/labels/asi/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/labels/break/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/labels/break/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/labels/continue/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/labels/continue/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/labels/labeled-statement/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/labels/labeled-statement/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/options.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/statement/asi/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/statement/asi/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/statement/nested/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/statement/nested/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/statement/top-level/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/statement/top-level/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/output.json create mode 100644 packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/input.js create mode 100644 packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/output.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 516aba3aa2db..b9195c3a9751 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1048,19 +1048,8 @@ export default class ExpressionParser extends LValParser { if (isPrivate) { this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]); const node = this.startNode(); - const columnHashEnd = this.state.end; this.next(); - const columnIdentifierStart = this.state.start; - - const spacesBetweenHashAndIdentifier = - columnIdentifierStart - columnHashEnd; - if (spacesBetweenHashAndIdentifier != 0) { - this.raise( - columnIdentifierStart, - "Unexpected space between # and identifier", - ); - } - + this.assertNoSpace("Unexpected space between # and identifier"); node.id = this.parseIdentifier(true); return this.finishNode(node, "PrivateName"); } else { diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 22cc9b24a001..47b3c9f2c7f0 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -416,15 +416,24 @@ export default class StatementParser extends ExpressionParser { if (this.isLineTerminator()) { node.label = null; - } else if (!this.match(tt.name)) { - this.unexpected(); } else { node.label = this.parseIdentifier(); this.semicolon(); } - // Verify that there is an actual destination to break or - // continue to. + this.verifyBreakContinue(node, keyword); + + return this.finishNode( + node, + isBreak ? "BreakStatement" : "ContinueStatement", + ); + } + + verifyBreakContinue( + node: N.BreakStatement | N.ContinueStatement, + keyword: string, + ) { + const isBreak = keyword === "break"; let i; for (i = 0; i < this.state.labels.length; ++i) { const lab = this.state.labels[i]; @@ -436,10 +445,6 @@ export default class StatementParser extends ExpressionParser { if (i === this.state.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); } - return this.finishNode( - node, - isBreak ? "BreakStatement" : "ContinueStatement", - ); } parseDebuggerStatement(node: N.DebuggerStatement): N.DebuggerStatement { @@ -800,7 +805,7 @@ export default class StatementParser extends ExpressionParser { parseExpressionStatement( node: N.ExpressionStatement, expr: N.Expression, - ): N.ExpressionStatement { + ): N.Statement { node.expression = expr; this.semicolon(); return this.finishNode(node, "ExpressionStatement"); @@ -1024,6 +1029,7 @@ export default class StatementParser extends ExpressionParser { ): T { const isStatement = statement & FUNC_STATEMENT; const isHangingStatement = statement & FUNC_HANGING_STATEMENT; + const requireId = !!isStatement && !(statement & FUNC_NULLABLE_ID); this.initFunction(node, isAsync); @@ -1036,10 +1042,7 @@ export default class StatementParser extends ExpressionParser { node.generator = this.eat(tt.star); if (isStatement) { - node.id = - statement & FUNC_NULLABLE_ID && !this.match(tt.name) - ? null - : this.parseIdentifier(); + node.id = this.parseFunctionId(requireId); if (node.id && !isHangingStatement) { // If it is a regular function declaration in sloppy mode, then it is // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding @@ -1067,7 +1070,7 @@ export default class StatementParser extends ExpressionParser { this.scope.enter(functionFlags(node.async, node.generator)); if (!isStatement) { - node.id = this.match(tt.name) ? this.parseIdentifier() : null; + node.id = this.parseFunctionId(); } this.parseFunctionParams(node); @@ -1090,6 +1093,10 @@ export default class StatementParser extends ExpressionParser { return node; } + parseFunctionId(requireId?: boolean): ?N.Identifier { + return requireId || this.match(tt.name) ? this.parseIdentifier() : null; + } + parseFunctionParams(node: N.Function, allowModifiers?: boolean): void { const oldInParameters = this.state.inParameters; this.state.inParameters = true; @@ -1122,7 +1129,7 @@ export default class StatementParser extends ExpressionParser { this.parseClassId(node, isStatement, optionalId); this.parseClassSuper(node); - this.parseClassBody(node); + node.body = this.parseClassBody(!!node.superClass); this.state.strict = oldStrict; @@ -1149,7 +1156,7 @@ export default class StatementParser extends ExpressionParser { ); } - parseClassBody(node: N.Class): void { + parseClassBody(constructorAllowsSuper: boolean): N.ClassBody { this.state.classLevel++; const state = { hadConstructor: false }; @@ -1159,8 +1166,6 @@ export default class StatementParser extends ExpressionParser { this.expect(tt.braceL); - const constructorAllowsSuper = node.superClass !== null; - // For the smartPipelines plugin: Disable topic references from outer // contexts within the class body. They are permitted in test expressions, // outside of the class body. @@ -1212,9 +1217,9 @@ export default class StatementParser extends ExpressionParser { ); } - node.body = this.finishNode(classBody, "ClassBody"); - this.state.classLevel--; + + return this.finishNode(classBody, "ClassBody"); } parseClassMember( diff --git a/packages/babel-parser/src/parser/util.js b/packages/babel-parser/src/parser/util.js index 6d5234793b6d..1681078d40f9 100644 --- a/packages/babel-parser/src/parser/util.js +++ b/packages/babel-parser/src/parser/util.js @@ -113,6 +113,13 @@ export default class UtilParser extends Tokenizer { this.eat(type) || this.unexpected(pos, type); } + // Throws if the current token and the prev one are separated by a space. + assertNoSpace(message: string = "Unexpected space."): void { + if (this.state.start > this.state.lastTokEnd) { + this.raise(this.state.lastTokEnd, message); + } + } + // Raise an unexpected token error. Can take the expected token type // instead of a message string. diff --git a/packages/babel-parser/src/plugin-utils.js b/packages/babel-parser/src/plugin-utils.js index d92800f46427..d9e368e666b9 100644 --- a/packages/babel-parser/src/plugin-utils.js +++ b/packages/babel-parser/src/plugin-utils.js @@ -88,12 +88,17 @@ import estree from "./plugins/estree"; import flow from "./plugins/flow"; import jsx from "./plugins/jsx"; import typescript from "./plugins/typescript"; +import placeholders from "./plugins/placeholders"; -// NOTE: estree must load first; flow and typescript must load last. -export const mixinPluginNames = ["estree", "jsx", "flow", "typescript"]; +// NOTE: order is important. estree must come first; placeholders must come last. export const mixinPlugins: { [name: string]: MixinPlugin } = { estree, jsx, flow, typescript, + placeholders, }; + +export const mixinPluginNames: $ReadOnlyArray = Object.keys( + mixinPlugins, +); diff --git a/packages/babel-parser/src/plugins/placeholders.js b/packages/babel-parser/src/plugins/placeholders.js new file mode 100644 index 000000000000..50956c9bb83b --- /dev/null +++ b/packages/babel-parser/src/plugins/placeholders.js @@ -0,0 +1,315 @@ +// @flow + +import * as charCodes from "charcodes"; + +import { types as tt, TokenType } from "../tokenizer/types"; +import type Parser from "../parser"; +import * as N from "../types"; + +tt.placeholder = new TokenType("%%", { startsExpr: true }); + +export type PlaceholderTypes = + | "Identifier" + | "StringLiteral" + | "Expression" + | "Statement" + | "Declaration" + | "BlockStatement" + | "ClassBody" + | "Pattern"; + +// $PropertyType doesn't support enums. Use a fake "switch" (GetPlaceholderNode) +//type MaybePlaceholder = $PropertyType | N.Placeholder; + +type _Switch = $Call< + ( + $ElementType<$ElementType, 0>, + ) => $ElementType<$ElementType, 1>, + Value, +>; +type $Switch = _Switch; + +type NodeOf = $Switch< + T, + [ + ["Identifier", N.Identifier], + ["StringLiteral", N.StringLiteral], + ["Expression", N.Expression], + ["Statement", N.Statement], + ["Declaration", N.Declaration], + ["BlockStatement", N.BlockStatement], + ["ClassBody", N.ClassBody], + ["Pattern", N.Pattern], + ], +>; + +// Placeholder breaks everything, because its type is incompatible with +// the substituted nodes. +type MaybePlaceholder = NodeOf; // | Placeholder + +export default (superClass: Class): Class => + class extends superClass { + parsePlaceholder( + expectedNode: T, + ): /*?N.Placeholder*/ ?MaybePlaceholder { + if (this.match(tt.placeholder)) { + const node = this.startNode(); + this.next(); + this.assertNoSpace("Unexpected space in placeholder."); + + // We can't use this.parseIdentifier because + // we don't want nested placeholders. + node.name = super.parseIdentifier(/* liberal */ true); + + this.assertNoSpace("Unexpected space in placeholder."); + this.expect(tt.placeholder); + return this.finishPlaceholder(node, expectedNode); + } + } + + finishPlaceholder( + node: N.Node, + expectedNode: T, + ): /*N.Placeholder*/ MaybePlaceholder { + node.expectedNode = expectedNode; + return this.finishNode(node, "Placeholder"); + } + + /* ============================================================ * + * tokenizer/index.js * + * ============================================================ */ + + getTokenFromCode(code: number) { + if ( + code === charCodes.percentSign && + this.state.input.charCodeAt(this.state.pos + 1) === + charCodes.percentSign + ) { + return this.finishOp(tt.placeholder, 2); + } + + return super.getTokenFromCode(...arguments); + } + + /* ============================================================ * + * parser/expression.js * + * ============================================================ */ + + parseExprAtom(): MaybePlaceholder<"Expression"> { + return ( + this.parsePlaceholder("Expression") || super.parseExprAtom(...arguments) + ); + } + + parseIdentifier(): MaybePlaceholder<"Identifier"> { + // NOTE: This function only handles identifiers outside of + // expressions and binding patterns, since they are already + // handled by the parseExprAtom and parseBindingAtom functions. + // This is needed, for example, to parse "class %%NAME%% {}". + return ( + this.parsePlaceholder("Identifier") || + super.parseIdentifier(...arguments) + ); + } + + checkReservedWord(word: string): void { + // Sometimes we call #checkReservedWord(node.name), expecting + // that node is an Identifier. If it is a Placeholder, name + // will be undefined. + if (word !== undefined) super.checkReservedWord(...arguments); + } + + /* ============================================================ * + * parser/lval.js * + * ============================================================ */ + + parseBindingAtom(): MaybePlaceholder<"Pattern"> { + return ( + this.parsePlaceholder("Pattern") || super.parseBindingAtom(...arguments) + ); + } + + checkLVal(expr: N.Expression): void { + if (expr.type !== "Placeholder") super.checkLVal(...arguments); + } + + toAssignable(node: N.Node): N.Node { + if ( + node && + node.type === "Placeholder" && + node.expectedNode === "Expression" + ) { + node.expectedNode = "Pattern"; + return node; + } + return super.toAssignable(...arguments); + } + + /* ============================================================ * + * parser/statement.js * + * ============================================================ */ + + verifyBreakContinue(node: N.BreakStatement | N.ContinueStatement) { + if (node.label && node.label.type === "Placeholder") return; + super.verifyBreakContinue(...arguments); + } + + parseExpressionStatement( + node: MaybePlaceholder<"Statement">, + expr: N.Expression, + ): MaybePlaceholder<"Statement"> { + if ( + expr.type !== "Placeholder" || + (expr.extra && expr.extra.parenthesized) + ) { + return super.parseExpressionStatement(...arguments); + } + + if (this.match(tt.colon)) { + const stmt: N.LabeledStatement = node; + stmt.label = this.finishPlaceholder(expr, "Identifier"); + this.next(); + stmt.body = this.parseStatement("label"); + return this.finishNode(stmt, "LabeledStatement"); + } + + this.semicolon(); + + node.name = expr.name; + return this.finishPlaceholder(node, "Statement"); + } + + parseBlock(): MaybePlaceholder<"BlockStatement"> { + return ( + this.parsePlaceholder("BlockStatement") || + super.parseBlock(...arguments) + ); + } + + parseFunctionId(): ?MaybePlaceholder<"Identifier"> { + return ( + this.parsePlaceholder("Identifier") || + super.parseFunctionId(...arguments) + ); + } + + parseClass( + node: T, + isStatement: /* T === ClassDeclaration */ boolean, + optionalId?: boolean, + ): T { + const type = isStatement ? "ClassDeclaration" : "ClassExpression"; + + this.next(); + this.takeDecorators(node); + + const placeholder = this.parsePlaceholder("Identifier"); + if (placeholder) { + if ( + this.match(tt._extends) || + this.match(tt.placeholder) || + this.match(tt.braceL) + ) { + node.id = placeholder; + } else if (optionalId || !isStatement) { + node.id = null; + node.body = this.finishPlaceholder(placeholder, "ClassBody"); + return this.finishNode(node, type); + } else { + this.unexpected(null, "A class name is required"); + } + } else { + this.parseClassId(node, isStatement, optionalId); + } + + this.parseClassSuper(node); + node.body = + this.parsePlaceholder("ClassBody") || + this.parseClassBody(!!node.superClass); + return this.finishNode(node, type); + } + + parseExport(node: N.Node): N.Node { + const placeholder = this.parsePlaceholder("Identifier"); + if (!placeholder) return super.parseExport(...arguments); + + if (!this.isContextual("from") && !this.match(tt.comma)) { + // export %%DECL%%; + node.specifiers = []; + node.source = null; + node.declaration = this.finishPlaceholder(placeholder, "Declaration"); + return this.finishNode(node, "ExportNamedDeclaration"); + } + + // export %%NAME%% from "foo"; + this.expectPlugin("exportDefaultFrom"); + const specifier = this.startNode(); + specifier.exported = placeholder; + node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")]; + + return super.parseExport(node); + } + + maybeParseExportDefaultSpecifier(node: N.Node): boolean { + if (node.specifiers && node.specifiers.length > 0) { + // "export %%NAME%%" has already been parsed by #parseExport. + return true; + } + return super.maybeParseExportDefaultSpecifier(...arguments); + } + + checkExport(node: N.ExportNamedDeclaration): void { + const { specifiers } = node; + if (specifiers && specifiers.length) { + node.specifiers = specifiers.filter( + node => node.exported.type === "Placeholder", + ); + } + super.checkExport(node); + node.specifiers = specifiers; + } + + parseImport( + node: N.Node, + ): N.ImportDeclaration | N.TsImportEqualsDeclaration { + const placeholder = this.parsePlaceholder("Identifier"); + if (!placeholder) return super.parseImport(...arguments); + + node.specifiers = []; + + if (!this.isContextual("from") && !this.match(tt.comma)) { + // import %%STRING%%; + node.source = this.finishPlaceholder(placeholder, "StringLiteral"); + this.semicolon(); + return this.finishNode(node, "ImportDeclaration"); + } + + // import %%DEFAULT%% ... + const specifier = this.startNodeAtNode(placeholder); + specifier.local = placeholder; + this.finishNode(specifier, "ImportDefaultSpecifier"); + node.specifiers.push(specifier); + + if (this.eat(tt.comma)) { + // import %%DEFAULT%%, * as ... + const hasStarImport = this.maybeParseStarImportSpecifier(node); + + // import %%DEFAULT%%, { ... + if (!hasStarImport) this.parseNamedImportSpecifiers(node); + } + + this.expectContextual("from"); + node.source = this.parseImportSource(); + this.semicolon(); + return this.finishNode(node, "ImportDeclaration"); + } + + parseImportSource(): MaybePlaceholder<"StringLiteral"> { + // import ... from %%STRING%%; + + return ( + this.parsePlaceholder("StringLiteral") || + super.parseImportSource(...arguments) + ); + } + }; diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 35d79c9ce925..e3a584ddc32c 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -3,6 +3,7 @@ import type { SourceType } from "./options"; import type { Token } from "./tokenizer"; import type { SourceLocation } from "./util/location"; +import type { PlaceholderTypes } from "./plugins/placeholders"; /* * If making any changes to the AST, update: @@ -45,6 +46,7 @@ export type Pattern = | ArrayPattern | RestElement | AssignmentPattern; +//| Placeholder<"Pattern">; export type Declaration = | VariableDeclaration | ClassDeclaration @@ -53,6 +55,8 @@ export type Declaration = | TsTypeAliasDeclaration | TsEnumDeclaration | TsModuleDeclaration; +// | Placeholder<"Declaration">; + export type DeclarationBase = NodeBase & { // TypeScript allows declarations to be prefixed by `declare`. //TODO: a FunctionDeclaration is never "declare", because it's a TSDeclareFunction instead. @@ -78,6 +82,7 @@ export type Identifier = PatternBase & { // TypeScript only. Used in case of an optional parameter. optional?: ?true, }; +// | Placeholder<"Identifier">; export type PrivateName = NodeBase & { type: "PrivateName", @@ -188,6 +193,7 @@ export type BlockStatement = NodeBase & { body: Array, // TODO: $ReadOnlyArray directives: $ReadOnlyArray, }; +// | Placeholder<"BlockStatement">; export type EmptyStatement = NodeBase & { type: "EmptyStatement", @@ -682,6 +688,7 @@ export type ClassBody = NodeBase & { type: "ClassBody", body: Array, // TODO: $ReadOnlyArray }; +// | Placeholder<"ClassBody">; export type ClassMemberBase = NodeBase & HasDecorators & { @@ -1421,6 +1428,16 @@ export type TsNonNullExpression = NodeBase & { expression: Expression, }; +// ================ +// Babel placeholders %%foo%% +// ================ + +export type Placeholder = NodeBase & { + type: "Placeholder", + id: Identifier, + expectedNode: N, +}; + // ================ // Other // ================ diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/options.json index f8dba0c322fe..9914950b66fe 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-methods/failure-spaces/options.json @@ -1,4 +1,4 @@ { - "throws": "Unexpected space between # and identifier (2:5)", + "throws": "Unexpected space between # and identifier (2:3)", "plugins": ["classPrivateMethods"] } diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/options.json b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/options.json index f8dba0c322fe..9914950b66fe 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/options.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-properties/failure-spaces/options.json @@ -1,4 +1,4 @@ { - "throws": "Unexpected space between # and identifier (2:5)", + "throws": "Unexpected space between # and identifier (2:3)", "plugins": ["classPrivateMethods"] } diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/input.js b/packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/input.js new file mode 100644 index 000000000000..06d3e367d700 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/input.js @@ -0,0 +1 @@ +%%FOO%% \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/options.json b/packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/options.json new file mode 100644 index 000000000000..550f9f8667f9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/no-plugin/options.json @@ -0,0 +1,4 @@ +{ + "plugins": [], + "throws": "Unexpected token (1:0)" +} diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/input.js b/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/input.js new file mode 100644 index 000000000000..f0c987242e5f --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/input.js @@ -0,0 +1 @@ +%%FOO %% \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json b/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json new file mode 100644 index 000000000000..a307a35df63e --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/space-after/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["placeholders"], + "throws": "Unexpected space in placeholder. (1:5)" +} diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/input.js b/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/input.js new file mode 100644 index 000000000000..a19d1a7dbf9d --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/input.js @@ -0,0 +1 @@ +%% FOO%% \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json b/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json new file mode 100644 index 000000000000..2d76cfab7e2f --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/_errors/space-before/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["placeholders"], + "throws": "Unexpected space in placeholder. (1:2)" +} diff --git a/packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/input.js b/packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/input.js new file mode 100644 index 000000000000..ccc04f6163ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/input.js @@ -0,0 +1 @@ +async %%PARAM%% => %%BODY%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/options.json b/packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/options.json new file mode 100644 index 000000000000..91e2a8bf915b --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/arrow/async-parenless/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["placeholders"], + "throws": "Unexpected token, expected \";\" (1:6)" +} diff --git a/packages/babel-parser/test/fixtures/placeholders/arrow/async/input.js b/packages/babel-parser/test/fixtures/placeholders/arrow/async/input.js new file mode 100644 index 000000000000..5620afc8e818 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/arrow/async/input.js @@ -0,0 +1 @@ +async (%%PARAM%%) => %%BODY%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/arrow/async/output.json b/packages/babel-parser/test/fixtures/placeholders/arrow/async/output.json new file mode 100644 index 000000000000..4896328afde6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/arrow/async/output.json @@ -0,0 +1,136 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "Placeholder", + "start": 7, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "PARAM" + }, + "name": "PARAM" + }, + "expectedNode": "Pattern" + } + ], + "body": { + "type": "Placeholder", + "start": 21, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "name": { + "type": "Identifier", + "start": 23, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "BODY" + }, + "name": "BODY" + }, + "expectedNode": "Expression" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/input.js b/packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/input.js new file mode 100644 index 000000000000..03f6196a9250 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/input.js @@ -0,0 +1 @@ +%%PARAM%% => %%BODY%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/options.json b/packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/options.json new file mode 100644 index 000000000000..c2a8ef725fb6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/arrow/sync-parenless/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["placeholders"], + "throws": "Unexpected token, expected \";\" (1:10)" +} diff --git a/packages/babel-parser/test/fixtures/placeholders/arrow/sync/input.js b/packages/babel-parser/test/fixtures/placeholders/arrow/sync/input.js new file mode 100644 index 000000000000..d8e462edb43b --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/arrow/sync/input.js @@ -0,0 +1 @@ +(%%PARAM%%) => %%BODY%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/arrow/sync/output.json b/packages/babel-parser/test/fixtures/placeholders/arrow/sync/output.json new file mode 100644 index 000000000000..6b0b16b70fc7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/arrow/sync/output.json @@ -0,0 +1,136 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Placeholder", + "start": 1, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "name": { + "type": "Identifier", + "start": 3, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "PARAM" + }, + "name": "PARAM" + }, + "expectedNode": "Pattern" + } + ], + "body": { + "type": "Placeholder", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "name": { + "type": "Identifier", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "BODY" + }, + "name": "BODY" + }, + "expectedNode": "Expression" + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/body_expression/input.js b/packages/babel-parser/test/fixtures/placeholders/class/body_expression/input.js new file mode 100644 index 000000000000..9789bed118e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/body_expression/input.js @@ -0,0 +1 @@ +void class %%BODY%% \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/body_expression/output.json b/packages/babel-parser/test/fixtures/placeholders/class/body_expression/output.json new file mode 100644 index 000000000000..61966406846e --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/body_expression/output.json @@ -0,0 +1,116 @@ +{ + "type": "File", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "expression": { + "type": "UnaryExpression", + "start": 0, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "operator": "void", + "prefix": true, + "argument": { + "type": "ClassExpression", + "start": 5, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "id": null, + "body": { + "type": "Placeholder", + "start": 11, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "name": { + "type": "Identifier", + "start": 13, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 17 + }, + "identifierName": "BODY" + }, + "name": "BODY" + }, + "expectedNode": "ClassBody" + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/body_statement/input.js b/packages/babel-parser/test/fixtures/placeholders/class/body_statement/input.js new file mode 100644 index 000000000000..4447c2e48a44 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/body_statement/input.js @@ -0,0 +1 @@ +class Cl %%BODY%% \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/body_statement/output.json b/packages/babel-parser/test/fixtures/placeholders/class/body_statement/output.json new file mode 100644 index 000000000000..70f4a636520e --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/body_statement/output.json @@ -0,0 +1,101 @@ +{ + "type": "File", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "Cl" + }, + "name": "Cl" + }, + "superClass": null, + "body": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "BODY" + }, + "name": "BODY" + }, + "expectedNode": "ClassBody" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/decorators/input.js b/packages/babel-parser/test/fixtures/placeholders/class/decorators/input.js new file mode 100644 index 000000000000..33732420452f --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/decorators/input.js @@ -0,0 +1,2 @@ +@(%%FOO%%) +class A {} diff --git a/packages/babel-parser/test/fixtures/placeholders/class/decorators/options.json b/packages/babel-parser/test/fixtures/placeholders/class/decorators/options.json new file mode 100644 index 000000000000..f453a9b6abdc --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/decorators/options.json @@ -0,0 +1,6 @@ +{ + "plugins": [ + "placeholders", + ["decorators", { "decoratorsBeforeExport": true }] + ] +} diff --git a/packages/babel-parser/test/fixtures/placeholders/class/decorators/output.json b/packages/babel-parser/test/fixtures/placeholders/class/decorators/output.json new file mode 100644 index 000000000000..459dacb35f2c --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/decorators/output.json @@ -0,0 +1,134 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "decorators": [ + { + "type": "Decorator", + "start": 0, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "expression": { + "type": "Placeholder", + "start": 2, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "name": { + "type": "Identifier", + "start": 4, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "FOO" + }, + "name": "FOO" + }, + "expectedNode": "Expression" + } + } + ], + "id": { + "type": "Identifier", + "start": 17, + "end": 18, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "A" + }, + "name": "A" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 19, + "end": 21, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id-body/input.js b/packages/babel-parser/test/fixtures/placeholders/class/id-body/input.js new file mode 100644 index 000000000000..e6b57a64de88 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id-body/input.js @@ -0,0 +1 @@ +class %%ID%% %%BODY%% diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id-body/output.json b/packages/babel-parser/test/fixtures/placeholders/class/id-body/output.json new file mode 100644 index 000000000000..0fe8c71d4786 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id-body/output.json @@ -0,0 +1,117 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Placeholder", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "name": { + "type": "Identifier", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "ID" + }, + "name": "ID" + }, + "expectedNode": "Identifier" + }, + "superClass": null, + "body": { + "type": "Placeholder", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "name": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "BODY" + }, + "name": "BODY" + }, + "expectedNode": "ClassBody" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id-super-body/input.js b/packages/babel-parser/test/fixtures/placeholders/class/id-super-body/input.js new file mode 100644 index 000000000000..30edd2cb7f4a --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id-super-body/input.js @@ -0,0 +1 @@ +class %%ID%% extends %%SUPER%% %%BODY%% diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id-super-body/output.json b/packages/babel-parser/test/fixtures/placeholders/class/id-super-body/output.json new file mode 100644 index 000000000000..b891fe7c30d9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id-super-body/output.json @@ -0,0 +1,149 @@ +{ + "type": "File", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "id": { + "type": "Placeholder", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "name": { + "type": "Identifier", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "ID" + }, + "name": "ID" + }, + "expectedNode": "Identifier" + }, + "superClass": { + "type": "Placeholder", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "name": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "SUPER" + }, + "name": "SUPER" + }, + "expectedNode": "Expression" + }, + "body": { + "type": "Placeholder", + "start": 31, + "end": 39, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 39 + } + }, + "name": { + "type": "Identifier", + "start": 33, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 37 + }, + "identifierName": "BODY" + }, + "name": "BODY" + }, + "expectedNode": "ClassBody" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id-super/input.js b/packages/babel-parser/test/fixtures/placeholders/class/id-super/input.js new file mode 100644 index 000000000000..2f652c767e90 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id-super/input.js @@ -0,0 +1 @@ +class %%ID%% extends %%SUPER%% {} diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id-super/output.json b/packages/babel-parser/test/fixtures/placeholders/class/id-super/output.json new file mode 100644 index 000000000000..cde4f271b7de --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id-super/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "id": { + "type": "Placeholder", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "name": { + "type": "Identifier", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "ID" + }, + "name": "ID" + }, + "expectedNode": "Identifier" + }, + "superClass": { + "type": "Placeholder", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "name": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "SUPER" + }, + "name": "SUPER" + }, + "expectedNode": "Expression" + }, + "body": { + "type": "ClassBody", + "start": 31, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 31 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id_expression/input.js b/packages/babel-parser/test/fixtures/placeholders/class/id_expression/input.js new file mode 100644 index 000000000000..d6f2785faa3a --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id_expression/input.js @@ -0,0 +1 @@ +void class %%ID%% {} diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id_expression/output.json b/packages/babel-parser/test/fixtures/placeholders/class/id_expression/output.json new file mode 100644 index 000000000000..8ec0bdeaeb64 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id_expression/output.json @@ -0,0 +1,132 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "expression": { + "type": "UnaryExpression", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "operator": "void", + "prefix": true, + "argument": { + "type": "ClassExpression", + "start": 5, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Placeholder", + "start": 11, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 13, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "ID" + }, + "name": "ID" + }, + "expectedNode": "Identifier" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id_statement/input.js b/packages/babel-parser/test/fixtures/placeholders/class/id_statement/input.js new file mode 100644 index 000000000000..b56524d15767 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id_statement/input.js @@ -0,0 +1 @@ +class %%ID%% {} diff --git a/packages/babel-parser/test/fixtures/placeholders/class/id_statement/output.json b/packages/babel-parser/test/fixtures/placeholders/class/id_statement/output.json new file mode 100644 index 000000000000..61ecc899ae22 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/id_statement/output.json @@ -0,0 +1,100 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "id": { + "type": "Placeholder", + "start": 6, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "name": { + "type": "Identifier", + "start": 8, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "ID" + }, + "name": "ID" + }, + "expectedNode": "Identifier" + }, + "superClass": null, + "body": { + "type": "ClassBody", + "start": 13, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/class/super/input.js b/packages/babel-parser/test/fixtures/placeholders/class/super/input.js new file mode 100644 index 000000000000..ce315dbaa68c --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/super/input.js @@ -0,0 +1 @@ +class Cl extends %%SUPER%% {} diff --git a/packages/babel-parser/test/fixtures/placeholders/class/super/output.json b/packages/babel-parser/test/fixtures/placeholders/class/super/output.json new file mode 100644 index 000000000000..966639d5d351 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/class/super/output.json @@ -0,0 +1,116 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ClassDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "Cl" + }, + "name": "Cl" + }, + "superClass": { + "type": "Placeholder", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "name": { + "type": "Identifier", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "SUPER" + }, + "name": "SUPER" + }, + "expectedNode": "Expression" + }, + "body": { + "type": "ClassBody", + "start": 27, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "body": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/declaration/input.js b/packages/babel-parser/test/fixtures/placeholders/export/declaration/input.js new file mode 100644 index 000000000000..e06647491291 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/declaration/input.js @@ -0,0 +1 @@ +export %%DECL%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/declaration/output.json b/packages/babel-parser/test/fixtures/placeholders/export/declaration/output.json new file mode 100644 index 000000000000..a0cc4fb21147 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/declaration/output.json @@ -0,0 +1,100 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "specifiers": [], + "source": null, + "declaration": { + "type": "Placeholder", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "DECL" + }, + "name": "DECL" + }, + "expectedNode": "Declaration" + } + }, + { + "type": "EmptyStatement", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/input.js b/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/input.js new file mode 100644 index 000000000000..e9e71b211a7a --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/input.js @@ -0,0 +1 @@ +export default from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json b/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json new file mode 100644 index 000000000000..b3f883263b7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "placeholders" + ], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/input.js b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/input.js new file mode 100644 index 000000000000..acd2d28ed6e0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/input.js @@ -0,0 +1 @@ +export %%NAME%% from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json new file mode 100644 index 000000000000..404b94bc6cbe --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "placeholders" + ], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:16)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/input.js b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/input.js new file mode 100644 index 000000000000..a2ac20ea9b87 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/input.js @@ -0,0 +1 @@ +export %%NAME%% from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json new file mode 100644 index 000000000000..404b94bc6cbe --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "placeholders" + ], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:16)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/input.js b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/input.js new file mode 100644 index 000000000000..2ec55e24cc45 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/input.js @@ -0,0 +1 @@ +export name from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json new file mode 100644 index 000000000000..b3f883263b7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "placeholders" + ], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/input.js new file mode 100644 index 000000000000..ccc71c84d0ab --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/input.js @@ -0,0 +1 @@ +export { name as %%ALIAS%% }; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/output.json new file mode 100644 index 000000000000..3da7a5b3b526 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-alias-2/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "name" + }, + "name": "name" + }, + "exported": { + "type": "Placeholder", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "name": { + "type": "Identifier", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "ALIAS" + }, + "name": "ALIAS" + }, + "expectedNode": "Identifier" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/input.js new file mode 100644 index 000000000000..ebe9a78080c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/input.js @@ -0,0 +1 @@ +export { %%NAME%% as %%ALIAS%% }; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/output.json new file mode 100644 index 000000000000..79bf65de1189 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-alias-3/output.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "local": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + }, + "exported": { + "type": "Placeholder", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "name": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "ALIAS" + }, + "name": "ALIAS" + }, + "expectedNode": "Identifier" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-alias/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-alias/input.js new file mode 100644 index 000000000000..ff261bd263d7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-alias/input.js @@ -0,0 +1 @@ +export { %%NAME%% as alias }; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-alias/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-alias/output.json new file mode 100644 index 000000000000..ddabad2b64c7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-alias/output.json @@ -0,0 +1,119 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "local": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + }, + "exported": { + "type": "Identifier", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "alias" + }, + "name": "alias" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-2/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-from-2/input.js new file mode 100644 index 000000000000..3bf7f2ff4f01 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-2/input.js @@ -0,0 +1 @@ +export { name } from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-2/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-from-2/output.json new file mode 100644 index 000000000000..5d7db268eb97 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-2/output.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "name" + }, + "name": "name" + }, + "exported": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "name" + }, + "name": "name" + } + } + ], + "source": { + "type": "Placeholder", + "start": 21, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "name": { + "type": "Identifier", + "start": 23, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "FILE" + }, + "name": "FILE" + }, + "expectedNode": "StringLiteral" + }, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-3/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-from-3/input.js new file mode 100644 index 000000000000..0a86eaa83ca1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-3/input.js @@ -0,0 +1 @@ +export { %%NAME%% } from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-3/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-from-3/output.json new file mode 100644 index 000000000000..f89643fc0a7b --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-3/output.json @@ -0,0 +1,167 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "local": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + }, + "exported": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "Placeholder", + "start": 25, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "name": { + "type": "Identifier", + "start": 27, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "FILE" + }, + "name": "FILE" + }, + "expectedNode": "StringLiteral" + }, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/input.js new file mode 100644 index 000000000000..7a9d409e879f --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/input.js @@ -0,0 +1 @@ +export { name as %%ALIAS%% } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/output.json new file mode 100644 index 000000000000..637b5256b845 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-2/output.json @@ -0,0 +1,138 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "local": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "name" + }, + "name": "name" + }, + "exported": { + "type": "Placeholder", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "name": { + "type": "Identifier", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "ALIAS" + }, + "name": "ALIAS" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 34, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + }, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/input.js new file mode 100644 index 000000000000..0fc04b4a2f46 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/input.js @@ -0,0 +1 @@ +export { %%NAME%% as %%ALIAS%% } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/output.json new file mode 100644 index 000000000000..2fd4cc6f3a99 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias-3/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "local": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + }, + "exported": { + "type": "Placeholder", + "start": 21, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "name": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "ALIAS" + }, + "name": "ALIAS" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 38, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + }, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/input.js new file mode 100644 index 000000000000..395bf89474cb --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/input.js @@ -0,0 +1 @@ +export { %%NAME%% as alias } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/output.json new file mode 100644 index 000000000000..34e8dd6e3a04 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from-alias/output.json @@ -0,0 +1,138 @@ +{ + "type": "File", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "local": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + }, + "exported": { + "type": "Identifier", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "alias" + }, + "name": "alias" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 34, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 40 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + }, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named-from/input.js new file mode 100644 index 000000000000..c74dfbf297a1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from/input.js @@ -0,0 +1 @@ +export { %%NAME%% } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named-from/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named-from/output.json new file mode 100644 index 000000000000..5c9ae8516dd4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named-from/output.json @@ -0,0 +1,154 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "local": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + }, + "exported": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 25, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + }, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named/input.js b/packages/babel-parser/test/fixtures/placeholders/export/named/input.js new file mode 100644 index 000000000000..03cd701e264c --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named/input.js @@ -0,0 +1 @@ +export { %%NAME%% }; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/named/output.json b/packages/babel-parser/test/fixtures/placeholders/export/named/output.json new file mode 100644 index 000000000000..67b0f0429f79 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/named/output.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "specifiers": [ + { + "type": "ExportSpecifier", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "local": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + }, + "exported": { + "type": "Placeholder", + "start": 9, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "NAME" + }, + "name": "NAME" + }, + "expectedNode": "Identifier" + } + } + ], + "source": null, + "declaration": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/options.json b/packages/babel-parser/test/fixtures/placeholders/export/options.json new file mode 100644 index 000000000000..e7ff26ae7014 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["placeholders", "exportDefaultFrom", "exportNamespaceFrom"], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/input.js b/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/input.js new file mode 100644 index 000000000000..8a6343daed94 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/input.js @@ -0,0 +1 @@ +export * as %%STAR%% from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json b/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json new file mode 100644 index 000000000000..8c48e4fc0f20 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from-2/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "placeholders" + ], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/input.js b/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/input.js new file mode 100644 index 000000000000..cdb724867079 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/input.js @@ -0,0 +1 @@ +export * as %%STAR%% from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json b/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json new file mode 100644 index 000000000000..8c48e4fc0f20 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from-3/options.json @@ -0,0 +1,7 @@ +{ + "plugins": [ + "placeholders" + ], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: 'exportNamespaceFrom' (1:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from/input.js b/packages/babel-parser/test/fixtures/placeholders/export/star-from/input.js new file mode 100644 index 000000000000..87fc3f0d362d --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from/input.js @@ -0,0 +1 @@ +export * from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/export/star-from/output.json b/packages/babel-parser/test/fixtures/placeholders/export/star-from/output.json new file mode 100644 index 000000000000..87a301212145 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/export/star-from/output.json @@ -0,0 +1,83 @@ +{ + "type": "File", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExportAllDeclaration", + "start": 0, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "source": { + "type": "Placeholder", + "start": 14, + "end": 22, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 22 + } + }, + "name": { + "type": "Identifier", + "start": 16, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "FILE" + }, + "name": "FILE" + }, + "expectedNode": "StringLiteral" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/expression/01/input.js b/packages/babel-parser/test/fixtures/placeholders/expression/01/input.js new file mode 100644 index 000000000000..1ca196c41413 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/expression/01/input.js @@ -0,0 +1 @@ +%%FOO%% + %%BAR%%(%%BAZ%%); \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/expression/01/output.json b/packages/babel-parser/test/fixtures/placeholders/expression/01/output.json new file mode 100644 index 000000000000..9de9b6f77eda --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/expression/01/output.json @@ -0,0 +1,182 @@ +{ + "type": "File", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "expression": { + "type": "BinaryExpression", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "left": { + "type": "Placeholder", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": { + "type": "Identifier", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "FOO" + }, + "name": "FOO" + }, + "expectedNode": "Expression" + }, + "operator": "+", + "right": { + "type": "CallExpression", + "start": 10, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "callee": { + "type": "Placeholder", + "start": 10, + "end": 17, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 12, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "BAR" + }, + "name": "BAR" + }, + "expectedNode": "Expression" + }, + "arguments": [ + { + "type": "Placeholder", + "start": 18, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "name": { + "type": "Identifier", + "start": 20, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "BAZ" + }, + "name": "BAZ" + }, + "expectedNode": "Expression" + } + ] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/expression/options.json b/packages/babel-parser/test/fixtures/placeholders/expression/options.json new file mode 100644 index 000000000000..92404e501295 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/expression/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["placeholders"] +} diff --git a/packages/babel-parser/test/fixtures/placeholders/function/body/input.js b/packages/babel-parser/test/fixtures/placeholders/function/body/input.js new file mode 100644 index 000000000000..09db19b409a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/body/input.js @@ -0,0 +1 @@ +function f() %%BODY%% diff --git a/packages/babel-parser/test/fixtures/placeholders/function/body/output.json b/packages/babel-parser/test/fixtures/placeholders/function/body/output.json new file mode 100644 index 000000000000..3139e3132180 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/body/output.json @@ -0,0 +1,103 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "Placeholder", + "start": 13, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "name": { + "type": "Identifier", + "start": 15, + "end": 19, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 19 + }, + "identifierName": "BODY" + }, + "name": "BODY" + }, + "expectedNode": "BlockStatement" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/function/id-params-body/input.js b/packages/babel-parser/test/fixtures/placeholders/function/id-params-body/input.js new file mode 100644 index 000000000000..9f0f6607b320 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/id-params-body/input.js @@ -0,0 +1 @@ +function %%ID%%(%%PARAM%%, %%PARAM%%) %%BODY%% diff --git a/packages/babel-parser/test/fixtures/placeholders/function/id-params-body/output.json b/packages/babel-parser/test/fixtures/placeholders/function/id-params-body/output.json new file mode 100644 index 000000000000..fd6205f7ab8e --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/id-params-body/output.json @@ -0,0 +1,186 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "id": { + "type": "Placeholder", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "ID" + }, + "name": "ID" + }, + "expectedNode": "Identifier" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Placeholder", + "start": 16, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "name": { + "type": "Identifier", + "start": 18, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 23 + }, + "identifierName": "PARAM" + }, + "name": "PARAM" + }, + "expectedNode": "Pattern" + }, + { + "type": "Placeholder", + "start": 27, + "end": 36, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 36 + } + }, + "name": { + "type": "Identifier", + "start": 29, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 1, + "column": 34 + }, + "identifierName": "PARAM" + }, + "name": "PARAM" + }, + "expectedNode": "Pattern" + } + ], + "body": { + "type": "Placeholder", + "start": 38, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "name": { + "type": "Identifier", + "start": 40, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 44 + }, + "identifierName": "BODY" + }, + "name": "BODY" + }, + "expectedNode": "BlockStatement" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/function/id_declaration/input.js b/packages/babel-parser/test/fixtures/placeholders/function/id_declaration/input.js new file mode 100644 index 000000000000..8afee84ad037 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/id_declaration/input.js @@ -0,0 +1 @@ +function %%ID%%() {} diff --git a/packages/babel-parser/test/fixtures/placeholders/function/id_declaration/output.json b/packages/babel-parser/test/fixtures/placeholders/function/id_declaration/output.json new file mode 100644 index 000000000000..a07531190e7d --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/id_declaration/output.json @@ -0,0 +1,103 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "id": { + "type": "Placeholder", + "start": 9, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "ID" + }, + "name": "ID" + }, + "expectedNode": "Identifier" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 18, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/function/id_expression/input.js b/packages/babel-parser/test/fixtures/placeholders/function/id_expression/input.js new file mode 100644 index 000000000000..69db50cde003 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/id_expression/input.js @@ -0,0 +1 @@ +void function %%ID%%() {}; diff --git a/packages/babel-parser/test/fixtures/placeholders/function/id_expression/output.json b/packages/babel-parser/test/fixtures/placeholders/function/id_expression/output.json new file mode 100644 index 000000000000..1bc90cefa7fc --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/id_expression/output.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "expression": { + "type": "UnaryExpression", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "operator": "void", + "prefix": true, + "argument": { + "type": "FunctionExpression", + "start": 5, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "id": { + "type": "Placeholder", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "name": { + "type": "Identifier", + "start": 16, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "ID" + }, + "name": "ID" + }, + "expectedNode": "Identifier" + }, + "generator": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 23, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "body": [], + "directives": [] + } + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/function/param/input.js b/packages/babel-parser/test/fixtures/placeholders/function/param/input.js new file mode 100644 index 000000000000..f06bb0431462 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/param/input.js @@ -0,0 +1 @@ +function f(%%PARAM%%) {} diff --git a/packages/babel-parser/test/fixtures/placeholders/function/param/output.json b/packages/babel-parser/test/fixtures/placeholders/function/param/output.json new file mode 100644 index 000000000000..9026f46c40db --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/function/param/output.json @@ -0,0 +1,121 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "id": { + "type": "Identifier", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + }, + "identifierName": "f" + }, + "name": "f" + }, + "generator": false, + "async": false, + "params": [ + { + "type": "Placeholder", + "start": 11, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "name": { + "type": "Identifier", + "start": 13, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "PARAM" + }, + "name": "PARAM" + }, + "expectedNode": "Pattern" + } + ], + "body": { + "type": "BlockStatement", + "start": 22, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-file/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/default-file/input.mjs new file mode 100644 index 000000000000..d4e434f4ccec --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-file/input.mjs @@ -0,0 +1 @@ +import %%DEFAULT%% from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-file/output.json b/packages/babel-parser/test/fixtures/placeholders/import/default-file/output.json new file mode 100644 index 000000000000..b4fdc7e984fa --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-file/output.json @@ -0,0 +1,133 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "local": { + "type": "Placeholder", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "DEFAULT" + }, + "name": "DEFAULT" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "Placeholder", + "start": 24, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "name": { + "type": "Identifier", + "start": 26, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 30 + }, + "identifierName": "FILE" + }, + "name": "FILE" + }, + "expectedNode": "StringLiteral" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-named-2/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/default-named-2/input.mjs new file mode 100644 index 000000000000..aca97b71e5c4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-named-2/input.mjs @@ -0,0 +1 @@ +import %%DEFAULT%%, { named } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-named-2/output.json b/packages/babel-parser/test/fixtures/placeholders/import/default-named-2/output.json new file mode 100644 index 000000000000..3ec417645be0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-named-2/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "local": { + "type": "Placeholder", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "DEFAULT" + }, + "name": "DEFAULT" + }, + "expectedNode": "Identifier" + } + }, + { + "type": "ImportSpecifier", + "start": 22, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "imported": { + "type": "Identifier", + "start": 22, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "named" + }, + "name": "named" + }, + "local": { + "type": "Identifier", + "start": 22, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "named" + }, + "name": "named" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 35, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-named-3/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/default-named-3/input.mjs new file mode 100644 index 000000000000..42d98a2cb7ba --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-named-3/input.mjs @@ -0,0 +1 @@ +import %%DEFAULT%%, { %%NAMED%% } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-named-3/output.json b/packages/babel-parser/test/fixtures/placeholders/import/default-named-3/output.json new file mode 100644 index 000000000000..e681ffb18417 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-named-3/output.json @@ -0,0 +1,201 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "local": { + "type": "Placeholder", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "DEFAULT" + }, + "name": "DEFAULT" + }, + "expectedNode": "Identifier" + } + }, + { + "type": "ImportSpecifier", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "imported": { + "type": "Placeholder", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "Identifier", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "NAMED" + }, + "name": "NAMED" + }, + "expectedNode": "Identifier" + }, + "local": { + "type": "Placeholder", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "Identifier", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "NAMED" + }, + "name": "NAMED" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 39, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-named/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/default-named/input.mjs new file mode 100644 index 000000000000..5857bed1cd1d --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-named/input.mjs @@ -0,0 +1 @@ +import _default, { %%NAMED%% } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-named/output.json b/packages/babel-parser/test/fixtures/placeholders/import/default-named/output.json new file mode 100644 index 000000000000..62d764263d3d --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-named/output.json @@ -0,0 +1,185 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "local": { + "type": "Identifier", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "_default" + }, + "name": "_default" + } + }, + { + "type": "ImportSpecifier", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "imported": { + "type": "Placeholder", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "name": { + "type": "Identifier", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "NAMED" + }, + "name": "NAMED" + }, + "expectedNode": "Identifier" + }, + "local": { + "type": "Placeholder", + "start": 19, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "name": { + "type": "Identifier", + "start": 21, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 1, + "column": 26 + }, + "identifierName": "NAMED" + }, + "name": "NAMED" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 36, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-star-2/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/default-star-2/input.mjs new file mode 100644 index 000000000000..32a49347ad55 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-star-2/input.mjs @@ -0,0 +1 @@ +import _default, * as %%STAR%% from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-star-2/output.json b/packages/babel-parser/test/fixtures/placeholders/import/default-star-2/output.json new file mode 100644 index 000000000000..6fd8a2dbed1f --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-star-2/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 43, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 43 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "local": { + "type": "Identifier", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + }, + "identifierName": "_default" + }, + "name": "_default" + } + }, + { + "type": "ImportNamespaceSpecifier", + "start": 17, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "local": { + "type": "Placeholder", + "start": 22, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "name": { + "type": "Identifier", + "start": 24, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "STAR" + }, + "name": "STAR" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 36, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-star-3/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/default-star-3/input.mjs new file mode 100644 index 000000000000..f2cafcebaea3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-star-3/input.mjs @@ -0,0 +1 @@ +import %%DEFAULT%%, * as %%STAR%% from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-star-3/output.json b/packages/babel-parser/test/fixtures/placeholders/import/default-star-3/output.json new file mode 100644 index 000000000000..a92281d0746a --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-star-3/output.json @@ -0,0 +1,168 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "local": { + "type": "Placeholder", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "DEFAULT" + }, + "name": "DEFAULT" + }, + "expectedNode": "Identifier" + } + }, + { + "type": "ImportNamespaceSpecifier", + "start": 20, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "local": { + "type": "Placeholder", + "start": 25, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "name": { + "type": "Identifier", + "start": 27, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 31 + }, + "identifierName": "STAR" + }, + "name": "STAR" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 39, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-star/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/default-star/input.mjs new file mode 100644 index 000000000000..97bb0fbb2083 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-star/input.mjs @@ -0,0 +1 @@ +import %%DEFAULT%%, * as star from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default-star/output.json b/packages/babel-parser/test/fixtures/placeholders/import/default-star/output.json new file mode 100644 index 000000000000..3976944a46bc --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default-star/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "local": { + "type": "Placeholder", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "DEFAULT" + }, + "name": "DEFAULT" + }, + "expectedNode": "Identifier" + } + }, + { + "type": "ImportNamespaceSpecifier", + "start": 20, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "local": { + "type": "Identifier", + "start": 25, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "star" + }, + "name": "star" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 35, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/default/input.mjs new file mode 100644 index 000000000000..cbfc52e13d87 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default/input.mjs @@ -0,0 +1 @@ +import %%DEFAULT%% from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/default/output.json b/packages/babel-parser/test/fixtures/placeholders/import/default/output.json new file mode 100644 index 000000000000..4ff06895645b --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/default/output.json @@ -0,0 +1,120 @@ +{ + "type": "File", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "specifiers": [ + { + "type": "ImportDefaultSpecifier", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "local": { + "type": "Placeholder", + "start": 7, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "DEFAULT" + }, + "name": "DEFAULT" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 24, + "end": 30, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/file-empty/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/file-empty/input.mjs new file mode 100644 index 000000000000..1412ce08fe08 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/file-empty/input.mjs @@ -0,0 +1 @@ +import {} from %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/file-empty/output.json b/packages/babel-parser/test/fixtures/placeholders/import/file-empty/output.json new file mode 100644 index 000000000000..5690ee81f00f --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/file-empty/output.json @@ -0,0 +1,84 @@ +{ + "type": "File", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "specifiers": [], + "source": { + "type": "Placeholder", + "start": 15, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "name": { + "type": "Identifier", + "start": 17, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "FILE" + }, + "name": "FILE" + }, + "expectedNode": "StringLiteral" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/file/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/file/input.mjs new file mode 100644 index 000000000000..634197cbb739 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/file/input.mjs @@ -0,0 +1 @@ +import %%FILE%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/file/output.json b/packages/babel-parser/test/fixtures/placeholders/import/file/output.json new file mode 100644 index 000000000000..e33e48771a60 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/file/output.json @@ -0,0 +1,84 @@ +{ + "type": "File", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "specifiers": [], + "source": { + "type": "Placeholder", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "FILE" + }, + "name": "FILE" + }, + "expectedNode": "StringLiteral" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/named-alias-2/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/named-alias-2/input.mjs new file mode 100644 index 000000000000..114cf3db239c --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/named-alias-2/input.mjs @@ -0,0 +1 @@ +import { %%NAMED%% as alias } from "file"; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/named-alias-2/output.json b/packages/babel-parser/test/fixtures/placeholders/import/named-alias-2/output.json new file mode 100644 index 000000000000..c7d936e96c64 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/named-alias-2/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "imported": { + "type": "Placeholder", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "NAMED" + }, + "name": "NAMED" + }, + "expectedNode": "Identifier" + }, + "local": { + "type": "Identifier", + "start": 22, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 27 + }, + "identifierName": "alias" + }, + "name": "alias" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 35, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/named-alias-3/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/named-alias-3/input.mjs new file mode 100644 index 000000000000..0531ff7d03a9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/named-alias-3/input.mjs @@ -0,0 +1 @@ +import { %%NAMED%% as %%ALIAS%% } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/named-alias-3/output.json b/packages/babel-parser/test/fixtures/placeholders/import/named-alias-3/output.json new file mode 100644 index 000000000000..bfae4a044410 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/named-alias-3/output.json @@ -0,0 +1,153 @@ +{ + "type": "File", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 46, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 46 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "imported": { + "type": "Placeholder", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "NAMED" + }, + "name": "NAMED" + }, + "expectedNode": "Identifier" + }, + "local": { + "type": "Placeholder", + "start": 22, + "end": 31, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 31 + } + }, + "name": { + "type": "Identifier", + "start": 24, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 29 + }, + "identifierName": "ALIAS" + }, + "name": "ALIAS" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 39, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 45 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/named-alias/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/named-alias/input.mjs new file mode 100644 index 000000000000..cc0bfd46c515 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/named-alias/input.mjs @@ -0,0 +1 @@ +import { named as %%ALIAS%% } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/named-alias/output.json b/packages/babel-parser/test/fixtures/placeholders/import/named-alias/output.json new file mode 100644 index 000000000000..5477bef4ca9e --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/named-alias/output.json @@ -0,0 +1,137 @@ +{ + "type": "File", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "imported": { + "type": "Identifier", + "start": 9, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 14 + }, + "identifierName": "named" + }, + "name": "named" + }, + "local": { + "type": "Placeholder", + "start": 18, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "name": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "ALIAS" + }, + "name": "ALIAS" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 35, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 35 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/named/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/named/input.mjs new file mode 100644 index 000000000000..24d0c9bc5adf --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/named/input.mjs @@ -0,0 +1 @@ +import { %%NAMED%% } from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/named/output.json b/packages/babel-parser/test/fixtures/placeholders/import/named/output.json new file mode 100644 index 000000000000..9b3f08486a88 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/named/output.json @@ -0,0 +1,153 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "imported": { + "type": "Placeholder", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "NAMED" + }, + "name": "NAMED" + }, + "expectedNode": "Identifier" + }, + "local": { + "type": "Placeholder", + "start": 9, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 18 + } + }, + "name": { + "type": "Identifier", + "start": 11, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "NAMED" + }, + "name": "NAMED" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 26, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/import/options.json b/packages/babel-parser/test/fixtures/placeholders/import/options.json new file mode 100644 index 000000000000..986e9cefa93e --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["placeholders"], + "sourceType": "module" +} diff --git a/packages/babel-parser/test/fixtures/placeholders/import/star/input.mjs b/packages/babel-parser/test/fixtures/placeholders/import/star/input.mjs new file mode 100644 index 000000000000..df386a7c7ba7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/star/input.mjs @@ -0,0 +1 @@ +import * as %%STAR%% from "file"; diff --git a/packages/babel-parser/test/fixtures/placeholders/import/star/output.json b/packages/babel-parser/test/fixtures/placeholders/import/star/output.json new file mode 100644 index 000000000000..7ff6bfd05846 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/import/star/output.json @@ -0,0 +1,120 @@ +{ + "type": "File", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ImportDeclaration", + "start": 0, + "end": 33, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 33 + } + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "start": 7, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "local": { + "type": "Placeholder", + "start": 12, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "name": { + "type": "Identifier", + "start": 14, + "end": 18, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 18 + }, + "identifierName": "STAR" + }, + "name": "STAR" + }, + "expectedNode": "Identifier" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 26, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "extra": { + "rawValue": "file", + "raw": "\"file\"" + }, + "value": "file" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/labels/asi/input.js b/packages/babel-parser/test/fixtures/placeholders/labels/asi/input.js new file mode 100644 index 000000000000..9c5f9fcc13d6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/labels/asi/input.js @@ -0,0 +1,4 @@ +loop: while (0) { + break + %%LABEL%%; +} diff --git a/packages/babel-parser/test/fixtures/placeholders/labels/asi/output.json b/packages/babel-parser/test/fixtures/placeholders/labels/asi/output.json new file mode 100644 index 000000000000..f1e2f1614781 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/labels/asi/output.json @@ -0,0 +1,169 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": { + "type": "WhileStatement", + "start": 6, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "test": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "body": [ + { + "type": "BreakStatement", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "label": null + }, + { + "type": "Placeholder", + "start": 28, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 12 + } + }, + "name": { + "type": "Identifier", + "start": 30, + "end": 35, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + }, + "identifierName": "LABEL" + }, + "name": "LABEL" + }, + "expectedNode": "Statement" + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "loop" + }, + "name": "loop" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/labels/break/input.js b/packages/babel-parser/test/fixtures/placeholders/labels/break/input.js new file mode 100644 index 000000000000..bcc6f5bae986 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/labels/break/input.js @@ -0,0 +1,3 @@ +block: { + break %%LABEL%%; +} diff --git a/packages/babel-parser/test/fixtures/placeholders/labels/break/output.json b/packages/babel-parser/test/fixtures/placeholders/labels/break/output.json new file mode 100644 index 000000000000..ab4488d5a04c --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/labels/break/output.json @@ -0,0 +1,133 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": { + "type": "BlockStatement", + "start": 7, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "BreakStatement", + "start": 11, + "end": 27, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 18 + } + }, + "label": { + "type": "Placeholder", + "start": 17, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "name": { + "type": "Identifier", + "start": 19, + "end": 24, + "loc": { + "start": { + "line": 2, + "column": 10 + }, + "end": { + "line": 2, + "column": 15 + }, + "identifierName": "LABEL" + }, + "name": "LABEL" + }, + "expectedNode": "Identifier" + } + } + ], + "directives": [] + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "block" + }, + "name": "block" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/labels/continue/input.js b/packages/babel-parser/test/fixtures/placeholders/labels/continue/input.js new file mode 100644 index 000000000000..52fd9da0d283 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/labels/continue/input.js @@ -0,0 +1,3 @@ +loop: while (0) { + continue %%LOOP%%; +} diff --git a/packages/babel-parser/test/fixtures/placeholders/labels/continue/output.json b/packages/babel-parser/test/fixtures/placeholders/labels/continue/output.json new file mode 100644 index 000000000000..b6876979197b --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/labels/continue/output.json @@ -0,0 +1,168 @@ +{ + "type": "File", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "LabeledStatement", + "start": 0, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": { + "type": "WhileStatement", + "start": 6, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "test": { + "type": "NumericLiteral", + "start": 13, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "body": { + "type": "BlockStatement", + "start": 16, + "end": 40, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "body": [ + { + "type": "ContinueStatement", + "start": 20, + "end": 38, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "label": { + "type": "Placeholder", + "start": 29, + "end": 37, + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 19 + } + }, + "name": { + "type": "Identifier", + "start": 31, + "end": 35, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 17 + }, + "identifierName": "LOOP" + }, + "name": "LOOP" + }, + "expectedNode": "Identifier" + } + } + ], + "directives": [] + } + }, + "label": { + "type": "Identifier", + "start": 0, + "end": 4, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + }, + "identifierName": "loop" + }, + "name": "loop" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/labels/labeled-statement/input.js b/packages/babel-parser/test/fixtures/placeholders/labels/labeled-statement/input.js new file mode 100644 index 000000000000..8bc65e46a765 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/labels/labeled-statement/input.js @@ -0,0 +1 @@ +%%FOO%%: 0; diff --git a/packages/babel-parser/test/fixtures/placeholders/labels/labeled-statement/output.json b/packages/babel-parser/test/fixtures/placeholders/labels/labeled-statement/output.json new file mode 100644 index 000000000000..597468988557 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/labels/labeled-statement/output.json @@ -0,0 +1,118 @@ +{ + "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": "LabeledStatement", + "start": 0, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "label": { + "type": "Placeholder", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": { + "type": "Identifier", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "FOO" + }, + "name": "FOO" + }, + "expectedNode": "Identifier" + }, + "body": { + "type": "ExpressionStatement", + "start": 9, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "expression": { + "type": "NumericLiteral", + "start": 9, + "end": 10, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/options.json b/packages/babel-parser/test/fixtures/placeholders/options.json new file mode 100644 index 000000000000..92404e501295 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["placeholders"] +} diff --git a/packages/babel-parser/test/fixtures/placeholders/statement/asi/input.js b/packages/babel-parser/test/fixtures/placeholders/statement/asi/input.js new file mode 100644 index 000000000000..deeb32f8f173 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/statement/asi/input.js @@ -0,0 +1,2 @@ +%%FOO%% +%%BAR%% diff --git a/packages/babel-parser/test/fixtures/placeholders/statement/asi/output.json b/packages/babel-parser/test/fixtures/placeholders/statement/asi/output.json new file mode 100644 index 000000000000..9980b76f599a --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/statement/asi/output.json @@ -0,0 +1,101 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "Placeholder", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "name": { + "type": "Identifier", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "FOO" + }, + "name": "FOO" + }, + "expectedNode": "Statement" + }, + { + "type": "Placeholder", + "start": 8, + "end": 15, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "name": { + "type": "Identifier", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 5 + }, + "identifierName": "BAR" + }, + "name": "BAR" + }, + "expectedNode": "Statement" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/statement/nested/input.js b/packages/babel-parser/test/fixtures/placeholders/statement/nested/input.js new file mode 100644 index 000000000000..6530842e22d9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/statement/nested/input.js @@ -0,0 +1 @@ +if (0) %%FOO%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/statement/nested/output.json b/packages/babel-parser/test/fixtures/placeholders/statement/nested/output.json new file mode 100644 index 000000000000..1f071964bf16 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/statement/nested/output.json @@ -0,0 +1,104 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "IfStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "test": { + "type": "NumericLiteral", + "start": 4, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 5 + } + }, + "extra": { + "rawValue": 0, + "raw": "0" + }, + "value": 0 + }, + "consequent": { + "type": "Placeholder", + "start": 7, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "name": { + "type": "Identifier", + "start": 9, + "end": 12, + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 12 + }, + "identifierName": "FOO" + }, + "name": "FOO" + }, + "expectedNode": "Statement" + }, + "alternate": null + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/statement/top-level/input.js b/packages/babel-parser/test/fixtures/placeholders/statement/top-level/input.js new file mode 100644 index 000000000000..34e9906e93b8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/statement/top-level/input.js @@ -0,0 +1 @@ +%%FOO%%; diff --git a/packages/babel-parser/test/fixtures/placeholders/statement/top-level/output.json b/packages/babel-parser/test/fixtures/placeholders/statement/top-level/output.json new file mode 100644 index 000000000000..d5f19f4035d0 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/statement/top-level/output.json @@ -0,0 +1,68 @@ +{ + "type": "File", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "Placeholder", + "start": 0, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "name": { + "type": "Identifier", + "start": 2, + "end": 5, + "loc": { + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + }, + "identifierName": "FOO" + }, + "name": "FOO" + }, + "expectedNode": "Statement" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/input.js b/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/input.js new file mode 100644 index 000000000000..97af833dd216 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/input.js @@ -0,0 +1 @@ +try %%TRY%% catch %%CATCH%% finally %%FINALLY%% diff --git a/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/output.json b/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/output.json new file mode 100644 index 000000000000..355f89df612f --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/output.json @@ -0,0 +1,166 @@ +{ + "type": "File", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "block": { + "type": "Placeholder", + "start": 4, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "name": { + "type": "Identifier", + "start": 6, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 9 + }, + "identifierName": "TRY" + }, + "name": "TRY" + }, + "expectedNode": "BlockStatement" + }, + "handler": { + "type": "CatchClause", + "start": 12, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "param": null, + "body": { + "type": "Placeholder", + "start": 18, + "end": 27, + "loc": { + "start": { + "line": 1, + "column": 18 + }, + "end": { + "line": 1, + "column": 27 + } + }, + "name": { + "type": "Identifier", + "start": 20, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 25 + }, + "identifierName": "CATCH" + }, + "name": "CATCH" + }, + "expectedNode": "BlockStatement" + } + }, + "guardedHandlers": [], + "finalizer": { + "type": "Placeholder", + "start": 36, + "end": 47, + "loc": { + "start": { + "line": 1, + "column": 36 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "name": { + "type": "Identifier", + "start": 38, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 1, + "column": 45 + }, + "identifierName": "FINALLY" + }, + "name": "FINALLY" + }, + "expectedNode": "BlockStatement" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/input.js b/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/input.js new file mode 100644 index 000000000000..e47082a3bd0d --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/input.js @@ -0,0 +1 @@ +try {} catch (%%PARAM%%) %%CATCH%% diff --git a/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/output.json b/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/output.json new file mode 100644 index 000000000000..cb39ff141899 --- /dev/null +++ b/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/output.json @@ -0,0 +1,150 @@ +{ + "type": "File", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "TryStatement", + "start": 0, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "block": { + "type": "BlockStatement", + "start": 4, + "end": 6, + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 6 + } + }, + "body": [], + "directives": [] + }, + "handler": { + "type": "CatchClause", + "start": 7, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "param": { + "type": "Placeholder", + "start": 14, + "end": 23, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 23 + } + }, + "name": { + "type": "Identifier", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "PARAM" + }, + "name": "PARAM" + }, + "expectedNode": "Pattern" + }, + "body": { + "type": "Placeholder", + "start": 25, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 1, + "column": 34 + } + }, + "name": { + "type": "Identifier", + "start": 27, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "CATCH" + }, + "name": "CATCH" + }, + "expectedNode": "BlockStatement" + } + }, + "guardedHandlers": [], + "finalizer": null + } + ], + "directives": [] + } +} \ No newline at end of file From 54ba6d80c01d9a1a68d2ae6cc690e62ad4b1d379 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 5 Mar 2019 17:05:03 +0100 Subject: [PATCH 34/58] Update identifier parsing per Unicode v12 (#9637) https://github.com/tc39/ecma262/issues/1467 https://github.com/tc39/ecma262/pull/1468 --- packages/babel-parser/package.json | 2 +- .../babel-parser/scripts/generate-identifier-regex.js | 5 +++-- packages/babel-parser/src/util/identifier.js | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/babel-parser/package.json b/packages/babel-parser/package.json index bdd0b80da331..c93d2cfbeac8 100644 --- a/packages/babel-parser/package.json +++ b/packages/babel-parser/package.json @@ -31,7 +31,7 @@ "@babel/code-frame": "^7.0.0", "@babel/helper-fixtures": "^7.2.0", "charcodes": "^0.2.0", - "unicode-11.0.0": "^0.7.8" + "unicode-12.0.0": "^0.7.9" }, "bin": { "parser": "./bin/babel-parser.js" diff --git a/packages/babel-parser/scripts/generate-identifier-regex.js b/packages/babel-parser/scripts/generate-identifier-regex.js index 083adcde0a2a..21e249ad4f28 100644 --- a/packages/babel-parser/scripts/generate-identifier-regex.js +++ b/packages/babel-parser/scripts/generate-identifier-regex.js @@ -1,7 +1,8 @@ "use strict"; -// Which Unicode version should be used? -const version = "11.0.0"; +// Always use the latest available version of Unicode! +// https://tc39.github.io/ecma262/#sec-conformance +const version = "12.0.0"; const start = require("unicode-" + version + diff --git a/packages/babel-parser/src/util/identifier.js b/packages/babel-parser/src/util/identifier.js index d8fa87603c1d..bfd2ca748f81 100644 --- a/packages/babel-parser/src/util/identifier.js +++ b/packages/babel-parser/src/util/identifier.js @@ -98,16 +98,16 @@ export const keywordRelationalOperator = /^in(stanceof)?$/; // ## Character categories -// Big ugly regular expressions that matches characters in the +// Big ugly regular expressions that match characters in the // whitespace, identifier, and identifier-start categories. These // are only applied when a character is found to actually have a // code point above 0x80. // Generated by `scripts/generate-identifier-regex.js`. /* prettier-ignore */ -let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7b9\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; +let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7c6\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; /* prettier-ignore */ -let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; +let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; const nonASCIIidentifierStart = new RegExp( "[" + nonASCIIidentifierStartChars + "]", @@ -124,9 +124,9 @@ nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; // offset to the next range, and then a size of the range. They were // generated by `scripts/generate-identifier-regex.js`. /* prettier-ignore */ -const astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,190,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,26,230,43,117,63,32,0,257,0,11,39,8,0,22,0,12,39,3,3,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,68,12,0,67,12,65,1,31,6129,15,754,9486,286,82,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]; +const astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,155,22,13,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,0,33,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,0,161,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,754,9486,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]; /* prettier-ignore */ -const astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,280,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239]; +const astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,232,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,792487,239]; // This has a complexity linear to the value of the code. The // assumption is that looking up astral identifier characters is From 349c0d4836808d1bec52dc2f6dfbd3afa039f9e9 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 5 Mar 2019 18:06:33 +0100 Subject: [PATCH 35/58] Update babel-plugin-proposal-unicode-property-regex for Unicode v12 (#9636) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/tc39/ecma262/issues/1467 https://github.com/tc39/ecma262/pull/1468 Co-authored-by: Nicolò Ribaudo --- .../package.json | 2 +- .../with-unicode-flag/unicode-12/input.js | 1 + .../with-unicode-flag/unicode-12/output.js | 1 + .../without-unicode-flag/unicode-12/input.js | 1 + .../without-unicode-flag/unicode-12/output.js | 1 + .../package.json | 2 +- .../package.json | 2 +- yarn.lock | 23 +++++++++++-------- 8 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/input.js create mode 100644 packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/output.js create mode 100644 packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/without-unicode-flag/unicode-12/input.js create mode 100644 packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/without-unicode-flag/unicode-12/output.js diff --git a/packages/babel-plugin-proposal-unicode-property-regex/package.json b/packages/babel-plugin-proposal-unicode-property-regex/package.json index e8ec8965fbe7..4e6f2207a8a4 100644 --- a/packages/babel-plugin-proposal-unicode-property-regex/package.json +++ b/packages/babel-plugin-proposal-unicode-property-regex/package.json @@ -24,7 +24,7 @@ "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", "@babel/helper-regex": "^7.0.0", - "regexpu-core": "^4.2.0" + "regexpu-core": "^4.5.2" }, "peerDependencies": { "@babel/core": "^7.0.0-0" diff --git a/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/input.js b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/input.js new file mode 100644 index 000000000000..711dde943b3c --- /dev/null +++ b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/input.js @@ -0,0 +1 @@ +var regex = /[\u{1E2C0}-\u{1E2F9}\u{1E2FF}]/u; diff --git a/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/output.js b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/output.js new file mode 100644 index 000000000000..711dde943b3c --- /dev/null +++ b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/with-unicode-flag/unicode-12/output.js @@ -0,0 +1 @@ +var regex = /[\u{1E2C0}-\u{1E2F9}\u{1E2FF}]/u; diff --git a/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/without-unicode-flag/unicode-12/input.js b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/without-unicode-flag/unicode-12/input.js new file mode 100644 index 000000000000..f563d323bd55 --- /dev/null +++ b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/without-unicode-flag/unicode-12/input.js @@ -0,0 +1 @@ +var regex = /\p{Script_Extensions=Wancho}/u; diff --git a/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/without-unicode-flag/unicode-12/output.js b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/without-unicode-flag/unicode-12/output.js new file mode 100644 index 000000000000..941a22ba2c3e --- /dev/null +++ b/packages/babel-plugin-proposal-unicode-property-regex/test/fixtures/without-unicode-flag/unicode-12/output.js @@ -0,0 +1 @@ +var regex = /(?:\uD838[\uDEC0-\uDEF9\uDEFF])/; diff --git a/packages/babel-plugin-transform-dotall-regex/package.json b/packages/babel-plugin-transform-dotall-regex/package.json index a10171064806..88316e83d19a 100644 --- a/packages/babel-plugin-transform-dotall-regex/package.json +++ b/packages/babel-plugin-transform-dotall-regex/package.json @@ -23,7 +23,7 @@ "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", "@babel/helper-regex": "^7.0.0", - "regexpu-core": "^4.1.3" + "regexpu-core": "^4.5.2" }, "peerDependencies": { "@babel/core": "^7.0.0-0" diff --git a/packages/babel-plugin-transform-unicode-regex/package.json b/packages/babel-plugin-transform-unicode-regex/package.json index d5167f6a11f2..ad6d64056c2b 100644 --- a/packages/babel-plugin-transform-unicode-regex/package.json +++ b/packages/babel-plugin-transform-unicode-regex/package.json @@ -14,7 +14,7 @@ "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", "@babel/helper-regex": "^7.0.0", - "regexpu-core": "^4.1.3" + "regexpu-core": "^4.5.2" }, "peerDependencies": { "@babel/core": "^7.0.0-0" diff --git a/yarn.lock b/yarn.lock index 1a41a9418210..19d99ed3cb0e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7602,9 +7602,10 @@ redent@^2.0.0: indent-string "^3.0.0" strip-indent "^2.0.0" -regenerate-unicode-properties@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-7.0.0.tgz#107405afcc4a190ec5ed450ecaa00ed0cafa7a4c" +regenerate-unicode-properties@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.0.0.tgz#01fc6d6c286fcc932c30f7025ca4a9928bbbb68c" + integrity sha512-tlYkVh6F/QXtosuyOZV2SkOtA248fjMAUWjGf8aYBvQK1ZMarbMvFBvkguSt93HhdXh20m15sc4b5EIBxXLHQQ== dependencies: regenerate "^1.4.0" @@ -7649,15 +7650,16 @@ regexpp@^2.0.1: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" regexpu-core@^4.1.3, regexpu-core@^4.2.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.4.0.tgz#8d43e0d1266883969720345e70c275ee0aec0d32" + version "4.5.2" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.5.2.tgz#9fcee72782f4fea6f8f428f7f14c8f242ca3dc82" + integrity sha512-CgGxXmuX0Cf57z7KahSHe4kaNY8gBRCFFEretQ5AHsnlLx/5VdCrQOoOz1POxLdZjPbwE5ncTspPJwp2WHPcHA== dependencies: regenerate "^1.4.0" - regenerate-unicode-properties "^7.0.0" + regenerate-unicode-properties "^8.0.0" regjsgen "^0.5.0" regjsparser "^0.6.0" unicode-match-property-ecmascript "^1.0.4" - unicode-match-property-value-ecmascript "^1.0.2" + unicode-match-property-value-ecmascript "^1.1.0" regjsgen@^0.5.0: version "0.5.0" @@ -8804,9 +8806,10 @@ unicode-match-property-ecmascript@^1.0.4: unicode-canonical-property-names-ecmascript "^1.0.4" unicode-property-aliases-ecmascript "^1.0.4" -unicode-match-property-value-ecmascript@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.0.2.tgz#9f1dc76926d6ccf452310564fd834ace059663d4" +unicode-match-property-value-ecmascript@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.1.0.tgz#5b4b426e08d13a80365e0d657ac7a6c1ec46a277" + integrity sha512-hDTHvaBk3RmFzvSl0UVrUmC3PuW9wKVnpoUDYH0JDkSIovzw+J5viQmeYHxVSBptubnr7PbH2e0fnpDRQnQl5g== unicode-property-aliases-ecmascript@^1.0.4: version "1.0.4" From 29999007f65a24153b74b0bb918242933b63f4df Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Tue, 5 Mar 2019 17:20:36 -0800 Subject: [PATCH 36/58] Disallow escape sequences in contextual keywords (#9618) * Disallow escape sequences in async * Disallow escape sequences in get, set and async in class * invalid escape tests * Update whitelist * tests for async in parens * Add test for invalid newline between params and arrow * Move canInsertSemilcolon() into shouldPArseAsyncArrow --- .../input.js | 4 +- .../babel-parser/src/parser/expression.js | 33 ++-- packages/babel-parser/src/parser/statement.js | 9 +- packages/babel-parser/src/plugins/flow.js | 2 + .../babel-parser/src/plugins/typescript.js | 10 +- .../core/object/invalid-escape-get/input.js | 1 + .../object/invalid-escape-get/options.json | 3 + .../fixtures/core/valid-escape/async/input.js | 1 + .../core/valid-escape/async/output.json | 87 ++++++++++ .../es2015/class/invalid-escape-get/input.js | 1 + .../class/invalid-escape-get/options.json | 3 + .../es2015/class/invalid-escape-set/input.js | 1 + .../class/invalid-escape-set/options.json | 3 + .../class/invalid-escape-static/input.js | 1 + .../class/invalid-escape-static/options.json | 3 + .../es2015/for-of/invalid-escape-of/input.js | 1 + .../for-of/invalid-escape-of/options.json | 3 + .../generators/invalid-escape-yield/input.js | 1 + .../invalid-escape-yield/options.json | 3 + .../es2015/let/invalid-escape/input.js | 1 + .../es2015/let/invalid-escape/options.json | 3 + .../input.js | 1 + .../options.json | 3 + .../modules/invalid-escape-export-as/input.js | 1 + .../invalid-escape-export-as/options.json | 4 + .../invalid-escape-import-from/input.js | 1 + .../invalid-escape-import-from/options.json | 4 + .../input.js | 1 + .../options.json | 3 + .../invalid-escape-async-obj-method/input.js | 1 + .../options.json | 3 + .../input.js | 1 + .../options.json | 3 + .../invalid-escape-await/input.js | 1 + .../invalid-escape-await/options.json | 3 + .../input.js | 1 + .../options.json | 3 + .../input.js | 1 + .../options.json | 3 + .../input.js | 1 + .../options.json | 3 + .../invalid-escape-sequence-arrow/input.js | 1 + .../options.json | 3 + .../input.js | 1 + .../options.json | 3 + .../invalid-escape-sequence-function/input.js | 1 + .../options.json | 3 + .../invalid-newline-after-params/input.js | 2 + .../invalid-newline-after-params/options.json | 3 + .../invalid-parens-async-arrow/input.js | 1 + .../invalid-parens-async-arrow/options.json | 3 + .../invalid-parens-async-func/input.js | 1 + .../invalid-parens-async-func/options.json | 3 + .../arrow-function-with-newline/input.js | 2 + .../arrow-function-with-newline/output.json | 152 ++++++++++++++++++ .../arrow-function-with-newline/input.js | 2 + .../arrow-function-with-newline/output.json | 151 +++++++++++++++++ scripts/tests/test262/test262_whitelist.txt | 4 - 58 files changed, 530 insertions(+), 22 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/core/object/invalid-escape-get/input.js create mode 100644 packages/babel-parser/test/fixtures/core/object/invalid-escape-get/options.json create mode 100644 packages/babel-parser/test/fixtures/core/valid-escape/async/input.js create mode 100644 packages/babel-parser/test/fixtures/core/valid-escape/async/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/class/invalid-escape-get/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/class/invalid-escape-get/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/class/invalid-escape-set/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/class/invalid-escape-set/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/class/invalid-escape-static/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/class/invalid-escape-static/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/for-of/invalid-escape-of/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/for-of/invalid-escape-of/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/let/invalid-escape/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/let/invalid-escape/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-export-as/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-export-as/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-class-method/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-class-method/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-obj-method/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-obj-method/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-static-class-method/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-static-class-method/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-async-function/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-async-function/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-dflt-async-function/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-dflt-async-function/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow-list/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow-list/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function-list/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function-list/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-newline-after-params/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-newline-after-params/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-arrow/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-arrow/options.json create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-func/input.js create mode 100644 packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-func/options.json create mode 100644 packages/babel-parser/test/fixtures/flow/regression/arrow-function-with-newline/input.js create mode 100644 packages/babel-parser/test/fixtures/flow/regression/arrow-function-with-newline/output.json create mode 100644 packages/babel-parser/test/fixtures/typescript/arrow-function/arrow-function-with-newline/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/arrow-function/arrow-function-with-newline/output.json diff --git a/packages/babel-generator/test/fixtures/edgecase/single-arg-async-arrow-with-retainlines/input.js b/packages/babel-generator/test/fixtures/edgecase/single-arg-async-arrow-with-retainlines/input.js index e409b79f575f..b5a205cc36d6 100644 --- a/packages/babel-generator/test/fixtures/edgecase/single-arg-async-arrow-with-retainlines/input.js +++ b/packages/babel-generator/test/fixtures/edgecase/single-arg-async-arrow-with-retainlines/input.js @@ -2,8 +2,8 @@ var fn = async ( arg ) => {} -async (x) -=> {} +async (x) => +{} async x => {} diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index b9195c3a9751..1483f90612ec 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -524,12 +524,21 @@ export default class ExpressionParser extends LValParser { startLoc: Position, noCalls?: ?boolean, ): N.Expression { + const maybeAsyncArrow = this.atPossibleAsync(base); + const state = { optionalChainMember: false, stop: false, }; do { - base = this.parseSubscript(base, startPos, startLoc, noCalls, state); + base = this.parseSubscript( + base, + startPos, + startLoc, + noCalls, + state, + maybeAsyncArrow, + ); } while (!state.stop); return base; } @@ -544,6 +553,7 @@ export default class ExpressionParser extends LValParser { startLoc: Position, noCalls: ?boolean, state: N.ParseSubscriptState, + maybeAsyncArrow: boolean, ): N.Expression { if (!noCalls && this.eat(tt.doubleColon)) { const node = this.startNodeAt(startPos, startLoc); @@ -575,13 +585,8 @@ export default class ExpressionParser extends LValParser { this.expect(tt.bracketR); return this.finishNode(node, "OptionalMemberExpression"); } else if (this.eat(tt.parenL)) { - const possibleAsync = this.atPossibleAsync(base); - node.callee = base; - node.arguments = this.parseCallExpressionArguments( - tt.parenR, - possibleAsync, - ); + node.arguments = this.parseCallExpressionArguments(tt.parenR, false); node.optional = true; return this.finishNode(node, "OptionalCallExpression"); } else { @@ -620,7 +625,6 @@ export default class ExpressionParser extends LValParser { this.state.yieldPos = 0; this.state.awaitPos = 0; - const possibleAsync = this.atPossibleAsync(base); this.next(); let node = this.startNodeAt(startPos, startLoc); @@ -631,7 +635,7 @@ export default class ExpressionParser extends LValParser { node.arguments = this.parseCallExpressionArguments( tt.parenR, - possibleAsync, + maybeAsyncArrow, base.type === "Import", base.type !== "Super", ); @@ -641,7 +645,7 @@ export default class ExpressionParser extends LValParser { this.finishOptionalCallExpression(node); } - if (possibleAsync && this.shouldParseAsyncArrow()) { + if (maybeAsyncArrow && this.shouldParseAsyncArrow()) { state.stop = true; this.checkCommaAfterRestFromSpread(); @@ -704,11 +708,11 @@ export default class ExpressionParser extends LValParser { atPossibleAsync(base: N.Expression): boolean { return ( - !this.state.containsEsc && - this.state.potentialArrowAt === base.start && base.type === "Identifier" && base.name === "async" && - !this.canInsertSemicolon() + this.state.lastTokEnd === base.end && + !this.canInsertSemicolon() && + this.state.input.slice(base.start, base.end) === "async" ); } @@ -791,7 +795,7 @@ export default class ExpressionParser extends LValParser { } shouldParseAsyncArrow(): boolean { - return this.match(tt.arrow); + return this.match(tt.arrow) && !this.canInsertSemicolon(); } parseAsyncArrowFromCallExpression( @@ -891,6 +895,7 @@ export default class ExpressionParser extends LValParser { return this.parseFunction(node, undefined, true); } else if ( canBeArrow && + !containsEsc && id.name === "async" && this.match(tt.name) && !this.canInsertSemicolon() diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 47b3c9f2c7f0..d97d4986a0a0 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -1321,6 +1321,7 @@ export default class StatementParser extends ExpressionParser { return; } + const containsEsc = this.state.containsEsc; const key = this.parseClassPropertyName(member); const isPrivate = key.type === "PrivateName"; // Check the key is not a computed expression or string literal. @@ -1371,7 +1372,12 @@ export default class StatementParser extends ExpressionParser { } else { this.pushClassProperty(classBody, publicProp); } - } else if (isSimple && key.name === "async" && !this.isLineTerminator()) { + } else if ( + isSimple && + key.name === "async" && + !containsEsc && + !this.isLineTerminator() + ) { // an async method const isGenerator = this.eat(tt.star); @@ -1407,6 +1413,7 @@ export default class StatementParser extends ExpressionParser { } else if ( isSimple && (key.name === "get" || key.name === "set") && + !containsEsc && !(this.match(tt.star) && this.isLineTerminator()) ) { // `get\n*` is an uninitialized property named 'get' followed by a generator. diff --git a/packages/babel-parser/src/plugins/flow.js b/packages/babel-parser/src/plugins/flow.js index 80961e09380b..725eea49573b 100644 --- a/packages/babel-parser/src/plugins/flow.js +++ b/packages/babel-parser/src/plugins/flow.js @@ -2619,6 +2619,7 @@ export default (superClass: Class): Class => startLoc: Position, noCalls: ?boolean, subscriptState: N.ParseSubscriptState, + maybeAsyncArrow: boolean, ): N.Expression { if (this.match(tt.questionDot) && this.isLookaheadRelational("<")) { this.expectPlugin("optionalChaining"); @@ -2671,6 +2672,7 @@ export default (superClass: Class): Class => startLoc, noCalls, subscriptState, + maybeAsyncArrow, ); } diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 7d1f81d1b8a7..0724db557024 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -1498,6 +1498,7 @@ export default (superClass: Class): Class => startLoc: Position, noCalls: ?boolean, state: N.ParseSubscriptState, + maybeAsyncArrow: boolean, ): N.Expression { if (!this.hasPrecedingLineBreak() && this.match(tt.bang)) { this.state.exprAllowed = false; @@ -1560,7 +1561,14 @@ export default (superClass: Class): Class => if (result) return result; } - return super.parseSubscript(base, startPos, startLoc, noCalls, state); + return super.parseSubscript( + base, + startPos, + startLoc, + noCalls, + state, + maybeAsyncArrow, + ); } parseNewArguments(node: N.NewExpression): void { diff --git a/packages/babel-parser/test/fixtures/core/object/invalid-escape-get/input.js b/packages/babel-parser/test/fixtures/core/object/invalid-escape-get/input.js new file mode 100644 index 000000000000..208cd4d559e8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/object/invalid-escape-get/input.js @@ -0,0 +1 @@ +({ ge\u0074 x() {} }) diff --git a/packages/babel-parser/test/fixtures/core/object/invalid-escape-get/options.json b/packages/babel-parser/test/fixtures/core/object/invalid-escape-get/options.json new file mode 100644 index 000000000000..0cd822570731 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/object/invalid-escape-get/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \",\" (1:12)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/valid-escape/async/input.js b/packages/babel-parser/test/fixtures/core/valid-escape/async/input.js new file mode 100644 index 000000000000..2e12a7c8d0a9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/valid-escape/async/input.js @@ -0,0 +1 @@ +(\u0061sync ()) diff --git a/packages/babel-parser/test/fixtures/core/valid-escape/async/output.json b/packages/babel-parser/test/fixtures/core/valid-escape/async/output.json new file mode 100644 index 000000000000..e220d3207f6b --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/valid-escape/async/output.json @@ -0,0 +1,87 @@ +{ + "type": "File", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "sourceType": "script", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 15, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "expression": { + "type": "CallExpression", + "start": 1, + "end": 14, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "callee": { + "type": "Identifier", + "start": 1, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "async" + }, + "name": "async" + }, + "arguments": [], + "extra": { + "parenthesized": true, + "parenStart": 0 + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-get/input.js b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-get/input.js new file mode 100644 index 000000000000..dca801f8de29 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-get/input.js @@ -0,0 +1 @@ +class X { ge\u0074 x() {} } diff --git a/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-get/options.json b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-get/options.json new file mode 100644 index 000000000000..1e730e170733 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-get/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:19)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-set/input.js b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-set/input.js new file mode 100644 index 000000000000..fafbe9ab9f4d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-set/input.js @@ -0,0 +1 @@ +class X { se\u0074 x(value) {} } diff --git a/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-set/options.json b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-set/options.json new file mode 100644 index 000000000000..1e730e170733 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-set/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:19)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-static/input.js b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-static/input.js new file mode 100644 index 000000000000..a561f8c32135 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-static/input.js @@ -0,0 +1 @@ +class X { st\u0061tic y() {} } diff --git a/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-static/options.json b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-static/options.json new file mode 100644 index 000000000000..b23f881870cf --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/class/invalid-escape-static/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:22)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/for-of/invalid-escape-of/input.js b/packages/babel-parser/test/fixtures/es2015/for-of/invalid-escape-of/input.js new file mode 100644 index 000000000000..7d8403183214 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-of/invalid-escape-of/input.js @@ -0,0 +1 @@ +for (x \u006ff y) {} diff --git a/packages/babel-parser/test/fixtures/es2015/for-of/invalid-escape-of/options.json b/packages/babel-parser/test/fixtures/es2015/for-of/invalid-escape-of/options.json new file mode 100644 index 000000000000..6b9933a77108 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/for-of/invalid-escape-of/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \";\" (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/input.js b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/input.js new file mode 100644 index 000000000000..521b91facbbc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/input.js @@ -0,0 +1 @@ +(function* () { y\u0069eld 10 }) diff --git a/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/options.json b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/options.json new file mode 100644 index 000000000000..dcd45c9b9715 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/generators/invalid-escape-yield/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Can not use 'yield' as identifier inside a generator (1:16)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/let/invalid-escape/input.js b/packages/babel-parser/test/fixtures/es2015/let/invalid-escape/input.js new file mode 100644 index 000000000000..b5cc585a2a7f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/invalid-escape/input.js @@ -0,0 +1 @@ +le\u0074 x = 5 diff --git a/packages/babel-parser/test/fixtures/es2015/let/invalid-escape/options.json b/packages/babel-parser/test/fixtures/es2015/let/invalid-escape/options.json new file mode 100644 index 000000000000..410ecd16fddf --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/let/invalid-escape/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \";\" (1:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/input.js b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/input.js new file mode 100644 index 000000000000..70a512c677a7 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/input.js @@ -0,0 +1 @@ +function f() { new.ta\u0072get; } diff --git a/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/options.json b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/options.json new file mode 100644 index 000000000000..4f4b2be4c186 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/meta-properties/new-target-invalid-escaped-target/options.json @@ -0,0 +1,3 @@ +{ + "throws": "The only valid meta property for new is new.target (1:19)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-export-as/input.js b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-export-as/input.js new file mode 100644 index 000000000000..bce203058944 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-export-as/input.js @@ -0,0 +1 @@ +export { X \u0061s Y } diff --git a/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-export-as/options.json b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-export-as/options.json new file mode 100644 index 000000000000..16c061d4dfd4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-export-as/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Unexpected token, expected \",\" (1:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/input.js b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/input.js new file mode 100644 index 000000000000..3f4408ab6e4c --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/input.js @@ -0,0 +1 @@ +import X fro\u006d 'x' diff --git a/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/options.json b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/options.json new file mode 100644 index 000000000000..6dab969b1115 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/modules/invalid-escape-import-from/options.json @@ -0,0 +1,4 @@ +{ + "sourceType": "module", + "throws": "Unexpected token (1:9)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-class-method/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-class-method/input.js new file mode 100644 index 000000000000..4dd0cd76e362 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-class-method/input.js @@ -0,0 +1 @@ +class X { \u0061sync x() { await x } } diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-class-method/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-class-method/options.json new file mode 100644 index 000000000000..b81bee7fa2e4 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-class-method/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:21)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-obj-method/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-obj-method/input.js new file mode 100644 index 000000000000..0807ff125175 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-obj-method/input.js @@ -0,0 +1 @@ +({ \u0061sync x() { await x } }) diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-obj-method/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-obj-method/options.json new file mode 100644 index 000000000000..f0907a448458 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-obj-method/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \",\" (1:14)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-static-class-method/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-static-class-method/input.js new file mode 100644 index 000000000000..a5b20dfebcfe --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-static-class-method/input.js @@ -0,0 +1 @@ +class X { static \u0061sync x() { await x } } diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-static-class-method/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-static-class-method/options.json new file mode 100644 index 000000000000..f55830c1c373 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-async-static-class-method/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (1:28)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/input.js new file mode 100644 index 000000000000..824b1c37725b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/input.js @@ -0,0 +1 @@ +(async function() { aw\u0061it x }) diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/options.json new file mode 100644 index 000000000000..ac6c5914cec6 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-await/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Can not use 'await' as identifier inside an async function (1:20)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-async-function/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-async-function/input.js new file mode 100644 index 000000000000..0d2ad1b32309 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-async-function/input.js @@ -0,0 +1 @@ +export \u0061sync function y() { await x } diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-async-function/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-async-function/options.json new file mode 100644 index 000000000000..9d60866b80c3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-async-function/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \"{\" (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-dflt-async-function/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-dflt-async-function/input.js new file mode 100644 index 000000000000..d14f4188a0b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-dflt-async-function/input.js @@ -0,0 +1 @@ +export default \u0061sync function y() { await x } diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-dflt-async-function/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-dflt-async-function/options.json new file mode 100644 index 000000000000..b0e5516212f3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-export-dflt-async-function/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \";\" (1:26)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow-list/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow-list/input.js new file mode 100644 index 000000000000..55506a887224 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow-list/input.js @@ -0,0 +1 @@ +(\u0061sync x => { await x }) diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow-list/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow-list/options.json new file mode 100644 index 000000000000..0cd822570731 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow-list/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \",\" (1:12)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow/input.js new file mode 100644 index 000000000000..1989072f30de --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow/input.js @@ -0,0 +1 @@ +\u0061sync x => { await x } diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow/options.json new file mode 100644 index 000000000000..f6eb197b1dd8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-arrow/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \";\" (1:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function-list/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function-list/input.js new file mode 100644 index 000000000000..978637393061 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function-list/input.js @@ -0,0 +1 @@ +(\u0061sync function() { await x }) diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function-list/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function-list/options.json new file mode 100644 index 000000000000..0cd822570731 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function-list/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \",\" (1:12)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function/input.js new file mode 100644 index 000000000000..a44cfbb62d1a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function/input.js @@ -0,0 +1 @@ +\u0061sync function() { await x } diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function/options.json new file mode 100644 index 000000000000..f6eb197b1dd8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-escape-sequence-function/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \";\" (1:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-newline-after-params/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-newline-after-params/input.js new file mode 100644 index 000000000000..52a0795cf08a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-newline-after-params/input.js @@ -0,0 +1,2 @@ +async (x) +=> {} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-newline-after-params/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-newline-after-params/options.json new file mode 100644 index 000000000000..0361d7c7d2b2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-newline-after-params/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token (2:0)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-arrow/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-arrow/input.js new file mode 100644 index 000000000000..33dbaaa09e00 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-arrow/input.js @@ -0,0 +1 @@ +(async)(a) => {} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-arrow/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-arrow/options.json new file mode 100644 index 000000000000..f6eb197b1dd8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-arrow/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \";\" (1:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-func/input.js b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-func/input.js new file mode 100644 index 000000000000..0af564cef72b --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-func/input.js @@ -0,0 +1 @@ +(async) function x (a) {} diff --git a/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-func/options.json b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-func/options.json new file mode 100644 index 000000000000..c2fcdb08cf9f --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2017/async-functions/invalid-parens-async-func/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected \";\" (1:8)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/regression/arrow-function-with-newline/input.js b/packages/babel-parser/test/fixtures/flow/regression/arrow-function-with-newline/input.js new file mode 100644 index 000000000000..5868c4e2feda --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/arrow-function-with-newline/input.js @@ -0,0 +1,2 @@ +async (f) +: t => { } diff --git a/packages/babel-parser/test/fixtures/flow/regression/arrow-function-with-newline/output.json b/packages/babel-parser/test/fixtures/flow/regression/arrow-function-with-newline/output.json new file mode 100644 index 000000000000..acc286d064ad --- /dev/null +++ b/packages/babel-parser/test/fixtures/flow/regression/arrow-function-with-newline/output.json @@ -0,0 +1,152 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "returnType": { + "type": "TypeAnnotation", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "typeAnnotation": { + "type": "GenericTypeAnnotation", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "typeParameters": null, + "id": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "t" + }, + "name": "t" + } + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "f" + }, + "name": "f" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/arrow-function/arrow-function-with-newline/input.js b/packages/babel-parser/test/fixtures/typescript/arrow-function/arrow-function-with-newline/input.js new file mode 100644 index 000000000000..5868c4e2feda --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/arrow-function/arrow-function-with-newline/input.js @@ -0,0 +1,2 @@ +async (f) +: t => { } diff --git a/packages/babel-parser/test/fixtures/typescript/arrow-function/arrow-function-with-newline/output.json b/packages/babel-parser/test/fixtures/typescript/arrow-function/arrow-function-with-newline/output.json new file mode 100644 index 000000000000..01a056dd1898 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/arrow-function/arrow-function-with-newline/output.json @@ -0,0 +1,151 @@ +{ + "type": "File", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "ExpressionStatement", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "expression": { + "type": "ArrowFunctionExpression", + "start": 0, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "returnType": { + "type": "TSTypeAnnotation", + "start": 10, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "typeAnnotation": { + "type": "TSTypeReference", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + } + }, + "typeName": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 3 + }, + "identifierName": "t" + }, + "name": "t" + } + } + }, + "id": null, + "generator": false, + "async": true, + "params": [ + { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "f" + }, + "name": "f" + } + ], + "body": { + "type": "BlockStatement", + "start": 17, + "end": 20, + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 10 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/scripts/tests/test262/test262_whitelist.txt b/scripts/tests/test262/test262_whitelist.txt index 03e75b2222f7..b936b9a595e2 100644 --- a/scripts/tests/test262/test262_whitelist.txt +++ b/scripts/tests/test262/test262_whitelist.txt @@ -601,10 +601,6 @@ language/module-code/privatename-not-valid-earlyerr-module-3.js(default) language/module-code/privatename-not-valid-earlyerr-module-3.js(strict mode) language/module-code/privatename-not-valid-earlyerr-module-4.js(default) language/module-code/privatename-not-valid-earlyerr-module-4.js(strict mode) -language/statements/class/async-gen-meth-escaped-async.js(default) -language/statements/class/async-gen-meth-escaped-async.js(strict mode) -language/statements/class/async-meth-escaped-async.js(default) -language/statements/class/async-meth-escaped-async.js(strict mode) language/statements/class/elements/fields-duplicate-privatenames.js(default) language/statements/class/elements/fields-duplicate-privatenames.js(strict mode) language/statements/class/elements/fields-literal-name-static-propname-constructor.js(default) From 28c71e88e2d0ec7c82504762dd7c0d824da48652 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Wed, 6 Mar 2019 11:41:03 +0100 Subject: [PATCH 37/58] Fix label name --- lerna.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lerna.json b/lerna.json index 806b98265731..8e4c852552ed 100644 --- a/lerna.json +++ b/lerna.json @@ -4,7 +4,7 @@ "repo": "babel/babel", "cacheDir": ".changelog", "labels": { - "PR: Spec Compliancy :eyeglasses:": ":eyeglasses: Spec Compliancy", + "PR: Spec Compliance :eyeglasses:": ":eyeglasses: Spec Compliance", "PR: Breaking Change :boom:": ":boom: Breaking Change", "PR: New Feature :rocket:": ":rocket: New Feature", "PR: Bug Fix :bug:": ":bug: Bug Fix", From fba5655a4483c05f4d5b17552614dd432a03bbe5 Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Fri, 22 Feb 2019 23:45:25 -0800 Subject: [PATCH 38/58] Parenthesized expressions (#8025) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add parser createParenthesizedExpressions option … When set to `true` we create `ParenthesizedExpression` nodes instead of setting `extra.parenthesized`. * Also update babel-parser.d.ts --- .../create-parenthesized-expressions/input.js | 12 + .../options.json | 3 + .../output.js | 10 + packages/babel-generator/test/index.js | 1 + packages/babel-parser/ast/spec.md | 12 + packages/babel-parser/src/options.js | 4 + .../babel-parser/src/parser/expression.js | 42 +- packages/babel-parser/src/parser/lval.js | 17 + packages/babel-parser/src/parser/statement.js | 17 +- packages/babel-parser/src/types.js | 5 + .../create-parenthesized-expressions/input.js | 12 + .../options.json | 3 + .../output.json | 391 +++++++++++++++++ .../fixtures/core/uncategorised/556/input.js | 1 + .../core/uncategorised/556/options.json | 4 + .../fixtures/core/uncategorised/557/input.js | 1 + .../core/uncategorised/557/options.json | 3 + .../core/uncategorised/557/output.json | 85 ++++ .../fixtures/core/uncategorised/558/input.js | 1 + .../core/uncategorised/558/options.json | 4 + .../create-parenthesized-expressions/input.js | 1 + .../options.json | 3 + .../output.json | 104 +++++ .../es2015/uncategorised/394/input.js | 4 + .../es2015/uncategorised/394/options.json | 3 + .../es2015/uncategorised/394/output.json | 392 ++++++++++++++++++ .../es2015/uncategorised/395/input.js | 1 + .../es2015/uncategorised/395/options.json | 4 + .../exponentiation-operator/15/input.js | 1 + .../exponentiation-operator/15/options.json | 4 + .../exponentiation-operator/16/input.js | 1 + .../exponentiation-operator/16/options.json | 4 + .../exponentiation-operator/2/output.json | 2 +- .../exponentiation-operator/7/output.json | 2 +- .../exponentiation-operator/8/output.json | 2 +- .../exponentiation-operator/9/output.json | 2 +- .../babel-parser/typings/babel-parser.d.ts | 8 + .../src/path/inference/inferers.js | 4 + .../src/asserts/generated/index.js | 12 +- .../src/builders/generated/index.js | 8 +- packages/babel-types/src/definitions/core.js | 10 + packages/babel-types/src/definitions/misc.js | 12 +- .../src/validators/generated/index.js | 40 +- 43 files changed, 1187 insertions(+), 65 deletions(-) create mode 100644 packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/input.js create mode 100644 packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/options.json create mode 100644 packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/output.js create mode 100644 packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/input.js create mode 100644 packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/options.json create mode 100644 packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/output.json create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/556/input.js create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/556/options.json create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/557/input.js create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/557/options.json create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/557/output.json create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/558/input.js create mode 100644 packages/babel-parser/test/fixtures/core/uncategorised/558/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/394/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/394/options.json create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/394/output.json create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/395/input.js create mode 100644 packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json create mode 100644 packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/input.js create mode 100644 packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json create mode 100644 packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/input.js create mode 100644 packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json diff --git a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/input.js b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/input.js new file mode 100644 index 000000000000..753a9cfbb2b5 --- /dev/null +++ b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/input.js @@ -0,0 +1,12 @@ +// One +(1); + +/* Two */ +(2); + +( + // Three + 3 +); + +(/* Four */ 4); diff --git a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/options.json b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/options.json new file mode 100644 index 000000000000..7c49b91ec9b2 --- /dev/null +++ b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/options.json @@ -0,0 +1,3 @@ +{ + "parserOpts": {"createParenthesizedExpressions": true} +} diff --git a/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/output.js b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/output.js new file mode 100644 index 000000000000..b78500e8017f --- /dev/null +++ b/packages/babel-generator/test/fixtures/comments/create-parenthesized-expressions/output.js @@ -0,0 +1,10 @@ +// One +(1); +/* Two */ + +(2); +( // Three +3); +( +/* Four */ +4); \ No newline at end of file diff --git a/packages/babel-generator/test/index.js b/packages/babel-generator/test/index.js index 057452885063..4781339b28ea 100644 --- a/packages/babel-generator/test/index.js +++ b/packages/babel-generator/test/index.js @@ -492,6 +492,7 @@ suites.forEach(function(testSuite) { strictMode: task.options.strictMode === false ? false : true, sourceType: "module", sourceMaps: !!task.sourceMap, + ...task.options.parserOpts, }); const options = { sourceFileName: path.relative(__dirname, actual.loc), diff --git a/packages/babel-parser/ast/spec.md b/packages/babel-parser/ast/spec.md index b4f5372cb440..34c04919cbd0 100644 --- a/packages/babel-parser/ast/spec.md +++ b/packages/babel-parser/ast/spec.md @@ -79,6 +79,7 @@ These are the core @babel/parser (babylon) AST node types. - [CallExpression](#callexpression) - [NewExpression](#newexpression) - [SequenceExpression](#sequenceexpression) + - [ParenthesizedExpression](#parenthesizedexpression) - [DoExpression](#doexpression) - [Template Literals](#template-literals) - [TemplateLiteral](#templateliteral) @@ -945,6 +946,17 @@ interface SequenceExpression <: Expression { 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 ```js diff --git a/packages/babel-parser/src/options.js b/packages/babel-parser/src/options.js index c11dd55cca99..5a615ccddfac 100755 --- a/packages/babel-parser/src/options.js +++ b/packages/babel-parser/src/options.js @@ -19,6 +19,7 @@ export type Options = { strictMode: ?boolean, ranges: boolean, tokens: boolean, + createParenthesizedExpressions: boolean, }; export const defaultOptions: Options = { @@ -55,6 +56,9 @@ export const defaultOptions: Options = { ranges: false, // Adds all parsed tokens to a `tokens` property on the `File` node 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 diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 1483f90612ec..71ce823720bd 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -40,6 +40,12 @@ import { SCOPE_PROGRAM, } from "../util/scopeflags"; +const unwrapParenthesizedExpression = node => { + return node.type === "ParenthesizedExpression" + ? unwrapParenthesizedExpression(node.expression) + : node; +}; + export default class ExpressionParser extends LValParser { // Forward-declaration: defined in statement.js +parseBlock: ( @@ -204,16 +210,22 @@ export default class ExpressionParser extends LValParser { this.checkLVal(left, undefined, undefined, "assignment expression"); + const maybePattern = unwrapParenthesizedExpression(left); + let patternErrorMsg; - if (left.type === "ObjectPattern") { + if (maybePattern.type === "ObjectPattern") { patternErrorMsg = "`({a}) = 0` use `({a} = 0)`"; - } else if (left.type === "ArrayPattern") { + } else if (maybePattern.type === "ArrayPattern") { patternErrorMsg = "`([a]) = 0` use `([a] = 0)`"; } - if (patternErrorMsg && left.extra && left.extra.parenthesized) { + if ( + patternErrorMsg && + ((left.extra && left.extra.parenthesized) || + left.type === "ParenthesizedExpression") + ) { this.raise( - left.start, + maybePattern.start, `You're trying to assign to a parenthesized expression, eg. instead of ${patternErrorMsg}`, ); } @@ -326,7 +338,8 @@ export default class ExpressionParser extends LValParser { if ( operator === "**" && left.type === "UnaryExpression" && - !(left.extra && left.extra.parenthesized) + (this.options.createParenthesizedExpressions || + !(left.extra && left.extra.parenthesized)) ) { this.raise( left.argument.start, @@ -1161,13 +1174,6 @@ export default class ExpressionParser extends LValParser { 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 { const startPos = this.state.start; const startLoc = this.state.startLoc; @@ -1278,10 +1284,16 @@ export default class ExpressionParser extends LValParser { val = exprList[0]; } - this.addExtra(val, "parenthesized", true); - this.addExtra(val, "parenStart", startPos); + if (!this.options.createParenthesizedExpressions) { + this.addExtra(val, "parenthesized", true); + this.addExtra(val, "parenStart", startPos); + return val; + } - return val; + const parenExpression = this.startNodeAt(startPos, startLoc); + parenExpression.expression = val; + this.finishNode(parenExpression, "ParenthesizedExpression"); + return parenExpression; } shouldParseArrow(): boolean { diff --git a/packages/babel-parser/src/parser/lval.js b/packages/babel-parser/src/parser/lval.js index dd02c8c97441..6db5558a8ff9 100644 --- a/packages/babel-parser/src/parser/lval.js +++ b/packages/babel-parser/src/parser/lval.js @@ -93,6 +93,14 @@ export default class LValParser extends NodeUtils { } break; + case "ParenthesizedExpression": + node.expression = this.toAssignable( + node.expression, + isBinding, + contextDescription, + ); + break; + case "MemberExpression": if (!isBinding) break; @@ -413,6 +421,15 @@ export default class LValParser extends NodeUtils { ); break; + case "ParenthesizedExpression": + this.checkLVal( + expr.expression, + bindingType, + checkClashes, + "parenthesized expression", + ); + break; + default: { const message = (bindingType === BIND_NONE diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index d97d4986a0a0..dd46a44df331 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -453,6 +453,13 @@ export default class StatementParser extends ExpressionParser { 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 { this.next(); this.state.labels.push(loopLabel); @@ -469,7 +476,7 @@ export default class StatementParser extends ExpressionParser { this.state.labels.pop(); this.expect(tt._while); - node.test = this.parseParenExpression(); + node.test = this.parseHeaderExpression(); this.eat(tt.semi); return this.finishNode(node, "DoWhileStatement"); } @@ -567,7 +574,7 @@ export default class StatementParser extends ExpressionParser { parseIfStatement(node: N.IfStatement): N.IfStatement { this.next(); - node.test = this.parseParenExpression(); + node.test = this.parseHeaderExpression(); node.consequent = this.parseStatement("if"); node.alternate = this.eat(tt._else) ? this.parseStatement("if") : null; return this.finishNode(node, "IfStatement"); @@ -596,7 +603,7 @@ export default class StatementParser extends ExpressionParser { parseSwitchStatement(node: N.SwitchStatement): N.SwitchStatement { this.next(); - node.discriminant = this.parseParenExpression(); + node.discriminant = this.parseHeaderExpression(); const cases = (node.cases = []); this.expect(tt.braceL); this.state.labels.push(switchLabel); @@ -715,7 +722,7 @@ export default class StatementParser extends ExpressionParser { parseWhileStatement(node: N.WhileStatement): N.WhileStatement { this.next(); - node.test = this.parseParenExpression(); + node.test = this.parseHeaderExpression(); this.state.labels.push(loopLabel); node.body = @@ -737,7 +744,7 @@ export default class StatementParser extends ExpressionParser { this.raise(this.state.start, "'with' in strict mode"); } this.next(); - node.object = this.parseParenExpression(); + node.object = this.parseHeaderExpression(); node.body = // For the smartPipelines plugin: diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index e3a584ddc32c..cc1fd01f305c 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -574,6 +574,11 @@ export type SequenceExpression = NodeBase & { expressions: $ReadOnlyArray, }; +export type ParenthesizedExpression = NodeBase & { + type: "ParenthesizedExpression", + expression: Expression, +}; + // Pipelines export type PipelineBody = NodeBase & { diff --git a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/input.js b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/input.js new file mode 100644 index 000000000000..753a9cfbb2b5 --- /dev/null +++ b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/input.js @@ -0,0 +1,12 @@ +// One +(1); + +/* Two */ +(2); + +( + // Three + 3 +); + +(/* Four */ 4); diff --git a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/options.json b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/options.json new file mode 100644 index 000000000000..0861962d889d --- /dev/null +++ b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/options.json @@ -0,0 +1,3 @@ +{ + "createParenthesizedExpressions": true +} diff --git a/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/output.json b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/output.json new file mode 100644 index 000000000000..761463790803 --- /dev/null +++ b/packages/babel-parser/test/fixtures/comments/basic/create-parenthesized-expressions/output.json @@ -0,0 +1,391 @@ +{ + "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 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/556/input.js b/packages/babel-parser/test/fixtures/core/uncategorised/556/input.js new file mode 100644 index 000000000000..13cfa4015d22 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/556/input.js @@ -0,0 +1 @@ +({x}) = {x: 1}; diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json new file mode 100644 index 000000000000..eff49cbfba64 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/556/options.json @@ -0,0 +1,4 @@ +{ + "createParenthesizedExpressions": true, + "throws": "You're trying to assign to a parenthesized expression, eg. instead of `({a}) = 0` use `({a} = 0)` (1:1)" +} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/557/input.js b/packages/babel-parser/test/fixtures/core/uncategorised/557/input.js new file mode 100644 index 000000000000..40d925520dfa --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/557/input.js @@ -0,0 +1 @@ +("hello"); diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/557/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/557/options.json new file mode 100644 index 000000000000..0861962d889d --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/557/options.json @@ -0,0 +1,3 @@ +{ + "createParenthesizedExpressions": true +} diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/557/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/557/output.json new file mode 100644 index 000000000000..b1f49f00e99f --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/557/output.json @@ -0,0 +1,85 @@ +{ + "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": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/558/input.js b/packages/babel-parser/test/fixtures/core/uncategorised/558/input.js new file mode 100644 index 000000000000..2cf717d47db3 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/558/input.js @@ -0,0 +1 @@ +([a]) = [] diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json b/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json new file mode 100644 index 000000000000..f37c4bc95c57 --- /dev/null +++ b/packages/babel-parser/test/fixtures/core/uncategorised/558/options.json @@ -0,0 +1,4 @@ +{ + "createParenthesizedExpressions": true, + "throws": "You're trying to assign to a parenthesized expression, eg. instead of `([a]) = 0` use `([a] = 0)` (1:1)" +} diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/input.js b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/input.js new file mode 100644 index 000000000000..6626a35389c8 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/input.js @@ -0,0 +1 @@ +(foo) => {} diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/options.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/options.json new file mode 100644 index 000000000000..0861962d889d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/options.json @@ -0,0 +1,3 @@ +{ + "createParenthesizedExpressions": true +} diff --git a/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/output.json b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/output.json new file mode 100644 index 000000000000..09568c70bbb9 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/arrow-functions/create-parenthesized-expressions/output.json @@ -0,0 +1,104 @@ +{ + "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": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/input.js new file mode 100644 index 000000000000..d6a05dcf09c2 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/input.js @@ -0,0 +1,4 @@ +var a; +(a) = {}; +(a.b) = {}; +(a['c']) = {}; diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/options.json new file mode 100644 index 000000000000..0861962d889d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/options.json @@ -0,0 +1,3 @@ +{ + "createParenthesizedExpressions": true +} diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/394/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/output.json new file mode 100644 index 000000000000..3eccd63cbd63 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/394/output.json @@ -0,0 +1,392 @@ +{ + "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": [] + } +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/input.js b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/input.js new file mode 100644 index 000000000000..874dec75a9cc --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/input.js @@ -0,0 +1 @@ +([a.a]) => 42 \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json new file mode 100644 index 000000000000..db72a6af957d --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/395/options.json @@ -0,0 +1,4 @@ +{ + "createParenthesizedExpressions": true, + "throws": "Invalid left-hand side in arrow function parameters (1:2)" +} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/input.js b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/input.js new file mode 100644 index 000000000000..63fce35a8a19 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/input.js @@ -0,0 +1 @@ +-(5) ** 6; diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json new file mode 100644 index 000000000000..c694133bf2b1 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/15/options.json @@ -0,0 +1,4 @@ +{ + "createParenthesizedExpressions": true, + "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:1)" +} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/input.js b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/input.js new file mode 100644 index 000000000000..47b91d35a849 --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/input.js @@ -0,0 +1 @@ +(-5 ** 6); diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json new file mode 100644 index 000000000000..19687fbe197a --- /dev/null +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/16/options.json @@ -0,0 +1,4 @@ +{ + "createParenthesizedExpressions": true, + "throws": "Illegal expression. Wrap left hand side or entire exponentiation in parentheses. (1:2)" +} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/2/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/2/output.json index e4e9ecd32a5d..e840aecbd18a 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/2/output.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/2/output.json @@ -124,4 +124,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/7/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/7/output.json index c4f295eacffd..2fb85f363b06 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/7/output.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/7/output.json @@ -160,4 +160,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/8/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/8/output.json index fd863ac0f6f6..56c71d7d2533 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/8/output.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/8/output.json @@ -156,4 +156,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/9/output.json b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/9/output.json index c3f4e42e1c0c..2691c6433738 100644 --- a/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/9/output.json +++ b/packages/babel-parser/test/fixtures/es2016/exponentiation-operator/9/output.json @@ -124,4 +124,4 @@ ], "directives": [] } -} \ No newline at end of file +} diff --git a/packages/babel-parser/typings/babel-parser.d.ts b/packages/babel-parser/typings/babel-parser.d.ts index b3f745f61a93..deba6be0e6a7 100644 --- a/packages/babel-parser/typings/babel-parser.d.ts +++ b/packages/babel-parser/typings/babel-parser.d.ts @@ -78,6 +78,14 @@ export interface ParserOptions { * Adds all parsed tokens to a tokens property on the File node. */ 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 = diff --git a/packages/babel-traverse/src/path/inference/inferers.js b/packages/babel-traverse/src/path/inference/inferers.js index 2f8ab658389b..fb9a467b1f64 100644 --- a/packages/babel-traverse/src/path/inference/inferers.js +++ b/packages/babel-traverse/src/path/inference/inferers.js @@ -102,6 +102,10 @@ export function SequenceExpression() { .getTypeAnnotation(); } +export function ParenthesizedExpression() { + return this.get("expression").getTypeAnnotation(); +} + export function AssignmentExpression() { return this.get("right").getTypeAnnotation(); } diff --git a/packages/babel-types/src/asserts/generated/index.js b/packages/babel-types/src/asserts/generated/index.js index 34a6a125a252..75fcbd6a8d22 100644 --- a/packages/babel-types/src/asserts/generated/index.js +++ b/packages/babel-types/src/asserts/generated/index.js @@ -162,6 +162,12 @@ export function assertSequenceExpression( ): void { assert("SequenceExpression", node, opts); } +export function assertParenthesizedExpression( + node: Object, + opts?: Object = {}, +): void { + assert("ParenthesizedExpression", node, opts); +} export function assertSwitchCase(node: Object, opts?: Object = {}): void { assert("SwitchCase", node, opts); } @@ -654,12 +660,6 @@ export function assertJSXClosingFragment( export function assertNoop(node: Object, opts?: Object = {}): void { assert("Noop", node, opts); } -export function assertParenthesizedExpression( - node: Object, - opts?: Object = {}, -): void { - assert("ParenthesizedExpression", node, opts); -} export function assertArgumentPlaceholder( node: Object, opts?: Object = {}, diff --git a/packages/babel-types/src/builders/generated/index.js b/packages/babel-types/src/builders/generated/index.js index 6b787e0bb3f8..e7af718d9c95 100644 --- a/packages/babel-types/src/builders/generated/index.js +++ b/packages/babel-types/src/builders/generated/index.js @@ -161,6 +161,10 @@ export function SequenceExpression(...args: Array): Object { return builder("SequenceExpression", ...args); } export { SequenceExpression as sequenceExpression }; +export function ParenthesizedExpression(...args: Array): Object { + return builder("ParenthesizedExpression", ...args); +} +export { ParenthesizedExpression as parenthesizedExpression }; export function SwitchCase(...args: Array): Object { return builder("SwitchCase", ...args); } @@ -592,10 +596,6 @@ export function Noop(...args: Array): Object { return builder("Noop", ...args); } export { Noop as noop }; -export function ParenthesizedExpression(...args: Array): Object { - return builder("ParenthesizedExpression", ...args); -} -export { ParenthesizedExpression as parenthesizedExpression }; export function ArgumentPlaceholder(...args: Array): Object { return builder("ArgumentPlaceholder", ...args); } diff --git a/packages/babel-types/src/definitions/core.js b/packages/babel-types/src/definitions/core.js index 214fa6ccd451..1e4de3ebbfa0 100644 --- a/packages/babel-types/src/definitions/core.js +++ b/packages/babel-types/src/definitions/core.js @@ -736,6 +736,16 @@ defineType("SequenceExpression", { aliases: ["Expression"], }); +defineType("ParenthesizedExpression", { + visitor: ["expression"], + aliases: ["Expression", "ExpressionWrapper"], + fields: { + expression: { + validate: assertNodeType("Expression"), + }, + }, +}); + defineType("SwitchCase", { visitor: ["test", "consequent"], fields: { diff --git a/packages/babel-types/src/definitions/misc.js b/packages/babel-types/src/definitions/misc.js index 2fc1334aac61..6bc22babc05f 100644 --- a/packages/babel-types/src/definitions/misc.js +++ b/packages/babel-types/src/definitions/misc.js @@ -1,16 +1,6 @@ // @flow -import defineType, { assertNodeType } from "./utils"; +import defineType from "./utils"; defineType("Noop", { visitor: [], }); - -defineType("ParenthesizedExpression", { - visitor: ["expression"], - aliases: ["Expression", "ExpressionWrapper"], - fields: { - expression: { - validate: assertNodeType("Expression"), - }, - }, -}); diff --git a/packages/babel-types/src/validators/generated/index.js b/packages/babel-types/src/validators/generated/index.js index c23ddcf11d97..969c6cdc2d5a 100644 --- a/packages/babel-types/src/validators/generated/index.js +++ b/packages/babel-types/src/validators/generated/index.js @@ -551,6 +551,23 @@ export function isSequenceExpression(node: ?Object, opts?: Object): boolean { 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 { if (!node) return false; @@ -2076,23 +2093,6 @@ export function isNoop(node: ?Object, opts?: Object): boolean { 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 isArgumentPlaceholder(node: ?Object, opts?: Object): boolean { if (!node) return false; @@ -3256,6 +3256,7 @@ export function isExpression(node: ?Object, opts?: Object): boolean { "NewExpression" === nodeType || "ObjectExpression" === nodeType || "SequenceExpression" === nodeType || + "ParenthesizedExpression" === nodeType || "ThisExpression" === nodeType || "UnaryExpression" === nodeType || "UpdateExpression" === nodeType || @@ -3269,7 +3270,6 @@ export function isExpression(node: ?Object, opts?: Object): boolean { "TypeCastExpression" === nodeType || "JSXElement" === nodeType || "JSXFragment" === nodeType || - "ParenthesizedExpression" === nodeType || "AwaitExpression" === nodeType || "BindExpression" === nodeType || "OptionalMemberExpression" === nodeType || @@ -3559,8 +3559,8 @@ export function isExpressionWrapper(node: ?Object, opts?: Object): boolean { if ( nodeType === "ExpressionWrapper" || "ExpressionStatement" === nodeType || - "TypeCastExpression" === nodeType || - "ParenthesizedExpression" === nodeType + "ParenthesizedExpression" === nodeType || + "TypeCastExpression" === nodeType ) { if (typeof opts === "undefined") { return true; From e53be4b387db4f5b9dffbf4710a31e3a29fdda70 Mon Sep 17 00:00:00 2001 From: Matt Tingen Date: Wed, 6 Mar 2019 16:54:42 -0500 Subject: [PATCH 39/58] [TS] Allow context type annotation on getters/setters (#9641) * Allow context type annotation on getters/setters * Extract getAccessorsExpectedParamCount --- .../babel-parser/src/parser/expression.js | 13 +- .../babel-parser/src/plugins/typescript.js | 13 + .../function/getter-setter/input.js | 6 + .../function/getter-setter/output.json | 396 ++++++++++++++++++ .../fixtures/function/this-parameter/input.js | 6 + .../function/this-parameter/output.js | 9 + 6 files changed, 441 insertions(+), 2 deletions(-) create mode 100644 packages/babel-parser/test/fixtures/typescript/function/getter-setter/input.js create mode 100644 packages/babel-parser/test/fixtures/typescript/function/getter-setter/output.json diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 71ce823720bd..35da903e7aa2 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -1564,10 +1564,16 @@ export default class ExpressionParser extends LValParser { ); } + getGetterSetterExpectedParamCount( + method: N.ObjectMethod | N.ClassMethod, + ): number { + return method.kind === "get" ? 0 : 1; + } + // get methods aren't allowed to have any parameters // set methods must have exactly 1 parameter which is not a rest parameter checkGetterSetterParams(method: N.ObjectMethod | N.ClassMethod): void { - const paramCount = method.kind === "get" ? 0 : 1; + const paramCount = this.getGetterSetterExpectedParamCount(method); const start = method.start; if (method.params.length !== paramCount) { if (method.kind === "get") { @@ -1577,7 +1583,10 @@ export default class ExpressionParser extends LValParser { } } - if (method.kind === "set" && method.params[0].type === "RestElement") { + if ( + method.kind === "set" && + method.params[method.params.length - 1].type === "RestElement" + ) { this.raise( start, "setter function argument must not be a rest parameter", diff --git a/packages/babel-parser/src/plugins/typescript.js b/packages/babel-parser/src/plugins/typescript.js index 0724db557024..513d0f3a94c0 100644 --- a/packages/babel-parser/src/plugins/typescript.js +++ b/packages/babel-parser/src/plugins/typescript.js @@ -2344,4 +2344,17 @@ export default (superClass: Class): Class => if (typeArguments) node.typeParameters = typeArguments; return super.jsxParseOpeningElementAfterName(node); } + + getGetterSetterExpectedParamCount( + method: N.ObjectMethod | N.ClassMethod, + ): number { + const baseCount = super.getGetterSetterExpectedParamCount(method); + const firstParam = method.params[0]; + const hasContextParam = + firstParam && + firstParam.type === "Identifier" && + firstParam.name === "this"; + + return hasContextParam ? baseCount + 1 : baseCount; + } }; diff --git a/packages/babel-parser/test/fixtures/typescript/function/getter-setter/input.js b/packages/babel-parser/test/fixtures/typescript/function/getter-setter/input.js new file mode 100644 index 000000000000..2a14042c1f49 --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/function/getter-setter/input.js @@ -0,0 +1,6 @@ +const g = { + get m(this: {}) {} +}; +const s = { + set m(this: {}, value) {} +}; \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/function/getter-setter/output.json b/packages/babel-parser/test/fixtures/typescript/function/getter-setter/output.json new file mode 100644 index 000000000000..ba424efc68ae --- /dev/null +++ b/packages/babel-parser/test/fixtures/typescript/function/getter-setter/output.json @@ -0,0 +1,396 @@ +{ + "type": "File", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 78, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "sourceType": "module", + "interpreter": null, + "body": [ + { + "type": "VariableDeclaration", + "start": 0, + "end": 35, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 6, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 6, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 7 + }, + "identifierName": "g" + }, + "name": "g" + }, + "init": { + "type": "ObjectExpression", + "start": 10, + "end": 34, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 3, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 14, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 18, + "end": 19, + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + }, + "identifierName": "m" + }, + "name": "m" + }, + "computed": false, + "kind": "get", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 20, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 16 + }, + "identifierName": "this" + }, + "name": "this", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 24, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "typeAnnotation": { + "type": "TSTypeLiteral", + "start": 26, + "end": 28, + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "members": [] + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 2, + "column": 18 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "kind": "const" + }, + { + "type": "VariableDeclaration", + "start": 36, + "end": 78, + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 6, + "column": 2 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 42, + "end": 77, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "id": { + "type": "Identifier", + "start": 42, + "end": 43, + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 7 + }, + "identifierName": "s" + }, + "name": "s" + }, + "init": { + "type": "ObjectExpression", + "start": 46, + "end": 77, + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "properties": [ + { + "type": "ObjectMethod", + "start": 50, + "end": 75, + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 27 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 54, + "end": 55, + "loc": { + "start": { + "line": 5, + "column": 6 + }, + "end": { + "line": 5, + "column": 7 + }, + "identifierName": "m" + }, + "name": "m" + }, + "computed": false, + "kind": "set", + "id": null, + "generator": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 56, + "end": 64, + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 16 + }, + "identifierName": "this" + }, + "name": "this", + "typeAnnotation": { + "type": "TSTypeAnnotation", + "start": 60, + "end": 64, + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "typeAnnotation": { + "type": "TSTypeLiteral", + "start": 62, + "end": 64, + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "members": [] + } + } + }, + { + "type": "Identifier", + "start": 66, + "end": 71, + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 23 + }, + "identifierName": "value" + }, + "name": "value" + } + ], + "body": { + "type": "BlockStatement", + "start": 73, + "end": 75, + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 27 + } + }, + "body": [], + "directives": [] + } + } + ] + } + } + ], + "kind": "const" + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/function/this-parameter/input.js b/packages/babel-plugin-transform-typescript/test/fixtures/function/this-parameter/input.js index 420e20481467..bcc3eb3624b3 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/function/this-parameter/input.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/function/this-parameter/input.js @@ -5,3 +5,9 @@ const o = { class C { m(this: {}) {} } +const g = { + get m(this: {}) {} +}; +const s = { + set m(this: {}, value: {}) {} +}; \ No newline at end of file diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/function/this-parameter/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/function/this-parameter/output.js index ded864e231dd..24b0164ac9cd 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/function/this-parameter/output.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/function/this-parameter/output.js @@ -9,3 +9,12 @@ class C { m() {} } + +const g = { + get m() {} + +}; +const s = { + set m(value) {} + +}; \ No newline at end of file From d8a53298345b0f2814f2964280890cd6b4a0752f Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 6 Mar 2019 14:30:04 -0800 Subject: [PATCH 40/58] Reorganize token types and use a map for them (#9645) --- .../babel-parser/src/plugins/jsx/index.js | 2 + packages/babel-parser/src/tokenizer/index.js | 2 +- packages/babel-parser/src/tokenizer/types.js | 128 ++++++++---------- packages/babel-parser/src/util/identifier.js | 39 +----- 4 files changed, 63 insertions(+), 108 deletions(-) diff --git a/packages/babel-parser/src/plugins/jsx/index.js b/packages/babel-parser/src/plugins/jsx/index.js index a129c6d27a27..378bba9286cc 100644 --- a/packages/babel-parser/src/plugins/jsx/index.js +++ b/packages/babel-parser/src/plugins/jsx/index.js @@ -14,6 +14,8 @@ import { isNewLine } from "../../util/whitespace"; const HEX_NUMBER = /^[\da-fA-F]+$/; const DECIMAL_NUMBER = /^\d+$/; +// Be aware that this file is always executed and not only when the plugin is enabled. +// Therefore this contexts and tokens do always exist. tc.j_oTag = new TokContext("...", true, true); diff --git a/packages/babel-parser/src/tokenizer/index.js b/packages/babel-parser/src/tokenizer/index.js index f576698130f5..5d86682bcd35 100644 --- a/packages/babel-parser/src/tokenizer/index.js +++ b/packages/babel-parser/src/tokenizer/index.js @@ -1329,7 +1329,7 @@ export default class Tokenizer extends LocationParser { readWord(): void { const word = this.readWord1(); - const type = keywordTypes[word] || tt.name; + const type = keywordTypes.get(word) || tt.name; if (type.keyword && this.state.containsEsc) { this.raise(this.state.pos, `Escape sequence in keyword ${word}`); diff --git a/packages/babel-parser/src/tokenizer/types.js b/packages/babel-parser/src/tokenizer/types.js index ea9f15c7082a..2301759f3892 100644 --- a/packages/babel-parser/src/tokenizer/types.js +++ b/packages/babel-parser/src/tokenizer/types.js @@ -32,7 +32,6 @@ const postfix = true; type TokenOptions = { keyword?: string, - beforeExpr?: boolean, startsExpr?: boolean, rightAssociative?: boolean, @@ -66,16 +65,21 @@ export class TokenType { this.isAssign = !!conf.isAssign; this.prefix = !!conf.prefix; this.postfix = !!conf.postfix; - this.binop = conf.binop === 0 ? 0 : conf.binop || null; + this.binop = conf.binop != null ? conf.binop : null; this.updateContext = null; } } -function KeywordTokenType(keyword: string, options: TokenOptions = {}) { - return new TokenType(keyword, { ...options, keyword }); +export const keywords = new Map(); + +function createKeyword(name: string, options: TokenOptions = {}): TokenType { + options.keyword = name; + const token = new TokenType(name, options); + keywords.set(name, token); + return token; } -function BinopTokenType(name: string, binop: number) { +function createBinop(name: string, binop: number) { return new TokenType(name, { beforeExpr, binop }); } @@ -133,74 +137,60 @@ export const types: { [name: string]: TokenType } = { incDec: new TokenType("++/--", { prefix, postfix, startsExpr }), bang: new TokenType("!", { beforeExpr, prefix, startsExpr }), tilde: new TokenType("~", { beforeExpr, prefix, startsExpr }), - pipeline: BinopTokenType("|>", 0), - nullishCoalescing: BinopTokenType("??", 1), - logicalOR: BinopTokenType("||", 1), - logicalAND: BinopTokenType("&&", 2), - bitwiseOR: BinopTokenType("|", 3), - bitwiseXOR: BinopTokenType("^", 4), - bitwiseAND: BinopTokenType("&", 5), - equality: BinopTokenType("==/!=", 6), - relational: BinopTokenType("", 7), - bitShift: BinopTokenType("<>", 8), + pipeline: createBinop("|>", 0), + nullishCoalescing: createBinop("??", 1), + logicalOR: createBinop("||", 1), + logicalAND: createBinop("&&", 2), + bitwiseOR: createBinop("|", 3), + bitwiseXOR: createBinop("^", 4), + bitwiseAND: createBinop("&", 5), + equality: createBinop("==/!=", 6), + relational: createBinop("", 7), + bitShift: createBinop("<>", 8), plusMin: new TokenType("+/-", { beforeExpr, binop: 9, prefix, startsExpr }), - modulo: BinopTokenType("%", 10), - star: BinopTokenType("*", 10), - slash: BinopTokenType("/", 10), + modulo: createBinop("%", 10), + star: createBinop("*", 10), + slash: createBinop("/", 10), exponent: new TokenType("**", { beforeExpr, binop: 11, rightAssociative: true, }), -}; -function makeKeywordProps( - name: string, - conf: any, -): PropertyDescriptor { - return { value: KeywordTokenType(name, conf), enumerable: true }; -} - -// $FlowIssue -export const keywords = Object.create(null, { - break: makeKeywordProps("break"), - case: makeKeywordProps("case", { beforeExpr }), - catch: makeKeywordProps("catch"), - continue: makeKeywordProps("continue"), - debugger: makeKeywordProps("debugger"), - default: makeKeywordProps("default", { beforeExpr }), - do: makeKeywordProps("do", { isLoop, beforeExpr }), - else: makeKeywordProps("else", { beforeExpr }), - finally: makeKeywordProps("finally"), - for: makeKeywordProps("for", { isLoop }), - function: makeKeywordProps("function", { startsExpr }), - if: makeKeywordProps("if"), - return: makeKeywordProps("return", { beforeExpr }), - switch: makeKeywordProps("switch"), - throw: makeKeywordProps("throw", { beforeExpr, prefix, startsExpr }), - try: makeKeywordProps("try"), - var: makeKeywordProps("var"), - const: makeKeywordProps("const"), - while: makeKeywordProps("while", { isLoop }), - with: makeKeywordProps("with"), - new: makeKeywordProps("new", { beforeExpr, startsExpr }), - this: makeKeywordProps("this", { startsExpr }), - super: makeKeywordProps("super", { startsExpr }), - class: makeKeywordProps("class", { startsExpr }), - extends: makeKeywordProps("extends", { beforeExpr }), - export: makeKeywordProps("export"), - import: makeKeywordProps("import", { startsExpr }), - null: makeKeywordProps("null", { startsExpr }), - true: makeKeywordProps("true", { startsExpr }), - false: makeKeywordProps("false", { startsExpr }), - in: makeKeywordProps("in", { beforeExpr, binop: 7 }), - instanceof: makeKeywordProps("instanceof", { beforeExpr, binop: 7 }), - typeof: makeKeywordProps("typeof", { beforeExpr, prefix, startsExpr }), - void: makeKeywordProps("void", { beforeExpr, prefix, startsExpr }), - delete: makeKeywordProps("delete", { beforeExpr, prefix, startsExpr }), -}); - -// Map keyword names to token types. -Object.keys(keywords).forEach(name => { - types["_" + name] = keywords[name]; -}); + // Keywords + _break: createKeyword("break"), + _case: createKeyword("case", { beforeExpr }), + _catch: createKeyword("catch"), + _continue: createKeyword("continue"), + _debugger: createKeyword("debugger"), + _default: createKeyword("default", { beforeExpr }), + _do: createKeyword("do", { isLoop, beforeExpr }), + _else: createKeyword("else", { beforeExpr }), + _finally: createKeyword("finally"), + _for: createKeyword("for", { isLoop }), + _function: createKeyword("function", { startsExpr }), + _if: createKeyword("if"), + _return: createKeyword("return", { beforeExpr }), + _switch: createKeyword("switch"), + _throw: createKeyword("throw", { beforeExpr, prefix, startsExpr }), + _try: createKeyword("try"), + _var: createKeyword("var"), + _const: createKeyword("const"), + _while: createKeyword("while", { isLoop }), + _with: createKeyword("with"), + _new: createKeyword("new", { beforeExpr, startsExpr }), + _this: createKeyword("this", { startsExpr }), + _super: createKeyword("super", { startsExpr }), + _class: createKeyword("class", { startsExpr }), + _extends: createKeyword("extends", { beforeExpr }), + _export: createKeyword("export"), + _import: createKeyword("import", { startsExpr }), + _null: createKeyword("null", { startsExpr }), + _true: createKeyword("true", { startsExpr }), + _false: createKeyword("false", { startsExpr }), + _in: createKeyword("in", { beforeExpr, binop: 7 }), + _instanceof: createKeyword("instanceof", { beforeExpr, binop: 7 }), + _typeof: createKeyword("typeof", { beforeExpr, prefix, startsExpr }), + _void: createKeyword("void", { beforeExpr, prefix, startsExpr }), + _delete: createKeyword("delete", { beforeExpr, prefix, startsExpr }), +}; diff --git a/packages/babel-parser/src/util/identifier.js b/packages/babel-parser/src/util/identifier.js index bfd2ca748f81..7fda0e27de71 100644 --- a/packages/babel-parser/src/util/identifier.js +++ b/packages/babel-parser/src/util/identifier.js @@ -3,6 +3,7 @@ // @flow import * as charCodes from "charcodes"; +import { keywords } from "../tokenizer/types"; const reservedWords = { strict: [ @@ -52,44 +53,6 @@ export function isStrictBindReservedWord( return isReservedWord(word, inModule) || reservedWordsStrictBindSet.has(word); } -const keywords = new Set([ - "break", - "case", - "catch", - "continue", - "debugger", - "default", - "do", - "else", - "finally", - "for", - "function", - "if", - "return", - "switch", - "throw", - "try", - "var", - "while", - "with", - "null", - "true", - "false", - "instanceof", - "typeof", - "void", - "delete", - "new", - "in", - "this", - "const", - "class", - "extends", - "export", - "import", - "super", -]); - export function isKeyword(word: string): boolean { return keywords.has(word); } From fb81e8f8b45b6264796841e57a9b0301cadb9ad9 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 6 Mar 2019 14:30:43 -0800 Subject: [PATCH 41/58] Make babel-standalone an ESModule and enable flow (#9025) * Make babel-standalone an ESModule and enable flow * autogenerate plugin list * Make config an array --- Makefile | 1 + packages/babel-standalone/scripts/generate.js | 37 +++ .../scripts/pluginConfig.json | 85 ++++++ .../babel-standalone/src/generated/plugins.js | 256 ++++++++++++++++++ packages/babel-standalone/src/index.js | 140 +++------- .../babel-standalone/src/preset-es2015.js | 82 +++--- .../babel-standalone/src/preset-stage-0.js | 8 +- .../babel-standalone/src/preset-stage-1.js | 23 +- .../babel-standalone/src/preset-stage-2.js | 20 +- .../babel-standalone/src/preset-stage-3.js | 19 +- .../scripts/generateTypeHelpers.js | 30 +- .../scripts => scripts}/utils/formatCode.js | 2 +- scripts/utils/writeFileAndMkDir.js | 14 + 13 files changed, 507 insertions(+), 210 deletions(-) create mode 100644 packages/babel-standalone/scripts/generate.js create mode 100644 packages/babel-standalone/scripts/pluginConfig.json create mode 100644 packages/babel-standalone/src/generated/plugins.js rename {packages/babel-types/scripts => scripts}/utils/formatCode.js (88%) create mode 100644 scripts/utils/writeFileAndMkDir.js diff --git a/Makefile b/Makefile index 0664763b8dd0..1a52c4cef887 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,7 @@ SOURCES = packages codemods build: clean clean-lib ./node_modules/.bin/gulp build + node ./packages/babel-standalone/scripts/generate.js node ./packages/babel-types/scripts/generateTypeHelpers.js # call build again as the generated files might need to be compiled again. ./node_modules/.bin/gulp build diff --git a/packages/babel-standalone/scripts/generate.js b/packages/babel-standalone/scripts/generate.js new file mode 100644 index 000000000000..a1c1cafb215d --- /dev/null +++ b/packages/babel-standalone/scripts/generate.js @@ -0,0 +1,37 @@ +// @flow +const pluginConfig = require("./pluginConfig.json"); +const path = require("path"); +const chalk = require("chalk"); +const camelCase = require("lodash/camelCase"); +const format = require("../../../scripts/utils/formatCode"); +const writeFile = require("../../../scripts/utils/writeFileAndMkDir"); + +const outputFile = path.join(__dirname, "../src/generated/plugins.js"); + +console.log("Generating @babel/standalone files"); + +let imports = ""; +let list = ""; +let allList = ""; + +for (const plugin of pluginConfig) { + const camelPlugin = camelCase(plugin); + imports += `import ${camelPlugin} from "@babel/plugin-${plugin}";`; + list += `${camelPlugin},`; + allList += `"${plugin}": ${camelPlugin},`; +} + +const fileContent = `// @flow +/* + * This file is auto-generated! Do not modify it directly. + * To re-generate run 'make build' + */ +${imports} + +export {${list}}; + +export const all = {${allList}}; +`; + +writeFile(outputFile, format(fileContent, outputFile)); +console.log(` ${chalk.green("✔")} Generated plugin list`); diff --git a/packages/babel-standalone/scripts/pluginConfig.json b/packages/babel-standalone/scripts/pluginConfig.json new file mode 100644 index 000000000000..812947393cdc --- /dev/null +++ b/packages/babel-standalone/scripts/pluginConfig.json @@ -0,0 +1,85 @@ +[ + "external-helpers", + "syntax-async-generators", + "syntax-class-properties", + "syntax-decorators", + "syntax-do-expressions", + "syntax-dynamic-import", + "syntax-export-default-from", + "syntax-export-namespace-from", + "syntax-flow", + "syntax-function-bind", + "syntax-function-sent", + "syntax-import-meta", + "syntax-jsx", + "syntax-object-rest-spread", + "syntax-optional-catch-binding", + "syntax-pipeline-operator", + "syntax-typescript", + "proposal-async-generator-functions", + "proposal-class-properties", + "proposal-decorators", + "proposal-do-expressions", + "proposal-export-default-from", + "proposal-export-namespace-from", + "proposal-function-bind", + "proposal-function-sent", + "proposal-json-strings", + "proposal-logical-assignment-operators", + "proposal-nullish-coalescing-operator", + "proposal-numeric-separator", + "proposal-object-rest-spread", + "proposal-optional-catch-binding", + "proposal-optional-chaining", + "proposal-pipeline-operator", + "proposal-private-methods", + "proposal-throw-expressions", + "proposal-unicode-property-regex", + "transform-async-to-generator", + "transform-arrow-functions", + "transform-block-scoped-functions", + "transform-block-scoping", + "transform-classes", + "transform-computed-properties", + "transform-destructuring", + "transform-dotall-regex", + "transform-duplicate-keys", + "transform-exponentiation-operator", + "transform-flow-comments", + "transform-flow-strip-types", + "transform-for-of", + "transform-function-name", + "transform-instanceof", + "transform-jscript", + "transform-literals", + "transform-member-expression-literals", + "transform-modules-amd", + "transform-modules-commonjs", + "transform-modules-systemjs", + "transform-modules-umd", + "transform-new-target", + "transform-object-assign", + "transform-object-super", + "transform-object-set-prototype-of-to-assign", + "transform-parameters", + "transform-property-literals", + "transform-property-mutators", + "transform-proto-to-assign", + "transform-react-constant-elements", + "transform-react-display-name", + "transform-react-inline-elements", + "transform-react-jsx", + "transform-react-jsx-compat", + "transform-react-jsx-self", + "transform-react-jsx-source", + "transform-regenerator", + "transform-runtime", + "transform-shorthand-properties", + "transform-spread", + "transform-sticky-regex", + "transform-strict-mode", + "transform-template-literals", + "transform-typeof-symbol", + "transform-typescript", + "transform-unicode-regex" +] diff --git a/packages/babel-standalone/src/generated/plugins.js b/packages/babel-standalone/src/generated/plugins.js new file mode 100644 index 000000000000..2e2e57576898 --- /dev/null +++ b/packages/babel-standalone/src/generated/plugins.js @@ -0,0 +1,256 @@ +// @flow +import externalHelpers from "@babel/plugin-external-helpers"; +import syntaxAsyncGenerators from "@babel/plugin-syntax-async-generators"; +import syntaxClassProperties from "@babel/plugin-syntax-class-properties"; +import syntaxDecorators from "@babel/plugin-syntax-decorators"; +import syntaxDoExpressions from "@babel/plugin-syntax-do-expressions"; +import syntaxDynamicImport from "@babel/plugin-syntax-dynamic-import"; +import syntaxExportDefaultFrom from "@babel/plugin-syntax-export-default-from"; +import syntaxExportNamespaceFrom from "@babel/plugin-syntax-export-namespace-from"; +import syntaxFlow from "@babel/plugin-syntax-flow"; +import syntaxFunctionBind from "@babel/plugin-syntax-function-bind"; +import syntaxFunctionSent from "@babel/plugin-syntax-function-sent"; +import syntaxImportMeta from "@babel/plugin-syntax-import-meta"; +import syntaxJsx from "@babel/plugin-syntax-jsx"; +import syntaxObjectRestSpread from "@babel/plugin-syntax-object-rest-spread"; +import syntaxOptionalCatchBinding from "@babel/plugin-syntax-optional-catch-binding"; +import syntaxPipelineOperator from "@babel/plugin-syntax-pipeline-operator"; +import syntaxTypescript from "@babel/plugin-syntax-typescript"; +import proposalAsyncGeneratorFunctions from "@babel/plugin-proposal-async-generator-functions"; +import proposalClassProperties from "@babel/plugin-proposal-class-properties"; +import proposalDecorators from "@babel/plugin-proposal-decorators"; +import proposalDoExpressions from "@babel/plugin-proposal-do-expressions"; +import proposalExportDefaultFrom from "@babel/plugin-proposal-export-default-from"; +import proposalExportNamespaceFrom from "@babel/plugin-proposal-export-namespace-from"; +import proposalFunctionBind from "@babel/plugin-proposal-function-bind"; +import proposalFunctionSent from "@babel/plugin-proposal-function-sent"; +import proposalJsonStrings from "@babel/plugin-proposal-json-strings"; +import proposalLogicalAssignmentOperators from "@babel/plugin-proposal-logical-assignment-operators"; +import proposalNullishCoalescingOperator from "@babel/plugin-proposal-nullish-coalescing-operator"; +import proposalNumericSeparator from "@babel/plugin-proposal-numeric-separator"; +import proposalObjectRestSpread from "@babel/plugin-proposal-object-rest-spread"; +import proposalOptionalCatchBinding from "@babel/plugin-proposal-optional-catch-binding"; +import proposalOptionalChaining from "@babel/plugin-proposal-optional-chaining"; +import proposalPipelineOperator from "@babel/plugin-proposal-pipeline-operator"; +import proposalPrivateMethods from "@babel/plugin-proposal-private-methods"; +import proposalThrowExpressions from "@babel/plugin-proposal-throw-expressions"; +import proposalUnicodePropertyRegex from "@babel/plugin-proposal-unicode-property-regex"; +import transformAsyncToGenerator from "@babel/plugin-transform-async-to-generator"; +import transformArrowFunctions from "@babel/plugin-transform-arrow-functions"; +import transformBlockScopedFunctions from "@babel/plugin-transform-block-scoped-functions"; +import transformBlockScoping from "@babel/plugin-transform-block-scoping"; +import transformClasses from "@babel/plugin-transform-classes"; +import transformComputedProperties from "@babel/plugin-transform-computed-properties"; +import transformDestructuring from "@babel/plugin-transform-destructuring"; +import transformDotallRegex from "@babel/plugin-transform-dotall-regex"; +import transformDuplicateKeys from "@babel/plugin-transform-duplicate-keys"; +import transformExponentiationOperator from "@babel/plugin-transform-exponentiation-operator"; +import transformFlowComments from "@babel/plugin-transform-flow-comments"; +import transformFlowStripTypes from "@babel/plugin-transform-flow-strip-types"; +import transformForOf from "@babel/plugin-transform-for-of"; +import transformFunctionName from "@babel/plugin-transform-function-name"; +import transformInstanceof from "@babel/plugin-transform-instanceof"; +import transformJscript from "@babel/plugin-transform-jscript"; +import transformLiterals from "@babel/plugin-transform-literals"; +import transformMemberExpressionLiterals from "@babel/plugin-transform-member-expression-literals"; +import transformModulesAmd from "@babel/plugin-transform-modules-amd"; +import transformModulesCommonjs from "@babel/plugin-transform-modules-commonjs"; +import transformModulesSystemjs from "@babel/plugin-transform-modules-systemjs"; +import transformModulesUmd from "@babel/plugin-transform-modules-umd"; +import transformNewTarget from "@babel/plugin-transform-new-target"; +import transformObjectAssign from "@babel/plugin-transform-object-assign"; +import transformObjectSuper from "@babel/plugin-transform-object-super"; +import transformObjectSetPrototypeOfToAssign from "@babel/plugin-transform-object-set-prototype-of-to-assign"; +import transformParameters from "@babel/plugin-transform-parameters"; +import transformPropertyLiterals from "@babel/plugin-transform-property-literals"; +import transformPropertyMutators from "@babel/plugin-transform-property-mutators"; +import transformProtoToAssign from "@babel/plugin-transform-proto-to-assign"; +import transformReactConstantElements from "@babel/plugin-transform-react-constant-elements"; +import transformReactDisplayName from "@babel/plugin-transform-react-display-name"; +import transformReactInlineElements from "@babel/plugin-transform-react-inline-elements"; +import transformReactJsx from "@babel/plugin-transform-react-jsx"; +import transformReactJsxCompat from "@babel/plugin-transform-react-jsx-compat"; +import transformReactJsxSelf from "@babel/plugin-transform-react-jsx-self"; +import transformReactJsxSource from "@babel/plugin-transform-react-jsx-source"; +import transformRegenerator from "@babel/plugin-transform-regenerator"; +import transformRuntime from "@babel/plugin-transform-runtime"; +import transformShorthandProperties from "@babel/plugin-transform-shorthand-properties"; +import transformSpread from "@babel/plugin-transform-spread"; +import transformStickyRegex from "@babel/plugin-transform-sticky-regex"; +import transformStrictMode from "@babel/plugin-transform-strict-mode"; +import transformTemplateLiterals from "@babel/plugin-transform-template-literals"; +import transformTypeofSymbol from "@babel/plugin-transform-typeof-symbol"; +import transformTypescript from "@babel/plugin-transform-typescript"; +import transformUnicodeRegex from "@babel/plugin-transform-unicode-regex"; + +export { + externalHelpers, + syntaxAsyncGenerators, + syntaxClassProperties, + syntaxDecorators, + syntaxDoExpressions, + syntaxDynamicImport, + syntaxExportDefaultFrom, + syntaxExportNamespaceFrom, + syntaxFlow, + syntaxFunctionBind, + syntaxFunctionSent, + syntaxImportMeta, + syntaxJsx, + syntaxObjectRestSpread, + syntaxOptionalCatchBinding, + syntaxPipelineOperator, + syntaxTypescript, + proposalAsyncGeneratorFunctions, + proposalClassProperties, + proposalDecorators, + proposalDoExpressions, + proposalExportDefaultFrom, + proposalExportNamespaceFrom, + proposalFunctionBind, + proposalFunctionSent, + proposalJsonStrings, + proposalLogicalAssignmentOperators, + proposalNullishCoalescingOperator, + proposalNumericSeparator, + proposalObjectRestSpread, + proposalOptionalCatchBinding, + proposalOptionalChaining, + proposalPipelineOperator, + proposalPrivateMethods, + proposalThrowExpressions, + proposalUnicodePropertyRegex, + transformAsyncToGenerator, + transformArrowFunctions, + transformBlockScopedFunctions, + transformBlockScoping, + transformClasses, + transformComputedProperties, + transformDestructuring, + transformDotallRegex, + transformDuplicateKeys, + transformExponentiationOperator, + transformFlowComments, + transformFlowStripTypes, + transformForOf, + transformFunctionName, + transformInstanceof, + transformJscript, + transformLiterals, + transformMemberExpressionLiterals, + transformModulesAmd, + transformModulesCommonjs, + transformModulesSystemjs, + transformModulesUmd, + transformNewTarget, + transformObjectAssign, + transformObjectSuper, + transformObjectSetPrototypeOfToAssign, + transformParameters, + transformPropertyLiterals, + transformPropertyMutators, + transformProtoToAssign, + transformReactConstantElements, + transformReactDisplayName, + transformReactInlineElements, + transformReactJsx, + transformReactJsxCompat, + transformReactJsxSelf, + transformReactJsxSource, + transformRegenerator, + transformRuntime, + transformShorthandProperties, + transformSpread, + transformStickyRegex, + transformStrictMode, + transformTemplateLiterals, + transformTypeofSymbol, + transformTypescript, + transformUnicodeRegex, +}; + +export const all = { + "external-helpers": externalHelpers, + "syntax-async-generators": syntaxAsyncGenerators, + "syntax-class-properties": syntaxClassProperties, + "syntax-decorators": syntaxDecorators, + "syntax-do-expressions": syntaxDoExpressions, + "syntax-dynamic-import": syntaxDynamicImport, + "syntax-export-default-from": syntaxExportDefaultFrom, + "syntax-export-namespace-from": syntaxExportNamespaceFrom, + "syntax-flow": syntaxFlow, + "syntax-function-bind": syntaxFunctionBind, + "syntax-function-sent": syntaxFunctionSent, + "syntax-import-meta": syntaxImportMeta, + "syntax-jsx": syntaxJsx, + "syntax-object-rest-spread": syntaxObjectRestSpread, + "syntax-optional-catch-binding": syntaxOptionalCatchBinding, + "syntax-pipeline-operator": syntaxPipelineOperator, + "syntax-typescript": syntaxTypescript, + "proposal-async-generator-functions": proposalAsyncGeneratorFunctions, + "proposal-class-properties": proposalClassProperties, + "proposal-decorators": proposalDecorators, + "proposal-do-expressions": proposalDoExpressions, + "proposal-export-default-from": proposalExportDefaultFrom, + "proposal-export-namespace-from": proposalExportNamespaceFrom, + "proposal-function-bind": proposalFunctionBind, + "proposal-function-sent": proposalFunctionSent, + "proposal-json-strings": proposalJsonStrings, + "proposal-logical-assignment-operators": proposalLogicalAssignmentOperators, + "proposal-nullish-coalescing-operator": proposalNullishCoalescingOperator, + "proposal-numeric-separator": proposalNumericSeparator, + "proposal-object-rest-spread": proposalObjectRestSpread, + "proposal-optional-catch-binding": proposalOptionalCatchBinding, + "proposal-optional-chaining": proposalOptionalChaining, + "proposal-pipeline-operator": proposalPipelineOperator, + "proposal-private-methods": proposalPrivateMethods, + "proposal-throw-expressions": proposalThrowExpressions, + "proposal-unicode-property-regex": proposalUnicodePropertyRegex, + "transform-async-to-generator": transformAsyncToGenerator, + "transform-arrow-functions": transformArrowFunctions, + "transform-block-scoped-functions": transformBlockScopedFunctions, + "transform-block-scoping": transformBlockScoping, + "transform-classes": transformClasses, + "transform-computed-properties": transformComputedProperties, + "transform-destructuring": transformDestructuring, + "transform-dotall-regex": transformDotallRegex, + "transform-duplicate-keys": transformDuplicateKeys, + "transform-exponentiation-operator": transformExponentiationOperator, + "transform-flow-comments": transformFlowComments, + "transform-flow-strip-types": transformFlowStripTypes, + "transform-for-of": transformForOf, + "transform-function-name": transformFunctionName, + "transform-instanceof": transformInstanceof, + "transform-jscript": transformJscript, + "transform-literals": transformLiterals, + "transform-member-expression-literals": transformMemberExpressionLiterals, + "transform-modules-amd": transformModulesAmd, + "transform-modules-commonjs": transformModulesCommonjs, + "transform-modules-systemjs": transformModulesSystemjs, + "transform-modules-umd": transformModulesUmd, + "transform-new-target": transformNewTarget, + "transform-object-assign": transformObjectAssign, + "transform-object-super": transformObjectSuper, + "transform-object-set-prototype-of-to-assign": transformObjectSetPrototypeOfToAssign, + "transform-parameters": transformParameters, + "transform-property-literals": transformPropertyLiterals, + "transform-property-mutators": transformPropertyMutators, + "transform-proto-to-assign": transformProtoToAssign, + "transform-react-constant-elements": transformReactConstantElements, + "transform-react-display-name": transformReactDisplayName, + "transform-react-inline-elements": transformReactInlineElements, + "transform-react-jsx": transformReactJsx, + "transform-react-jsx-compat": transformReactJsxCompat, + "transform-react-jsx-self": transformReactJsxSelf, + "transform-react-jsx-source": transformReactJsxSource, + "transform-regenerator": transformRegenerator, + "transform-runtime": transformRuntime, + "transform-shorthand-properties": transformShorthandProperties, + "transform-spread": transformSpread, + "transform-sticky-regex": transformStickyRegex, + "transform-strict-mode": transformStrictMode, + "transform-template-literals": transformTemplateLiterals, + "transform-typeof-symbol": transformTypeofSymbol, + "transform-typescript": transformTypescript, + "transform-unicode-regex": transformUnicodeRegex, +}; diff --git a/packages/babel-standalone/src/index.js b/packages/babel-standalone/src/index.js index 5804409ad095..d7ed72afd261 100644 --- a/packages/babel-standalone/src/index.js +++ b/packages/babel-standalone/src/index.js @@ -4,12 +4,26 @@ * plugins, instead explicitly registering all the available plugins and * presets, and requiring custom ones to be registered through `registerPlugin` * and `registerPreset` respectively. + * @flow */ /* global VERSION */ /* eslint-disable max-len */ -import * as Babel from "@babel/core"; +import { + transformFromAst as babelTransformFromAst, + transform as babelTransform, + buildExternalHelpers as babelBuildExternalHelpers, +} from "@babel/core"; +import { all } from "./generated/plugins"; +import preset2015 from "./preset-es2015"; +import presetStage0 from "./preset-stage-0"; +import presetStage1 from "./preset-stage-1"; +import presetStage2 from "./preset-stage-2"; +import presetStage3 from "./preset-stage-3"; +import presetReact from "@babel/preset-react"; +import presetFlow from "@babel/preset-flow"; +import presetTypescript from "@babel/preset-typescript"; import { runScripts } from "./transformScriptTags"; @@ -84,20 +98,20 @@ function processOptions(options) { }; } -export function transform(code, options) { - return Babel.transform(code, processOptions(options)); +export function transform(code: string, options: Object) { + return babelTransform(code, processOptions(options)); } -export function transformFromAst(ast, code, options) { - return Babel.transformFromAst(ast, code, processOptions(options)); +export function transformFromAst(ast: Object, code: string, options: Object) { + return babelTransformFromAst(ast, code, processOptions(options)); } export const availablePlugins = {}; export const availablePresets = {}; -export const buildExternalHelpers = Babel.buildExternalHelpers; +export const buildExternalHelpers = babelBuildExternalHelpers; /** * Registers a named plugin for use with Babel. */ -export function registerPlugin(name, plugin) { +export function registerPlugin(name: string, plugin: Object | Function): void { if (availablePlugins.hasOwnProperty(name)) { console.warn( `A plugin named "${name}" is already registered, it will be overridden`, @@ -109,7 +123,9 @@ export function registerPlugin(name, plugin) { * Registers multiple plugins for use with Babel. `newPlugins` should be an object where the key * is the name of the plugin, and the value is the plugin itself. */ -export function registerPlugins(newPlugins) { +export function registerPlugins(newPlugins: { + [string]: Object | Function, +}): void { Object.keys(newPlugins).forEach(name => registerPlugin(name, newPlugins[name]), ); @@ -118,7 +134,7 @@ export function registerPlugins(newPlugins) { /** * Registers a named preset for use with Babel. */ -export function registerPreset(name, preset) { +export function registerPreset(name: string, preset: Object | Function): void { if (availablePresets.hasOwnProperty(name)) { console.warn( `A preset named "${name}" is already registered, it will be overridden`, @@ -130,7 +146,9 @@ export function registerPreset(name, preset) { * Registers multiple presets for use with Babel. `newPresets` should be an object where the key * is the name of the preset, and the value is the preset itself. */ -export function registerPresets(newPresets) { +export function registerPresets(newPresets: { + [string]: Object | Function, +}): void { Object.keys(newPresets).forEach(name => registerPreset(name, newPresets[name]), ); @@ -139,90 +157,13 @@ export function registerPresets(newPresets) { // All the plugins we should bundle // Want to get rid of this long whitelist of plugins? // Wait! Please read https://github.com/babel/babel/pull/6177 first. -registerPlugins({ - "external-helpers": require("@babel/plugin-external-helpers"), - "syntax-async-generators": require("@babel/plugin-syntax-async-generators"), - "syntax-class-properties": require("@babel/plugin-syntax-class-properties"), - "syntax-decorators": require("@babel/plugin-syntax-decorators"), - "syntax-do-expressions": require("@babel/plugin-syntax-do-expressions"), - "syntax-dynamic-import": require("@babel/plugin-syntax-dynamic-import"), - "syntax-export-default-from": require("@babel/plugin-syntax-export-default-from"), - "syntax-export-namespace-from": require("@babel/plugin-syntax-export-namespace-from"), - "syntax-flow": require("@babel/plugin-syntax-flow"), - "syntax-function-bind": require("@babel/plugin-syntax-function-bind"), - "syntax-function-sent": require("@babel/plugin-syntax-function-sent"), - "syntax-import-meta": require("@babel/plugin-syntax-import-meta"), - "syntax-jsx": require("@babel/plugin-syntax-jsx"), - "syntax-object-rest-spread": require("@babel/plugin-syntax-object-rest-spread"), - "syntax-optional-catch-binding": require("@babel/plugin-syntax-optional-catch-binding"), - "syntax-pipeline-operator": require("@babel/plugin-syntax-pipeline-operator"), - "syntax-typescript": require("@babel/plugin-syntax-typescript"), - "transform-async-to-generator": require("@babel/plugin-transform-async-to-generator"), - "proposal-async-generator-functions": require("@babel/plugin-proposal-async-generator-functions"), - "proposal-class-properties": require("@babel/plugin-proposal-class-properties"), - "proposal-decorators": require("@babel/plugin-proposal-decorators"), - "proposal-do-expressions": require("@babel/plugin-proposal-do-expressions"), - "proposal-export-default-from": require("@babel/plugin-proposal-export-default-from"), - "proposal-export-namespace-from": require("@babel/plugin-proposal-export-namespace-from"), - "proposal-pipeline-operator": require("@babel/plugin-proposal-pipeline-operator"), - "proposal-private-methods": require("@babel/plugin-proposal-private-methods"), - "transform-arrow-functions": require("@babel/plugin-transform-arrow-functions"), - "transform-block-scoped-functions": require("@babel/plugin-transform-block-scoped-functions"), - "transform-block-scoping": require("@babel/plugin-transform-block-scoping"), - "transform-classes": require("@babel/plugin-transform-classes"), - "transform-computed-properties": require("@babel/plugin-transform-computed-properties"), - "transform-destructuring": require("@babel/plugin-transform-destructuring"), - "transform-dotall-regex": require("@babel/plugin-transform-dotall-regex"), - "transform-duplicate-keys": require("@babel/plugin-transform-duplicate-keys"), - "transform-for-of": require("@babel/plugin-transform-for-of"), - "transform-function-name": require("@babel/plugin-transform-function-name"), - "transform-instanceof": require("@babel/plugin-transform-instanceof"), - "transform-literals": require("@babel/plugin-transform-literals"), - "transform-modules-amd": require("@babel/plugin-transform-modules-amd"), - "transform-modules-commonjs": require("@babel/plugin-transform-modules-commonjs"), - "transform-modules-systemjs": require("@babel/plugin-transform-modules-systemjs"), - "transform-modules-umd": require("@babel/plugin-transform-modules-umd"), - "transform-object-super": require("@babel/plugin-transform-object-super"), - "transform-parameters": require("@babel/plugin-transform-parameters"), - "transform-shorthand-properties": require("@babel/plugin-transform-shorthand-properties"), - "transform-spread": require("@babel/plugin-transform-spread"), - "transform-sticky-regex": require("@babel/plugin-transform-sticky-regex"), - "transform-template-literals": require("@babel/plugin-transform-template-literals"), - "transform-typeof-symbol": require("@babel/plugin-transform-typeof-symbol"), - "transform-typescript": require("@babel/plugin-transform-typescript"), - "transform-unicode-regex": require("@babel/plugin-transform-unicode-regex"), - "transform-member-expression-literals": require("@babel/plugin-transform-member-expression-literals"), - "transform-property-literals": require("@babel/plugin-transform-property-literals"), - "transform-property-mutators": require("@babel/plugin-transform-property-mutators"), - "transform-exponentiation-operator": require("@babel/plugin-transform-exponentiation-operator"), - "transform-flow-comments": require("@babel/plugin-transform-flow-comments"), - "transform-flow-strip-types": require("@babel/plugin-transform-flow-strip-types"), - "proposal-function-bind": require("@babel/plugin-proposal-function-bind"), - "transform-jscript": require("@babel/plugin-transform-jscript"), - "transform-new-target": require("@babel/plugin-transform-new-target"), - "transform-object-assign": require("@babel/plugin-transform-object-assign"), - "proposal-object-rest-spread": require("@babel/plugin-proposal-object-rest-spread"), - "transform-object-set-prototype-of-to-assign": require("@babel/plugin-transform-object-set-prototype-of-to-assign"), - "proposal-optional-catch-binding": require("@babel/plugin-proposal-optional-catch-binding"), - "transform-proto-to-assign": require("@babel/plugin-transform-proto-to-assign"), - "transform-react-constant-elements": require("@babel/plugin-transform-react-constant-elements"), - "transform-react-display-name": require("@babel/plugin-transform-react-display-name"), - "transform-react-inline-elements": require("@babel/plugin-transform-react-inline-elements"), - "transform-react-jsx": require("@babel/plugin-transform-react-jsx"), - "transform-react-jsx-compat": require("@babel/plugin-transform-react-jsx-compat"), - "transform-react-jsx-self": require("@babel/plugin-transform-react-jsx-self"), - "transform-react-jsx-source": require("@babel/plugin-transform-react-jsx-source"), - "transform-regenerator": require("@babel/plugin-transform-regenerator"), - "transform-runtime": require("@babel/plugin-transform-runtime"), - "transform-strict-mode": require("@babel/plugin-transform-strict-mode"), - "proposal-unicode-property-regex": require("@babel/plugin-proposal-unicode-property-regex"), -}); +registerPlugins(all); // All the presets we should bundle // Want to get rid of this whitelist of presets? // Wait! Please read https://github.com/babel/babel/pull/6177 first. registerPresets({ - es2015: require("./preset-es2015"), + es2015: preset2015, es2016: () => { return { plugins: [availablePlugins["transform-exponentiation-operator"]], @@ -233,22 +174,23 @@ registerPresets({ plugins: [availablePlugins["transform-async-to-generator"]], }; }, - react: require("@babel/preset-react"), - "stage-0": require("./preset-stage-0"), - "stage-1": require("./preset-stage-1"), - "stage-2": require("./preset-stage-2"), - "stage-3": require("./preset-stage-3"), + react: presetReact, + "stage-0": presetStage0, + "stage-1": presetStage1, + "stage-2": presetStage2, + "stage-3": presetStage3, "es2015-loose": { - presets: [[require("./preset-es2015"), { loose: true }]], + presets: [[preset2015, { loose: true }]], }, // ES2015 preset with es2015-modules-commonjs removed "es2015-no-commonjs": { - presets: [[require("./preset-es2015"), { modules: false }]], + presets: [[preset2015, { modules: false }]], }, - typescript: require("@babel/preset-typescript"), - flow: require("@babel/preset-flow"), + typescript: presetTypescript, + flow: presetFlow, }); +// $FlowIgnore export const version = VERSION; function onDOMContentLoaded() { @@ -265,7 +207,7 @@ if (typeof window !== "undefined" && window && window.addEventListener) { * Transform