lue-bird / elm-review-missing-record-field-lens

elm-review: helper generation
https://package.elm-lang.org/packages/lue-bird/elm-review-missing-record-field-lens/latest/
MIT License
2 stars 1 forks source link

Simple self-contained correct example missing #10

Open myrho opened 11 months ago

myrho commented 11 months ago

Unfortunately I cannot get this review rule working. It always results in "I found no errors!". Here's my example code:

Main.elm

module Main exposing (Model, main)

import Browser
import Html exposing (Html, div, text)

type alias Model =
    { x : Int
    }

main : Program () Model Msg
main =
    Browser.sandbox { init = { x = 0 }, update = update, view = view }

type Msg
    = Increment
    | Decrement

update : Msg -> Model -> Model
update msg model =
    case msg of
        Increment ->
            { model | x = model.x + 1 }

        Decrement ->
            { model | x = model.x - 1 }

view : Model -> Html Msg
view model =
    div []
        [ text <| String.fromInt model.x
        ]

review/src/ReviewConfig.elm

module ReviewConfig exposing (config)

import RecordFieldHelper.GenerateUsed
import Review.Rule as Rule exposing (Rule)

config : List Rule
config =
    [ RecordFieldHelper.GenerateUsed.rule
        { generator = RecordFieldHelper.GenerateUsed.accessors
        , generateIn = ( "Lense", [] )
        }
    ]

Then I run npx elm-review --debug:

I found no errors!

I had expected that something gets generated in Lense.elm.

I also tried to create Lense.elm as an empty module beforehand, but didn't work either.

Could someone provide a simple self-contained correct example?

lue-bird commented 11 months ago

Whenever you add Lense.yourField somewhere in your code, that lens should automatically be generated.

myrho commented 11 months ago

Ah, alright! Got it. Thanks for the quick response! However, a SSCCE would be a helpful addition to the package's docs.