Skip to content

Commit 7907a5d

Browse files
authored
Merge pull request #5 from fernandrone/fix-autofix-and-add-stdin
Fix autofix and add stdin input
2 parents fd137ed + af685f4 commit 7907a5d

File tree

9 files changed

+317
-87
lines changed

9 files changed

+317
-87
lines changed

.drone.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ platform:
88
os: linux
99

1010
steps:
11+
1112
- name: get
1213
image: golang:1.14.0
1314
commands:
@@ -18,6 +19,13 @@ steps:
1819
image: fernandrone/linelint:latest
1920
pull: true
2021

22+
- name: markdown
23+
image: node:14.13.1
24+
group: test
25+
commands:
26+
- npm install -g markdownlint-cli
27+
- markdownlint .
28+
2129
- name: golangci-lint
2230
group: test
2331
image: golangci/golangci-lint:v1.26.0

.markdownlint.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"MD013": false,
3+
"MD033": false
4+
}

README.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Build Status](https://cloud.drone.io/api/badges/fernandrone/linelint/status.svg)](https://cloud.drone.io/fernandrone/linelint)
55
[![Go Report Card](https://goreportcard.com/badge/github.com/fernandrone/linelint)](https://goreportcard.com/report/github.com/fernandrone/linelint)
66

7-
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:
88

99
- Recursively check a directory tree for files that do not end in a newline
1010
- 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
3131

3232
> This is a project in development. Use it at your own risk!
3333
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.
3535

3636
```console
3737
$ linelint .
@@ -41,7 +41,7 @@ $ linelint .
4141
Total of 2 lint errors!
4242
```
4343

44-
Or:
44+
Pass a list of files or directories to limit your search.
4545

4646
```console
4747
$ linelint README.md LICENSE linter/config.go
@@ -52,7 +52,9 @@ Total of 1 lint errors!
5252

5353
After checking all files, in case any rule has failed, Linelint will finish with an error (exit code 1).
5454

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.
5658

5759
```console
5860
$ linelint -a .
@@ -62,21 +64,43 @@ $ linelint -a .
6264
[EOF Rule] File "linter/eof.go" lint errors fixed
6365
```
6466

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.
6690

6791
## Configuration
6892

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.
7094

7195
## Rules
7296

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.
7498

7599
### EndOfFile
76100

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.
78102

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`.
80104

81105
```yaml
82106
rules:
@@ -102,7 +126,7 @@ This project is available at the [GitHub Actions Marketplace](https://github.com
102126
103127
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):
104128

105-
```
129+
```yaml
106130
# .github/workflows/main.yml
107131
on: [push]
108132
name: lint

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn
221221
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
222222
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
223223
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
224+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
224225
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
225226
github.com/kyoh86/exportloopref v0.1.7 h1:u+iHuTbkbTS2D/JP7fCuZDo/t3rBVGo3Hf58Rc+lQVY=
226227
github.com/kyoh86/exportloopref v0.1.7/go.mod h1:h1rDl2Kdj97+Kwh4gdz3ujE7XHmH51Q0lUiZ1z4NLj8=
@@ -265,6 +266,7 @@ github.com/nakabonne/nestif v0.3.0 h1:+yOViDGhg8ygGrmII72nV9B/zGxY188TYpfolntsaP
265266
github.com/nakabonne/nestif v0.3.0/go.mod h1:dI314BppzXjJ4HsCnbo7XzrJHPszZsjnk5wEBSYHI2c=
266267
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d h1:AREM5mwr4u1ORQBMvzfzBgpsctsbQikCVpvC+tX285E=
267268
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d/go.mod h1:o96djdrsSGy3AWPyBgZMAGfxZNfgntdJG+11KU4QvbU=
269+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
268270
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
269271
github.com/nishanths/exhaustive v0.0.0-20200708172631-8866003e3856 h1:W3KBC2LFyfgd+wNudlfgCCsTo4q97MeNWrfz8/wSdSc=
270272
github.com/nishanths/exhaustive v0.0.0-20200708172631-8866003e3856/go.mod h1:wBEpHwM2OdmeNpdCvRPUlkEbBuaFmcK4Wv8Q7FuGW3c=
@@ -562,6 +564,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
562564
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
563565
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
564566
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
567+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
565568
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
566569
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
567570
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=

0 commit comments

Comments
 (0)