7

Announcing dotenv-linter

 3 years ago
source link: https://sobolevn.me/2019/01/announcing-dotenv-linter
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

I happy to announce a simple yet very useful tool to lint your .env files.

dotenv-linter logo

Background

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 .env files:

  • Some developers used CONSTANT_CASE for variable names and some developers used snake_case for 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=VALUE and 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 KEY=VALUE notation
  • 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!

Installation

You can install it via pip (or any other similar tool):

$ pip install dotenv-linter

Why pip? Because python is present almost on all Linux setups. And we try to make this tool as portable as possible.

Usage

Usage is really simple:

$ dotenv-linter path/to/your/.env even/multiple/files/are/fine/.env

Real-life examples

If you are interested in how we use it real life applications you can have a look at (and even try!) our django template. Here’s the line that invokes it.

We also have a full list of linting rules in our docs, check it out.

Conclusion

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!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK