You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A linter that validates simple _newline_ and _whitespace_ rules in all sorts of files. It can:
7
+
A linter that validates simple *newline* and *whitespace* rules in all sorts of files. It can:
8
8
9
9
- Recursively check a directory tree for files that do not end in a newline
10
10
- Automatically fix these files by adding a newline or trimming extra newlines
@@ -31,7 +31,7 @@ See the **[#GitHub Actions](#GitHub-Actions)** and the **[#Docker](#Docker)** fo
31
31
32
32
> This is a project in development. Use it at your own risk!
33
33
34
-
To run it locally, execute the binary and pass a list of file or directories as argument.
34
+
Executing the binary will automatically search the local directory tree for linting errors.
35
35
36
36
```console
37
37
$ linelint .
@@ -41,7 +41,7 @@ $ linelint .
41
41
Total of 2 lint errors!
42
42
```
43
43
44
-
Or:
44
+
Pass a list of files or directories to limit your search.
45
45
46
46
```console
47
47
$ linelint README.md LICENSE linter/config.go
@@ -52,7 +52,9 @@ Total of 1 lint errors!
52
52
53
53
After checking all files, in case any rule has failed, Linelint will finish with an error (exit code 1).
54
54
55
-
If the `autofix` option is set to `true` (it is `false` by default, activate it with the `-a` flag), Linelint will attempt to fix any file with error by rewriting it.
55
+
### AutoFix
56
+
57
+
If the `autofix` option is set to `true` (it is `false` by default, activate it with the `-a` flag or set it in the configuration file), Linelint will attempt to fix any linting error by rewriting the file.
56
58
57
59
```console
58
60
$ linelint -a .
@@ -62,21 +64,43 @@ $ linelint -a .
62
64
[EOF Rule] File "linter/eof.go" lint errors fixed
63
65
```
64
66
65
-
When all files are fixed successfully, Linelint terminates with with a success as well (exit code 0).
67
+
If all files are fixed successfully, Linelint terminates with exit code 0.
68
+
69
+
### Stdin
70
+
71
+
Pass "-" as an argument to read data from standard input instead of a list of files.
72
+
73
+
```console
74
+
$ cat hello.txt
75
+
Hello World
76
+
77
+
78
+
```
79
+
80
+
```console
81
+
$ cat hello.txt | linelint -
82
+
Hello World
83
+
```
84
+
85
+
When reading from stdin, linelint behavior changes and it won't report lint errors. Instead when autofix is on, it will fix them and output the result to `/dev/stdout`. When autofix is off, it will terminate the program with an error code in case there are any linting violations, but won't output anything.
86
+
87
+
### Help
88
+
89
+
At any time run `linenlint --help` for a list of available command line arguments.
66
90
67
91
## Configuration
68
92
69
-
Create a `.linelint.yml` file in the same working directory you run `linelint` to adjust your settings. See [.linelint.yml](.linelint.yml) for an up-to-date example:
93
+
Create a `.linelint.yml` file in the same working directory you run `linelint` to adjust your settings. See [.linelint.yml](.linelint.yml) for an up-to-date example.
70
94
71
95
## Rules
72
96
73
-
Right now it only supports a single rule, "End of File", which is enabled by default.
97
+
Right now it supports only a single rule, "End of File", which is enabled by default.
74
98
75
99
### EndOfFile
76
100
77
-
The _End of File_ rule checks if the file ends in a newline character, or `\n`. You may find this rule useful if you dislike seeing these 🚫 symbols at the end of files on GitHub Pull Requests.
101
+
The *End of File* rule checks if the file ends in a newline character, or `\n`. You may find it useful if you dislike seeing these 🚫 symbols at the end of files on GitHub Pull Requests.
78
102
79
-
By default it also checks if it ends strictly in a single newline character. This behavior can be disabled by setting the `single-new-line` parameter to `false`.
103
+
By default it also checks if it strictly ends in a single newline character. This behavior can be disabled by setting the `single-new-line` parameter to `false`.
80
104
81
105
```yaml
82
106
rules:
@@ -102,7 +126,7 @@ This project is available at the [GitHub Actions Marketplace](https://github.com
102
126
103
127
Create a workflow file at your repository's Workflow folder, like `.github/workflows/lint.yml` (see [lint.yml](.github/workflows/lint.yml) for an updated example):
0 commit comments