Skip to content

Commit 34bae02

Browse files
authored
Merge pull request #63 from dotenv-linter/develop
Release v4.0.0
2 parents 6f9ba95 + a4f1d18 commit 34bae02

File tree

12 files changed

+262
-60
lines changed

12 files changed

+262
-60
lines changed

.github/workflows/reviewdog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Check out code.
10-
uses: actions/checkout@v1
10+
uses: actions/checkout@v4
1111
- name: misspell
1212
uses: reviewdog/action-misspell@v1
1313
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
---
66

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

99
**Available checks**:
1010
<p>
@@ -16,6 +16,7 @@ Dotenv-linter can [check](/usage/check) / [fix](/usage/fix) / [compare](/usage/c
1616
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#/checks/leading_character">Leading character</a><br />
1717
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#/checks/lowercase_key">Lowercase key</a><br />
1818
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#/checks/quote_character">Quote character</a><br />
19+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#/checks/schema_violation">Schema violation</a><br />
1920
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#/checks/space_character">Space character</a><br />
2021
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#/checks/substitution_key">Substitution key</a><br />
2122
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#/checks/trailing_whitespace">Trailing whitespace</a><br />

docs/_sidebar.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
* [👨‍💻 Installation](installation.md)
33

44
* 🎉 What's new?
5-
* [v3.3.0 (latest)](whats_new/v330.md)
5+
* [v4.0.0 (latest)](whats_new/v400.md)
6+
* [v3.3.1](whats_new/v331.md)
7+
* [v3.3.0](whats_new/v330.md)
68
* [v3.2.0](whats_new/v320.md)
79
* [v3.1.1](whats_new/v311.md)
810
* [v3.1.0](whats_new/v310.md)
@@ -12,9 +14,8 @@
1214

1315
* 🚀 Usage
1416
* [✅ Check](usage/check.md)
15-
* [🤲 Compare](usage/compare.md)
17+
* [🤲 Diff](usage/diff.md)
1618
* [🛠 Fix](usage/fix.md)
17-
* [📄 List](usage/list.md)
1819

1920
* ✅ Checks
2021
* [Duplicated key](checks/duplicated_key.md)
@@ -25,6 +26,7 @@
2526
* [Leading character](checks/leading_character.md)
2627
* [Lowercase key](checks/lowercase_key.md)
2728
* [Quote character](checks/quote_character.md)
29+
* [Schema violation](checks/schema_violation.md)
2830
* [Space character](checks/space_character.md)
2931
* [Substitution key](checks/substitution_key.md)
3032
* [Trailing whitespace](checks/trailing_whitespace.md)

docs/checks/schema_violation.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Schema violation
2+
3+
`dotenv-linter` can check `.env` files for schema compliance.
4+
A schema is simply a `JSON` file that describes the names of keys and the format of their values.
5+
If a key value is of a different type, `dotenv-linter` will display a warning.
6+
7+
Example of the contents of a schema file (the schema file name can be anything):
8+
```json
9+
// .schema.env.json
10+
{
11+
"version": "1.0",
12+
"entries": {
13+
"NAME": {
14+
"type": "String",
15+
"regex": "^DOT*"
16+
},
17+
"PORT": {
18+
"type": "Integer"
19+
},
20+
"PRICE": {
21+
"type": "Float"
22+
},
23+
"URL": {
24+
"type": "Url"
25+
},
26+
"EMAIL": {
27+
"type": "Email"
28+
},
29+
"FLAG": {
30+
"type": "Boolean"
31+
}
32+
}
33+
}
34+
```
35+
36+
To run `dotenv-linter` using a schema, there is a special argument `--schema` (or its short version `-s`):
37+
38+
```bash
39+
$ dotenv-linter check --schema .schema.env.json .
40+
Checking .env
41+
.env:1 SchemaViolation: The EMAIL key is not a valid email address
42+
.env:2 SchemaViolation: The FLAG key is not a valid boolean
43+
.env:3 SchemaViolation: The NAME key does not match the regex
44+
.env:4 SchemaViolation: The PORT key is not an integer
45+
.env:5 SchemaViolation: The PRICE key is not a valid float
46+
.env:6 SchemaViolation: The URL key is not a valid URL
47+
48+
Found 6 problems
49+
```

docs/usage/check.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# ✅ Check
22

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

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

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

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

4848
```bash
49-
$ dotenv-linter --recursive
49+
$ dotenv-linter check --recursive .
5050
Checking .env
5151
Checking dir1/.env
5252
dir1/.env:2 DuplicatedKey: The FOO key is duplicated
@@ -57,12 +57,12 @@ dir2/subdir/.env:3 IncorrectDelimiter: The FOO-BAR key has incorrect delimiter
5757
Found 2 problems
5858
```
5959

60-
#### Skip checks
60+
#### Ignore checks
6161

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

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

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

8989
```bash
90-
$ dotenv-linter --quiet
90+
$ dotenv-linter check --quiet .
9191
.env:2 DuplicatedKey: The FOO key is duplicated
9292
.env:3 UnorderedKey: The BAR key should go before the FOO key
9393
.env.test:1 LeadingCharacter: Invalid leading character detected
9494
```
9595

9696
#### Disable colored output
9797

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

100100
```bash
101-
$ dotenv-linter --no-color
101+
$ dotenv-linter check --plain .
102102
.env:2 DuplicatedKey: The FOO key is duplicated
103103
.env:3 UnorderedKey: The BAR key should go before the FOO key
104104
.env.test:1 LeadingCharacter: Invalid leading character detected
@@ -112,7 +112,7 @@ By default, `dotenv-linter` checks for a new version once a day.
112112
If the new version is available, it will display information about it:
113113

114114
```bash
115-
$ dotenv-linter
115+
$ dotenv-linter check .
116116
.env:2 DuplicatedKey: The FOO key is duplicated
117117
.env:3 UnorderedKey: The BAR key should go before the FOO key
118118
.env.test:1 LeadingCharacter: Invalid leading character detected
@@ -123,7 +123,7 @@ A new release of dotenv-linter is available: v3.1.0 -> v3.1.1
123123
https://github.com/dotenv-linter/dotenv-linter/releases/tag/v3.1.1
124124
```
125125

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

128128
#### Export prefix
129129

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

134134
Some tools use `.env` file names but content of these files is not what `dotenv-linter` expects.<br/>
135135
Currently `dotenv-linter` doesn't check `.envrc` files because [direnv](https://direnv.net) uses them as bash scripts.
136+
137+
#### Environment variables
138+
139+
Some settings can be controlled via environment variables.
140+
141+
* `DOTENV_LINTER_IGNORE_CHECKS` - disables checks (multiple checks are specified separated by commas):
142+
```bash
143+
$ DOTENV_LINTER_IGNORE_CHECKS=QuoteCharacter dotenv-linter check .
144+
```
145+
146+
* `DOTENV_LINTER_SKIP_UPDATES` - disables checking for updates:
147+
```bash
148+
$ DOTENV_LINTER_SKIP_UPDATES=true dotenv-linter check .
149+
```

docs/usage/compare.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

docs/usage/diff.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 🤲 Diff
2+
3+
`dotenv-linter` can compare `.env` files with each other and output the difference between them with the `diff` command:
4+
5+
```bash
6+
$ dotenv-linter diff .env .env.example
7+
Comparing .env
8+
Comparing .env.example
9+
.env is missing keys: BAR
10+
.env.example is missing keys: FOO
11+
```
12+
13+
#### Additional arguments
14+
15+
In addition, the `diff` command supports the following list of arguments:
16+
* [--quiet](/usage/check?id=quiet-mode)
17+
* [--plain](/usage/check?id=disable-colored-output)

docs/usage/fix.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# 🛠 Fix
22

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

55
```bash
6-
$ dotenv-linter fix
6+
$ dotenv-linter fix .
77
Fixing .env
88
Original file was backed up to: ".env_1601378896"
99

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

2020
```bash
21-
$ dotenv-linter fix --no-backup
21+
$ dotenv-linter fix --no-backup .
2222
Fixing .env
2323
.env:2 DuplicatedKey: The BAR key is duplicated
2424
.env:3 LowercaseKey: The foo key should be in uppercase
2525

2626
All warnings are fixed. Total: 2
2727
```
2828

29-
#### Addition arguments
29+
#### Dry run
30+
31+
If you want to run `fix` without modifying any files on disk, use the `--dry-run` flag.
32+
33+
```bash
34+
$ dotenv-linter fix --dry-run .
35+
Fixing .env
36+
Dry run - not changing any files on disk.
37+
38+
BAR=bar_example_one
39+
# BAR=bar_example_two
40+
FOO=foo_example
41+
42+
.env:2 DuplicatedKey: The BAR key is duplicated
43+
.env:3 LowercaseKey: The foo key should be in uppercase
44+
45+
All warnings are fixed. Total: 2
46+
```
47+
48+
#### Additional arguments
3049

3150
In addition, the `fix` command supports the following list of arguments:
3251
* [--exclude](/usage/check?id=exclude-files)
3352
* [--recursive](/usage/check?id=recursive-check)
34-
* [--skip](/usage/check?id=skip-checks)
53+
* [--ignore-checks](/usage/check?id=ignore-checks)
3554
* [--quiet](/usage/check?id=quiet-mode)
36-
* [--no-color](/usage/check?id=disable-colored-output)
55+
* [--plain](/usage/check?id=disable-colored-output)

docs/usage/list.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)