Severity: Error | Category: Linting

Description

Detects lines that don't follow the KEY=VALUE format expected in .env files.

Valid Syntax

FormatExampleValid
Simple assignmentKEY=value
With spaces in valueKEY=value with spaces
Quoted valueKEY="quoted value"
Empty valueKEY=⚠️ (W001)
Comment# This is a comment
Empty line(blank)

Examples

❌ Problematic

# Missing equals sign
DATABASE_URL postgres://localhost

# Invalid characters in key
123INVALID=value
MY-KEY=value  # hyphens not recommended

# Invalid escape sequence
KEY=value\nmore

✅ Fixed

DATABASE_URL=postgres://localhost

INVALID_123=value
MY_KEY=value  # Use underscores

KEY="value\nmore"  # Quote for escapes

Key Naming Rules

Valid keys:

  • Start with letter (A-Z, a-z) or underscore
  • Followed by letters, numbers, or underscores
  • Convention: SCREAMING_SNAKE_CASE

Detection

$ envcheck lint .env

.env:8: E002: Invalid syntax: 'DATABASE_URL postgres://localhost'

Configuration

# .envcheckrc.yaml
rules:
  E002:
    severity: error
    allow_hyphens: false  # Set true to allow MY-KEY

See Also