@asdsadw12312dwd2112xz/dotenv-lint-cli
v1.0.0
Published
Lint and validate .env files
Maintainers
Readme
dotenv-lint-cli
Lint and validate .env files. Catches common issues like duplicate keys, empty values, missing quotes, invalid key names, and inconsistent quoting. Compares .env against .env.example to find missing or extra keys.
Install
npm install -g dotenv-lint-cliOr use directly with npx:
npx dotenv-lint-cliUsage
dotenv-lint # lint .env in current directory
dotenv-lint --file .env.production # lint a specific file
dotenv-lint --example .env.sample # compare against a custom example file
dotenv-lint --fix # auto-fix fixable issues
dotenv-lint --json # output results as JSON
dotenv-lint --strict # treat warnings as errors (exit 1)Options
| Flag | Default | Description |
|------|---------|-------------|
| -f, --file <path> | .env | Path to the .env file to lint |
| -e, --example <path> | .env.example | Path to the example file for comparison |
| --fix | — | Auto-fix fixable issues (missing quotes, inconsistent quoting) |
| --json | — | Output results as JSON |
| --strict | — | Treat warnings as errors |
Rules
| Rule | Severity | Fixable | Description |
|------|----------|---------|-------------|
| invalid-line | error | no | Line is not a valid key=value assignment or comment |
| invalid-key | error | no | Key name contains invalid characters |
| duplicate-key | error | no | Same key defined more than once |
| missing-key | error | no | Key exists in .env.example but not in .env |
| empty-value | warning | no | Key has an empty value |
| missing-quotes | warning | yes | Value contains spaces but is not quoted |
| extra-key | warning | no | Key exists in .env but not in .env.example |
| inconsistent-quotes | info | yes | File mixes single and double quotes |
JSON Output
{
"file": ".env",
"issueCount": 2,
"errors": 1,
"warnings": 1,
"infos": 0,
"issues": [
{
"line": 3,
"severity": "error",
"rule": "duplicate-key",
"message": "Duplicate key \"API_KEY\" (first defined on line 1)",
"key": "API_KEY"
}
]
}License
MIT
