dfinity / prettier-plugin-motoko

A code formatter for the Motoko smart contract language.
Apache License 2.0
28 stars 1 forks source link

Object auto-formatted into one very long line #89

Open ByronBecker opened 1 year ago

ByronBecker commented 1 year ago

In my tests, I had an object formatted such that each property was on a new line and then the formatter did this to it 😅

M.equals(testableItemGetTransactionsResult({ results = [{ timestamp = timestamp_1; customerId = Principal.fromText("aaaaa-aa"); transaction = #topup({ icpCharged = { e8s = 1 }; cyclesToppedUpWith = 1_000_000_000_000; canisterId = Principal.fromText("aaaaa-aa") }); transactionId = "0" }, { timestamp = timestamp_1; customerId = Principal.fromText("aaaaa-aa"); transaction = #topup({ icpCharged = { e8s = 2 }; cyclesToppedUpWith = 2_000_000_000_000; canisterId = Principal.fromText("aaaaa-aa") }); transactionId = "1" }, { timestamp = timestamp_2; customerId = Principal.fromText("aaaaa-aa"); transaction = #topup({ icpCharged = { e8s = 3 }; cyclesToppedUpWith = 3_000_000_000_000; canisterId = Principal.fromText("aaaaa-aa") }); transactionId = "2" }, { timestamp = timestamp_2; customerId = Principal.fromText("renrk-eyaaa-aaaaa-aaada-cai"); transaction = #topup({ icpCharged = { e8s = 4 }; cyclesToppedUpWith = 3_000_000_000_000; canisterId = Principal.fromText("aaaaa-aa") }); transactionId = "3" }]; nextKey = null })),

Here's some more context

// within a matchers suite
    test(
      "gets all transactions in the transaction history if the timestamp bounds and limit are sufficient",
      TransactionHistory.getTransactions(
        preseededTransactionHistory,
        timestamp_1 / 1_000_000,
        timestamp_2 / 1_000_000,
        10,
      ),
      M.equals(testableItemGetTransactionsResult({ results = [{ timestamp = timestamp_1; customerId = Principal.fromText("aaaaa-aa"); transaction = #topup({ icpCharged = { e8s = 1 }; cyclesToppedUpWith = 1_000_000_000_000; canisterId = Principal.fromText("aaaaa-aa") }); transactionId = "0" }, { timestamp = timestamp_1; customerId = Principal.fromText("aaaaa-aa"); transaction = #topup({ icpCharged = { e8s = 2 }; cyclesToppedUpWith = 2_000_000_000_000; canisterId = Principal.fromText("aaaaa-aa") }); transactionId = "1" }, { timestamp = timestamp_2; customerId = Principal.fromText("aaaaa-aa"); transaction = #topup({ icpCharged = { e8s = 3 }; cyclesToppedUpWith = 3_000_000_000_000; canisterId = Principal.fromText("aaaaa-aa") }); transactionId = "2" }, { timestamp = timestamp_2; customerId = Principal.fromText("renrk-eyaaa-aaaaa-aaada-cai"); transaction = #topup({ icpCharged = { e8s = 4 }; cyclesToppedUpWith = 3_000_000_000_000; canisterId = Principal.fromText("aaaaa-aa") }); transactionId = "3" }]; nextKey = null })),
    ),
rvanasa commented 1 year ago

Yeah, that doesn't look right, haha. I'll take a look at this when I get a chance after ETHDenver.