Skip to content

Commit

Permalink
Add trailing comma for JS objects, and all record-like structures.
Browse files Browse the repository at this point in the history
Summary:

Test Plan:

Reviewers:

CC:
  • Loading branch information
jordwalke committed Jan 25, 2018
1 parent a0ad953 commit d0cb1a6
Show file tree
Hide file tree
Showing 17 changed files with 150,581 additions and 141 deletions.
2 changes: 1 addition & 1 deletion formatTest/typeCheckedTests/expected_output/attributes.re
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ and unusedType = unit;
[@onMyRecord]
let rec myRecord = {
p: () => myRecord,
q: () => ()
q: () => (),
}
[@onUnused]
and unused = ();
Expand Down
50 changes: 25 additions & 25 deletions formatTest/typeCheckedTests/expected_output/jsx.re
Original file line number Diff line number Diff line change
Expand Up @@ -2,87 +2,87 @@ type component = {displayName: string};

module Bar = {
let createElement = (~c=?, ~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Nesting = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Much = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Foo = {
let createElement =
(~a=?, ~b=?, ~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module One = {
let createElement =
(~test=?, ~foo=?, ~children, ()) => {
displayName: "test"
displayName: "test",
};
let createElementobvioustypo =
(~test, ~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Two = {
let createElement = (~foo=?, ~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Sibling = {
let createElement =
(~foo=?, ~children: list(component), ()) => {
displayName: "test"
displayName: "test",
};
};

module Test = {
let createElement = (~yo=?, ~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module So = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Foo2 = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Text = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Exp = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module Pun = {
let createElement =
(~intended=?, ~children, ()) => {
displayName: "test"
displayName: "test",
};
};

Expand All @@ -95,7 +95,7 @@ module Namespace = {
~children,
(),
) => {
displayName: "test"
displayName: "test",
};
};
};
Expand Down Expand Up @@ -138,40 +138,40 @@ module LotsOfArguments = {
~children,
(),
) => {
displayName: "test"
displayName: "test",
};
};

let div = (~argument1=?, ~children, ()) => {
displayName: "test"
displayName: "test",
};

module List1 = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module List2 = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module List3 = {
let createElement = (~children, ()) => {
displayName: "test"
displayName: "test",
};
};

module NotReallyJSX = {
let createElement = (~foo, ~bar, children) => {
displayName: "test"
displayName: "test",
};
};

let notReallyJSX = (~foo, ~bar, children) => {
displayName: "test"
displayName: "test",
};

let fakeRender = (el: component) =>
Expand Down Expand Up @@ -587,7 +587,7 @@ module Metal = {

module OverEager = {
let createElement = (~fiber, ~children, ()) => {
displayName: "test"
displayName: "test",
};
};

Expand All @@ -604,7 +604,7 @@ type style = {

module Window = {
let createElement = (~style, ~children, ()) => {
displayName: "window"
displayName: "window",
};
};

Expand All @@ -616,7 +616,7 @@ let w =
paddingTop: 10,
paddingLeft: 10,
paddingRight: 10,
paddingBottom: 10
paddingBottom: 10,
}
/>;

Expand Down
4 changes: 3 additions & 1 deletion formatTest/typeCheckedTests/expected_output/lazy.re
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ let operateOnLazyValue = (lazy {myRecordField}) => {
};

let result =
operateOnLazyValue(lazy {myRecordField: 100});
operateOnLazyValue(
lazy {myRecordField: 100},
);

type box('a) =
| Box('a);
Expand Down
2 changes: 1 addition & 1 deletion formatTest/typeCheckedTests/expected_output/oo.re
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ let constrainedAndCoerced = (
* idempotent test case.
*/
let xs: ref({. x: int}) = {
contents: (anonClosedObject :> {. x: int})
contents: (anonClosedObject :> {. x: int}),
};

let coercedReturn = {
Expand Down
4 changes: 2 additions & 2 deletions formatTest/typeCheckedTests/expected_output/sequences.re
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let number = 20;
* be very rare anyways.
*/
let cannotPunASingleFieldRecord = {
number: number
number: number,
};

let fourty =
Expand Down Expand Up @@ -91,5 +91,5 @@ let thirdFieldPunned = {a, b, c};

let singlePunAcceptedIfExtended = {
...firstFieldPunned,
a
a,
};
48 changes: 24 additions & 24 deletions formatTest/unit_tests/expected_output/basicStructures.re
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ let myRecord = {
IoEligible;
} else {
IoInelibleButTryComposition;
}
}
},
},
};

if (printIfFirstArgGreater) {
Expand Down Expand Up @@ -620,58 +620,58 @@ type withThreeFields = {
let testRecord = {
name: "joe",
age: 20,
occupation: "engineer"
occupation: "engineer",
};

let anotherRecord = {
...testRecord,
name: "joe++",
age: testRecord.age + 10
age: testRecord.age + 10,
};

let makeRecordBase = () => {
name: "Joe",
age: 30,
occupation: "Engineer"
occupation: "Engineer",
};

let anotherRecord = {
/* These parens should be evaporated. */
...makeRecordBase(),
name: "joe++",
age: testRecord.age + 10
age: testRecord.age + 10,
};

let anotherRecord = {
/* Comments should be correctly placed before ... expression */
...makeRecordBase(),
/* Comment after record extension */
name: "joe++",
age: testRecord.age + 10
age: testRecord.age + 10,
};

let anotherRecord = {
/* Currently, type annotations must be wrapped in parens - that's easy to improve */
...(makeRecordBase(): withThreeFields),
name: "joe++",
age: testRecord.age + 10
age: testRecord.age + 10,
};

let anotherRecord = {
/* This is meaningless, sure */
...someArray.[0] = 20,
name: "joe++",
age: testRecord.age + 10
age: testRecord.age + 10,
};

let anotherRecord = {
...
SomeReally.longFunctionCall({
passingRecordField: 0,
andThisOtherRecordField: 10
andThisOtherRecordField: 10,
}),
name: "joe++",
age: testRecord.age + 10
age: testRecord.age + 10,
};

let anotherRecord = {
Expand All @@ -681,7 +681,7 @@ let anotherRecord = {
thatWrap: bool,
),
name: "joe++",
age: testRecord.age + 10
age: testRecord.age + 10,
};

let anotherRecord = {
Expand All @@ -698,7 +698,7 @@ let anotherRecord = {
],
),
name: "joe++",
age: testRecord.age + 10
age: testRecord.age + 10,
};

/* Record type punning */
Expand Down Expand Up @@ -748,7 +748,7 @@ type foo = {
let moreFoo = {
bar: Baz.bar,
qux,
fooo: Fooo.fooo
fooo: Fooo.fooo,
};

/* record value punning */
Expand Down Expand Up @@ -792,49 +792,49 @@ let () = {
let z = {
a: {
b: c,
d: e
d: e,
},
f: g
f: g,
};

let z = {
a: {
"b": c,
"d": e
"d": e,
},
f: g
f: g,
};

let z = {
a: {
pub b = c;
pub d = e
},
f: g
f: g,
};

let z = {
"a": {
"b": c,
"d": e
"d": e,
},
"f": g
"f": g,
};

let z = {
"a": {
b: c,
d: e
d: e,
},
"f": g
"f": g,
};

let z = {
"a": {
pub b = c;
pub d = e
},
"f": g
"f": g,
};

/**
Expand Down
Loading

0 comments on commit d0cb1a6

Please sign in to comment.