diff options
author | Michaƫl Zasso <mic.besace@gmail.com> | 2016-01-12 20:50:19 +0100 |
---|---|---|
committer | Roman Reiss <me@silverwind.io> | 2016-01-13 23:15:39 +0100 |
commit | 2d441493a4a46a511ba1bdf93e442c3288fbe92d (patch) | |
tree | c649c3aa100a57ff38ed267e3a5e5bba7ac8d961 /tools/eslint/node_modules/espree/espree.js | |
parent | ed55169834a3ce16a271def9630c858626ded34d (diff) | |
download | node-new-2d441493a4a46a511ba1bdf93e442c3288fbe92d.tar.gz |
tools: update eslint to v1.10.3
PR-URL: https://github.com/nodejs/io.js/pull/2286
Reviewed-By: Roman Reiss <me@silverwind.io>
Diffstat (limited to 'tools/eslint/node_modules/espree/espree.js')
-rw-r--r-- | tools/eslint/node_modules/espree/espree.js | 77 |
1 files changed, 67 insertions, 10 deletions
diff --git a/tools/eslint/node_modules/espree/espree.js b/tools/eslint/node_modules/espree/espree.js index 7ccf2dd298..a83286c3fc 100644 --- a/tools/eslint/node_modules/espree/espree.js +++ b/tools/eslint/node_modules/espree/espree.js @@ -580,6 +580,7 @@ function scanPunctuator() { // The ... operator (spread, restParams, JSX, etc.) if (extra.ecmaFeatures.spread || extra.ecmaFeatures.restParams || + extra.ecmaFeatures.experimentalObjectRestSpread || (extra.ecmaFeatures.jsx && state.inJSXSpreadAttribute) ) { if (ch1 === "." && ch2 === "." && ch3 === ".") { @@ -2069,7 +2070,7 @@ function throwError(token, messageFormat) { error = new Error("Line " + token.lineNumber + ": " + msg); error.index = token.range[0]; error.lineNumber = token.lineNumber; - error.column = token.range[0] - lineStart + 1; + error.column = token.range[0] - token.lineStart + 1; } else { error = new Error("Line " + lineNumber + ": " + msg); error.index = index; @@ -2464,6 +2465,7 @@ function parseObjectProperty() { allowShorthand = extra.ecmaFeatures.objectLiteralShorthandProperties, allowGenerators = extra.ecmaFeatures.generators, allowDestructuring = extra.ecmaFeatures.destructuring, + allowSpread = extra.ecmaFeatures.experimentalObjectRestSpread, marker = markerCreate(); token = lookahead; @@ -2612,6 +2614,12 @@ function parseObjectProperty() { ); } + // object spread property + if (allowSpread && match("...")) { + lex(); + return markerApply(marker, astNodeFactory.createExperimentalSpreadProperty(parseAssignmentExpression())); + } + // only possibility in this branch is a shorthand generator if (token.type === Token.EOF || token.type === Token.Punctuator) { if (!allowGenerators || !match("*") || !allowMethod) { @@ -2696,7 +2704,7 @@ function parseObjectInitialiser() { property = parseObjectProperty(); - if (!property.computed) { + if (!property.computed && property.type.indexOf("Experimental") === -1) { name = getFieldName(property.key); propertyFn = (property.kind === "get") ? PropertyKind.Get : PropertyKind.Set; @@ -2959,6 +2967,19 @@ function parseNewExpression() { marker = markerCreate(); expectKeyword("new"); + + if (extra.ecmaFeatures.newTarget && match(".")) { + lex(); + if (lookahead.type === Token.Identifier && lookahead.value === "target") { + if (state.inFunctionBody) { + lex(); + return markerApply(marker, astNodeFactory.createMetaProperty("new", "target")); + } + } + + throwUnexpected(lookahead); + } + callee = parseLeftHandSideExpression(); args = match("(") ? parseArguments() : []; @@ -3288,7 +3309,7 @@ function reinterpretAsCoverFormalsList(expressions) { throwError({}, Messages.UnexpectedToken, "."); } - reinterpretAsDestructuredParameter(options, param.argument); + validateParam(options, param.argument, param.argument.name); param.type = astNodeTypes.RestElement; params.push(param); } else if (param.type === astNodeTypes.RestElement) { @@ -3300,6 +3321,17 @@ function reinterpretAsCoverFormalsList(expressions) { param.type = astNodeTypes.AssignmentPattern; delete param.operator; + if (param.right.type === astNodeTypes.YieldExpression) { + if (param.right.argument) { + throwUnexpected(lookahead); + } + + param.right.type = astNodeTypes.Identifier; + param.right.name = "yield"; + delete param.right.argument; + delete param.right.delegate; + } + params.push(param); validateParam(options, param.left, param.left.name); } else { @@ -3324,10 +3356,15 @@ function reinterpretAsCoverFormalsList(expressions) { function parseArrowFunctionExpression(options, marker) { var previousStrict, body; + var arrowStart = lineNumber; expect("=>"); previousStrict = strict; + if (lineNumber > arrowStart) { + throwError({}, Messages.UnexpectedToken, "=>"); + } + body = parseConciseBody(); if (strict && options.firstRestricted) { @@ -3351,7 +3388,8 @@ function parseArrowFunctionExpression(options, marker) { function reinterpretAsAssignmentBindingPattern(expr) { var i, len, property, element, - allowDestructuring = extra.ecmaFeatures.destructuring; + allowDestructuring = extra.ecmaFeatures.destructuring, + allowRest = extra.ecmaFeatures.experimentalObjectRestSpread; if (!allowDestructuring) { throwUnexpected(lex()); @@ -3361,6 +3399,18 @@ function reinterpretAsAssignmentBindingPattern(expr) { expr.type = astNodeTypes.ObjectPattern; for (i = 0, len = expr.properties.length; i < len; i += 1) { property = expr.properties[i]; + + if (allowRest && property.type === astNodeTypes.ExperimentalSpreadProperty) { + + // only allow identifiers + if (property.argument.type !== astNodeTypes.Identifier) { + throwErrorTolerant({}, "Invalid object rest."); + } + + property.type = astNodeTypes.ExperimentalRestProperty; + return; + } + if (property.kind !== "init") { throwErrorTolerant({}, Messages.InvalidLHSInAssignment); } @@ -3475,7 +3525,6 @@ function parseAssignmentExpression() { if (match("=>") && (state.parenthesisCount === oldParenthesisCount || state.parenthesisCount === (oldParenthesisCount + 1))) { - if (node.type === astNodeTypes.Identifier) { params = reinterpretAsCoverFormalsList([ node ]); } else if (node.type === astNodeTypes.AssignmentExpression || @@ -3490,6 +3539,7 @@ function parseAssignmentExpression() { } if (params) { + state.parenthesisCount--; return parseArrowFunctionExpression(params, marker); } } @@ -3510,6 +3560,7 @@ function parseAssignmentExpression() { token = lex(); right = parseAssignmentExpression(); + node = markerApply(marker, astNodeFactory.createAssignmentExpression(token.value, left, right)); } @@ -3846,6 +3897,11 @@ function parseForStatement(opts) { init = parseExpression(); state.allowIn = true; + if (init.type === astNodeTypes.ArrayExpression) { + init.type = astNodeTypes.ArrayPattern; + } + + if (allowForOf && matchContextualKeyword("of")) { operator = lex(); left = init; @@ -4353,7 +4409,7 @@ function parseFunctionSourceElements() { oldInIteration = state.inIteration; oldInSwitch = state.inSwitch; oldInFunctionBody = state.inFunctionBody; - oldParenthesisCount = state.parenthesizedCount; + oldParenthesisCount = state.parenthesisCount; state.labelSet = new StringMap(); state.inIteration = false; @@ -4381,7 +4437,7 @@ function parseFunctionSourceElements() { state.inIteration = oldInIteration; state.inSwitch = oldInSwitch; state.inFunctionBody = oldInFunctionBody; - state.parenthesizedCount = oldParenthesisCount; + state.parenthesisCount = oldParenthesisCount; return markerApply(marker, astNodeFactory.createBlockStatement(sourceElements)); } @@ -4726,7 +4782,7 @@ function parseExportNamedDeclaration() { do { isExportFromIdentifier = isExportFromIdentifier || matchKeyword("default"); specifiers.push(parseExportSpecifier()); - } while (match(",") && lex()); + } while (match(",") && lex() && !match("}")); } expect("}"); @@ -4856,7 +4912,7 @@ function parseNamedImports() { if (!match("}")) { do { specifiers.push(parseImportSpecifier()); - } while (match(",") && lex()); + } while (match(",") && lex() && !match("}")); } expect("}"); return specifiers; @@ -5403,7 +5459,8 @@ function parse(code, options) { generators: true, destructuring: true, classes: true, - modules: true + modules: true, + newTarget: true }; } |