Severity: Warning | Category: Linting

Description

Detects lines that end with whitespace characters (spaces or tabs).

Why It Matters

  • Git diffs become noisy
  • Can cause issues in some parsers
  • Generally considered poor style

Examples

⚠️ Warning

DATABASE_URL=postgres://localhost␣
API_KEY=secret␣␣␣

✅ Fixed

DATABASE_URL=postgres://localhost
API_KEY=secret

Detection

$ envcheck lint .env

.env:5: W002: Trailing whitespace on line 5

Auto-Fix

The fix command automatically removes trailing whitespace:

$ envcheck fix .env

Fixed .env:
  - Trimmed trailing whitespace from 3 lines

Configuration

# .envcheckrc.yaml
rules:
  W002:
    severity: warning  # Can set to info
    auto_fix: true

Editor Configuration

Prevent trailing whitespace in your editor:

VSCode

{
  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true
}

Vim

set listchars+=trail:·
set list
autocmd BufWritePre * :%s/\s\+$//e

See Also