Skip to content

ravsii/sorted

Repository files navigation

Sorted Build Test

sorted is a linter and formatter used to maintain consistent sorting across various structures.

At the moment it only supports alphabetic sorting in const, var and struct blocks, but we're aiming to support any kind of sortable or order-related structures like generics, func in/out arguments and more.

So what's working?

It can be generalized into 2 main categories for now, that are

  • Blocks

    const ( // or var
      B = iota // B, A are not sorted alphabetically
      A
    )
  • Multiple sections treated as such

    const ( // or var
      B = iota // B, A are not sorted alphabetically
      A
    
      C // ok
      D
    
      Z // Z, Y are not sorted alphabetically
      Y
      X
    )
  • Multiple inline identifiers

    const c, b, a = 0, 0, 0 // single line idents are not sorted alphabetically

These checks are working for const, var, struct blocks.

TODO

  • const, var
    • Blocks
      • Alphabetical sorting
      • Auto Fix
    • Inline
      • Alphabetical sorting
      • Auto Fix
  • struct
    • Alphabetical sorting
    • Auto Fix
  • //sorted:ignore comment

TODO later

in order of most importance

  • golangci-lint integration
  • switch only for basic type values (string, int, ...)
  • imports (pretty much what gci does with some more)
  • func
    • Alphabetical sorting
    • Public/Private sorting
    • New* func order
  • Generics

About

Go linter that makes your code alphabetically sorted

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published