Merge pull request #3225 from hzoo/cp-semi
`babylon`: throw parse error if class properties do not have a semico…
This commit is contained in:
commit
d2f5a409da
@ -5,5 +5,5 @@ class Child extends Parent {
|
||||
|
||||
scopedFunctionWithThis = () => {
|
||||
this.name = {};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
call(class {
|
||||
static test = true
|
||||
static test = true;
|
||||
});
|
||||
|
||||
export default class {
|
||||
static test = true
|
||||
static test = true;
|
||||
};
|
||||
|
||||
@ -595,7 +595,7 @@ pp.parseClass = function (node, isStatement, optionalId) {
|
||||
};
|
||||
|
||||
pp.isClassProperty = function () {
|
||||
return this.match(tt.eq) || this.isLineTerminator();
|
||||
return this.match(tt.eq) || this.match(tt.semi) || this.canInsertSemicolon();
|
||||
};
|
||||
|
||||
pp.parseClassBody = function (node) {
|
||||
@ -747,7 +747,9 @@ pp.parseClassProperty = function (node) {
|
||||
} else {
|
||||
node.value = null;
|
||||
}
|
||||
this.semicolon();
|
||||
if (!this.eat(tt.semi)) {
|
||||
this.raise(this.state.start, "A semicolon is required after a class property");
|
||||
}
|
||||
return this.finishNode(node, "ClassProperty");
|
||||
};
|
||||
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
class A {
|
||||
asdf = 1
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "A semicolon is required after a class property (3:0)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
class A {
|
||||
asdf
|
||||
}
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"throws": "A semicolon is required after a class property (3:0)",
|
||||
"plugins": ["classProperties"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user