Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple self-contained correct example missing #10

Open
myrho opened this issue Oct 3, 2023 · 2 comments
Open

Simple self-contained correct example missing #10

myrho opened this issue Oct 3, 2023 · 2 comments

Comments

@myrho
Copy link

myrho commented Oct 3, 2023

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
Copy link
Owner

lue-bird commented Oct 3, 2023

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

@myrho
Copy link
Author

myrho commented Oct 3, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants