1
0
mirror of https://github.com/mgechev/revive.git synced 2025-01-10 03:17:11 +02:00

docs: add recommended config

This commit is contained in:
mgechev 2018-07-23 16:44:51 -07:00
parent f555377e10
commit 3cbd027513
No known key found for this signature in database
GPG Key ID: 3C44F5A2A289C6BB

View File

@ -38,6 +38,7 @@ Here's how `revive` is different from `golint`:
- [Comment Annotations](#comment-annotations)
- [Configuration](#configuration)
- [Default Configuration](#default-configuration)
- [Custom Configuration](#custom-configuration)
- [Recommended Configuration](#recommended-configuration)
- [Available Rules](#available-rules)
- [Available Formatters](#available-formatters)
@ -91,6 +92,7 @@ go get -u github.com/mgechev/revive
- `-config [PATH]` - path to config file in TOML format.
- `-exclude [PATTERN]` - pattern for files/directories/packages to be excluded for linting. You can specify the files you want to exclude for linting either as package name (i.e. `github.com/mgechev/revive`), list them as individual files (i.e. `file.go`), directories (i.e. `./foo/...`), or any combination of the three.
- `-formatter [NAME]` - formatter to be used for the output. The currently available formatters are:
- `default` - will output the failures the same way that `golint` does.
- `json` - outputs the failures in JSON format.
- `ndjson` - outputs the failures as stream in newline delimited JSON (NDJSON) format.
@ -175,7 +177,7 @@ revive -config defaults.toml github.com/mgechev/revive
This will use the configuration file `defaults.toml`, the `default` formatter, and will run linting over the `github.com/mgechev/revive` package.
### Recommended Configuration
### Custom Configuration
```shell
revive -config config.toml -formatter friendly github.com/mgechev/revive
@ -183,6 +185,42 @@ revive -config config.toml -formatter friendly github.com/mgechev/revive
This will use `config.toml`, the `friendly` formatter, and will run linting over the `github.com/mgechev/revive` package.
### Recommended Configuration
The following snippet contains the recommended `revive` configuration that you can use in your project:
```toml
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 0
warningCode = 0
[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.error-naming]
[rule.exported]
[rule.if-return]
[rule.increment-decrement]
[rule.var-naming]
[rule.var-declaration]
[rule.package-comments]
[rule.range]
[rule.receiver-naming]
[rule.time-naming]
[rule.unexported-return]
[rule.indent-error-flow]
[rule.errorf]
[rule.empty-block]
[rule.superfluous-else]
[rule.unused-parameter]
[rule.unreachable-code]
```
## Available Rules
List of all available rules. The rules ported from `golint` are left unchanged and indicated in the `golint` column.
@ -329,13 +367,13 @@ Currently, type checking is enabled by default. If you want to run the linter wi
## Contributors
[<img alt="mgechev" src="https://avatars1.githubusercontent.com/u/455023?v=4&s=117" width="117">](https://github.com/mgechev) |[<img alt="chavacava" src="https://avatars2.githubusercontent.com/u/25788468?v=4&s=117" width="117">](https://github.com/chavacava) |[<img alt="morphy2k" src="https://avatars2.githubusercontent.com/u/4280578?v=4&s=117" width="117">](https://github.com/morphy2k) |[<img alt="tamird" src="https://avatars0.githubusercontent.com/u/1535036?v=4&s=117" width="117">](https://github.com/tamird) |[<img alt="paul-at-start" src="https://avatars2.githubusercontent.com/u/5486775?v=4&s=117" width="117">](https://github.com/paul-at-start) |[<img alt="vkrol" src="https://avatars3.githubusercontent.com/u/153412?v=4&s=117" width="117">](https://github.com/vkrol) |
:---: |:---: |:---: |:---: |:---: |:---: |
[mgechev](https://github.com/mgechev) |[chavacava](https://github.com/chavacava) |[morphy2k](https://github.com/morphy2k) |[tamird](https://github.com/tamird) |[paul-at-start](https://github.com/paul-at-start) |[vkrol](https://github.com/vkrol) |
| [<img alt="mgechev" src="https://avatars1.githubusercontent.com/u/455023?v=4&s=117" width="117">](https://github.com/mgechev) | [<img alt="chavacava" src="https://avatars2.githubusercontent.com/u/25788468?v=4&s=117" width="117">](https://github.com/chavacava) | [<img alt="morphy2k" src="https://avatars2.githubusercontent.com/u/4280578?v=4&s=117" width="117">](https://github.com/morphy2k) | [<img alt="tamird" src="https://avatars0.githubusercontent.com/u/1535036?v=4&s=117" width="117">](https://github.com/tamird) | [<img alt="paul-at-start" src="https://avatars2.githubusercontent.com/u/5486775?v=4&s=117" width="117">](https://github.com/paul-at-start) | [<img alt="vkrol" src="https://avatars3.githubusercontent.com/u/153412?v=4&s=117" width="117">](https://github.com/vkrol) |
| :---------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------: |
| [mgechev](https://github.com/mgechev) | [chavacava](https://github.com/chavacava) | [morphy2k](https://github.com/morphy2k) | [tamird](https://github.com/tamird) | [paul-at-start](https://github.com/paul-at-start) | [vkrol](https://github.com/vkrol) |
[<img alt="haya14busa" src="https://avatars0.githubusercontent.com/u/3797062?v=4&s=117" width="117">](https://github.com/haya14busa) |
:---: |
[haya14busa](https://github.com/haya14busa) |
| [<img alt="haya14busa" src="https://avatars0.githubusercontent.com/u/3797062?v=4&s=117" width="117">](https://github.com/haya14busa) |
| :----------------------------------------------------------------------------------------------------------------------------------: |
| [haya14busa](https://github.com/haya14busa) |
## License