Skip to content

Add elm-review rule NoConfusingPrefixOperator

Overview

Add elm-review rule NoConfusingPrefixOperator

This forbids the use of operators as functions, e.g. Maybe.map ((>=) b) maybeA instead recommending Maybe.map (\a -> a >= b) maybeA

-- ELM-REVIEW ERROR --------------- src/DesignSystem/Stories/DataList.elm:242:24

NoConfusingPrefixOperator: Found a confusing usage of prefix operator

241|             in
242|             Maybe.map ((>=) createdAt) startAt
                            ^^^^
243|                 |> Maybe.withDefault True

Prefix operators for operators like this one are very error-prone. While `a >=
b` is easy to understand, it is not as obvious to a reader that `(>=) b` is the
same as `\a -> b >= a`.

Prefer using the form `\b -> a >= b` which will be a lot easier to understand
and to get right.

Discussion

Personally, I find the use of operator prefixes easy to read, but they may be found confusing by newer elm users?

Merge request reports