gampleman/elm-review-derive/1.0.0

Derive

rule : Bool -> List CodeGenerator -> Rule

Forbids the use of Debug.todo and uses type information at the top-level to fix.

config =
    [ NoDebug.TodoItForMe.rule []
    ]

🔧 Running with --fix will automatically generate code to replace some Debug.todo uses.

In particular it will generate code when Debug.todo is used in a top-level definition with an explicit type annotation, like so:

 someFunction : Decoder SomeType
 someFunction =
        Debug.todo ""

There is an ever-expanding list of type signatures that this rule supports, however, it is relatively straightforward to add your own. See CodeGenerator for details.

Try it out

You can try this rule out by running the following command:

elm-review --template gampleman/elm-review-derive/preview --fix

Pro-tip for VSCode users

Open your command palette and select Preferences: Open Keyboard Shortcuts (JSON) and add the following object to the array:

 {
    "key": "ctrl+alt+d",
    "command": "runCommands",
    "when": "editorTextFocus",
    "args": {
      "commands": [
        {
          "command": "editor.action.insertSnippet",
          "args": {
            "snippet": "${TM_CURRENT_LINE/(.*):.+/\n$1 =\n    Debug.todo \"\"/}",
            "langId": "elm"
          }
        },
        { "command": "workbench.action.files.save" },
        { "command": "workbench.action.terminal.focus" },
        {
          "command": "workbench.action.terminal.sendSequence",
          "args": {
            "text": "npx elm-review --fix --template gampleman/elm-review-derive/preview\n"
          }
        }
      ]
    }

Then whenever you type a type signature, you can hit ctrl+alt+d (you can customize the keybinding above).

For instance if you typed:

decodeUserProfile : Decoder UserProfile

Then running this will modify it to read:

decodeUserProfile : Decoder UserProfile
decodeUserProfile =
    Debug.todo ""

It will then save the file, open the integrated terminal and run npx elm-review --fix --template gampleman/elm-review-derive/preview in it.