Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dotenv-linter/dotenv-linter

⚡️Lightning-fast linter for .env files. Written in Rust 🦀
https://github.com/dotenv-linter/dotenv-linter

check compare contributor-friendly contributors-welcome dotenv dotenv-linter env fix hacktoberfest linter rust rust-lang

Last synced: about 2 months ago
JSON representation

⚡️Lightning-fast linter for .env files. Written in Rust 🦀

Awesome Lists containing this project

README

        



dotenv-linter


⚡️Lightning-fast linter for .env files. Written in Rust 🦀



GitHub Actions


Coverage Status


License


Releases

`dotenv-linter` can **[check](#-check)** / **[fix](#-fix)** / **[compare](#-compare)** `.env` files for problems that may cause the application to malfunction.

**Available checks**:


    ✅ Duplicated key

    ✅ Ending blank line

    ✅ Extra blank line

    ✅ Incorrect delimiter

    ✅ Key without value

    ✅ Leading character

    ✅ Lowercase key

    ✅ Quote character

    ✅ Space character

    ✅ Substitution key

    ✅ Trailing whitespace

    ✅ Unordered key

    ✅ Value without quotes

**What is a `.env` file?**


    💡 A .env file or dotenv file is a simple text file containing all the environment variables of a project.
    Storing configuration in the environment variables is one of the tenets of the Manifesto of Twelve-Factor App.

    The .env file has a simple key-value format, for example: FOO=BAR.

    More information you can find in articles in English and Russian.

**The key features**:


    ⚡️ Lightning-fast because it is written in Rust 🦀

    💣 Can be used on any project regardless of the programming language 💥

    🚀 Can be integrated with reviewdog and other CI services (including GitHub Actions and Super-Linter) 🔥

**Articles about dotenv-linter**:

- [EN] [Dotenv-linter: looking after the environment for you](https://evrone.com/dotenv-linter)
- [EN] [What's new in dotenv-linter v2.2.0?](https://evrone.com/dotenv-linter-v220)
- [EN] [What are the key changes in dotenv-linter v3.0.0 release?](https://evrone.com/dotenv-linter-v300)
- [RU] [Dotenv-linter: линтер .env файлов](https://www.mgrachev.com/2020/04/20/dotenv-linter)
- [RU] [Что нового в dotenv-linter v2.2.1?](https://evrone.ru/dotenv-linter-v220)
- [RU] [Что нового в dotenv-linter v3.0.0?](https://evrone.ru/dotenv-linter-v300)

## 👨‍💻 Installation

### Pre-compiled binary

```shell script
# Linux / macOS / Windows (MINGW and etc). Installs it into ./bin/ by default
$ curl -sSfL https://raw.githubusercontent.com/dotenv-linter/dotenv-linter/master/install.sh | sh -s

# Or a shorter way
$ curl -sSfL https://git.io/JLbXn | sh -s

# Specify installation directory and version
$ curl -sSfL https://git.io/JLbXn | sh -s -- -b usr/local/bin v2.0.0

# Alpine Linux (using wget)
$ wget -q -O - https://git.io/JLbXn | sh -s
```

You can find other installation methods here: https://dotenv-linter.github.io/#/installation

## 🚀 Usage

#### ✅ Check

By default, `dotenv-linter` checks all `.env` files in the current directory:

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

Checking .env.test
.env.test:1 LeadingCharacter: Invalid leading character detected

Found 3 problems
```

#### 🛠 Fix

It can also fix the found warnings with the `fix` command:

```shell
$ dotenv-linter fix
Fixing .env
Original file was backed up to: ".env_1601378896"

.env:2 DuplicatedKey: The BAR key is duplicated
.env:3 LowercaseKey: The foo key should be in uppercase

All warnings are fixed. Total: 2
```

#### 🤲 Compare

In addition, `dotenv-linter` can compare `.env` files with each other and output the difference between them:

```shell
$ dotenv-linter compare .env .env.example
Comparing .env
Comparing .env.example
.env is missing keys: BAR
.env.example is missing keys: FOO
```

Other use cases you can find on the documentation site (https://dotenv-linter.github.io):

- [Check](https://dotenv-linter.github.io/#/usage/check)
- [Fix](https://dotenv-linter.github.io/#/usage/fix)
- [Compare](https://dotenv-linter.github.io/#/usage/compare)

## 🚦 Continuous Integration

`dotenv-linter` can also be used with CI services such as: [GitHub Actions](https://dotenv-linter.github.io/#/integrations/github_actions) and [Circle CI](https://dotenv-linter.github.io/#/integrations/circleci).

## 🚧 Benchmark

Benchmarking [dotenv-linter/dotenv-linter](https://github.com/dotenv-linter/dotenv-linter) and [wemake-services/dotenv-linter](https://github.com/wemake-services/dotenv-linter) has done using the [hyperfine](https://github.com/sharkdp/hyperfine) utility:

| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :----------------------------------- | -----------: | -------: | -------: | ------------: |
| `dotenv-linter/dotenv-linter .env` | 2.7 ± 0.4 | 2.0 | 4.3 | 1.00 |
| `wemake-services/dotenv-linter .env` | 162.6 ± 12.1 | 153.0 | 201.3 | 60.83 ± 10.20 |

Content of .env file used for benchmarking

```dotenv
SPACED=

KEY = VALUE

SECRET="my value"

SECRET=Already defined

kebab-case-name=1
snake_case_name=2
```

## ✌️ Mentorship

`dotenv-linter` is not just a linter for `.env` files — it is also a **contributor-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 in Rust. ❤️

We act [as a mentor](https://rustbeginners.github.io/awesome-rust-mentors) within this project and **help developers** follow the path of a novice contributor from start to the top. 🤗

## 🤝 Contributing

If you've ever wanted to contribute to open source, now you have a great opportunity:

- [How to set up the project](/CONTRIBUTING.md#how-to-set-up-the-project)
- [How to add a new check](/CONTRIBUTING.md#how-to-add-a-new-check)

## 👍 Similar projects

- [wemake-services/dotenv-linter](https://github.com/wemake-services/dotenv-linter) (Python)

## ✨ Contributors

This project exists thanks to all the people who contribute. [[Contribute](/CONTRIBUTING.md)].



## ♥️ Sponsors

[dotenv-linter](https://evrone.com/dotenv-linter?utm_source=github&utm_campaign=dotenv-linter) is created & supported by [Evrone](https://evrone.com/?utm_source=github&utm_campaign=dotenv-linter). What else we develop with [Rust](https://evrone.com/rust?utm_source=github&utm_campaign=dotenv-linter).



Sponsored by Evrone

Become a financial contributor and help us sustain our community.

## 📃 License

[MIT](https://choosealicense.com/licenses/mit)