VSCode + Puppet-lint

Mike R
2 min readJun 8, 2018

--

Quick guide on how to puppet-lint your puppet code in VSCode IDE

Why

When Im working on my puppet code using Microsofts excellent VSCode editor, I’m also using the Puppet extension (can get it in the Marketplace), which does auto-linting, meaning that if you have some issues with your syntax, it alerts you

puppet-lint warnings below

The problem is that it doesn’t run a basic fix routine, puppet-lint --fix

To do this, heres a quick way to configure this inside VSCode,

How

  1. make sure you have puppet-lint gem installed
  2. in VSCode open up tasks.json (or hit F1 and type configure task)

3. create a new task “Puppetlint”

4. a Task is basically a JSON file defining an action, add this


{
“version”: “2.0.0”,
“tasks”: [
{
“label”: “puppetlint”,
“type”: “shell”,
“command”: “puppet-lint”,
“args”: [“-f”, “${file}”]
}
]
}

5. this tells VSCode to run a shell command “puppet-lint -f (the file you’re currently working on)”

6. Now add a keybinding to run this action, hit F1 and type in “key”, select “Preferences: Open Keyboard Shortcuts File”

7. This will open upkeybindings.json

[
{
"key":"Alt+L", "command":"workbench.action.tasks.runTask",
"args": "puppetlint"
}
]

Save the file. Go back to your puppet code, hit Alt+”l” (letter L), puppet-lint will now auto-fix your file.

--

--

No responses yet