Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code.
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: misspell
uses: reviewdog/action-misspell@v1
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

---

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

**Available checks**:
<p>
Expand All @@ -16,6 +16,7 @@ Dotenv-linter can [check](/usage/check) / [fix](/usage/fix) / [compare](/usage/c
&nbsp;&nbsp;&nbsp;&nbsp;✅&nbsp;<a href="#/checks/leading_character">Leading character</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;✅&nbsp;<a href="#/checks/lowercase_key">Lowercase key</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;✅&nbsp;<a href="#/checks/quote_character">Quote character</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;✅&nbsp;<a href="#/checks/schema_violation">Schema violation</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;✅&nbsp;<a href="#/checks/space_character">Space character</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;✅&nbsp;<a href="#/checks/substitution_key">Substitution key</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;✅&nbsp;<a href="#/checks/trailing_whitespace">Trailing whitespace</a><br />
Expand Down
8 changes: 5 additions & 3 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
* [👨‍💻 Installation](installation.md)

* 🎉 What's new?
* [v3.3.0 (latest)](whats_new/v330.md)
* [v4.0.0 (latest)](whats_new/v400.md)
* [v3.3.1](whats_new/v331.md)
* [v3.3.0](whats_new/v330.md)
* [v3.2.0](whats_new/v320.md)
* [v3.1.1](whats_new/v311.md)
* [v3.1.0](whats_new/v310.md)
Expand All @@ -12,9 +14,8 @@

* 🚀 Usage
* [✅ Check](usage/check.md)
* [🤲 Compare](usage/compare.md)
* [🤲 Diff](usage/diff.md)
* [🛠 Fix](usage/fix.md)
* [📄 List](usage/list.md)

* ✅ Checks
* [Duplicated key](checks/duplicated_key.md)
Expand All @@ -25,6 +26,7 @@
* [Leading character](checks/leading_character.md)
* [Lowercase key](checks/lowercase_key.md)
* [Quote character](checks/quote_character.md)
* [Schema violation](checks/schema_violation.md)
* [Space character](checks/space_character.md)
* [Substitution key](checks/substitution_key.md)
* [Trailing whitespace](checks/trailing_whitespace.md)
Expand Down
49 changes: 49 additions & 0 deletions docs/checks/schema_violation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Schema violation

`dotenv-linter` can check `.env` files for schema compliance.
A schema is simply a `JSON` file that describes the names of keys and the format of their values.
If a key value is of a different type, `dotenv-linter` will display a warning.

Example of the contents of a schema file (the schema file name can be anything):
```json
// .schema.env.json
{
"version": "1.0",
"entries": {
"NAME": {
"type": "String",
"regex": "^DOT*"
},
"PORT": {
"type": "Integer"
},
"PRICE": {
"type": "Float"
},
"URL": {
"type": "Url"
},
"EMAIL": {
"type": "Email"
},
"FLAG": {
"type": "Boolean"
}
}
}
```

To run `dotenv-linter` using a schema, there is a special argument `--schema` (or its short version `-s`):

```bash
$ dotenv-linter check --schema .schema.env.json .
Checking .env
.env:1 SchemaViolation: The EMAIL key is not a valid email address
.env:2 SchemaViolation: The FLAG key is not a valid boolean
.env:3 SchemaViolation: The NAME key does not match the regex
.env:4 SchemaViolation: The PORT key is not an integer
.env:5 SchemaViolation: The PRICE key is not a valid float
.env:6 SchemaViolation: The URL key is not a valid URL

Found 6 problems
```
40 changes: 27 additions & 13 deletions docs/usage/check.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# ✅ Check

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

```bash
$ dotenv-linter
$ dotenv-linter check .
Checking .env
.env:2 DuplicatedKey: The FOO key is duplicated
.env:3 UnorderedKey: The BAR key should go before the FOO key
Expand All @@ -17,7 +17,7 @@ Found 3 problems
To check another directory, just pass its path as an argument. The same approach works if you need to check any files individually:

```bash
$ dotenv-linter dir1 dir2/.my-env-file
$ dotenv-linter check dir1 dir2/.my-env-file
Checking dir1/.env
dir1/.env:1 LeadingCharacter: Invalid leading character detected
dir1/.env:3 IncorrectDelimiter: The FOO-BAR key has incorrect delimiter
Expand All @@ -33,7 +33,7 @@ Found 3 problems
If you need to exclude a file from check, you can use the `--exclude FILE_PATH` argument (or its short version `-e`):

```bash
$ dotenv-linter --exclude .env.test
$ dotenv-linter check --exclude .env.test .
Checking .env
.env:2 DuplicatedKey: The FOO key is duplicated
.env:3 UnorderedKey: The BAR key should go before the FOO key
Expand All @@ -46,7 +46,7 @@ Found 2 problems
If you need a recursive search inside directories (deeper than 1 level), you can use the `--recursive` argument (or its short version `-r`):

```bash
$ dotenv-linter --recursive
$ dotenv-linter check --recursive .
Checking .env
Checking dir1/.env
dir1/.env:2 DuplicatedKey: The FOO key is duplicated
Expand All @@ -57,12 +57,12 @@ dir2/subdir/.env:3 IncorrectDelimiter: The FOO-BAR key has incorrect delimiter
Found 2 problems
```

#### Skip checks
#### Ignore checks

If you need to skip some checks, you can use the `--skip CHECK_NAME` argument (or its short version `-s`):
If you need to ignore some checks, you can use the `--ignore-checks CHECK_NAME` argument (or its short version `-i`):

```bash
$ dotenv-linter --skip UnorderedKey EndingBlankLine
$ dotenv-linter check --ignore-checks UnorderedKey,EndingBlankLine .
Checking .env
.env:2 DuplicatedKey: The FOO key is duplicated

Expand All @@ -87,18 +87,18 @@ BAR=FOO
If you want to see only warnings without additional information, use the `--quiet` argument (or its short version `-q`):

```bash
$ dotenv-linter --quiet
$ dotenv-linter check --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
```

#### Disable colored output

By default, the output is colored. If you want to disable colored output, you can use the `--no-color` argument:
By default, the output is colored. If you want to disable colored output, you can use the `--plain` argument:

```bash
$ dotenv-linter --no-color
$ dotenv-linter check --plain .
.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
Expand All @@ -112,7 +112,7 @@ By default, `dotenv-linter` checks for a new version once a day.
If the new version is available, it will display information about it:

```bash
$ dotenv-linter
$ dotenv-linter check .
.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
Expand All @@ -123,7 +123,7 @@ A new release of dotenv-linter is available: v3.1.0 -> v3.1.1
https://github.com/dotenv-linter/dotenv-linter/releases/tag/v3.1.1
```

If you want to disable checking for updates, you can use the `--not-check-updates` argument.
If you want to disable checking for updates, you can use the `--skip-updates` argument.

#### Export prefix

Expand All @@ -133,3 +133,17 @@ It is possible to use `export` prefix for defined variables. For example, `expor

Some tools use `.env` file names but content of these files is not what `dotenv-linter` expects.<br/>
Currently `dotenv-linter` doesn't check `.envrc` files because [direnv](https://direnv.net) uses them as bash scripts.

#### Environment variables

Some settings can be controlled via environment variables.

* `DOTENV_LINTER_IGNORE_CHECKS` - disables checks (multiple checks are specified separated by commas):
```bash
$ DOTENV_LINTER_IGNORE_CHECKS=QuoteCharacter dotenv-linter check .
```

* `DOTENV_LINTER_SKIP_UPDATES` - disables checking for updates:
```bash
$ DOTENV_LINTER_SKIP_UPDATES=true dotenv-linter check .
```
17 changes: 0 additions & 17 deletions docs/usage/compare.md

This file was deleted.

17 changes: 17 additions & 0 deletions docs/usage/diff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 🤲 Diff

`dotenv-linter` can compare `.env` files with each other and output the difference between them with the `diff` command:

```bash
$ dotenv-linter diff .env .env.example
Comparing .env
Comparing .env.example
.env is missing keys: BAR
.env.example is missing keys: FOO
```

#### Additional arguments

In addition, the `diff` command supports the following list of arguments:
* [--quiet](/usage/check?id=quiet-mode)
* [--plain](/usage/check?id=disable-colored-output)
31 changes: 25 additions & 6 deletions docs/usage/fix.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# 🛠 Fix

`dotenv-linter` can also fix the found warnings with the `fix` command (or its short version `f`):
`dotenv-linter` can also fix the found warnings with the `fix` command:

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

Expand All @@ -18,19 +18,38 @@ All warnings are fixed. Total: 2
By default, `fix` creates backups of files. If you want to disable the backup function, use the argument `--no-backup`:

```bash
$ dotenv-linter fix --no-backup
$ dotenv-linter fix --no-backup .
Fixing .env
.env:2 DuplicatedKey: The BAR key is duplicated
.env:3 LowercaseKey: The foo key should be in uppercase

All warnings are fixed. Total: 2
```

#### Addition arguments
#### Dry run

If you want to run `fix` without modifying any files on disk, use the `--dry-run` flag.

```bash
$ dotenv-linter fix --dry-run .
Fixing .env
Dry run - not changing any files on disk.

BAR=bar_example_one
# BAR=bar_example_two
FOO=foo_example

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

All warnings are fixed. Total: 2
```

#### Additional arguments

In addition, the `fix` command supports the following list of arguments:
* [--exclude](/usage/check?id=exclude-files)
* [--recursive](/usage/check?id=recursive-check)
* [--skip](/usage/check?id=skip-checks)
* [--ignore-checks](/usage/check?id=ignore-checks)
* [--quiet](/usage/check?id=quiet-mode)
* [--no-color](/usage/check?id=disable-colored-output)
* [--plain](/usage/check?id=disable-colored-output)
19 changes: 0 additions & 19 deletions docs/usage/list.md

This file was deleted.

22 changes: 22 additions & 0 deletions docs/whats_new/v331.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# What's new in v3.3.1?

Here's an overview of the key changes included in this release.

### 1. Fix docker image for `arm64`

PR: [#757](https://github.com/dotenv-linter/dotenv-linter/pull/757) ([@harryzcy](https://github.com/harryzcy))

### 2. Add `--dry-run` option to the "fix" subcommand

PR: [#772](https://github.com/dotenv-linter/dotenv-linter/pull/772) ([@Dev380](https://github.com/Dev380))

These are all the key changes that are included in the new `v3.3.1` release.<br/>
Thanks to everyone who contributed 🙏

---

How you can support the project 😉

* Star on [GitHub](https://github.com/dotenv-linter/dotenv-linter) ⭐️
* Become a sponsor on [GitHub Sponsors](https://github.com/sponsors/dotenv-linter) or [OpenCollective](https://opencollective.com/dotenv-linter) ❤️
* Contribute to the [dotenv-linter](https://github.com/dotenv-linter/dotenv-linter/blob/master/CONTRIBUTING.md) ⚙️
Loading