Skip to content

truqu/elm-review-noredundantconcat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-review-noredundantconcat

Helps with preventing redundant usage of concatenation. Expressions like [ a ] ++ b can be rewritten as a :: b, and expressions like [ a ] ++ [ b ] could be simply [ a, b ].

Configuration

module ReviewConfig exposing (config)

import NoRedundantConcat
import Review.Rule exposing (Rule)

config : List Rule
config =
    [ NoRedundantConcat.rule
    ]

Currently covered

  • Concatenating list literals with ++ ([ foo ] ++ [ bar ] -> [ foo, bar ])
  • Concatenating a list literal with some other value ([ foo ] ++ bar -> foo :: bar)
  • Using List.concat with list literals (List.concat [ [ foo ], [ bar ] ] -> [ foo, bar ])
  • Using ++ with String literals ("foo" ++ "bar" -> "foobar")

Future work

  • Using List.append with list literals
  • Using String.append with string literals
  • Using String.concat with string literals
  • Using String.join "" over String.concat

These all follow a common pattern of making the concatenation of literals more complex than it has to be.

About

Provides an elm-review rule to prohibit redundant usage of `++`

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages