Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/truqu/elm-review-noleftpizza
Provides an elm-review rule to prevent the use of the left pizza operator
https://github.com/truqu/elm-review-noleftpizza
elm elm-review lint
Last synced: 17 days ago
JSON representation
Provides an elm-review rule to prevent the use of the left pizza operator
- Host: GitHub
- URL: https://github.com/truqu/elm-review-noleftpizza
- Owner: truqu
- License: bsd-3-clause
- Created: 2020-05-15T14:59:11.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-12T10:23:48.000Z (about 2 years ago)
- Last Synced: 2024-05-08T23:40:44.059Z (8 months ago)
- Topics: elm, elm-review, lint
- Language: Elm
- Size: 48.8 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-review-noleftpizza
Prohibits (redundant/all) use of the left pizza (`<|`) operator and helps
rewriting expressions that use them.Redundant application of `<|` adds visual noise and may make things harder to
read. For some people, it might act as a visual separator, which is completely
fine!## Configuration
To allow `<|` only when extra parentheses would need to be added in order to
remove `<|` - in other words, to only flag redundant left pizzas, pass the
`NoLeftPizza.Redundant` flag to the rule:```elm
import NoLeftPizza
import Review.Rule exposing (Rule)config : List Rule
config =
[ NoLeftPizza.rule NoLeftPizza.Redundant
]
```If you wish to go all in and remove any and all left pizza's, you can pass
`NoLeftPizza.Any` instead:```elm
import NoLeftPizza
import Review.Rule exposing (Rule)config : List Rule
config =
[ NoLeftPizza.rule NoLeftPizza.Any
]
```## Rationale for `NoLeftPizza.Any`
Our team writes vastly more application code than we write test code. Within our
application code, we have - for quite a long time - enforced the rule that `<|`
left pizza is a sad pizza. The one and only exception is in test code, where we
prefer to stick to the generally accepted style (`test "description" <| \_ ->
...`).So, this is an interesting case. The docs call out this specific example as the
type of rule that would need very careful consideration before inclusion. And
considered, we have. Carefully, too!For our specific codebase, we choose to remove noise from our code reviews and
automate that part of the process by enforcing a `NoLeftPizza` rule, for
everything other than tests.You should likely very carefully consider and evaluate the pros and cons before
enabling this rule on your codebase.Like any stylistic choice, it is not for everyone.