2017-04-11 23:50:47 +03:00
|
|
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`comments.js - babylon-verify 1`] = `
|
2017-04-14 04:33:46 +03:00
|
|
|
let error = new Error(response.statusText);
|
|
|
|
// comment
|
|
|
|
(error: any).response = response
|
|
|
|
|
|
|
|
x;
|
|
|
|
|
|
|
|
/* comment */ (error: any).response = response
|
|
|
|
|
|
|
|
x;
|
|
|
|
|
|
|
|
(error: any).response = response; /* comment */
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2018-07-03 09:06:29 +03:00
|
|
|
let error = new Error(response.statusText)
|
2017-04-14 04:33:46 +03:00
|
|
|
// comment
|
2018-07-03 09:06:29 +03:00
|
|
|
;(error: any).response = response
|
2017-04-14 04:33:46 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x
|
2017-04-14 04:33:46 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
/* comment */ ;(error: any).response = response
|
2017-04-14 04:33:46 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x
|
2017-04-14 04:33:46 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
;(error: any).response = response /* comment */
|
2017-04-14 04:33:46 +03:00
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`comments.js - flow-verify 1`] = `
|
2017-04-14 04:33:46 +03:00
|
|
|
let error = new Error(response.statusText);
|
|
|
|
// comment
|
|
|
|
(error: any).response = response
|
|
|
|
|
|
|
|
x;
|
|
|
|
|
|
|
|
/* comment */ (error: any).response = response
|
|
|
|
|
|
|
|
x;
|
|
|
|
|
|
|
|
(error: any).response = response; /* comment */
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2018-07-03 09:06:29 +03:00
|
|
|
let error = new Error(response.statusText);
|
2017-04-14 04:33:46 +03:00
|
|
|
// comment
|
2018-07-03 09:06:29 +03:00
|
|
|
(error: any).response = response;
|
2017-04-14 04:33:46 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x;
|
2017-04-14 04:33:46 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
/* comment */ (error: any).response = response;
|
2017-04-14 04:33:46 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x;
|
2017-04-14 04:33:46 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
(error: any).response = response; /* comment */
|
2017-04-14 04:33:46 +03:00
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`comments.js - flow-verify 2`] = `
|
2017-04-14 04:33:46 +03:00
|
|
|
let error = new Error(response.statusText);
|
|
|
|
// comment
|
|
|
|
(error: any).response = response
|
|
|
|
|
|
|
|
x;
|
|
|
|
|
|
|
|
/* comment */ (error: any).response = response
|
|
|
|
|
|
|
|
x;
|
|
|
|
|
|
|
|
(error: any).response = response; /* comment */
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
let error = new Error(response.statusText)
|
|
|
|
// comment
|
|
|
|
;(error: any).response = response
|
|
|
|
|
|
|
|
x
|
|
|
|
|
|
|
|
/* comment */ ;(error: any).response = response
|
|
|
|
|
|
|
|
x
|
|
|
|
|
|
|
|
;(error: any).response = response /* comment */
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`flow-interfaces.js - babylon-verify 1`] = `
|
2017-09-25 14:45:40 +03:00
|
|
|
declare class A {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare class B {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
declare interface C {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare interface D {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
interface E {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// interface F {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
declare class A {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare class B {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
declare interface C {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare interface D {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
interface E {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// interface F {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`flow-interfaces.js - flow-verify 1`] = `
|
2017-09-25 14:45:40 +03:00
|
|
|
declare class A {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare class B {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
declare interface C {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare interface D {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
interface E {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// interface F {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
declare class A {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare class B {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
declare interface C {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare interface D {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
interface E {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// interface F {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`flow-interfaces.js - flow-verify 2`] = `
|
2017-09-25 14:45:40 +03:00
|
|
|
declare class A {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare class B {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
declare interface C {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare interface D {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
interface E {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string }
|
|
|
|
| number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// interface F {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
declare class A {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare class B {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
declare interface C {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// declare interface D {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
interface E {
|
|
|
|
one: boolean;
|
|
|
|
two: { three: string } | number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: Flow and Babylon both fail to apply ASI here
|
|
|
|
// interface F {
|
|
|
|
// one: boolean
|
|
|
|
// two: { three: string }
|
|
|
|
// | number
|
|
|
|
// }
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`issue2006.js - babylon-verify 1`] = `
|
2017-06-07 00:28:51 +03:00
|
|
|
switch (n) {
|
|
|
|
case 11:
|
|
|
|
var c = a.e;
|
|
|
|
(i.a += Ga(c.e)), F(i, c.i, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
var c = a.e;
|
|
|
|
(i.a += Ga(c.e)), F(i, c.i, 0);
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
switch (n) {
|
|
|
|
case 11:
|
2018-07-03 09:06:29 +03:00
|
|
|
var c = a.e
|
|
|
|
;(i.a += Ga(c.e)), F(i, c.i, 0)
|
2017-06-07 00:28:51 +03:00
|
|
|
}
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
var c = a.e
|
|
|
|
;(i.a += Ga(c.e)), F(i, c.i, 0)
|
2017-06-07 00:28:51 +03:00
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`issue2006.js - flow-verify 1`] = `
|
2017-06-07 00:28:51 +03:00
|
|
|
switch (n) {
|
|
|
|
case 11:
|
|
|
|
var c = a.e;
|
|
|
|
(i.a += Ga(c.e)), F(i, c.i, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
var c = a.e;
|
|
|
|
(i.a += Ga(c.e)), F(i, c.i, 0);
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
switch (n) {
|
|
|
|
case 11:
|
2018-07-03 09:06:29 +03:00
|
|
|
var c = a.e;
|
|
|
|
(i.a += Ga(c.e)), F(i, c.i, 0);
|
2017-06-07 00:28:51 +03:00
|
|
|
}
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
var c = a.e;
|
|
|
|
(i.a += Ga(c.e)), F(i, c.i, 0);
|
2017-06-07 00:28:51 +03:00
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`issue2006.js - flow-verify 2`] = `
|
2017-06-07 00:28:51 +03:00
|
|
|
switch (n) {
|
|
|
|
case 11:
|
|
|
|
var c = a.e;
|
|
|
|
(i.a += Ga(c.e)), F(i, c.i, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
var c = a.e;
|
|
|
|
(i.a += Ga(c.e)), F(i, c.i, 0);
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
switch (n) {
|
|
|
|
case 11:
|
|
|
|
var c = a.e
|
|
|
|
;(i.a += Ga(c.e)), F(i, c.i, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
var c = a.e
|
|
|
|
;(i.a += Ga(c.e)), F(i, c.i, 0)
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`no-semi.js - babylon-verify 1`] = `
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
// with preexisting semi
|
|
|
|
|
|
|
|
x; [1, 2, 3].forEach(fn)
|
|
|
|
x; [a, b, ...c] = [1, 2]
|
|
|
|
x; /r/i.test('r')
|
|
|
|
x; +1
|
|
|
|
x; - 1
|
|
|
|
x; ('h' + 'i').repeat(10)
|
|
|
|
x; (1, 2)
|
|
|
|
x; (() => {})()
|
|
|
|
x; ({ a: 1 }).entries()
|
|
|
|
x; ({ a: 1 }).entries()
|
|
|
|
x; <Hello />
|
|
|
|
x; \`string\`
|
|
|
|
x; (x, y) => x
|
|
|
|
|
|
|
|
// doesn't have to be preceded by a semicolon
|
|
|
|
|
|
|
|
class X {} [1, 2, 3].forEach(fn)
|
|
|
|
|
|
|
|
// TODO: upgrade parser
|
|
|
|
// class A {
|
|
|
|
// async; // The semicolon is *not* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
|
|
|
// class B {
|
|
|
|
// static; // The semicolon *is* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
2017-12-07 16:03:55 +03:00
|
|
|
|
|
|
|
class C {
|
|
|
|
get; // The semicolon *is* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
get = () => {}; // The semicolon is *not* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set; // The semicolon *is* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set = () => {}; // The semicolon is *not* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
// don't semicolon if it doesn't start statement
|
|
|
|
|
|
|
|
if (true) (() => {})()
|
|
|
|
|
|
|
|
class A {
|
|
|
|
a = 0;
|
|
|
|
[b](){}
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
*d(){}
|
|
|
|
|
|
|
|
e = 0;
|
|
|
|
[f] = 0
|
|
|
|
|
|
|
|
// none of the semicolons above this comment can be omitted.
|
|
|
|
// none of the semicolons below this comment are necessary.
|
|
|
|
|
|
|
|
q() {};
|
|
|
|
[h](){}
|
|
|
|
|
|
|
|
p() {};
|
|
|
|
*i(){}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
get ['y']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
static ['y']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
set ['z'](z) {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
async ['a']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
async *g() {}
|
|
|
|
|
|
|
|
a = 0;
|
|
|
|
b = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// being first/last shouldn't break things
|
|
|
|
class G {
|
|
|
|
x = 1
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
*x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
[x] = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// check indentation
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
x; (() => {})()
|
|
|
|
}
|
|
|
|
|
|
|
|
// flow
|
|
|
|
|
|
|
|
(x: void);
|
|
|
|
(y: void)
|
|
|
|
|
|
|
|
// check statement clauses
|
|
|
|
|
|
|
|
do break; while (false)
|
|
|
|
if (true) do break; while (false)
|
|
|
|
|
|
|
|
if (true) 1; else 2
|
|
|
|
for (;;) ;
|
|
|
|
for (x of y) ;
|
|
|
|
|
|
|
|
debugger
|
|
|
|
|
|
|
|
// check that it doesn't break non-ASI
|
|
|
|
|
|
|
|
1
|
|
|
|
- 1
|
|
|
|
|
|
|
|
1
|
|
|
|
+ 1
|
|
|
|
|
|
|
|
1
|
|
|
|
/ 1
|
|
|
|
|
|
|
|
arr
|
|
|
|
[0]
|
|
|
|
|
|
|
|
fn
|
|
|
|
(x)
|
|
|
|
|
|
|
|
!1
|
|
|
|
|
|
|
|
1
|
|
|
|
< 1
|
|
|
|
|
|
|
|
tag
|
|
|
|
\`string\`
|
|
|
|
|
|
|
|
x; x => x
|
|
|
|
|
2017-04-28 00:00:53 +03:00
|
|
|
x; (a || b).c++
|
|
|
|
|
|
|
|
x; ++(a || b).c
|
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
while (false)
|
|
|
|
(function(){}())
|
|
|
|
|
|
|
|
aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
|
|
|
(b + c)
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
// with preexisting semi
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x
|
|
|
|
;[1, 2, 3].forEach(fn)
|
|
|
|
x
|
|
|
|
;[a, b, ...c] = [1, 2]
|
|
|
|
x
|
|
|
|
;/r/i.test("r")
|
|
|
|
x
|
|
|
|
;+1
|
|
|
|
x
|
|
|
|
;-1
|
|
|
|
x
|
|
|
|
;("h" + "i").repeat(10)
|
|
|
|
x
|
|
|
|
1, 2
|
|
|
|
x
|
|
|
|
;(() => {})()
|
|
|
|
x
|
|
|
|
;({ a: 1 }.entries())
|
|
|
|
x
|
|
|
|
;({ a: 1 }.entries())
|
|
|
|
x
|
|
|
|
;<Hello />
|
|
|
|
x
|
|
|
|
;\`string\`
|
|
|
|
x
|
|
|
|
;(x, y) => x
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// doesn't have to be preceded by a semicolon
|
|
|
|
|
|
|
|
class X {}
|
2018-07-03 09:06:29 +03:00
|
|
|
;[1, 2, 3].forEach(fn)
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// TODO: upgrade parser
|
|
|
|
// class A {
|
|
|
|
// async; // The semicolon is *not* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
|
|
|
// class B {
|
|
|
|
// static; // The semicolon *is* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
2017-12-07 16:03:55 +03:00
|
|
|
|
|
|
|
class C {
|
|
|
|
get; // The semicolon *is* necessary
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
2018-07-03 09:06:29 +03:00
|
|
|
get = () => {} // The semicolon is *not* necessary
|
2017-12-07 16:03:55 +03:00
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set; // The semicolon *is* necessary
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
2018-07-03 09:06:29 +03:00
|
|
|
set = () => {} // The semicolon is *not* necessary
|
2017-12-07 16:03:55 +03:00
|
|
|
x() {}
|
|
|
|
}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// don't semicolon if it doesn't start statement
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
if (true) (() => {})()
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
class A {
|
|
|
|
a = 0;
|
|
|
|
[b]() {}
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
*d() {}
|
|
|
|
|
|
|
|
e = 0;
|
2018-07-03 09:06:29 +03:00
|
|
|
[f] = 0
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// none of the semicolons above this comment can be omitted.
|
|
|
|
// none of the semicolons below this comment are necessary.
|
2017-04-28 00:59:18 +03:00
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
q() {}
|
|
|
|
[h]() {}
|
|
|
|
|
|
|
|
p() {}
|
|
|
|
*i() {}
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1
|
2017-04-12 23:41:51 +03:00
|
|
|
get ["y"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1
|
2017-04-12 23:41:51 +03:00
|
|
|
static ["y"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1
|
2017-04-12 23:41:51 +03:00
|
|
|
set ["z"](z) {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1
|
2017-04-12 23:41:51 +03:00
|
|
|
async ["a"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1
|
2017-04-11 23:50:47 +03:00
|
|
|
async *g() {}
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 0
|
|
|
|
b = 1
|
2017-04-11 23:50:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// being first/last shouldn't break things
|
|
|
|
class G {
|
2018-07-03 09:06:29 +03:00
|
|
|
x = 1
|
2017-04-11 23:50:47 +03:00
|
|
|
}
|
|
|
|
class G {
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
*x() {}
|
|
|
|
}
|
|
|
|
class G {
|
2018-07-03 09:06:29 +03:00
|
|
|
[x] = 1
|
2017-04-11 23:50:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// check indentation
|
|
|
|
|
|
|
|
if (true) {
|
2018-07-03 09:06:29 +03:00
|
|
|
x
|
|
|
|
;(() => {})()
|
2017-04-11 23:50:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// flow
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
;(x: void)
|
|
|
|
;(y: void)
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// check statement clauses
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
do break
|
|
|
|
while (false)
|
2017-04-11 23:50:47 +03:00
|
|
|
if (true)
|
2018-07-03 09:06:29 +03:00
|
|
|
do break
|
|
|
|
while (false)
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
if (true) 1
|
|
|
|
else 2
|
2017-04-11 23:50:47 +03:00
|
|
|
for (;;);
|
|
|
|
for (x of y);
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
debugger
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// check that it doesn't break non-ASI
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
1 - 1
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
1 + 1
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
1 / 1
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
arr[0]
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
fn(x)
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
!1
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
1 < 1
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
tag\`string\`
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x
|
|
|
|
x => x
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x
|
|
|
|
;(a || b).c++
|
2017-04-28 00:00:53 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x
|
|
|
|
++(a || b).c
|
2017-04-28 00:00:53 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
while (false) (function() {})()
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
2018-07-03 09:06:29 +03:00
|
|
|
(b + c)
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`no-semi.js - flow-verify 1`] = `
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
// with preexisting semi
|
|
|
|
|
|
|
|
x; [1, 2, 3].forEach(fn)
|
|
|
|
x; [a, b, ...c] = [1, 2]
|
|
|
|
x; /r/i.test('r')
|
|
|
|
x; +1
|
|
|
|
x; - 1
|
|
|
|
x; ('h' + 'i').repeat(10)
|
|
|
|
x; (1, 2)
|
|
|
|
x; (() => {})()
|
|
|
|
x; ({ a: 1 }).entries()
|
|
|
|
x; ({ a: 1 }).entries()
|
|
|
|
x; <Hello />
|
|
|
|
x; \`string\`
|
|
|
|
x; (x, y) => x
|
|
|
|
|
|
|
|
// doesn't have to be preceded by a semicolon
|
|
|
|
|
|
|
|
class X {} [1, 2, 3].forEach(fn)
|
|
|
|
|
|
|
|
// TODO: upgrade parser
|
|
|
|
// class A {
|
|
|
|
// async; // The semicolon is *not* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
|
|
|
// class B {
|
|
|
|
// static; // The semicolon *is* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
2017-12-07 16:03:55 +03:00
|
|
|
|
|
|
|
class C {
|
|
|
|
get; // The semicolon *is* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
get = () => {}; // The semicolon is *not* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set; // The semicolon *is* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set = () => {}; // The semicolon is *not* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
// don't semicolon if it doesn't start statement
|
|
|
|
|
|
|
|
if (true) (() => {})()
|
|
|
|
|
|
|
|
class A {
|
|
|
|
a = 0;
|
|
|
|
[b](){}
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
*d(){}
|
|
|
|
|
|
|
|
e = 0;
|
|
|
|
[f] = 0
|
|
|
|
|
|
|
|
// none of the semicolons above this comment can be omitted.
|
|
|
|
// none of the semicolons below this comment are necessary.
|
|
|
|
|
|
|
|
q() {};
|
|
|
|
[h](){}
|
|
|
|
|
|
|
|
p() {};
|
|
|
|
*i(){}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
get ['y']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
static ['y']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
set ['z'](z) {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
async ['a']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
async *g() {}
|
|
|
|
|
|
|
|
a = 0;
|
|
|
|
b = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// being first/last shouldn't break things
|
|
|
|
class G {
|
|
|
|
x = 1
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
*x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
[x] = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// check indentation
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
x; (() => {})()
|
|
|
|
}
|
|
|
|
|
|
|
|
// flow
|
|
|
|
|
|
|
|
(x: void);
|
|
|
|
(y: void)
|
|
|
|
|
|
|
|
// check statement clauses
|
|
|
|
|
|
|
|
do break; while (false)
|
|
|
|
if (true) do break; while (false)
|
|
|
|
|
|
|
|
if (true) 1; else 2
|
|
|
|
for (;;) ;
|
|
|
|
for (x of y) ;
|
|
|
|
|
|
|
|
debugger
|
|
|
|
|
|
|
|
// check that it doesn't break non-ASI
|
|
|
|
|
|
|
|
1
|
|
|
|
- 1
|
|
|
|
|
|
|
|
1
|
|
|
|
+ 1
|
|
|
|
|
|
|
|
1
|
|
|
|
/ 1
|
|
|
|
|
|
|
|
arr
|
|
|
|
[0]
|
|
|
|
|
|
|
|
fn
|
|
|
|
(x)
|
|
|
|
|
|
|
|
!1
|
|
|
|
|
|
|
|
1
|
|
|
|
< 1
|
|
|
|
|
|
|
|
tag
|
|
|
|
\`string\`
|
|
|
|
|
|
|
|
x; x => x
|
|
|
|
|
2017-04-28 00:00:53 +03:00
|
|
|
x; (a || b).c++
|
|
|
|
|
|
|
|
x; ++(a || b).c
|
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
while (false)
|
|
|
|
(function(){}())
|
|
|
|
|
|
|
|
aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
|
|
|
(b + c)
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
// with preexisting semi
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x;
|
|
|
|
[1, 2, 3].forEach(fn);
|
|
|
|
x;
|
|
|
|
[a, b, ...c] = [1, 2];
|
|
|
|
x;
|
|
|
|
/r/i.test("r");
|
|
|
|
x;
|
|
|
|
+1;
|
|
|
|
x;
|
|
|
|
-1;
|
|
|
|
x;
|
|
|
|
("h" + "i").repeat(10);
|
|
|
|
x;
|
|
|
|
1, 2;
|
|
|
|
x;
|
|
|
|
(() => {})();
|
|
|
|
x;
|
|
|
|
({ a: 1 }.entries());
|
|
|
|
x;
|
|
|
|
({ a: 1 }.entries());
|
|
|
|
x;
|
|
|
|
<Hello />;
|
|
|
|
x;
|
|
|
|
\`string\`;
|
|
|
|
x;
|
|
|
|
(x, y) => x;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// doesn't have to be preceded by a semicolon
|
|
|
|
|
|
|
|
class X {}
|
2018-07-03 09:06:29 +03:00
|
|
|
[1, 2, 3].forEach(fn);
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// TODO: upgrade parser
|
|
|
|
// class A {
|
|
|
|
// async; // The semicolon is *not* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
|
|
|
// class B {
|
|
|
|
// static; // The semicolon *is* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
2017-12-07 16:03:55 +03:00
|
|
|
|
|
|
|
class C {
|
|
|
|
get; // The semicolon *is* necessary
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
2018-07-03 09:06:29 +03:00
|
|
|
get = () => {}; // The semicolon is *not* necessary
|
2017-12-07 16:03:55 +03:00
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set; // The semicolon *is* necessary
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
2018-07-03 09:06:29 +03:00
|
|
|
set = () => {}; // The semicolon is *not* necessary
|
2017-12-07 16:03:55 +03:00
|
|
|
x() {}
|
|
|
|
}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// don't semicolon if it doesn't start statement
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
if (true) (() => {})();
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
class A {
|
|
|
|
a = 0;
|
|
|
|
[b]() {}
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
*d() {}
|
|
|
|
|
|
|
|
e = 0;
|
2018-07-03 09:06:29 +03:00
|
|
|
[f] = 0;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// none of the semicolons above this comment can be omitted.
|
|
|
|
// none of the semicolons below this comment are necessary.
|
2017-04-28 00:59:18 +03:00
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
q() {}
|
|
|
|
[h]() {}
|
|
|
|
|
|
|
|
p() {}
|
|
|
|
*i() {}
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1;
|
2017-04-12 23:41:51 +03:00
|
|
|
get ["y"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1;
|
2017-04-12 23:41:51 +03:00
|
|
|
static ["y"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1;
|
2017-04-12 23:41:51 +03:00
|
|
|
set ["z"](z) {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1;
|
2017-04-12 23:41:51 +03:00
|
|
|
async ["a"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 1;
|
2017-04-11 23:50:47 +03:00
|
|
|
async *g() {}
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
a = 0;
|
|
|
|
b = 1;
|
2017-04-11 23:50:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// being first/last shouldn't break things
|
|
|
|
class G {
|
2018-07-03 09:06:29 +03:00
|
|
|
x = 1;
|
2017-04-11 23:50:47 +03:00
|
|
|
}
|
|
|
|
class G {
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
*x() {}
|
|
|
|
}
|
|
|
|
class G {
|
2018-07-03 09:06:29 +03:00
|
|
|
[x] = 1;
|
2017-04-11 23:50:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// check indentation
|
|
|
|
|
|
|
|
if (true) {
|
2018-07-03 09:06:29 +03:00
|
|
|
x;
|
|
|
|
(() => {})();
|
2017-04-11 23:50:47 +03:00
|
|
|
}
|
|
|
|
|
2017-04-14 04:33:46 +03:00
|
|
|
// flow
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
(x: void);
|
|
|
|
(y: void);
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// check statement clauses
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
do break;
|
|
|
|
while (false);
|
2017-04-11 23:50:47 +03:00
|
|
|
if (true)
|
2018-07-03 09:06:29 +03:00
|
|
|
do break;
|
|
|
|
while (false);
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
if (true) 1;
|
|
|
|
else 2;
|
2017-04-11 23:50:47 +03:00
|
|
|
for (;;);
|
|
|
|
for (x of y);
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
debugger;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// check that it doesn't break non-ASI
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
1 - 1;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
1 + 1;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
1 / 1;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
arr[0];
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
fn(x);
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
!1;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
1 < 1;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
tag\`string\`;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x;
|
|
|
|
x => x;
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x;
|
|
|
|
(a || b).c++;
|
2017-04-28 00:00:53 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
x;
|
|
|
|
++(a || b).c;
|
2017-04-28 00:00:53 +03:00
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
while (false) (function() {})();
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
2018-07-03 09:06:29 +03:00
|
|
|
(b + c);
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
`;
|
|
|
|
|
2018-07-03 09:06:29 +03:00
|
|
|
exports[`no-semi.js - flow-verify 2`] = `
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
// with preexisting semi
|
|
|
|
|
|
|
|
x; [1, 2, 3].forEach(fn)
|
|
|
|
x; [a, b, ...c] = [1, 2]
|
|
|
|
x; /r/i.test('r')
|
|
|
|
x; +1
|
|
|
|
x; - 1
|
|
|
|
x; ('h' + 'i').repeat(10)
|
|
|
|
x; (1, 2)
|
|
|
|
x; (() => {})()
|
|
|
|
x; ({ a: 1 }).entries()
|
|
|
|
x; ({ a: 1 }).entries()
|
|
|
|
x; <Hello />
|
|
|
|
x; \`string\`
|
|
|
|
x; (x, y) => x
|
|
|
|
|
|
|
|
// doesn't have to be preceded by a semicolon
|
|
|
|
|
|
|
|
class X {} [1, 2, 3].forEach(fn)
|
|
|
|
|
|
|
|
// TODO: upgrade parser
|
|
|
|
// class A {
|
|
|
|
// async; // The semicolon is *not* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
|
|
|
// class B {
|
|
|
|
// static; // The semicolon *is* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
2017-12-07 16:03:55 +03:00
|
|
|
|
|
|
|
class C {
|
|
|
|
get; // The semicolon *is* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
get = () => {}; // The semicolon is *not* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set; // The semicolon *is* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set = () => {}; // The semicolon is *not* necessary
|
|
|
|
x(){}
|
|
|
|
}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
// don't semicolon if it doesn't start statement
|
|
|
|
|
|
|
|
if (true) (() => {})()
|
|
|
|
|
|
|
|
class A {
|
|
|
|
a = 0;
|
|
|
|
[b](){}
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
*d(){}
|
|
|
|
|
|
|
|
e = 0;
|
|
|
|
[f] = 0
|
|
|
|
|
|
|
|
// none of the semicolons above this comment can be omitted.
|
|
|
|
// none of the semicolons below this comment are necessary.
|
|
|
|
|
|
|
|
q() {};
|
|
|
|
[h](){}
|
|
|
|
|
|
|
|
p() {};
|
|
|
|
*i(){}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
get ['y']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
static ['y']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
set ['z'](z) {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
async ['a']() {}
|
|
|
|
|
|
|
|
a = 1;
|
|
|
|
async *g() {}
|
|
|
|
|
|
|
|
a = 0;
|
|
|
|
b = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// being first/last shouldn't break things
|
|
|
|
class G {
|
|
|
|
x = 1
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
*x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
[x] = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// check indentation
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
x; (() => {})()
|
|
|
|
}
|
|
|
|
|
|
|
|
// flow
|
|
|
|
|
|
|
|
(x: void);
|
|
|
|
(y: void)
|
|
|
|
|
|
|
|
// check statement clauses
|
|
|
|
|
|
|
|
do break; while (false)
|
|
|
|
if (true) do break; while (false)
|
|
|
|
|
|
|
|
if (true) 1; else 2
|
|
|
|
for (;;) ;
|
|
|
|
for (x of y) ;
|
|
|
|
|
|
|
|
debugger
|
|
|
|
|
|
|
|
// check that it doesn't break non-ASI
|
|
|
|
|
|
|
|
1
|
|
|
|
- 1
|
|
|
|
|
|
|
|
1
|
|
|
|
+ 1
|
|
|
|
|
|
|
|
1
|
|
|
|
/ 1
|
|
|
|
|
|
|
|
arr
|
|
|
|
[0]
|
|
|
|
|
|
|
|
fn
|
|
|
|
(x)
|
|
|
|
|
|
|
|
!1
|
|
|
|
|
|
|
|
1
|
|
|
|
< 1
|
|
|
|
|
|
|
|
tag
|
|
|
|
\`string\`
|
|
|
|
|
|
|
|
x; x => x
|
|
|
|
|
2017-04-28 00:00:53 +03:00
|
|
|
x; (a || b).c++
|
|
|
|
|
|
|
|
x; ++(a || b).c
|
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
while (false)
|
|
|
|
(function(){}())
|
|
|
|
|
|
|
|
aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
|
|
|
(b + c)
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
// with preexisting semi
|
|
|
|
|
|
|
|
x
|
|
|
|
;[1, 2, 3].forEach(fn)
|
|
|
|
x
|
|
|
|
;[a, b, ...c] = [1, 2]
|
|
|
|
x
|
2017-04-12 23:41:51 +03:00
|
|
|
;/r/i.test("r")
|
2017-04-11 23:50:47 +03:00
|
|
|
x
|
|
|
|
;+1
|
|
|
|
x
|
|
|
|
;-1
|
|
|
|
x
|
2017-04-12 23:41:51 +03:00
|
|
|
;("h" + "i").repeat(10)
|
2017-04-11 23:50:47 +03:00
|
|
|
x
|
|
|
|
1, 2
|
|
|
|
x
|
|
|
|
;(() => {})()
|
|
|
|
x
|
|
|
|
;({ a: 1 }.entries())
|
|
|
|
x
|
|
|
|
;({ a: 1 }.entries())
|
|
|
|
x
|
|
|
|
;<Hello />
|
|
|
|
x
|
|
|
|
;\`string\`
|
|
|
|
x
|
|
|
|
;(x, y) => x
|
|
|
|
|
|
|
|
// doesn't have to be preceded by a semicolon
|
|
|
|
|
|
|
|
class X {}
|
|
|
|
;[1, 2, 3].forEach(fn)
|
|
|
|
|
|
|
|
// TODO: upgrade parser
|
|
|
|
// class A {
|
|
|
|
// async; // The semicolon is *not* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
|
|
|
// class B {
|
|
|
|
// static; // The semicolon *is* necessary
|
|
|
|
// x(){}
|
|
|
|
// }
|
2017-12-07 16:03:55 +03:00
|
|
|
|
|
|
|
class C {
|
|
|
|
get; // The semicolon *is* necessary
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
get = () => {} // The semicolon is *not* necessary
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set; // The semicolon *is* necessary
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class C {
|
|
|
|
set = () => {} // The semicolon is *not* necessary
|
|
|
|
x() {}
|
|
|
|
}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
// don't semicolon if it doesn't start statement
|
|
|
|
|
|
|
|
if (true) (() => {})()
|
|
|
|
|
|
|
|
class A {
|
|
|
|
a = 0;
|
|
|
|
[b]() {}
|
|
|
|
|
|
|
|
c = 0;
|
|
|
|
*d() {}
|
|
|
|
|
|
|
|
e = 0;
|
|
|
|
[f] = 0
|
|
|
|
|
|
|
|
// none of the semicolons above this comment can be omitted.
|
|
|
|
// none of the semicolons below this comment are necessary.
|
|
|
|
|
|
|
|
q() {}
|
|
|
|
[h]() {}
|
|
|
|
|
|
|
|
p() {}
|
|
|
|
*i() {}
|
|
|
|
|
|
|
|
a = 1
|
2017-04-12 23:41:51 +03:00
|
|
|
get ["y"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
a = 1
|
2017-04-12 23:41:51 +03:00
|
|
|
static ["y"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
a = 1
|
2017-04-12 23:41:51 +03:00
|
|
|
set ["z"](z) {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
a = 1
|
2017-04-12 23:41:51 +03:00
|
|
|
async ["a"]() {}
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
a = 1
|
|
|
|
async *g() {}
|
|
|
|
|
|
|
|
a = 0
|
|
|
|
b = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// being first/last shouldn't break things
|
|
|
|
class G {
|
|
|
|
x = 1
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
*x() {}
|
|
|
|
}
|
|
|
|
class G {
|
|
|
|
[x] = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
// check indentation
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
x
|
|
|
|
;(() => {})()
|
|
|
|
}
|
|
|
|
|
2017-04-14 04:33:46 +03:00
|
|
|
// flow
|
2017-04-11 23:50:47 +03:00
|
|
|
|
2017-04-14 04:33:46 +03:00
|
|
|
;(x: void)
|
2017-04-11 23:50:47 +03:00
|
|
|
;(y: void)
|
|
|
|
|
|
|
|
// check statement clauses
|
|
|
|
|
2017-05-04 01:50:48 +03:00
|
|
|
do break
|
2017-04-11 23:50:47 +03:00
|
|
|
while (false)
|
|
|
|
if (true)
|
2017-05-04 01:50:48 +03:00
|
|
|
do break
|
2017-04-11 23:50:47 +03:00
|
|
|
while (false)
|
|
|
|
|
|
|
|
if (true) 1
|
|
|
|
else 2
|
|
|
|
for (;;);
|
|
|
|
for (x of y);
|
|
|
|
|
|
|
|
debugger
|
|
|
|
|
|
|
|
// check that it doesn't break non-ASI
|
|
|
|
|
|
|
|
1 - 1
|
|
|
|
|
|
|
|
1 + 1
|
|
|
|
|
|
|
|
1 / 1
|
|
|
|
|
|
|
|
arr[0]
|
|
|
|
|
|
|
|
fn(x)
|
|
|
|
|
|
|
|
!1
|
|
|
|
|
|
|
|
1 < 1
|
|
|
|
|
|
|
|
tag\`string\`
|
|
|
|
|
|
|
|
x
|
|
|
|
x => x
|
|
|
|
|
2017-04-28 00:00:53 +03:00
|
|
|
x
|
|
|
|
;(a || b).c++
|
|
|
|
|
|
|
|
x
|
|
|
|
++(a || b).c
|
|
|
|
|
2017-05-04 01:50:48 +03:00
|
|
|
while (false) (function() {})()
|
2017-04-11 23:50:47 +03:00
|
|
|
|
|
|
|
aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
|
|
|
(b + c)
|
2017-04-12 23:41:51 +03:00
|
|
|
|
2017-04-11 23:50:47 +03:00
|
|
|
`;
|