dotenv-linter / dotenv-linter Goto Github PK
View Code? Open in Web Editor NEW⚡️Lightning-fast linter for .env files. Written in Rust 🦀
Home Page: https://dotenv-linter.github.io
License: MIT License
⚡️Lightning-fast linter for .env files. Written in Rust 🦀
Home Page: https://dotenv-linter.github.io
License: MIT License
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
@mstruebing Hi there!
Is it possible to automate releases for dotenv-linter-bin via GitHub Actions?
What do you think about it?
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
Example:
# FOO
# BAR
What should be done:
-e FILE_NAME
, --exclude FILE_NAME
;-e FILE_1 -e FILE_2 -e FILE_3
;Add a GitHub Action to run tests.
Need to fix this bug and write a test for this case.
Link: https://github.com/mgrachev/dotenv-linter/blob/master/src/checks/leading_space.rs#L18
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
What should be done:
After the PR #99 we have two unused args which we need to remove: --include
and --path
.
Link: https://github.com/mgrachev/dotenv-linter/blob/master/src/lib.rs#L28
Refresh instruction about how to add new checks in README due to changes in code.
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
What should be done:
-i FILE_NAME
, --include FILE_NAME
;-i FILE_1 -i FILE_2 -i FILE_3
;Add a GitHub Action to check if the project is building.
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
I think filtering should be realized before all checks, here: https://github.com/mgrachev/dotenv-linter/blob/9e28fcb41608d03181f01a444802b193725d3867/src/lib.rs#L36-L43
For now incorrect_delimiter
check fails on line:
#FOO=BAR
with message .env:1 The #FOO key has incorrect delimiter
Inline comments may affect some checks (but I don't investigate it):
FOO=BAR # some comment ===
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 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.
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
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 :)
Add a GitHub Action to run linters like rust-lang/rust-clippy.
Need to replace the current solution of checking the length of the vector and getting a value by a key with the method Vector#get. It's more clear and convenient way to do that.
Source: https://github.com/mgrachev/dotenv-linter/blob/master/src/checks/unordered_keys.rs#L28:L33
What should be done:
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
All checks should have names in a single form.
So need to rename the check UnorderedKeys
to UnorderedKey
.
Instead of using the unwrap method and getting &str
, we can use the type &OsStr
without the method unwrap
. Need to replace &str
with &OsStr
in that file.
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
What should be done:
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)))
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.
Add test cover for these functions:
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
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
dotenv-linter
always exits with code 1 even if there are no warnings.
Need to fix that bug and write some integration tests to cover that case.
Link: https://github.com/mgrachev/dotenv-linter/blob/master/src/main.rs#L18
Need to rename the check SpacesAroundEqual
to SpaceCharacter
.
Implement the Display
trait for the LineEntry
struct to remove the line #[allow(dead_code)]
Need to automate Homebrew releases to https://github.com/dotenv-linter/homebrew-tap using GitHub Actions.
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
What should be done:
FOO=VAR
;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
All checks should have names in a single form.
So need to rename the check DuplicatedKeys
to DuplicatedKey
.
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?
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.