Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>Terraform LinterNew to Visual Studio Code? Get it now.
Terraform Linter

Terraform Linter

assad layne

|
5 installs
| (0) | Free
Highlights empty line issues, unused locals, and naming conventions in Terraform files
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Terraform Linter — VS Code Extension

Keeps your .tf files clean with three automatic checks.

What it checks

1. Empty lines at the start of a file

If your .tf file begins with one or more blank lines before any content, those lines are flagged. Terraform files should start immediately with content.

2. Empty lines at the end of a file

More than one trailing blank line at the end of a .tf file is flagged. One trailing newline is fine (it's standard), anything beyond that gets a warning.

3. Consecutive empty lines

Two or more blank lines in a row anywhere in a .tf file are flagged. One blank line for spacing is fine — you never need two.

4. Unused locals

Any local defined in locals.tf that is never referenced as local.<name> in any other .tf file in your workspace gets flagged directly on the definition line.


Installation

Option A — Install the .vsix directly

  1. Download tf-linter-1.0.0.vsix
  2. Open VS Code
  3. Ctrl+Shift+P → Extensions: Install from VSIX...
  4. Select the file

Option B — Run from source

  1. Clone / copy the tf-linter folder
  2. Open it in VS Code
  3. Press F5 — this opens an Extension Development Host with the extension active

Usage

The extension runs automatically whenever you open or edit a .tf file. All issues appear in:

  • The Problems panel (Ctrl+Shift+M)
  • As yellow squiggly underlines in the editor

You can also manually trigger the unused locals check from the Command Palette: Ctrl+Shift+P → TF Linter: Check Unused Locals in Workspace


Settings

Setting Default Description
tfLinter.enableEmptyLineChecks true Toggle empty line warnings
tfLinter.enableUnusedLocalsCheck true Toggle unused locals warnings

Notes

  • The unused locals check compares locals.tf against all other .tf files in the workspace. It uses the pattern local.<name> so it won't false-positive on variable names that happen to match.
  • The check respects currently open (unsaved) files — it reads from VS Code's in-memory buffer, not just disk.
  • The extension activates on any workspace containing .tf files, so you don't need to open a .tf file first.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft