Code Monkey home page Code Monkey logo

dotenv-linter's Issues

LowercaseKey: Show check name in message

Right now the message looks like this:

.env:2 The FOo_BAR key should be in uppercase

Need to add the check name to the message:

.env:2 LowercaseKey: The FOo_BAR key should be in uppercase

Add check: Lowercase keys

Example:

# .env

# Wrong
rails_env=development

# Correct
RAILS_ENV=development

This check should display a message:

.env:1 The rails_env key should be in uppercase

Add ability to exclude files from check

What should be done:

  • Add the command line argument: -e FILE_NAME, --exclude FILE_NAME;
  • Support multiple use: -e FILE_1 -e FILE_2 -e FILE_3;
  • Add usage information to README.

Remove inline comments from lines

We should remove inline comments before running checks, because inline comments may affect checks behaviour.

Example:

FOO=BAR # some comment ===

Is need to ensure that commented lines with leading spaces will be skipped too:

 # FOO=BAR

Release first version

What should be done:

  • Create a GitHub Action to make a release;
  • Build binaries for Linux, macOS and Windows;
  • Publish release to GitHub;
  • Update README.md.

IncorrectDelimiter: Show check name in message

Right now the message looks like this:

.env:2 The FOO-BAR key has incorrect delimiter

Need to add the check name to the message:

.env:2 IncorrectDelimiter: The FOO-BAR key has incorrect delimiter

Add ability to include files to check

What should be done:

  • Add the command line argument: -i FILE_NAME, --include FILE_NAME;
  • Support multiple use: -i FILE_1 -i FILE_2 -i FILE_3;
  • Add usage information to README.

Add check: Unordered keys

Example:

# .env

# Wrong
RAILS_ENV=development
DATABASE_URL=postgres://postgres@db

# Correct
DATABASE_URL=postgres://postgres@db
RAILS_ENV=development

This check should display a message:

.env:2 The DATABASE_URL key should go before the RAILS_ENV key

Add check: Duplicated keys

Example:

# .env

# Wrong
RAILS_ENV=development
RAILS_ENV=test

# Correct
RAILS_ENV=development
RAILS_MAX_THREADS=5

This check should display a message:

.env:2 The RAILS_ENV key is duplicated

Add support for command line arguments

Add support for 2 command line arguments:

  • --help, -h;
  • --version, -v.

To implement that we should use clap, because in the future we will increase the number of supported arguments.

Fix a bug with duplicate paths

We can pass an argument to dotenv-linter to include some files to check:

$ dotenv-linter -i .my-env-file
.env:1 Leading space detected
.my-env-file:1 Leading space detected

If the file already exists in the paths, we will get a duplicate result:

$ dotenv-linter -i .env -i .env
.env:1 Leading space detected
.env:1 Leading space detected
.env:1 Leading space detected

Need to fix that and write tests for that case.

Link: https://github.com/mgrachev/dotenv-linter/blob/master/src/lib.rs#L101

Provide dotenv-linter in the Arch User Repository

The Arch User Repository is like a package repository for Arch linux maintained by it's users.
I would be happy to set it up there so that any arch user can simply install it with:

<your-aur-helper> -S dotenv-linter (-S is mostly the command to install a package, in case your aur helper does it differently you need to substitute this command.

If that would be desired I would be happy to go :)

Prepare a template for easy adding new checks

What should be done:

  • Implement a structure for new checks (File structure, Struct, Trait);
  • Add documentation "How to write new check";
  • Add documentation "How to test new check".

Add check: Keys without values

Example:

# .env

# Wrong
RAILS_ENV

# Correct
RAILS_ENV=

# Correct
RAILS_ENV=development

This check should display a message:

.env:1 The RAILS_ENV key should be with a value

Add check: Spaces around equal sign

Example:

# .env

# Wrong
RAILS_ENV = development

# Correct
RAILS_ENV=development

This check should display a message:

.env:1 The line has spaces around equal sign

Build Docker image

What should be done:

  • Build a Docker image;
  • Publish to Docker Hub;
  • Update README.

Replace field warning with template for all check structs

If we look at existing checks, we will see a little weird way of working with warnings:

pub(crate) struct KeyWithoutValueChecker {
    warning: Warning,
}

impl Default for KeyWithoutValueChecker {
    fn default() -> Self {
        Self {
            warning: Warning::new("The {} key should be with a value or have an equal sign"),
        }
    }
}

Some(Warning { message: self.warning.message.replace("{}", &line.raw_string) })
}

Therefore, I suggest replacing warning: Warning with template: String for all check structs:

pub(crate) struct KeyWithoutValueChecker {
    template: String,
}

impl Default for KeyWithoutValueChecker {
    fn default() -> Self {
        Self {
            template: String::from("The {} key should be with a value or have an equal sign"),
        }
    }
}

Some(Warning::new(self.template.replace("{}", &line.raw_string)))

Provide more short way to install dotenv-linter

Right now we can install dotenv-linter something like this:

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

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

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

I would like to have a script which provides more short way to install it. For example:

curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s

Or something like that.

SpaceCharacter: Show check name in message

Right now the message looks like this:

.env:2 The line has spaces around equal sign

Need to add the check name to the message:

.env:2 SpaceCharacter: The line has spaces around equal sign

Add check: Incorrect delimiter

Example:

# .env

# Wrong
RAILS-ENV=development

# Correct
RAILS_ENV=development

This check should display a message:

.env:1 The RAILS-ENV key has incorrect delimiter

KeyWithoutValue: Show check name in message

Right now the message looks like this:

.env:2 The FOO1 key should be with a value or have an equal sign

Need to add the check name to the message:

.env:2 KeyWithoutValue: The FOO1 key should be with a value or have an equal sign

Update README

What should be done:

  • Add build status badge;
  • Add license badge;
  • Add latest version badge;
  • Replace examples with FOO=VAR;
  • Add some emoji ✌️

DuplicatedKey: Show check name in message

Right now the message looks like this:

.env:2 The FOO key is duplicated

Need to add the check name to the message:

.env:2 DuplicatedKey: The FOO key is duplicated

Proposal: New API

Hi there!

I would like to suggest the new way of using dotenv-linter:

# Checks `*.env*` files in the current directory
$ dotenv-linter
$ dotenv-linter .

# Checks `*.env*` files in the `path`
$ dotenv-linter path

# Checks `*.env*` files in several paths
$ dotenv-linter path1 path2

# Checks only the `.env` file
$ dotenv-linter .env

# Checks only several files
$ dotenv-linter .env path/.env

# Checks only the `.env` file and `*.env*` files in the `path`
$ dotenv-linter .env path

I also want to remove --include and --path arguments, because they are no longer needed;

@mstruebing @artem-russkikh @qelphybox @sonro @Louis-Lesage
What do you think about these changes?

LeadingCharacter: Show check name in message

Right now the message looks like this:

.env:2 Invalid leading character detected

Need to add the check name to the message:

.env:2 LeadingCharacter: Invalid leading character detected

Global refactoring

What should be done:

  • Add mutability support for checks (First of all, this is necessary for #4, #5, #33);
  • Reorder checks alphabetically;
  • Split some tests into methods;
  • Remove dead_code (Methods used in tests).

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.