lue-bird / elm-review-upgrade

tell me how to get rid of outdated stuff
https://dark.elm.dmy.fr/packages/lue-bird/elm-review-upgrade/latest/
MIT License
0 stars 1 forks source link
elm elm-review migration upgrade version-upgrade

elm-review-upgrade

🔧 Upgrade reports functions and types that can be upgraded to give users an easy time migrating to a new version of a package or an internal elm API.

What this rule is not for: simplifying your code to use new functions and types, like replacing YourString.join "" by your new YourString.concat.

import Review.Rule
import Upgrade
import Elm.CodeGen -- the-sett/elm-syntax-dsl

config : List Review.Rule.Rule
config =
    [ Upgrade.rule
        [ Upgrade.reference { old = ( "Fuzz", "tuple" ), new = ( "Fuzz", "pair" ) }
        , Upgrade.application
            { oldName = ( "Expect", "true" )
            , oldArgumentNames = [ "onFalseDescription", "actualBool" ]
            , oldArgumentsToNew =
                \oldArguments ->
                    case oldArguments of
                        [ onFalse, actual ] ->
                            Upgrade.call ( "Expect", "equal" )
                                [ Elm.CodeGen.fqVal [ "Basics" ] "True", actual ]
                                |> Upgrade.pipeInto ( "Expect", "onFail" ) [ onFalse ]
                                |> Just

                        _ ->
                            Nothing
            }
        ]
    ]

(full examples of test 1→2 and elmcraft/core-extra 1→2)

Writing custom elm-review rules for every version upgrade yourself will get tricky. A few examples:

This rule has your back in cases like these :)

not currently supported