From e13bb7dbba5b9b725338f19cc196f75201b9fc82 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 24 Jan 2017 11:38:12 -0800 Subject: [PATCH] [RFC] Do not put spacing inside of arrays with bracketSpacing option enabled (#446) Given the discussion on #296, it seems like there's debate between spaces around `{}` but no one puts spaces around `[]`. So changing the behavior to respect this. --- src/printer.js | 4 +- tests/annot/__snapshots__/jsfmt.spec.js.snap | 14 +++---- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 28 ++++++------- .../arraylib/__snapshots__/jsfmt.spec.js.snap | 24 +++++------ tests/arrays/__snapshots__/jsfmt.spec.js.snap | 12 +++--- .../binding/__snapshots__/jsfmt.spec.js.snap | 2 +- tests/bom/__snapshots__/jsfmt.spec.js.snap | 12 +++--- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../builtins/__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 14 +++---- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 40 +++++++++---------- .../__snapshots__/jsfmt.spec.js.snap | 4 +- tests/fetch/__snapshots__/jsfmt.spec.js.snap | 12 +++--- tests/for/__snapshots__/jsfmt.spec.js.snap | 4 +- .../function/__snapshots__/jsfmt.spec.js.snap | 28 ++++++------- .../generics/__snapshots__/jsfmt.spec.js.snap | 2 +- tests/init/__snapshots__/jsfmt.spec.js.snap | 8 ++-- tests/iter/__snapshots__/jsfmt.spec.js.snap | 2 +- .../iterable/__snapshots__/jsfmt.spec.js.snap | 10 ++--- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../literal/__snapshots__/jsfmt.spec.js.snap | 2 +- .../logical/__snapshots__/jsfmt.spec.js.snap | 2 +- tests/misc/__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../buffer/__snapshots__/jsfmt.spec.js.snap | 6 +-- .../__snapshots__/jsfmt.spec.js.snap | 14 +++---- .../nullable/__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- .../optional/__snapshots__/jsfmt.spec.js.snap | 6 +-- .../overload/__snapshots__/jsfmt.spec.js.snap | 2 +- .../plsummit/__snapshots__/jsfmt.spec.js.snap | 4 +- .../promises/__snapshots__/jsfmt.spec.js.snap | 2 +- tests/react/__snapshots__/jsfmt.spec.js.snap | 6 +-- tests/refi/__snapshots__/jsfmt.spec.js.snap | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 6 +-- tests/spread/__snapshots__/jsfmt.spec.js.snap | 2 +- .../suggest/__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 2 +- tests/tuples/__snapshots__/jsfmt.spec.js.snap | 16 ++++---- .../__snapshots__/jsfmt.spec.js.snap | 8 ++-- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 2 +- .../__snapshots__/jsfmt.spec.js.snap | 4 +- tests/union/__snapshots__/jsfmt.spec.js.snap | 10 ++--- .../__snapshots__/jsfmt.spec.js.snap | 16 ++++---- 49 files changed, 183 insertions(+), 183 deletions(-) diff --git a/src/printer.js b/src/printer.js index 48251f0bb..d5f1a29c8 100644 --- a/src/printer.js +++ b/src/printer.js @@ -674,7 +674,7 @@ function genericPrintNoParens(path, options, print) { indent( options.tabWidth, concat([ - options.bracketSpacing ? line : softline, + softline, join(concat([ ",", line ]), path.map(print, "elements")) ]) ), @@ -686,7 +686,7 @@ function genericPrintNoParens(path, options, print) { ? "," : "" ), - options.bracketSpacing ? line : softline, + softline, "]" ]) ) diff --git a/tests/annot/__snapshots__/jsfmt.spec.js.snap b/tests/annot/__snapshots__/jsfmt.spec.js.snap index 965015087..3bb0e5020 100644 --- a/tests/annot/__snapshots__/jsfmt.spec.js.snap +++ b/tests/annot/__snapshots__/jsfmt.spec.js.snap @@ -75,20 +75,20 @@ var obj: { str: string, i: number, j: boolean } = { k: false }; -var arr: Array = [ 1, 2, \"...\" ]; +var arr: Array = [1, 2, \"...\"]; // array sugar -var array: number[] = [ 1, 2, \"...\" ]; +var array: number[] = [1, 2, \"...\"]; -var matrix: number[][] = [ [ 1, 2 ], [ 3, 4 ] ]; +var matrix: number[][] = [[1, 2], [3, 4]]; var matrix_parens: number[][] = matrix; var nullable_array: ?(number[]) = null; var nullable_array_parens: ?(number[]) = nullable_array; -var array_of_nullable: (?number)[] = [ null, 3 ]; +var array_of_nullable: (?number)[] = [null, 3]; -var array_of_tuple: [number, string][] = [ [ 0, \"foo\" ], [ 1, \"bar\" ] ]; +var array_of_tuple: [number, string][] = [[0, \"foo\"], [1, \"bar\"]]; var array_of_tuple_parens: [number, string][] = array_of_tuple; type ObjType = { \"bar-foo\": string, \"foo-bar\": number }; @@ -279,7 +279,7 @@ function insertMany( vs: [K, V][], m: Map ): Map { - function f([ k, v ]: [K, V], m: Map): Map { + function f([k, v]: [K, V], m: Map): Map { return m.insertWith(merge, k, v); } return foldr(f, m, vs); @@ -288,7 +288,7 @@ function insertMany( class Foo { bar() { return function(a: A, b: B, c: C): void { - ([ a, b, c ]: [A, B, C]); + ([a, b, c]: [A, B, C]); }; } } diff --git a/tests/array-filter/__snapshots__/jsfmt.spec.js.snap b/tests/array-filter/__snapshots__/jsfmt.spec.js.snap index d2dfcc8fa..e37e925e8 100644 --- a/tests/array-filter/__snapshots__/jsfmt.spec.js.snap +++ b/tests/array-filter/__snapshots__/jsfmt.spec.js.snap @@ -50,7 +50,7 @@ function filterItems(items: Array): Array { }).filter(Boolean); } -const filteredItems = filterItems([ \"foo\", \"b\", 1, 2 ]); +const filteredItems = filterItems([\"foo\", \"b\", 1, 2]); console.log(filteredItems); " diff --git a/tests/array_spread/__snapshots__/jsfmt.spec.js.snap b/tests/array_spread/__snapshots__/jsfmt.spec.js.snap index e5932153c..730b63ef0 100644 --- a/tests/array_spread/__snapshots__/jsfmt.spec.js.snap +++ b/tests/array_spread/__snapshots__/jsfmt.spec.js.snap @@ -2,8 +2,8 @@ exports[`test multiple.js 1`] = ` "[...a, ...b,]; [...a, ...b]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -[ ...a, ...b ]; -[ ...a, ...b ]; +[...a, ...b]; +[...a, ...b]; " `; @@ -11,8 +11,8 @@ exports[`test multiple.js 2`] = ` "[...a, ...b,]; [...a, ...b]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -[ ...a, ...b ]; -[ ...a, ...b ]; +[...a, ...b]; +[...a, ...b]; " `; @@ -26,14 +26,14 @@ C.sort((a, b) => a - b); var x: Array = [\'1\', \'2\']; var y: Array = [\'3\', ...x]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var A = [ 1, 2, 3 ]; -var B = [ ...A ]; -var C = [ 1, 2, 3 ]; +var A = [1, 2, 3]; +var B = [...A]; +var C = [1, 2, 3]; B.sort((a, b) => a - b); C.sort((a, b) => a - b); -var x: Array = [ \"1\", \"2\" ]; -var y: Array = [ \"3\", ...x ]; +var x: Array = [\"1\", \"2\"]; +var y: Array = [\"3\", ...x]; " `; @@ -47,13 +47,13 @@ C.sort((a, b) => a - b); var x: Array = [\'1\', \'2\']; var y: Array = [\'3\', ...x]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var A = [ 1, 2, 3 ]; -var B = [ ...A ]; -var C = [ 1, 2, 3 ]; +var A = [1, 2, 3]; +var B = [...A]; +var C = [1, 2, 3]; B.sort((a, b) => a - b); C.sort((a, b) => a - b); -var x: Array = [ \"1\", \"2\" ]; -var y: Array = [ \"3\", ...x ]; +var x: Array = [\"1\", \"2\"]; +var y: Array = [\"3\", ...x]; " `; diff --git a/tests/arraylib/__snapshots__/jsfmt.spec.js.snap b/tests/arraylib/__snapshots__/jsfmt.spec.js.snap index 88da71ed2..f0948b5dd 100644 --- a/tests/arraylib/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arraylib/__snapshots__/jsfmt.spec.js.snap @@ -60,7 +60,7 @@ function from_test() { /* @flow */ function foo(x: string) {} -var a = [ 0 ]; +var a = [0]; var b = a.map(function(x) { foo(x); @@ -72,13 +72,13 @@ var d: number = b[0]; var e: Array = a.reverse(); -var f = [ \"\" ]; +var f = [\"\"]; var g: number = f.map(function() { return 0; })[0]; -var h: Array = [ 1, 2, 3 ]; -var i: Array = [ \"a\", \"b\", \"c\" ]; +var h: Array = [1, 2, 3]; +var i: Array = [\"a\", \"b\", \"c\"]; var j: Array = h.concat(i); var k: Array = h.concat(h); var l: Array = h.concat(1, 2, 3); @@ -90,37 +90,37 @@ function reduce_test() { /* Adapted from the following source: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce */ - [ 0, 1, 2, 3, 4 ].reduce(function(previousValue, currentValue, index, array) { + [0, 1, 2, 3, 4].reduce(function(previousValue, currentValue, index, array) { return previousValue + currentValue + array[index]; }); - [ 0, 1, 2, 3, 4 ].reduce( + [0, 1, 2, 3, 4].reduce( function(previousValue, currentValue, index, array) { return previousValue + currentValue + array[index]; }, 10 ); - var total = [ 0, 1, 2, 3 ].reduce(function(a, b) { + var total = [0, 1, 2, 3].reduce(function(a, b) { return a + b; }); - var flattened = [ [ 0, 1 ], [ 2, 3 ], [ 4, 5 ] ].reduce(function(a, b) { + var flattened = [[0, 1], [2, 3], [4, 5]].reduce(function(a, b) { return a.concat(b); }); /* Added later, because the above is insufficient */ // acc is element type of array when no init is provided - [ \"\" ].reduce((acc, str) => acc * str.length); + [\"\"].reduce((acc, str) => acc * str.length); // error, string ~> number - [ \"\" ].reduceRight((acc, str) => acc * str.length); // error, string ~> number + [\"\"].reduceRight((acc, str) => acc * str.length); // error, string ~> number } function from_test() { - var a: Array = Array.from([ 1, 2, 3 ], function(val, index) { + var a: Array = Array.from([1, 2, 3], function(val, index) { return index % 2 ? \"foo\" : String(val); }); - var b: Array = Array.from([ 1, 2, 3 ], function(val) { + var b: Array = Array.from([1, 2, 3], function(val) { return String(val); }); } diff --git a/tests/arrays/__snapshots__/jsfmt.spec.js.snap b/tests/arrays/__snapshots__/jsfmt.spec.js.snap index 723cb78af..2333ac789 100644 --- a/tests/arrays/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrays/__snapshots__/jsfmt.spec.js.snap @@ -53,8 +53,8 @@ a.forEach(x => y = x); // for literals, composite element type is union of individuals // note: test both tuple and non-tuple inferred literals -var alittle: Array = [ 0, 1, 2, 3, null ]; -var abig: Array = [ 0, 1, 2, 3, 4, 5, 6, 8, null ]; +var alittle: Array = [0, 1, 2, 3, null]; +var abig: Array = [0, 1, 2, 3, 4, 5, 6, 8, null]; var abig2: Array<{ x: number, y: number }> = [ { x: 0, y: 0 }, @@ -86,10 +86,10 @@ exports[`test last.js 1`] = ` [,,1,]; [,,1,1]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -[ , ]; -[ , , ]; -[ , , 1 ]; -[ , , 1, 1 ]; +[,]; +[, ,]; +[, , 1]; +[, , 1, 1]; " `; diff --git a/tests/binding/__snapshots__/jsfmt.spec.js.snap b/tests/binding/__snapshots__/jsfmt.spec.js.snap index 2b85941a6..8c37fe284 100644 --- a/tests/binding/__snapshots__/jsfmt.spec.js.snap +++ b/tests/binding/__snapshots__/jsfmt.spec.js.snap @@ -45,7 +45,7 @@ x &= 0; // regression tests -- OK to assign consts like this: const { foo } = { foo: \"foo\" }; -const [ bar ] = [ \"bar\" ]; +const [bar] = [\"bar\"]; (foo: number); // error: string ~> number (bar: number); diff --git a/tests/bom/__snapshots__/jsfmt.spec.js.snap b/tests/bom/__snapshots__/jsfmt.spec.js.snap index 141b64899..6f7998cdb 100644 --- a/tests/bom/__snapshots__/jsfmt.spec.js.snap +++ b/tests/bom/__snapshots__/jsfmt.spec.js.snap @@ -174,19 +174,19 @@ for (let x: string | File | Blob of a.values()) { // incorrect // entries -for (let [ x, y ]: [string, string | File] of a.entries()) { +for (let [x, y]: [string, string | File] of a.entries()) { } // correct -for (let [ x, y ]: [string, string | File | Blob] of a.entries()) { +for (let [x, y]: [string, string | File | Blob] of a.entries()) { } // incorrect -for (let [ x, y ]: [number, string] of a.entries()) { +for (let [x, y]: [number, string] of a.entries()) { } // incorrect -for (let [ x, y ]: [string, number] of a.entries()) { +for (let [x, y]: [string, number] of a.entries()) { } // incorrect -for (let [ x, y ]: [number, number] of a.entries()) { +for (let [x, y]: [number, number] of a.entries()) { } // incorrect " `; @@ -246,7 +246,7 @@ new MutationObserver((n: number) => {}); // incorrect // observe const div = document.createElement(\"div\"); -o.observe(div, { attributes: true, attributeFilter: [ \"style\" ] }); +o.observe(div, { attributes: true, attributeFilter: [\"style\"] }); // correct o.observe(div, { characterData: true, invalid: true }); // correct diff --git a/tests/bracketSpacing/__snapshots__/jsfmt.spec.js.snap b/tests/bracketSpacing/__snapshots__/jsfmt.spec.js.snap index 69d639e88..12dda2761 100644 --- a/tests/bracketSpacing/__snapshots__/jsfmt.spec.js.snap +++ b/tests/bracketSpacing/__snapshots__/jsfmt.spec.js.snap @@ -2,8 +2,8 @@ exports[`test array.js 1`] = ` "const arr1 = [1,2,3,4]; const arr2 = [1, 2, 3, 4]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const arr1 = [ 1, 2, 3, 4 ]; -const arr2 = [ 1, 2, 3, 4 ]; +const arr1 = [1, 2, 3, 4]; +const arr2 = [1, 2, 3, 4]; " `; diff --git a/tests/builtins/__snapshots__/jsfmt.spec.js.snap b/tests/builtins/__snapshots__/jsfmt.spec.js.snap index a811c9bda..47fe9f7f0 100644 --- a/tests/builtins/__snapshots__/jsfmt.spec.js.snap +++ b/tests/builtins/__snapshots__/jsfmt.spec.js.snap @@ -17,7 +17,7 @@ function g() { foo = foo1; } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var a = [ \"...\" ]; +var a = [\"...\"]; var b = a.map(function(x) { return 0; }); diff --git a/tests/core_tests/__snapshots__/jsfmt.spec.js.snap b/tests/core_tests/__snapshots__/jsfmt.spec.js.snap index 0f7a856ba..ea1f57af7 100644 --- a/tests/core_tests/__snapshots__/jsfmt.spec.js.snap +++ b/tests/core_tests/__snapshots__/jsfmt.spec.js.snap @@ -122,7 +122,7 @@ let tests = [ function* generator(): Iterable<[string, number]> { while (true) { - yield [ \"foo\", 123 ]; + yield [\"foo\", 123]; } } @@ -131,17 +131,17 @@ let tests = [ function() { let w = new Map(); let x = new Map(null); - let y = new Map([ [ \"foo\", 123 ] ]); + let y = new Map([[\"foo\", 123]]); let z = new Map(generator()); let a: Map = new Map(); - let b: Map = new Map([ [ \"foo\", 123 ] ]); + let b: Map = new Map([[\"foo\", 123]]); let c: Map = new Map(generator()); }, // bad constructors function() { - let x = new Map([ \"foo\", 123 ]); + let x = new Map([\"foo\", 123]); // error - let y: Map = new Map([ [ \"foo\", 123 ] ]); // error + let y: Map = new Map([[\"foo\", 123]]); // error }, // get() function(x: Map) { @@ -271,9 +271,9 @@ ws.delete(window); ws.delete(obj); ws.delete(dict); -let ws2 = new WeakSet([ obj, dict ]); +let ws2 = new WeakSet([obj, dict]); -let ws3 = new WeakSet([ 1, 2, 3 ]); +let ws3 = new WeakSet([1, 2, 3]); // error, must be objects function* generator(): Iterable<{ foo: string }> { diff --git a/tests/covariance/__snapshots__/jsfmt.spec.js.snap b/tests/covariance/__snapshots__/jsfmt.spec.js.snap index 1862bb4b6..a73112031 100644 --- a/tests/covariance/__snapshots__/jsfmt.spec.js.snap +++ b/tests/covariance/__snapshots__/jsfmt.spec.js.snap @@ -63,7 +63,7 @@ class NVerbose { } var nv: NVerbose = new NVerbose(); -nv.x = [ 0 ]; +nv.x = [0]; (nv.x[0]: string); // error (nv.foo()[0]: string); // error diff --git a/tests/destructuring/__snapshots__/jsfmt.spec.js.snap b/tests/destructuring/__snapshots__/jsfmt.spec.js.snap index 6480c3a36..fe1ca2361 100644 --- a/tests/destructuring/__snapshots__/jsfmt.spec.js.snap +++ b/tests/destructuring/__snapshots__/jsfmt.spec.js.snap @@ -12,9 +12,9 @@ let d = zs[1]; // run off the end let [...e] = 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -let xs = [ 0, \"\", true ]; -let [ a, ...ys ] = xs; -let [ b, ...zs ] = ys; +let xs = [0, \"\", true]; +let [a, ...ys] = xs; +let [b, ...zs] = ys; let c = zs[0]; // retain tuple info let d = zs[1]; @@ -29,7 +29,7 @@ let d = zs[1]; (d: void); // error: number|string|boolean ~> void -let [ ...e ] = 0; +let [...e] = 0; " `; @@ -222,9 +222,9 @@ function obj_prop_err({ x: { y } } = null) {} // error: property \`x\` cannot be accessed on null function obj_rest_err({ ...o } = 0) {} // error: expected object instead of number -function arr_elem_err([ x ] = null) {} +function arr_elem_err([x] = null) {} // error: element 0 cannot be accessed on null -function arr_rest_err([ ...a ] = null) {} +function arr_rest_err([...a] = null) {} // error: expected array instead of null function gen(x: T, { p = x }: { p: T }): T { @@ -325,23 +325,23 @@ var cp2_err: string = others.childprop2; // Error: number ~> string declare var a: string; declare var b: string; declare var c: string; -[ { a1: a, b }, c ] = [ { a1: 0, b: 1 }, 2 ]; +[{ a1: a, b }, c] = [{ a1: 0, b: 1 }, 2]; var { m } = { m: 0 }; ({ m } = { m: m }); var obj; ({ n: obj.x } = { n: 3 }); -[ obj.x ] = [ \"foo\" ]; +[obj.x] = [\"foo\"]; -function foo({ p, z: [ r ] }) { +function foo({ p, z: [r] }) { a = p; b = z; c = r; } -foo({ p: 0, z: [ 1, 2 ] }); +foo({ p: 0, z: [1, 2] }); -[ a, , b, ...c ] = [ 0, 1, true, 3 ]; +[a, , b, ...c] = [0, 1, true, 3]; function bar({ x, ...z }) { var o: { x: string, y: number } = z; @@ -479,16 +479,16 @@ type Prop = { prop: X }; function obj_pattern2({ prop }: Prop) {} // prop: X -function arr_pattern([ elem ]: X[]) {} +function arr_pattern([elem]: X[]) {} // elem: X type Elem = X[]; -function arr_pattern2([ elem ]: Elem) {} +function arr_pattern2([elem]: Elem) {} // elem: X -function tup_pattern([ proj ]: [X]) {} +function tup_pattern([proj]: [X]) {} // proj: X type Proj = [X]; -function tup_pattern2([ proj ]: Proj) {} +function tup_pattern2([proj]: Proj) {} // proj: X function rest_antipattern(...t: T) {} @@ -506,12 +506,12 @@ function obj_rest_pattern({ _, ...o }: ObjRest) { o.x; } -function arr_rest_pattern([ _, ...a ]: [any, X]) { +function arr_rest_pattern([_, ...a]: [any, X]) { // a: [X] a[0]; } type ArrRest = [any, X]; -function arr_rest_pattern([ _, ...a ]: ArrRest) { +function arr_rest_pattern([_, ...a]: ArrRest) { // a: [X] a[0]; } @@ -545,11 +545,11 @@ var { x: o } = o; // Make sure that destructuring doesn\'t cause infinite loops when combined with // funny doses of repositioning -let foo = (i: number) => [ i ]; +let foo = (i: number) => [i]; const bar = (i: number) => { - [ i ] = foo(i); - return [ i ]; + [i] = foo(i); + return [i]; }; foo = (i: number) => { diff --git a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap index 48bd8eb95..984f707be 100644 --- a/tests/es6modules/__snapshots__/jsfmt.spec.js.snap +++ b/tests/es6modules/__snapshots__/jsfmt.spec.js.snap @@ -541,7 +541,7 @@ export class NumberGenerator { export var varDeclNumber1 = 1, varDeclNumber2 = 2; export var { destructuredObjNumber } = { destructuredObjNumber: 1 }; -export var [ destructuredArrNumber ] = [ 1 ]; +export var [destructuredArrNumber] = [1]; " `; @@ -592,7 +592,7 @@ export class NumberGenerator2 { export var varDeclNumber3 = 1, varDeclNumber4 = 2; export var { destructuredObjNumber2 } = { destructuredObjNumber2: 1 }; -export var [ destructuredArrNumber2 ] = [ 1 ]; +export var [destructuredArrNumber2] = [1]; " `; diff --git a/tests/fetch/__snapshots__/jsfmt.spec.js.snap b/tests/fetch/__snapshots__/jsfmt.spec.js.snap index a1ca01b8d..f21844029 100644 --- a/tests/fetch/__snapshots__/jsfmt.spec.js.snap +++ b/tests/fetch/__snapshots__/jsfmt.spec.js.snap @@ -85,7 +85,7 @@ e.getAll(\'content-type\').forEach((v: string) => {}); // correct const a = new Headers(\"\'Content-Type\': \'image/jpeg\'\"); // not correct -const b = new Headers([ \"Content-Type\", \"image/jpeg\" ]); +const b = new Headers([\"Content-Type\", \"image/jpeg\"]); // not correct const c = new Headers({ \"Content-Type\", \"image/jpeg\" }); // correct @@ -115,11 +115,11 @@ const h: number = e.get(\"Content-Type\"); // not correct for (let v of e) { - const [ i, j ]: [string, string] = v; // correct + const [i, j]: [string, string] = v; // correct } for (let v of e.entries()) { - const [ i, j ]: [string, string] = v; // correct + const [i, j]: [string, string] = v; // correct } e.getAll(\"content-type\").forEach((v: string) => {}); // correct @@ -374,7 +374,7 @@ e.getAll(\'key1\').forEach((v: string) => {}); // correct const a = new URLSearchParams(\"key1=value1\"); // correct -const b = new URLSearchParams([ \"key1\", \"value1\" ]); +const b = new URLSearchParams([\"key1\", \"value1\"]); // not correct const c = new URLSearchParams({ \"key1\", \"value1\" }); // not correct @@ -404,11 +404,11 @@ const h: number = e.get(\"key1\"); // not correct for (let v of e) { - const [ i, j ]: [string, string] = v; // correct + const [i, j]: [string, string] = v; // correct } for (let v of e.entries()) { - const [ i, j ]: [string, string] = v; // correct + const [i, j]: [string, string] = v; // correct } e.getAll(\"key1\").forEach((v: string) => {}); // correct diff --git a/tests/for/__snapshots__/jsfmt.spec.js.snap b/tests/for/__snapshots__/jsfmt.spec.js.snap index e0ce51b1c..a8684ed23 100644 --- a/tests/for/__snapshots__/jsfmt.spec.js.snap +++ b/tests/for/__snapshots__/jsfmt.spec.js.snap @@ -235,7 +235,7 @@ function corge(x: boolean) { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function foo(x: boolean) { - var arr = [ 1, 2, 3 ]; + var arr = [1, 2, 3]; for (var elem of arr) { if (x) { continue; @@ -260,7 +260,7 @@ function baz(x: boolean) { } function bliffl(x: boolean) { - var arr = [ 1, 2, 3 ]; + var arr = [1, 2, 3]; loop1: for (var elem of arr) { loop2: diff --git a/tests/function/__snapshots__/jsfmt.spec.js.snap b/tests/function/__snapshots__/jsfmt.spec.js.snap index c433e46fb..01585406d 100644 --- a/tests/function/__snapshots__/jsfmt.spec.js.snap +++ b/tests/function/__snapshots__/jsfmt.spec.js.snap @@ -47,31 +47,31 @@ function test(a: string, b: number): number { } // tuples flow correctly into params -test.apply(\"\", [ \"\", 0 ]); +test.apply(\"\", [\"\", 0]); // wrong this is an error -test.apply(0, [ \"\", 0 ]); +test.apply(0, [\"\", 0]); // error: lookup \`length\` on Number // not enough arguments is an error (via incompatible RestT) -test.apply(\"\", [ \"\" ]); +test.apply(\"\", [\"\"]); // error: string ~> number // mistyped arguments is an error -test.apply(\"\", [ \"\", \"\" ]); +test.apply(\"\", [\"\", \"\"]); // error: string ~> number (2nd arg) -test.apply(\"\", [ 0, 0 ]); +test.apply(\"\", [0, 0]); // error: number ~> string (1st arg) // resolve args array from tvar function f(args) { test.apply(\"\", args); } -f([ \"\", 0 ]); +f([\"\", 0]); // OK -f([ \"\", \"\" ]); +f([\"\", \"\"]); // error: string ~> number (2nd arg) -f([ 0, 0 ]); +f([0, 0]); // error: number ~> string (1st arg) // expect array @@ -83,12 +83,12 @@ test.apply(\"\", \"not array\"); // - 123 is not a string // - \'foo\' is not a number // - return type (number) is not void -(test.call.apply(test, [ 0, 123, \"foo\" ]): void); +(test.call.apply(test, [0, 123, \"foo\"]): void); // expect 2 errors: // - lookup length on number (0 is used as \`this\`) // - 123 is not a string -(test.bind.apply(test, [ 0, 123 ]): (b: number) => number); +(test.bind.apply(test, [0, 123]): (b: number) => number); // args are optional function test2(): number { @@ -187,18 +187,18 @@ test.call(\"\", 0, 0); function f(args) { test.call(\"\", args[0], args[1]); } -f([ \"\", 0 ]); +f([\"\", 0]); // OK -f([ \"\", \"\" ]); +f([\"\", \"\"]); // error: string ~> number (2nd arg) -f([ 0, 0 ]); +f([0, 0]); // error: number ~> string (1st arg) // expect 3 errors: // - lookup length on Number (0 used as \`this\`) // - number !~> string (param a) // - string !~> number (param b) -(test.apply.call(test, 0, [ 0, \"foo\" ]): number); +(test.apply.call(test, 0, [0, \"foo\"]): number); // args are optional function test2(): number { diff --git a/tests/generics/__snapshots__/jsfmt.spec.js.snap b/tests/generics/__snapshots__/jsfmt.spec.js.snap index 798517ba3..8d23ba21a 100644 --- a/tests/generics/__snapshots__/jsfmt.spec.js.snap +++ b/tests/generics/__snapshots__/jsfmt.spec.js.snap @@ -92,7 +92,7 @@ class H extends G> { } var h1 = new H(); -h1.foo([ \"...\" ]); +h1.foo([\"...\"]); var h2: F>>> = h1; var obj: Object = {}; diff --git a/tests/init/__snapshots__/jsfmt.spec.js.snap b/tests/init/__snapshots__/jsfmt.spec.js.snap index 7482a041d..7548b9704 100644 --- a/tests/init/__snapshots__/jsfmt.spec.js.snap +++ b/tests/init/__snapshots__/jsfmt.spec.js.snap @@ -619,7 +619,7 @@ function for_in_post_init() { // local use of annotated var in for-of is ok function for_of_scoped_init() { - for (var x of [ 1, 2, 3 ]) { + for (var x of [1, 2, 3]) { var x: number = 0; var y: number = x; } @@ -629,14 +629,14 @@ function for_of_scoped_init() { function for_in_pre_init() { var y: number = x; // error - for (var x of [ 1, 2, 3 ]) { + for (var x of [1, 2, 3]) { var x: number = 0; } } // ...and after function for_in_post_init() { - for (var x of [ 1, 2, 3 ]) { + for (var x of [1, 2, 3]) { var x: number = 0; } var y: number = x; // error @@ -975,6 +975,6 @@ exports[`test nullable-init.js 1`] = ` var a: Array = [null,null]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var o: { x: ?number } = { x: null }; -var a: Array = [ null, null ]; +var a: Array = [null, null]; " `; diff --git a/tests/iter/__snapshots__/jsfmt.spec.js.snap b/tests/iter/__snapshots__/jsfmt.spec.js.snap index 1c8153be7..4f013fca5 100644 --- a/tests/iter/__snapshots__/jsfmt.spec.js.snap +++ b/tests/iter/__snapshots__/jsfmt.spec.js.snap @@ -37,7 +37,7 @@ for (var y in this) { // allowed, even though we can\'t actually enumerate all the keys on \`this\`. } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var a = [ true, false ]; +var a = [true, false]; function foo(x) {} for (var i = 0; i < 3; i++) { diff --git a/tests/iterable/__snapshots__/jsfmt.spec.js.snap b/tests/iterable/__snapshots__/jsfmt.spec.js.snap index c4289206a..93842243e 100644 --- a/tests/iterable/__snapshots__/jsfmt.spec.js.snap +++ b/tests/iterable/__snapshots__/jsfmt.spec.js.snap @@ -12,14 +12,14 @@ var arrayTest5: Iterable = [\"hi\", 1]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /* @flow */ -var arrayTest1: Iterable = ([ 1, 2 ]: Array); -var arrayTest2: Iterable = [ 1, 2, \"hi\" ]; -var arrayTest3: Iterable<*> = [ 1, 2, 3 ]; +var arrayTest1: Iterable = ([1, 2]: Array); +var arrayTest2: Iterable = [1, 2, \"hi\"]; +var arrayTest3: Iterable<*> = [1, 2, 3]; // Error string ~> number -var arrayTest4: Iterable = [ \"hi\" ]; +var arrayTest4: Iterable = [\"hi\"]; // Error string ~> number -var arrayTest5: Iterable = [ \"hi\", 1 ]; +var arrayTest5: Iterable = [\"hi\", 1]; " `; diff --git a/tests/last_argument_expansion/__snapshots__/jsfmt.spec.js.snap b/tests/last_argument_expansion/__snapshots__/jsfmt.spec.js.snap index b71d51638..0304387da 100644 --- a/tests/last_argument_expansion/__snapshots__/jsfmt.spec.js.snap +++ b/tests/last_argument_expansion/__snapshots__/jsfmt.spec.js.snap @@ -36,7 +36,7 @@ export const log = y => { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const formatData = pipe( zip, - map(([ ref, data ]) => ({ + map(([ref, data]) => ({ nodeId: ref.nodeId.toString(), ...attributeFromDataValue(ref.attributeId, data) })), diff --git a/tests/literal/__snapshots__/jsfmt.spec.js.snap b/tests/literal/__snapshots__/jsfmt.spec.js.snap index 5491c1c0e..1f350b20a 100644 --- a/tests/literal/__snapshots__/jsfmt.spec.js.snap +++ b/tests/literal/__snapshots__/jsfmt.spec.js.snap @@ -59,7 +59,7 @@ var name: number = object[APIKeys.NAME]; // error: object.name is a string var indices = { red: 0, green: 1, blue: 2 }; -var tuple = [ 42, \"hello\", false ]; +var tuple = [42, \"hello\", false]; var red: string = tuple[indices.red]; // error: tuple[0] is a number " `; diff --git a/tests/logical/__snapshots__/jsfmt.spec.js.snap b/tests/logical/__snapshots__/jsfmt.spec.js.snap index b19177b0c..f3cab28a7 100644 --- a/tests/logical/__snapshots__/jsfmt.spec.js.snap +++ b/tests/logical/__snapshots__/jsfmt.spec.js.snap @@ -580,7 +580,7 @@ function logical2f(): string { * A literal on the left side of && */ function logical2g(): string { - return [ 1, 2, 3 ] && \"foo\"; + return [1, 2, 3] && \"foo\"; } /** diff --git a/tests/misc/__snapshots__/jsfmt.spec.js.snap b/tests/misc/__snapshots__/jsfmt.spec.js.snap index a62ca5f16..c3f2e0dbc 100644 --- a/tests/misc/__snapshots__/jsfmt.spec.js.snap +++ b/tests/misc/__snapshots__/jsfmt.spec.js.snap @@ -188,7 +188,7 @@ var a = { length: \"duck\" }; a.length = 123; a.length(); -var b = [ 123 ]; +var b = [123]; b.length = \"duck\"; b.length(); " diff --git a/tests/missing_annotation/__snapshots__/jsfmt.spec.js.snap b/tests/missing_annotation/__snapshots__/jsfmt.spec.js.snap index d0ec15df8..d7d4b4f7c 100644 --- a/tests/missing_annotation/__snapshots__/jsfmt.spec.js.snap +++ b/tests/missing_annotation/__snapshots__/jsfmt.spec.js.snap @@ -9,7 +9,7 @@ export var arr = [f]; type Foo = {}; var f: Foo = {}; -export var arr = [ f ]; +export var arr = [f]; " `; diff --git a/tests/namespace/__snapshots__/jsfmt.spec.js.snap b/tests/namespace/__snapshots__/jsfmt.spec.js.snap index 47c3ef33a..b6f41871f 100644 --- a/tests/namespace/__snapshots__/jsfmt.spec.js.snap +++ b/tests/namespace/__snapshots__/jsfmt.spec.js.snap @@ -42,8 +42,8 @@ function bar(x: U, f: Map): V { var y: number = bar(0, x => \"\"); type Seq = number | Array; -var s1: Seq = [ 0, [ 0 ] ]; -var s2: Seq = [ [ \"\" ] ]; +var s1: Seq = [0, [0]]; +var s2: Seq = [[\"\"]]; module.exports = { foo: (\"\": number) }; " diff --git a/tests/node_tests/buffer/__snapshots__/jsfmt.spec.js.snap b/tests/node_tests/buffer/__snapshots__/jsfmt.spec.js.snap index 85d6f7cf5..9cf18fa99 100644 --- a/tests/node_tests/buffer/__snapshots__/jsfmt.spec.js.snap +++ b/tests/node_tests/buffer/__snapshots__/jsfmt.spec.js.snap @@ -116,8 +116,8 @@ num = buffer.indexOf(3); num = buffer.indexOf(3, 4); // static methods -buffer = Buffer.from([ 0x62, 0x75, 0x66, 0x66, 0x65, 0x72 ]); -const typedArray = new Uint8Array([ 0x34 ]); +buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]); +const typedArray = new Uint8Array([0x34]); buffer = Buffer.from( typedArray.buffer, typedArray.byteOffset, @@ -131,7 +131,7 @@ buffer = Buffer.from(\"foo\", \"utf8\"); // flow doesn\'t support a subclass hiding a superclass member, so this checks out as // ok, even though it is not correct. buffer = Buffer.from( - [ 0x62, 0x75, 0x66, 0x66, 0x65, 0x72 ], + [0x62, 0x75, 0x66, 0x66, 0x65, 0x72], (a: number) => a + 1, {} ); // should error but doesn\'t diff --git a/tests/node_tests/child_process/__snapshots__/jsfmt.spec.js.snap b/tests/node_tests/child_process/__snapshots__/jsfmt.spec.js.snap index 630144e90..eab7c1a60 100644 --- a/tests/node_tests/child_process/__snapshots__/jsfmt.spec.js.snap +++ b/tests/node_tests/child_process/__snapshots__/jsfmt.spec.js.snap @@ -69,7 +69,7 @@ execFile(\'ls\', [\'-l\'], {timeout: 250}, function(error, stdout, stderr) { var execFile = require(\"child_process\").execFile; // args only. -execFile(\"ls\", [ \"-lh\" ]); +execFile(\"ls\", [\"-lh\"]); // callback only. execFile(\"ls\", function(error, stdout, stderr) { @@ -80,15 +80,15 @@ execFile(\"ls\", function(error, stdout, stderr) { execFile(\"wc\", { timeout: 250 }); // args + callback. -execFile(\"ls\", [ \"-l\" ], function(error, stdout, stderr) { +execFile(\"ls\", [\"-l\"], function(error, stdout, stderr) { console.info(stdout); }); // args + options. -execFile(\"ls\", [ \"-l\" ], { timeout: 250 }); +execFile(\"ls\", [\"-l\"], { timeout: 250 }); // Put it all together. -execFile(\"ls\", [ \"-l\" ], { timeout: 250 }, function(error, stdout, stderr) { +execFile(\"ls\", [\"-l\"], { timeout: 250 }, function(error, stdout, stderr) { console.info(stdout); }); " @@ -120,7 +120,7 @@ execSync(\"ls\", { timeout: \"250\" }); // error, no signatures match execSync(\"ls\", { stdio: \"inherit\" }); // error, no signatures match -execSync(\"ls\", { stdio: [ \"inherit\" ] }); // error, no signatures match +execSync(\"ls\", { stdio: [\"inherit\"] }); // error, no signatures match " `; @@ -161,10 +161,10 @@ wc.stderr.pipe(process.stderr); var child_process = require(\"child_process\"); var ls = child_process.spawn(\"ls\"); -var wc = child_process.spawn(\"wc\", [ \"-l\" ]); +var wc = child_process.spawn(\"wc\", [\"-l\"]); // args + options. -child_process.spawn(\"echo\", [ \"-n\", \'\"Testing...\"\' ], { env: { TEST: \"foo\" } }); +child_process.spawn(\"echo\", [\"-n\", \'\"Testing...\"\'], { env: { TEST: \"foo\" } }); // options only. child_process.spawn(\"echo\", { env: { FOO: 2 } }); diff --git a/tests/nullable/__snapshots__/jsfmt.spec.js.snap b/tests/nullable/__snapshots__/jsfmt.spec.js.snap index 9854a54d0..026f134a0 100644 --- a/tests/nullable/__snapshots__/jsfmt.spec.js.snap +++ b/tests/nullable/__snapshots__/jsfmt.spec.js.snap @@ -61,7 +61,7 @@ if (x != null) { qux(x); } -var array_of_nullable: Array = [ null, 3 ]; +var array_of_nullable: Array = [null, 3]; " `; diff --git a/tests/object_assign/__snapshots__/jsfmt.spec.js.snap b/tests/object_assign/__snapshots__/jsfmt.spec.js.snap index 19f5fa957..b13bb09e6 100644 --- a/tests/object_assign/__snapshots__/jsfmt.spec.js.snap +++ b/tests/object_assign/__snapshots__/jsfmt.spec.js.snap @@ -105,11 +105,11 @@ exports[`test apply.js 1`] = ` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @flow -(Object.assign.apply(null, [ {}, { a: 1 }, { b: \"foo\" } ]): { +(Object.assign.apply(null, [{}, { a: 1 }, { b: \"foo\" }]): { a: number, b: string }); -(Object.assign({}, ...[ { a: 1 }, { b: \"foo\" } ]): { a: number, b: string }); +(Object.assign({}, ...[{ a: 1 }, { b: \"foo\" }]): { a: number, b: string }); " `; diff --git a/tests/optional/__snapshots__/jsfmt.spec.js.snap b/tests/optional/__snapshots__/jsfmt.spec.js.snap index 237d37a39..b7f694d85 100644 --- a/tests/optional/__snapshots__/jsfmt.spec.js.snap +++ b/tests/optional/__snapshots__/jsfmt.spec.js.snap @@ -15,7 +15,7 @@ exports[`test default.js 1`] = ` } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function f(foo, bar = foo): [T, T] { - return [ foo, bar ]; + return [foo, bar]; } " `; @@ -178,7 +178,7 @@ function qux(x = \"hello\", ...y): string { } qux(0, 0); -qux(0, ...[ \"\", 42 ]); +qux(0, ...[\"\", 42]); module.exports = qux; " @@ -324,7 +324,7 @@ foo(123, true); // ERROR boolean ~> string /* @flow */ function foo(x?: number, ...y: Array): [?number, Array] { - return [ x, y ]; + return [x, y]; } foo(); diff --git a/tests/overload/__snapshots__/jsfmt.spec.js.snap b/tests/overload/__snapshots__/jsfmt.spec.js.snap index cc90236a3..33aee36c8 100644 --- a/tests/overload/__snapshots__/jsfmt.spec.js.snap +++ b/tests/overload/__snapshots__/jsfmt.spec.js.snap @@ -199,6 +199,6 @@ function foo(x: $Either, U>): Array { } var x1: number = foo(0)[0]; -var x2: string = foo([ \"\" ])[0]; +var x2: string = foo([\"\"])[0]; " `; diff --git a/tests/plsummit/__snapshots__/jsfmt.spec.js.snap b/tests/plsummit/__snapshots__/jsfmt.spec.js.snap index b7c5075fc..a45cfc412 100644 --- a/tests/plsummit/__snapshots__/jsfmt.spec.js.snap +++ b/tests/plsummit/__snapshots__/jsfmt.spec.js.snap @@ -5,10 +5,10 @@ var [n, b, s] = foo(42); n * s.length; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function foo(x) { - return [ x, x > 0, \"number \" + x ]; + return [x, x > 0, \"number \" + x]; } -var [ n, b, s ] = foo(42); +var [n, b, s] = foo(42); n * s.length; " `; diff --git a/tests/promises/__snapshots__/jsfmt.spec.js.snap b/tests/promises/__snapshots__/jsfmt.spec.js.snap index 80ff640a1..3e3979456 100644 --- a/tests/promises/__snapshots__/jsfmt.spec.js.snap +++ b/tests/promises/__snapshots__/jsfmt.spec.js.snap @@ -51,7 +51,7 @@ Promise.all([ true ]).then(xs => { // tuple information is preserved - let [ a, b, c ] = xs; + let [a, b, c] = xs; (a: number); // Error: string ~> number (b: boolean); diff --git a/tests/react/__snapshots__/jsfmt.spec.js.snap b/tests/react/__snapshots__/jsfmt.spec.js.snap index b8ee1ec40..94b7025d7 100644 --- a/tests/react/__snapshots__/jsfmt.spec.js.snap +++ b/tests/react/__snapshots__/jsfmt.spec.js.snap @@ -167,10 +167,10 @@ var Example = React.createClass({ }); var ok_empty = ; -var ok_numbers = ; +var ok_numbers = ; var fail_not_array = ; -var fail_mistyped_elems = ; +var fail_mistyped_elems = ; " `; @@ -350,7 +350,7 @@ var ex2 = ; var React = require(\"react\"); var Example = React.createClass({ - propTypes: { literal: React.PropTypes.oneOf([ \"foo\" ]).isRequired } + propTypes: { literal: React.PropTypes.oneOf([\"foo\"]).isRequired } }); var ex1 = ; diff --git a/tests/refi/__snapshots__/jsfmt.spec.js.snap b/tests/refi/__snapshots__/jsfmt.spec.js.snap index 934e63275..8fc9cf1e9 100644 --- a/tests/refi/__snapshots__/jsfmt.spec.js.snap +++ b/tests/refi/__snapshots__/jsfmt.spec.js.snap @@ -429,7 +429,7 @@ var tests = [ var y: string = x.p || \"\"; // ok }, function() { - var x: { p: string | string[] } = { p: [ \"xxx\" ] }; + var x: { p: string | string[] } = { p: [\"xxx\"] }; if (Array.isArray(x.p)) { var y: string[] = x.p; // ok } else { @@ -806,7 +806,7 @@ var paths = [ var y: string = x || \"\"; // ok }, function() { - var x: string | string[] = [ \"xxx\" ]; + var x: string | string[] = [\"xxx\"]; if (Array.isArray(x)) { var y: string[] = x; // ok } else { diff --git a/tests/requireLazy/__snapshots__/jsfmt.spec.js.snap b/tests/requireLazy/__snapshots__/jsfmt.spec.js.snap index b0e7bb062..7aedf6a94 100644 --- a/tests/requireLazy/__snapshots__/jsfmt.spec.js.snap +++ b/tests/requireLazy/__snapshots__/jsfmt.spec.js.snap @@ -66,7 +66,7 @@ requireLazy([\'A\']); // Error: No calback expression * @flow */ -requireLazy([ \"A\", \"B\" ], function(A, B) { +requireLazy([\"A\", \"B\"], function(A, B) { var num1: number = A.numberValueA; var str1: string = A.stringValueA; var num2: number = A.stringValueA; @@ -86,8 +86,8 @@ var notB: Object = B; requireLazy(); // Error: No args -requireLazy([ nope ], function() {}); +requireLazy([nope], function() {}); // Error: Non-stringliteral args -requireLazy([ \"A\" ]); // Error: No calback expression +requireLazy([\"A\"]); // Error: No calback expression " `; diff --git a/tests/spread/__snapshots__/jsfmt.spec.js.snap b/tests/spread/__snapshots__/jsfmt.spec.js.snap index 3aa4d9d7c..87430e08e 100644 --- a/tests/spread/__snapshots__/jsfmt.spec.js.snap +++ b/tests/spread/__snapshots__/jsfmt.spec.js.snap @@ -120,7 +120,7 @@ test(0, ...[1, 2, 3]); /* @flow */ function test(...nums: Array) {} -test(0, ...[ 1, 2, 3 ]); +test(0, ...[1, 2, 3]); " `; diff --git a/tests/suggest/__snapshots__/jsfmt.spec.js.snap b/tests/suggest/__snapshots__/jsfmt.spec.js.snap index 4f36af195..25eb1902f 100644 --- a/tests/suggest/__snapshots__/jsfmt.spec.js.snap +++ b/tests/suggest/__snapshots__/jsfmt.spec.js.snap @@ -35,7 +35,7 @@ function foo(z: number) { return bar(z); } -var array = [ \"foo\", \"bar\" ]; +var array = [\"foo\", \"bar\"]; array; module.exports = { foo: foo }; diff --git a/tests/this_type/__snapshots__/jsfmt.spec.js.snap b/tests/this_type/__snapshots__/jsfmt.spec.js.snap index 4ca1fb19f..242c9088e 100644 --- a/tests/this_type/__snapshots__/jsfmt.spec.js.snap +++ b/tests/this_type/__snapshots__/jsfmt.spec.js.snap @@ -106,7 +106,7 @@ class Invariant { inout_object: { _: this }; out_array(): Array { - return [ this ]; + return [this]; } in_array(_: Array) {} inout_array: Array; diff --git a/tests/tuples/__snapshots__/jsfmt.spec.js.snap b/tests/tuples/__snapshots__/jsfmt.spec.js.snap index 59ea3f91e..71e05fd34 100644 --- a/tests/tuples/__snapshots__/jsfmt.spec.js.snap +++ b/tests/tuples/__snapshots__/jsfmt.spec.js.snap @@ -16,7 +16,7 @@ function foo(x: Array): [number, ?number] { } function foo(x: Array): [number, ?number] { - return [ x[0], x[1] ]; // OK. This is unsound, but at least arity is enforced + return [x[0], x[1]]; // OK. This is unsound, but at least arity is enforced } " `; @@ -31,9 +31,9 @@ exports[`test optional.js 1`] = ` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @flow -([ 0, undefined ]: [number, ?string]); +([0, undefined]: [number, ?string]); // Ok, correct arity -([ 0 ]: [number, ?string]); +([0]: [number, ?string]); // Error, arity is enforced ([]: [?number, string]); // error, since second element is not marked optional @@ -51,7 +51,7 @@ foo([ {} ]); // error, too few elements in array passed to a tuple function foo(a: [Object, Object]) {} -foo([ {} ]); // error, too few elements in array passed to a tuple +foo([{}]); // error, too few elements in array passed to a tuple " `; @@ -64,12 +64,12 @@ var e: [number, string,] = [123,\'duck\']; var f: [number, string] = [123, 456]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var a: [] = []; -var b: [] = [ 123 ]; +var b: [] = [123]; // Error - arity mismatch var c: [number] = []; // nope -var d: [number, string] = [ 123, \"duck\" ]; -var e: [number, string] = [ 123, \"duck\" ]; -var f: [number, string] = [ 123, 456 ]; +var d: [number, string] = [123, \"duck\"]; +var e: [number, string] = [123, \"duck\"]; +var f: [number, string] = [123, 456]; " `; diff --git a/tests/type-at-pos/__snapshots__/jsfmt.spec.js.snap b/tests/type-at-pos/__snapshots__/jsfmt.spec.js.snap index e133e7235..063438e35 100644 --- a/tests/type-at-pos/__snapshots__/jsfmt.spec.js.snap +++ b/tests/type-at-pos/__snapshots__/jsfmt.spec.js.snap @@ -21,7 +21,7 @@ export const X = { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @flow -let [ x, y ] = [ 1, 2 ]; +let [x, y] = [1, 2]; /** * Test what happens when the destructuring is unevaluated. In this case, @@ -31,10 +31,10 @@ let [ x, y ] = [ 1, 2 ]; */ export const X = { returnsATuple: function(): [number, number] { - return [ 1, 2 ]; + return [1, 2]; }, test: function() { - let [ a, b ] = this.returnsATuple(); + let [a, b] = this.returnsATuple(); } }; " @@ -255,7 +255,7 @@ foo(); str; type Point = [number, string]; -const x: Point = [ 1, \"foo\" ]; +const x: Point = [1, \"foo\"]; type MyStr = \"cool\"; const y: MyStr = \"cool\"; type MyBool = true; diff --git a/tests/type_args_nonstrict/__snapshots__/jsfmt.spec.js.snap b/tests/type_args_nonstrict/__snapshots__/jsfmt.spec.js.snap index 0be9b1502..47b29b936 100644 --- a/tests/type_args_nonstrict/__snapshots__/jsfmt.spec.js.snap +++ b/tests/type_args_nonstrict/__snapshots__/jsfmt.spec.js.snap @@ -138,7 +138,7 @@ class MySubclass extends MyClass { // no arity error in call of polymorphic function function singleton(x: T): Array { - return [ x ]; + return [x]; } var num_array: Array = singleton(0); // ok, type arg inferred diff --git a/tests/type_args_strict/__snapshots__/jsfmt.spec.js.snap b/tests/type_args_strict/__snapshots__/jsfmt.spec.js.snap index 73644bdcd..54907393d 100644 --- a/tests/type_args_strict/__snapshots__/jsfmt.spec.js.snap +++ b/tests/type_args_strict/__snapshots__/jsfmt.spec.js.snap @@ -136,7 +136,7 @@ class MySubclass extends MyClass { // *no* arity error in call of polymorphic function function singleton(x: T): Array { - return [ x ]; + return [x]; } var num_array: Array = singleton(0); // ok, type arg inferred diff --git a/tests/type_only_vars/__snapshots__/jsfmt.spec.js.snap b/tests/type_only_vars/__snapshots__/jsfmt.spec.js.snap index 01c10c061..452f9af7e 100644 --- a/tests/type_only_vars/__snapshots__/jsfmt.spec.js.snap +++ b/tests/type_only_vars/__snapshots__/jsfmt.spec.js.snap @@ -175,7 +175,7 @@ var x = Foo; // But using it in a type should still work var a: Foo = 123; -var b: Array = [ 123 ]; +var b: Array = [123]; type c = Foo; " `; diff --git a/tests/undefined/__snapshots__/jsfmt.spec.js.snap b/tests/undefined/__snapshots__/jsfmt.spec.js.snap index 962c80c4e..3be7818eb 100644 --- a/tests/undefined/__snapshots__/jsfmt.spec.js.snap +++ b/tests/undefined/__snapshots__/jsfmt.spec.js.snap @@ -97,7 +97,7 @@ let tests = [ (name: boolean); // error, string or void - const bar = [ undefined, \"bar\" ]; + const bar = [undefined, \"bar\"]; (bar[x]: boolean); // error, string or void }, function(x: number) { @@ -110,7 +110,7 @@ let tests = [ x[0]; // should error, could be void } - const bar = [ undefined, \"bar\" ]; + const bar = [undefined, \"bar\"]; (bar[x]: boolean); // error, string only } ]; diff --git a/tests/union/__snapshots__/jsfmt.spec.js.snap b/tests/union/__snapshots__/jsfmt.spec.js.snap index 6b4fb6133..0702b43e9 100644 --- a/tests/union/__snapshots__/jsfmt.spec.js.snap +++ b/tests/union/__snapshots__/jsfmt.spec.js.snap @@ -110,8 +110,8 @@ myclass.myfun([\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", function (ar) {} declare class Myclass { myfun(myarray: Array): any } declare var myclass: Myclass; -myclass.myfun([ \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", function(ar) {} ]); -myclass.myfun([ \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", function(ar) {} ]); +myclass.myfun([\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", function(ar) {}]); +myclass.myfun([\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", function(ar) {}]); " `; @@ -184,7 +184,7 @@ class Tag { type Node = Tag_ | string; class Tag_ { constructor() { - var a1: Array = [ new Tag_() ]; + var a1: Array = [new Tag_()]; var a2: Array = a1; } } @@ -197,8 +197,8 @@ var stringArr:Array = [\'a\',\'b\']; var result = numberAndStringArr.concat(stringArr); // no error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var numberAndStringArr: Array = [ 1, 2 ]; -var stringArr: Array = [ \"a\", \"b\" ]; +var numberAndStringArr: Array = [1, 2]; +var stringArr: Array = [\"a\", \"b\"]; var result = numberAndStringArr.concat(stringArr); // no error " diff --git a/tests/union_new/__snapshots__/jsfmt.spec.js.snap b/tests/union_new/__snapshots__/jsfmt.spec.js.snap index 45e7731e5..497a493cc 100644 --- a/tests/union_new/__snapshots__/jsfmt.spec.js.snap +++ b/tests/union_new/__snapshots__/jsfmt.spec.js.snap @@ -493,7 +493,7 @@ function inst(a: A5 | A6) {} class B5 {} class B6 {} -inst([ new B6() ]); +inst([new B6()]); type A5 = B5[]; type A6 = B6[]; @@ -647,7 +647,7 @@ type B5 = string; // tuples function tup(a: [number, boolean] | [string, boolean]) {} -tup(([ \"\", false ]: A6)); +tup(([\"\", false]: A6)); type A6 = [B6, boolean]; type B6 = string; @@ -1198,10 +1198,10 @@ check_obj({ x: id(\"\") }); function check_arr(_: number[] | string[]) {} // ok -check_arr([ \"\" ]); +check_arr([\"\"]); // help! -check_arr([ id(\"\") ]); +check_arr([id(\"\")]); ////////////////////////////////////// // generic class instance annotations @@ -1443,7 +1443,7 @@ exports[`test test17.js 1`] = ` [].concat([]); -([].concat([ 0, 1 ])[1]: string); +([].concat([0, 1])[1]: string); " `; @@ -1521,16 +1521,16 @@ exports[`test test20.js 1`] = ` // Array#reduce -[ 0, 1 ].reduce((x, y, i) => y); +[0, 1].reduce((x, y, i) => y); -[ \"a\", \"b\" ].reduce( +[\"a\", \"b\"].reduce( (regex, representation, index) => { return regex + (index ? \"|\" : \"\") + \"(\" + representation + \")\"; }, \"\" ); -[ \"\" ].reduce((acc, str) => acc * str.length); +[\"\"].reduce((acc, str) => acc * str.length); " `;