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 UserProfileThen 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.
Forbids the use of
Debug.todoand uses type information at the top-level to fix.🔧 Running with
--fixwill automatically generate code to replace someDebug.todouses.In particular it will generate code when
Debug.todois used in a top-level definition with an explicit type annotation, like so:There is an ever-expanding list of type signatures that this rule supports, however, it is relatively straightforward to add your own. See
CodeGeneratorfor details.Try it out
You can try this rule out by running the following command: