Require semicolons before class props named 'in' or 'instanceof' (#1878)

master
Kevin Gibbons 2017-06-02 10:52:11 -07:00 committed by Christopher Chedeau
parent 78b99329bf
commit 4915e0228e
3 changed files with 49 additions and 0 deletions

View File

@ -4591,6 +4591,10 @@ function classChildNeedsASIProtection(node) {
return;
}
if (!node.computed) {
const name = node.key && node.key.name;
if (name === "in" || name === "instanceof") return true;
}
switch (node.type) {
case "ClassProperty":
case "TSAbstractClassProperty":

View File

@ -3,17 +3,53 @@
exports[`no-semi.js 1`] = `
a
;::b.c
class A {
a = b;
in
c
a = b;
instanceof(){}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a;
::b.c;
class A {
a = b;
in;
c;
a = b;
instanceof() {}
}
`;
exports[`no-semi.js 2`] = `
a
;::b.c
class A {
a = b;
in
c
a = b;
instanceof(){}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a
;::b.c
class A {
a = b;
in
c
a = b;
instanceof() {}
}
`;

View File

@ -1,2 +1,11 @@
a
;::b.c
class A {
a = b;
in
c
a = b;
instanceof(){}
}