GithubHelp home page GithubHelp logo

sonro / dotenv-linter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dotenv-linter/dotenv-linter

0.0 0.0 0.0 223 KB

Linter for dotenv files (.env) ✌️

Home Page: https://www.mgrachev.com/projects

License: MIT License

Rust 99.69% Dockerfile 0.31%

dotenv-linter's Introduction

✌️dotenv-linter

Linter for .env files. Written in Rust 🦀

👨‍💻 Installation

Binary

# Linux
$ curl https://github.com/mgrachev/dotenv-linter/releases/download/v1.0.0/dotenv-linter-v1.0.0-linux-x86_64.tar.gz -sSfL | tar -xzf - 

# Alpine Linux
$ wget https://github.com/mgrachev/dotenv-linter/releases/download/v1.0.0/dotenv-linter-v1.0.0-alpine-x86_64.tar.gz -O - -q | tar -xzf -

# macOS
$ curl https://github.com/mgrachev/dotenv-linter/releases/download/v1.0.0/dotenv-linter-v1.0.0-darwin-x86_64.tar.gz -sSfL | tar -xzf -

GitHub Action

Use mgrachev/action-dotenv-linter to run dotenv-linter:

# .github/workflows/dotenv_linter.yml
name: reviewdog
on: [pull_request]
jobs:
  dotenv-linter:
    name: runner / dotenv-linter
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v1
      - name: dotenv-linter
        uses: mgrachev/action-dotenv-linter@v1
        with:
          github_token: ${{ secrets.github_token }}

Docker

$ docker run --rm -v `pwd`:/app -w /app mgrachev/dotenv-linter

🚀 Usage

By default, dotenv-linter checks all files with the .env prefix. For example: .env, .env.test, .env.qa:

$ dotenv-linter
.env:1 Leading space detected
.env:2 The FOO-BAR key has incorrect delimiter
.env:3 The FOo_BAR key should be in uppercase
.env:4 The line has spaces around equal sign
.env.test:5 The foo_bar key should be in uppercase
.env.test:6 The FOO key should be with a value or have an equal sign

If you want to include a file with a specific name to check, you can use the argument --include FILE_NAME or its short version -i FILE_NAME:

$ dotenv-linter -i test.env --include .my-env-file
.env:1 Leading space detected
test.env:2 The FOO-BAR key has incorrect delimiter
.my-env-file:3 The line has spaces around equal sign

If you want to exclude a file with a specific name from check, you can use the argument --exclude FILE_NAME or its short version -e FILE_NAME:

$ dotenv-linter -e .env --exclude .env.test

If you want to specify the directory where to run dotenv-linter, you can use the argument --path DIRECTORY_PATH or its short version -p DIRECTORY_PATH:

$ dotenv-linter -p /directory/where/to/run

✅ Checks

Duplicated Keys

Detects if a key is not unique:

❌Wrong
FOO=BAR
FOO=BAR

✅Correct
FOO=BAR
BAR=FOO

Incorrect delimiter

Detects if a key does not use an underscore to separate words:

❌Wrong
FOO-BAR=FOOBAR

✅Correct
FOO_BAR=FOOBAR

Keys without values

Detects if a line has a key without a value:

❌Wrong
FOO

✅Correct
FOO=

✅Correct
FOO=BAR

Leading space

Detects if a line starts with a space or a tab character:

❌Wrong
 FOO=BAR

✅Correct
FOO=BAR

Lowercase key

Detects if a key has lowercase characters:

❌Wrong
FOo_BAR=FOOBAR

❌Wrong
foo_bar=FOOBAR

✅Correct
FOO_BAR=FOOBAR

Spaces around equal sign

Detects lines with a whitespace around equal sign character =:

❌Wrong
FOO =BAR

❌Wrong
FOO= BAR

❌Wrong
FOO = BAR

✅Correct
FOO=BAR

📋 Roadmap

  • Add more checks:
    • Duplicated keys;
    • Incorrect delimiter;
    • Keys without values;
    • Leading Space;
    • Lowercase keys;
    • Spaces around equal sign;
    • Unordered keys;
    • Other checks.
  • Support reviewdog;
  • Create a GitHub Action for easily using dotenv-linter.

🤝 Contributing

👍 Similar projects

♥️ Sponsor

Sponsored by Evrone

📃 License

MIT

dotenv-linter's People

Contributors

artem-russkikh avatar louis-lesage avatar mgrachev avatar mstruebing avatar qelphybox avatar sonro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.