Skip to content

Commit 052235c

Browse files
authored
configuring revive in golanci-lint (#523)
1 parent b298ffe commit 052235c

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ Here's how `revive` is different from `golint`:
6363

6464
- [revive](#revive)
6565
- [Usage](#usage)
66+
- [Bazel](#bazel)
6667
- [Text Editors](#text-editors)
6768
- [Continuous Integration](#continuous-integration)
68-
- [Bazel](#bazel)
69+
- [Linter Aggregators](#linter-aggregators)
70+
- [golangci-lint](#golangci-lint)
6971
- [Installation](#installation)
7072
- [Command Line Flags](#command-line-flags)
7173
- [Sample Invocations](#sample-invocations)
@@ -128,6 +130,39 @@ let g:ale_linters = {
128130

129131
[Codeac.io](https://www.codeac.io?ref=revive) - Automated code review service integrates with GitHub, Bitbucket and GitLab (even self-hosted) and helps you fight technical debt. Check your [pull-requests](https://www.codeac.io/documentation/pull-requests.html?ref=revive) with [revive](https://www.codeac.io/documentation/revive-configuration.html?ref=revive) automatically. (free for open-source projects)
130132

133+
### Linter aggregators
134+
135+
#### golangci-lint
136+
To enable `revive` in `golangci-lint` you need to add `revive` to the list of enabled linters:
137+
138+
```yaml
139+
# golangci-lint configuration file
140+
linters:
141+
enable:
142+
- revive
143+
```
144+
Then `revive` can be configured by adding an entry to the `linters-settings` section of the configuration, for example:
145+
146+
```yaml
147+
# golangci-lint configuration file
148+
linters-settings:
149+
revive:
150+
ignore-generated-header: true
151+
severity: warning
152+
rules:
153+
- name: atomic
154+
- name: line-length-limit
155+
severity: error
156+
arguments: [80]
157+
- name: unhandled-error
158+
arguments : ["fmt.Printf", "myFunction"]
159+
```
160+
161+
The above configuration enables three rules of `revive`: _atomic_, _line-length-limit_ and _unhandled-error_ and pass some arguments to the last two.
162+
The [Configuration](#configuration) section of this document provides details on how to configure `revive`. Note that while `revive` configuration is in TOML, that of `golangci-lint` is in YAML.
163+
164+
Please notice that if no particular configuration is provided, `revive` will behave as `go-lint` does, i.e. all `go-lint` rules are enabled (the [Available Rules table](#available-rules) details what are the `go-lint` rules). When a configuration is provided, only rules in the configuration are enabled.
165+
131166
### Installation
132167

133168
```bash

0 commit comments

Comments
 (0)