Index / Blog / What's new in dotenv-linter v2.2.0?

Dotenv-linter v2.2.0: find and fix problems in .env files

October 2020 3 mins

We have developed dotenv-linter — a useful tool for checking .env files. It helps to find problems in .env files that you might miss at first, but which later may result in incorrect work of applications. We have made the tool universal, it can be connected to any project regardless of the programming language.

We've just released a new version of dotenv-linter — v2.2.0, and here is an overview of the key changes included in this release!

Fixing warnings ?

Previously, dotenv-linter could only find problems in .env files:

$ dotenv-linter
.env:2 DuplicatedKey: The FOO key is duplicated
.env:3 UnorderedKey: The BAR key should go before the FOO key

Now, it can fix them right away with the new --fix/-f argument:

$ dotenv-linter --fix
Original file was backed up to: ".env_1601378896"

.env:2 DuplicatedKey: The FOO key is duplicated
.env:3 UnorderedKey: The BAR key should go before the FOO key

All warnings are fixed. Total: 2

Making a backup ?

Fixing problems in .env files is cool, but dotenv-linter creates a backup for each of the files, just in case. You can enable this feature, or disable it using the --no-backup argument — it's up to you:

$ dotenv-linter --fix --no-backup

.env:2 DuplicatedKey: The FOO key is duplicated
.env:3 UnorderedKey: The BAR key should go before the FOO key

All warnings are fixed. Total: 2

Support for control comments ?

Previously, checks could be disabled globally using the --skip/-s argument:

$ dotenv-linter --skip UnorderedKey EndingBlankLine
.env:2 DuplicatedKey: The FOO key is duplicated

Found 1 problem

Now, dotenv-linter supports control comments that allow you to turn off checks for both the entire file and a specific line:

# .env
# At the beginning - it disables checks for the whole file
# dotenv-linter:off DuplicatedKey, EndingBlankLine

# dotenv-linter:off UnorderedKey (You can disable a check for only some lines)
FOO=BAR
BAR=FOO
# dotenv-linter:on UnorderedKey (And enable it again)

Displaying the total number of problems ?

When checking several .env files, there was often not enough information provided about how many problems had been found in all files. We have added this information:

$ dotenv-linter
.env:2 DuplicatedKey: The FOO key is duplicated
.env:3 UnorderedKey: The BAR key should go before the FOO key
.env.test:1 LeadingCharacter: Invalid leading character detected

Found 3 problems

We have also added the new argument --quiet/-q to disable this:

$ dotenv-linter --quiet
.env:2 DuplicatedKey: The FOO key is duplicated
.env:3 UnorderedKey: The BAR key should go before the FOO key
.env.test:1 LeadingCharacter: Invalid leading character detected

Installing the latest version from the repository ?

The ability to install the latest version from the repository via Homebrew was added:

$ brew install --HEAD dotenv-linter/tap/dotenv-linter

These are all the key changes in the project that were included in the new v2.2.0 release. More information you can find in the changelog: v2.2.0.

 

This release wouldn't have been possible without the help of 19 talented developers! How can you support the project? It's very simple - just give us a star on GitHub.

Dotenv-linter is not just a linter for .env files — it is also a friendly open-source project with the purpose of helping others learn Rust using a simple, but useful tool. In addition to studying Rust, this project has another goal — to promote love for open-source, help you with the first steps in it and give an opportunity to contribute to the open-source project written on Rust. We act as a mentor within this project and help developers follow the path of a novice contributor from start to the top.

Client Review

In the process of working with .env files, some issues may appear that you may not notice at first sight or skip when checking the code, but which may cause the application to malfunction. Here is when dotenv-linter comes for help — it can be used on any of your projects regardless of the programming language!
Mikhail Grachev
Software engineer, Evrone.com
Let’s talk about you
Attach file
Files must be less than 8 MB.
Allowed file types: jpg jpeg png txt rtf pdf doc docx ppt pptx.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.