Skip to content

Commit 76943d3

Browse files
authored
Merge pull request #515 from prettier-solidity/enum_in_each_line
enums should belong in their own line
2 parents 3ac105d + fe7fae2 commit 76943d3

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

src/nodes/EnumDefinition.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
const {
22
doc: {
3-
builders: { group, line, softline }
3+
builders: { group, hardline }
44
}
55
} = require('prettier/standalone');
66

77
const printSeparatedList = require('./print-separated-list');
88

99
const EnumDefinition = {
10-
print: ({ node, path, print, options }) =>
10+
print: ({ node, path, print }) =>
1111
group([
1212
'enum ',
1313
node.name,
1414
' {',
1515
printSeparatedList(path.map(print, 'members'), {
16-
firstSeparator: options.bracketSpacing ? line : softline
16+
firstSeparator: hardline
1717
}),
1818
'}'
1919
])

tests/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,12 @@ contract c {
569569
}
570570
571571
contract test {
572-
enum ActionChoices {GoLeft, GoRight, GoStraight, SitStill}
572+
enum ActionChoices {
573+
GoLeft,
574+
GoRight,
575+
GoStraight,
576+
SitStill
577+
}
573578
574579
function test() {
575580
choices = ActionChoices.GoStraight;
@@ -995,7 +1000,11 @@ struct TopLevelStruct {
9951000
uint256 y;
9961001
}
9971002
998-
enum TopLevelEnum {Top, Level, Enum}
1003+
enum TopLevelEnum {
1004+
Top,
1005+
Level,
1006+
Enum
1007+
}
9991008
pragma solidity ^0.6.0;
10001009
10011010
contract A {

tests/EnumDefinitions/__snapshots__/jsfmt.spec.js.snap

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ contract EnumDefinitions {
1414
1515
=====================================output=====================================
1616
contract EnumDefinitions {
17-
enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }
17+
enum ActionChoices {
18+
GoLeft,
19+
GoRight,
20+
GoStraight,
21+
SitStill
22+
}
1823
enum States {
1924
State1,
2025
State2,
@@ -44,7 +49,12 @@ contract EnumDefinitions {
4449
4550
=====================================output=====================================
4651
contract EnumDefinitions {
47-
enum ActionChoices {GoLeft, GoRight, GoStraight, SitStill}
52+
enum ActionChoices {
53+
GoLeft,
54+
GoRight,
55+
GoStraight,
56+
SitStill
57+
}
4858
enum States {
4959
State1,
5060
State2,

0 commit comments

Comments
 (0)