I happy to announce a simple yet very useful tool to lint your
Simple linter for
.env files are very simple it is required to keep them consistent.
This tool offers a wide range of consistency rules and best practices.
And it integrates perfectly to any existing workflow.
pip install dotenv-linter
See Usage section to get started.
There are many things that can go wrong in your
# Next line has leading space which will be removed: SPACED= # Equal signs should not be spaced: KEY = VALUE # Quotes won't be preserved after parsing, do not use them: SECRET="my value" # Beware of duplicates! SECRET=Already defined ;( # Respect the convention, use `UPPER_CASE`: kebab-case-name=1 snake_case_name=2
And much more! You can find the full list of violations in our docs.
Special thanks goes to Ignacio Toledo for creating an awesome logo for the project.
As a part of our "not blaming but fixing" corporate culture we build a lot of tools that prevent us from making the same mistakes over and over again.
dotenv-linter is one of these tools.
Some time ago we had several problems with
- Some developers used
CONSTANT_CASEfor variable names and some developers used
snake_casefor that. While this is not a technical issue, but it is not very practical to mix these two cases and then think: what case I have used for this particular variable? Consistency is important!
- We also had a problem with quotes and extra spaces. Some developers used
KEY=VALUEand some used
KEY = "VALUE"while in fact, these two examples will resolve in exactly the same thing - we prefer to have one-- and preferably only one --obvious way to do it. So, we now stick to
- We also once had a duplicate key that ruined my day. I have spent several hours debugging my app because of this simple issue. That was a turning point for me and I have decided: let's automate it!
You can install it via
pip (or any other similar tool):
$ pip install dotenv-linter
python is present almost on all Linux setups. And we try to make this tool as portable as possible.
Usage is really simple:
$ dotenv-linter path/to/your/.env even/multiple/files/are/fine/.env
We also have a full list of linting rules in our docs, check it out.
I hope this simple tool will save you some time, make your project more consistent, and your life slightly better. Add me on github to stay informed about the tools I am building!