DEV Community

poolion
poolion

Posted on

Config Linter: Validate JSON/YAML Config Files for Trailing Commas and Undefined Variables

Config Linter: Validate Configuration Files in Pure Python

Configuration files can be tricky—trailing commas that break YAML parsers, undefined variables that cause deployment failures, or empty sections that go unnoticed until runtime. The Config Linter is a lightweight CLI tool written in pure Python that checks for these common issues without requiring any external dependencies.

What Problem Does It Solve?

When working with configuration files (application configs, CI/CD parameters, database connection strings, etc.), developers often encounter:

  • Trailing commas that break YAML parsers but pass some JSON checkers
  • Undefined variables like ${DATABASE_HOST} or %DB_PATH% referenced but not defined anywhere
  • Empty sections in nested config structures
  • Syntax issues that require manual inspection of large files

Config Linter provides automated checks for these problems.

Installation

# Clone and use directly
git clone https://github.com/Poolion/config-linter.git
cd config-linter
python config-lint.py your-config.yaml
Enter fullscreen mode Exit fullscreen mode

Add to PATH (optional):

cp config-lint.py /usr/local/bin/
Enter fullscreen mode Exit fullscreen mode

Usage Examples

Basic Validation

python config-lint.py app.yaml
# Scans for trailing commas, undefined variables, and empty sections
Enter fullscreen mode Exit fullscreen mode

With Key Listing

python config-lint.py database.json --list-keys
# Shows all configuration keys found in the file
Enter fullscreen mode Exit fullscreen mode

Reading from Stdin

echo "database:" | python config-lint.py - 
# Pipe content directly, no filename needed
Enter fullscreen mode Exit fullscreen mode

Top comments (0)