gnolang / tlin

Advanced Linter for Gno
MIT License
13 stars 1 forks source link

feat: Emit function formatter #39

Closed notJoon closed 2 months ago

notJoon commented 2 months ago

Description

Implemented the formatter for the std.Emit funcrtion.

Ensure that key-value pairs are only on the one line at a time when there are more than 3 parameters.

Example

Problematic code:

package main

import "std"

func main() {
    std.Emit(
        "OwnershipChange",
        "newOwner", newOwner.String(),
        "oldOwner", 
        oldOwner.String(),
        "anotherOwner", anotherOwner.String(),
    )
}

linting result:

error: emit-format
 --> testdata/emit0.gno
 6 |     std.Emit(
 7 |                "OwnershipChange",
 8 |                "newOwner", newOwner.String(),
 9 |                "oldOwner", 
10 |                oldOwner.String(),
11 |                "anotherOwner", anotherOwner.String(),
12 |         )
   | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   | Consider formatting std.Emit call for better readability

Suggestion:
 6 | std.Emit(
 7 |     "OwnershipChange",
 8 |     "newOwner", newOwner.String(),
 9 |     "oldOwner", oldOwner.String(),
10 |     "anotherOwner", anotherOwner.String(),
11 | )