Skip to content

Commit 5b043cd

Browse files
authored
By popular demand Contracts, Libraries, and Interfaces will have 1 line of separation (#283)
1 parent 0db9c14 commit 5b043cd

File tree

29 files changed

+1
-110
lines changed

29 files changed

+1
-110
lines changed

src/nodes/print-preserving-empty-lines.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@ function printPreservingEmptyLines(path, key, options, print) {
1616
}
1717

1818
if (childPath.getName() > 0) {
19-
if (nodeType === 'ContractDefinition') {
20-
if (parts[parts.length - 2] !== hardline) {
21-
parts.push(hardline);
22-
}
23-
parts.push(hardline);
24-
}
25-
2619
if (
27-
nodeType === 'FunctionDefinition' &&
20+
['ContractDefinition', 'FunctionDefinition'].includes(nodeType) &&
2821
parts[parts.length - 2] !== hardline
2922
) {
3023
parts.push(hardline);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ contract AddressPayable {
1414
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1515
pragma solidity ^0.5.2;
1616
17-
1817
contract AddressPayable {
1918
using Address for address payable;
2019
address payable[] hello;

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,10 @@ import "SomeFile.sol" as SomeOtherFile;
480480
import "AnotherFile.sol" as SomeSymbol;
481481
import {symbol1 as alias, symbol2} from "File.sol";
482482
483-
484483
interface i {
485484
function f();
486485
}
487486
488-
489487
contract c {
490488
function c() {
491489
val1 = 1 wei; // 1
@@ -500,7 +498,6 @@ contract c {
500498
uint256 val4;
501499
}
502500
503-
504501
contract test {
505502
enum ActionChoices {GoLeft, GoRight, GoStraight, SitStill}
506503
@@ -515,7 +512,6 @@ contract test {
515512
ActionChoices choices;
516513
}
517514
518-
519515
contract Base {
520516
function Base(uint256 i) {
521517
m_i = i;
@@ -524,12 +520,10 @@ contract Base {
524520
uint256 public m_i;
525521
}
526522
527-
528523
contract Derived is Base(0) {
529524
function Derived(uint256 i) Base(i) {}
530525
}
531526
532-
533527
contract C {
534528
uint248 x; // 31 bytes: slot 0, offset 0
535529
uint16 y; // 2 bytes: slot 1, offset 0 (does not fit in slot 0)
@@ -545,7 +539,6 @@ contract C {
545539
uint8 gamma; // 1 byte, slot 7 (start new slot after array)
546540
}
547541
548-
549542
contract test {
550543
function f(uint256 x, uint256 y) returns (uint256 z) {
551544
var c = x + 3;
@@ -554,14 +547,12 @@ contract test {
554547
}
555548
}
556549
557-
558550
contract test {
559551
function f(uint256 x, uint256 y) returns (uint256 z) {
560552
return 10;
561553
}
562554
}
563555
564-
565556
contract c {
566557
function() returns (uint256) {
567558
return g(8);
@@ -583,15 +574,13 @@ contract c {
583574
mapping(uint256 => uint256) data;
584575
}
585576
586-
587577
contract Sharer {
588578
function sendHalf(address addr) returns (uint256 balance) {
589579
if (!addr.send(msg.value / 2)) throw; // also reverts the transfer to Sharer
590580
return address(this).balance;
591581
}
592582
}
593583
594-
595584
/// @dev Models a modifiable and iterable set of uint values.
596585
library IntegerSet {
597586
struct data {
@@ -655,7 +644,6 @@ library IntegerSet {
655644
}
656645
}
657646
658-
659647
/// How to use it:
660648
contract User {
661649
/// Just a struct holding our data.
@@ -679,7 +667,6 @@ contract User {
679667
}
680668
}
681669
682-
683670
// This broke it at one point (namely the modifiers).
684671
contract DualIndex {
685672
mapping(uint256 => mapping(uint256 => uint256)) data;
@@ -711,26 +698,20 @@ contract DualIndex {
711698
}
712699
}
713700
714-
715701
contract A {}
716702
717-
718703
contract B {}
719704
720-
721705
contract C is A, B {}
722706
723-
724707
contract TestPrivate {
725708
uint256 private value;
726709
}
727710
728-
729711
contract TestInternal {
730712
uint256 internal value;
731713
}
732714
733-
734715
contract FromSolparse is A, B, TestPrivate, TestInternal {
735716
function() {
736717
uint256 a = 6**9;
@@ -739,7 +720,6 @@ contract FromSolparse is A, B, TestPrivate, TestInternal {
739720
}
740721
}
741722
742-
743723
contract CommentedOutFunction {
744724
// FYI: This empty function, as well as the commented
745725
// out function below (bad code) is important to this test.
@@ -750,26 +730,22 @@ contract CommentedOutFunction {
750730
// }
751731
}
752732
753-
754733
library VarHasBrackets {
755734
string constant specialRight = "}";
756735
//string storage specialLeft = "{";
757736
}
758737
759-
760738
library UsingExampleLibrary {
761739
function sum(uint256[] storage self) returns (uint256 s) {
762740
for (uint256 i = 0; i < self.length; i++) s += self[i];
763741
}
764742
}
765743
766-
767744
contract UsingExampleContract {
768745
using UsingExampleLibrary for *;
769746
using UsingExampleLibrary for uint256[];
770747
}
771748
772-
773749
contract NewStuff {
774750
uint256[] b;
775751
@@ -779,13 +755,11 @@ contract NewStuff {
779755
}
780756
}
781757
782-
783758
// modifier with expression
784759
contract MyContract {
785760
function fun() mymodifier(foo.bar()) {}
786761
}
787762
788-
789763
library GetCode {
790764
function at(address _addr) returns (bytes o_code) {
791765
assembly {
@@ -807,7 +781,6 @@ library GetCode {
807781
}
808782
}
809783
810-
811784
contract assemblyLocalBinding {
812785
function test() {
813786
assembly {
@@ -819,7 +792,6 @@ contract assemblyLocalBinding {
819792
}
820793
}
821794
822-
823795
contract assemblyReturn {
824796
uint256 a = 10;
825797
@@ -833,12 +805,10 @@ contract assemblyReturn {
833805
}
834806
}
835807
836-
837808
contract usesConst {
838809
uint256 const = 0;
839810
}
840811
841-
842812
contract memoryArrays {
843813
uint256 seven = 7;
844814
@@ -852,7 +822,6 @@ contract memoryArrays {
852822
}
853823
}
854824
855-
856825
contract DeclarativeExpressions {
857826
uint256 a;
858827
uint256 b = 7;
@@ -874,7 +843,6 @@ contract DeclarativeExpressions {
874843
}
875844
}
876845
877-
878846
contract VariableDeclarationTuple {
879847
function getMyTuple() returns (bool, bool) {
880848
return (true, false);
@@ -891,13 +859,11 @@ contract VariableDeclarationTuple {
891859
}
892860
}
893861
894-
895862
contract TypeIndexSpacing {
896863
uint256[7] x;
897864
uint256[] y;
898865
}
899866
900-
901867
contract Ballot {
902868
struct Voter {
903869
uint256 weight;
@@ -934,14 +900,12 @@ contract Ballot {
934900
Voter airbnb = Voter({weight: 2, voted: true});
935901
}
936902
937-
938903
contract multilineReturn {
939904
function a() returns (uint256 x) {
940905
return 5;
941906
}
942907
}
943908
944-
945909
contract continueStatement {
946910
function a() {
947911
while (true) {
@@ -950,10 +914,8 @@ contract continueStatement {
950914
}
951915
}
952916
953-
954917
abstract contract AbstractContract {}
955918
956-
957919
contract ContractWithVirtual {
958920
function foo() public virtual returns (uint256) {}
959921
}
@@ -976,7 +938,6 @@ contract B is A {
976938
function doStuff() public override {}
977939
}
978940
979-
980941
contract Overrides {
981942
mapping(address => bool) public override varName;
982943

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ contract Arrays {
1313
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1414
pragma solidity ^0.5.2;
1515
16-
1716
contract Arrays {
1817
bytes32[] public permissions = [
1918
bytes32("addPartner"),

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ contract ArithmeticOperators {
277277
}
278278
}
279279
280-
281280
contract ArithmeticOperators {
282281
// ['**']
283282
function someFunction() {
@@ -358,7 +357,6 @@ contract ArithmeticOperators {
358357
}
359358
}
360359
361-
362360
contract ShiftOperators {
363361
// ['<<', '>>']
364362
function someFunction() {
@@ -391,7 +389,6 @@ contract ShiftOperators {
391389
}
392390
}
393391
394-
395392
contract BitOperators {
396393
// ['&', '|', '^']
397394
function someFunction() {
@@ -427,7 +424,6 @@ contract BitOperators {
427424
}
428425
}
429426
430-
431427
contract ComparisonOperators {
432428
// ['<', '>', '<=', '>=', '==', '!=']
433429
function someFunction() {
@@ -517,7 +513,6 @@ contract ComparisonOperators {
517513
}
518514
}
519515
520-
521516
contract AssignmentOperators {
522517
// ['=', '|=', '^=', '&=', '<<=', '>>=', '+=', '-=', '*=', '/=', '%=']
523518
function someFunction() {
@@ -568,7 +563,6 @@ contract AssignmentOperators {
568563
}
569564
}
570565
571-
572566
contract LogicalOperators {
573567
// ['&&', '||']
574568
function someFunction() {
@@ -811,7 +805,6 @@ contract Parentheses {
811805
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
812806
pragma solidity 0.5.8;
813807
814-
815808
contract Parentheses {
816809
function() {
817810
a + b + c;

0 commit comments

Comments
 (0)