test: fix a FIXME, add typescript (#6744)
* test: fix a FIXME, add typescript * tests/es6modules * tests/no-semi * tests/array_spreadmaster
parent
e66e34a435
commit
ea6ae31ba0
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
exports[`multiple.js 1`] = `
|
exports[`multiple.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow", "typescript"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
run_spec(__dirname, ["flow", "typescript"]);
|
run_spec(__dirname, ["babel", "flow", "typescript"]);
|
||||||
|
|
|
@ -2,21 +2,7 @@
|
||||||
|
|
||||||
exports[`export_default_arrow_expression.js 1`] = `
|
exports[`export_default_arrow_expression.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default () => {};
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default () => {};
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_arrow_expression.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -30,21 +16,7 @@ export default () => {};
|
||||||
|
|
||||||
exports[`export_default_call_expression.js 1`] = `
|
exports[`export_default_call_expression.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default foo()
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default foo();
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_call_expression.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -58,21 +30,7 @@ export default foo();
|
||||||
|
|
||||||
exports[`export_default_class_declaration.js 1`] = `
|
exports[`export_default_class_declaration.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default class Foo {}
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default class Foo {}
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_class_declaration.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -86,21 +44,7 @@ export default class Foo {}
|
||||||
|
|
||||||
exports[`export_default_class_expression.js 1`] = `
|
exports[`export_default_class_expression.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default (class foobar {})
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default (class foobar {});
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_class_expression.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -114,21 +58,7 @@ export default (class foobar {});
|
||||||
|
|
||||||
exports[`export_default_function_declaration.js 1`] = `
|
exports[`export_default_function_declaration.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default function() {}
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default function() {}
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_function_declaration.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -142,21 +72,7 @@ export default function() {}
|
||||||
|
|
||||||
exports[`export_default_function_declaration_async.js 1`] = `
|
exports[`export_default_function_declaration_async.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default async function foo() {}
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default async function foo() {}
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_function_declaration_async.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -170,21 +86,7 @@ export default async function foo() {}
|
||||||
|
|
||||||
exports[`export_default_function_declaration_named.js 1`] = `
|
exports[`export_default_function_declaration_named.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default function f(){}
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default function f() {}
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_function_declaration_named.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -198,21 +100,7 @@ export default function f() {}
|
||||||
|
|
||||||
exports[`export_default_function_expression.js 1`] = `
|
exports[`export_default_function_expression.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default (function() {});
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default (function() {});
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_function_expression.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -226,21 +114,7 @@ export default (function() {});
|
||||||
|
|
||||||
exports[`export_default_function_expression_named.js 1`] = `
|
exports[`export_default_function_expression_named.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default (function f(){})
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default (function f() {});
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_function_expression_named.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -254,21 +128,7 @@ export default (function f() {});
|
||||||
|
|
||||||
exports[`export_default_new_expression.js 1`] = `
|
exports[`export_default_new_expression.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
export default new Foo();
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
export default new Foo();
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`export_default_new_expression.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel", "typescript"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
run_spec(__dirname, ["flow"]);
|
run_spec(__dirname, ["babel", "flow", "typescript"]);
|
||||||
// FIXME export_default_function_declaration_async.js flow != babel output
|
|
||||||
run_spec(__dirname, ["babel", "typescript"]);
|
|
||||||
|
|
|
@ -2,21 +2,7 @@
|
||||||
|
|
||||||
exports[`escape.js 1`] = `
|
exports[`escape.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
<div><</div>
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
<div><</div>;
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`escape.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
@ -30,41 +16,7 @@ printWidth: 80
|
||||||
|
|
||||||
exports[`nbsp.js 1`] = `
|
exports[`nbsp.js 1`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow", "typescript"]
|
||||||
printWidth: 80
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
many_nbsp = <div> </div>
|
|
||||||
single_nbsp = <div> </div>
|
|
||||||
nbsp_with_newline =
|
|
||||||
<div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
many_raw_nbsp = <div> </div>
|
|
||||||
many_raw_spaces = <div> </div>
|
|
||||||
|
|
||||||
|
|
||||||
amp = <span>foo & bar</span>
|
|
||||||
raw_amp = <span>foo & bar</span>
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
many_nbsp = <div> </div>;
|
|
||||||
single_nbsp = <div> </div>;
|
|
||||||
nbsp_with_newline = <div> </div>;
|
|
||||||
|
|
||||||
many_raw_nbsp = <div> </div>;
|
|
||||||
many_raw_spaces = <div> </div>;
|
|
||||||
|
|
||||||
amp = <span>foo & bar</span>;
|
|
||||||
raw_amp = <span>foo & bar</span>;
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`nbsp.js 2`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
| printWidth
|
| printWidth
|
||||||
=====================================input======================================
|
=====================================input======================================
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
run_spec(__dirname, ["flow"]);
|
run_spec(__dirname, ["babel", "flow", "typescript"]);
|
||||||
// FIXME nbsp.js flow != babel output, waiting for: https://github.com/babel/babylon/pull/344
|
|
||||||
run_spec(__dirname, ["babel"]);
|
|
||||||
|
|
|
@ -36,42 +36,7 @@ x;
|
||||||
|
|
||||||
exports[`comments.js 2`] = `
|
exports[`comments.js 2`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow"]
|
||||||
printWidth: 80
|
|
||||||
semi: false
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
let error = new Error(response.statusText);
|
|
||||||
// comment
|
|
||||||
(error: any).response = response
|
|
||||||
|
|
||||||
x;
|
|
||||||
|
|
||||||
/* comment */ (error: any).response = response
|
|
||||||
|
|
||||||
x;
|
|
||||||
|
|
||||||
(error: any).response = response; /* comment */
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
let error = new Error(response.statusText)
|
|
||||||
// comment
|
|
||||||
;(error: any).response = response
|
|
||||||
|
|
||||||
x
|
|
||||||
|
|
||||||
/* comment */ ;(error: any).response = response
|
|
||||||
|
|
||||||
x
|
|
||||||
|
|
||||||
;(error: any).response = response /* comment */
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`comments.js 3`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
semi: false
|
semi: false
|
||||||
| printWidth
|
| printWidth
|
||||||
|
@ -191,93 +156,7 @@ interface E {
|
||||||
|
|
||||||
exports[`flow-interfaces.js 2`] = `
|
exports[`flow-interfaces.js 2`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow"]
|
||||||
printWidth: 80
|
|
||||||
semi: false
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
declare class A {
|
|
||||||
one: boolean;
|
|
||||||
two: { three: string }
|
|
||||||
| number;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: Flow and Babel 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 Babel 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 Babel both fail to apply ASI here
|
|
||||||
// interface F {
|
|
||||||
// one: boolean
|
|
||||||
// two: { three: string }
|
|
||||||
// | number
|
|
||||||
// }
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
declare class A {
|
|
||||||
one: boolean;
|
|
||||||
two: { three: string } | number;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: Flow and Babel 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 Babel 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 Babel both fail to apply ASI here
|
|
||||||
// interface F {
|
|
||||||
// one: boolean
|
|
||||||
// two: { three: string }
|
|
||||||
// | number
|
|
||||||
// }
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`flow-interfaces.js 3`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
semi: false
|
semi: false
|
||||||
| printWidth
|
| printWidth
|
||||||
|
@ -391,36 +270,7 @@ var c = a.e;
|
||||||
|
|
||||||
exports[`issue2006.js 2`] = `
|
exports[`issue2006.js 2`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow"]
|
||||||
printWidth: 80
|
|
||||||
semi: false
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
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);
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
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)
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`issue2006.js 3`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
semi: false
|
semi: false
|
||||||
| printWidth
|
| printWidth
|
||||||
|
@ -799,358 +649,7 @@ aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
||||||
|
|
||||||
exports[`no-semi.js 2`] = `
|
exports[`no-semi.js 2`] = `
|
||||||
====================================options=====================================
|
====================================options=====================================
|
||||||
parsers: ["flow"]
|
parsers: ["babel", "flow"]
|
||||||
printWidth: 80
|
|
||||||
semi: false
|
|
||||||
| printWidth
|
|
||||||
=====================================input======================================
|
|
||||||
|
|
||||||
// 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(){}
|
|
||||||
// }
|
|
||||||
|
|
||||||
class C1 {
|
|
||||||
get; // The semicolon *is* necessary
|
|
||||||
x(){}
|
|
||||||
}
|
|
||||||
class C2 {
|
|
||||||
get = () => {}; // The semicolon is *not* necessary
|
|
||||||
x(){}
|
|
||||||
}
|
|
||||||
class C3 {
|
|
||||||
set; // The semicolon *is* necessary
|
|
||||||
x(){}
|
|
||||||
}
|
|
||||||
class C4 {
|
|
||||||
set = () => {}; // The semicolon is *not* necessary
|
|
||||||
x(){}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 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 G1 {
|
|
||||||
x = 1
|
|
||||||
}
|
|
||||||
class G2 {
|
|
||||||
x() {}
|
|
||||||
}
|
|
||||||
class G3 {
|
|
||||||
*x() {}
|
|
||||||
}
|
|
||||||
class G4 {
|
|
||||||
[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
|
|
||||||
|
|
||||||
x; (a || b).c++
|
|
||||||
|
|
||||||
x; ++(a || b).c
|
|
||||||
|
|
||||||
while (false)
|
|
||||||
(function(){}())
|
|
||||||
|
|
||||||
aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
|
||||||
(b + c)
|
|
||||||
|
|
||||||
=====================================output=====================================
|
|
||||||
// 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(){}
|
|
||||||
// }
|
|
||||||
|
|
||||||
class C1 {
|
|
||||||
get; // The semicolon *is* necessary
|
|
||||||
x() {}
|
|
||||||
}
|
|
||||||
class C2 {
|
|
||||||
get = () => {} // The semicolon is *not* necessary
|
|
||||||
x() {}
|
|
||||||
}
|
|
||||||
class C3 {
|
|
||||||
set; // The semicolon *is* necessary
|
|
||||||
x() {}
|
|
||||||
}
|
|
||||||
class C4 {
|
|
||||||
set = () => {} // The semicolon is *not* necessary
|
|
||||||
x() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 G1 {
|
|
||||||
x = 1
|
|
||||||
}
|
|
||||||
class G2 {
|
|
||||||
x() {}
|
|
||||||
}
|
|
||||||
class G3 {
|
|
||||||
*x() {}
|
|
||||||
}
|
|
||||||
class G4 {
|
|
||||||
[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
|
|
||||||
|
|
||||||
x
|
|
||||||
;(a || b).c++
|
|
||||||
|
|
||||||
x
|
|
||||||
++(a || b).c
|
|
||||||
|
|
||||||
while (false) (function() {})()
|
|
||||||
|
|
||||||
aReallyLongLine012345678901234567890123456789012345678901234567890123456789 *
|
|
||||||
(b + c)
|
|
||||||
|
|
||||||
================================================================================
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`no-semi.js 3`] = `
|
|
||||||
====================================options=====================================
|
|
||||||
parsers: ["babel"]
|
|
||||||
printWidth: 80
|
printWidth: 80
|
||||||
semi: false
|
semi: false
|
||||||
| printWidth
|
| printWidth
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
run_spec(__dirname, ["flow"]);
|
run_spec(__dirname, ["flow"]);
|
||||||
run_spec(__dirname, ["flow"], { semi: false });
|
run_spec(__dirname, ["babel", "flow"], { semi: false });
|
||||||
run_spec(__dirname, ["babel"], { semi: false });
|
|
||||||
|
|
Loading…
Reference in New Issue