[ES7] Trailing comma in function parameter list
Currenly a stage 1 proposal. See https://github.com/jeffmo/es-trailing-function-commas.
This commit is contained in:
parent
320a39f4c4
commit
584532cc2c
@ -224,7 +224,7 @@ pp.parseSubscripts = function(base, start, noCalls) {
|
|||||||
} else if (!noCalls && this.eat(tt.parenL)) {
|
} else if (!noCalls && this.eat(tt.parenL)) {
|
||||||
let node = this.startNodeAt(start)
|
let node = this.startNodeAt(start)
|
||||||
node.callee = base
|
node.callee = base
|
||||||
node.arguments = this.parseExprList(tt.parenR, false)
|
node.arguments = this.parseExprList(tt.parenR, this.options.features["es7.trailingFunctionCommas"])
|
||||||
return this.parseSubscripts(this.finishNode(node, "CallExpression"), start, noCalls)
|
return this.parseSubscripts(this.finishNode(node, "CallExpression"), start, noCalls)
|
||||||
} else if (this.type === tt.backQuote) {
|
} else if (this.type === tt.backQuote) {
|
||||||
let node = this.startNodeAt(start)
|
let node = this.startNodeAt(start)
|
||||||
|
|||||||
@ -458,7 +458,7 @@ pp.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) {
|
|||||||
|
|
||||||
pp.parseFunctionParams = function(node) {
|
pp.parseFunctionParams = function(node) {
|
||||||
this.expect(tt.parenL)
|
this.expect(tt.parenL)
|
||||||
node.params = this.parseBindingList(tt.parenR, false, false)
|
node.params = this.parseBindingList(tt.parenR, false, this.options.features["es7.trailingFunctionCommas"])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse a class declaration or literal (depending on the
|
// Parse a class declaration or literal (depending on the
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
export var metadata = {
|
||||||
|
stage: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
export function check() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
export default {
|
export default {
|
||||||
"es7.classProperties": require("./es7/class-properties"),
|
"es7.classProperties": require("./es7/class-properties"),
|
||||||
|
"es7.trailingFunctionCommas": require("./es7/trailing-function-commas"),
|
||||||
"es7.asyncFunctions": require("./es7/async-functions"),
|
"es7.asyncFunctions": require("./es7/async-functions"),
|
||||||
"es7.decorators": require("./es7/decorators"),
|
"es7.decorators": require("./es7/decorators"),
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
Math.max(1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
);
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
Math.max(1, 2, 3);
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
function thisIsAFunctionWithAVeryLongNameAndWayTooManyParameters(
|
||||||
|
thisIsTheFirstParameter, andThisOneIsRelatedToIt,
|
||||||
|
butNotThisOne,
|
||||||
|
andNeitherThis,
|
||||||
|
inFactThereArentThatManyParameters,
|
||||||
|
) {
|
||||||
|
throw null;
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
function thisIsAFunctionWithAVeryLongNameAndWayTooManyParameters(thisIsTheFirstParameter, andThisOneIsRelatedToIt, butNotThisOne, andNeitherThis, inFactThereArentThatManyParameters) {
|
||||||
|
throw null;
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"optional": ["es7.trailingFunctionCommas"]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user