Skip to content

Commit 76c48dd

Browse files
authored
docs: clean old configuration examples (#5626)
1 parent 474ac3e commit 76c48dd

File tree

4 files changed

+95
-98
lines changed

4 files changed

+95
-98
lines changed

Diff for: .golangci.reference.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,12 @@ linters:
415415
# if check-error-free-encoding is set to true and errcheck linter is enabled,
416416
# it is recommended to add the following exceptions to prevent from false positives:
417417
#
418-
# linters-settings:
419-
# errcheck:
420-
# exclude-functions:
421-
# - encoding/json.Marshal
422-
# - encoding/json.MarshalIndent
418+
# linters:
419+
# settings:
420+
# errcheck:
421+
# exclude-functions:
422+
# - encoding/json.Marshal
423+
# - encoding/json.MarshalIndent
423424
#
424425
# Default: false
425426
check-error-free-encoding: true

Diff for: docs/src/docs/plugins/go-plugins.mdx

+18-15
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,32 @@ An example linter can be found at [here](https://github.com/golangci/example-plu
4848
If you're looking for instructions on how to configure your own custom linter, they can be found further down.
4949

5050
1. If the project you want to lint does not have one already, copy the [.golangci.yml](https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.yml) to the root directory.
51-
2. Adjust the YAML to appropriate `linters-settings.custom` entries as so:
51+
2. Adjust the YAML to appropriate `linters.settings.custom` entries as so:
5252
```yaml title=.golangci.yml
53-
linters-settings:
54-
custom:
55-
example:
56-
path: /example.so
57-
description: The description of the linter
58-
original-url: github.com/golangci/example-linter
59-
settings: # Settings are optional.
60-
one: Foo
61-
two:
62-
- name: Bar
63-
three:
64-
name: Bar
53+
version: "2"
54+
55+
linters:
56+
settings:
57+
custom:
58+
example:
59+
path: /example.so
60+
description: The description of the linter
61+
original-url: github.com/golangci/example-linter
62+
settings: # Settings are optional.
63+
one: Foo
64+
two:
65+
- name: Bar
66+
three:
67+
name: Bar
6568
```
6669
6770
That is all the configuration that is required to run a custom linter in your project.
6871
6972
Custom linters are enabled by default, but abide by the same rules as other linters.
7073
71-
If the disable all option is specified either on command line or in `.golang.yml` files `linters.disable-all: true`, custom linters will be disabled;
74+
If the disable all option is specified either on command line or in `.golangci.yml` files `linters.default: none`, custom linters will be disabled;
7275
they can be re-enabled by adding them to the `linters.enable` list,
7376
or providing the enabled option on the command line, `golangci-lint run -Eexample`.
7477

75-
The configuration inside the `settings` field of linter have some limitations (there are NOT related to the plugin system itself):
78+
The configuration inside the `linters.settings` field of linter have some limitations (there are NOT related to the plugin system itself):
7679
we use Viper to handle the configuration but Viper put all the keys in lowercase, and `.` cannot be used inside a key.

Diff for: docs/src/docs/plugins/module-plugins.mdx

+20-18
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ An example linter can be found at [here](https://github.com/golangci/example-plu
88

99
- Define your building configuration into `.custom-gcl.yml`.
1010
- Run the command `golangci-lint custom` (or `golangci-lint custom -v` to have logs).
11-
- Define the plugin inside the `linters-settings.custom` section with the type `module`.
11+
- Define the plugin inside the `linters.settings.custom` section with the type `module`.
1212
- Run your custom version of golangci-lint.
1313

1414
Requirements:
@@ -31,43 +31,45 @@ plugins:
3131
```
3232
3333
```yaml title=.golangci.yml
34-
linters-settings:
35-
custom:
36-
foo:
37-
type: "module"
38-
description: This is an example usage of a plugin linter.
39-
settings:
40-
message: hello
34+
version: "2"
4135

4236
linters:
43-
disable-all: true
37+
default: none
4438
enable:
4539
- foo
40+
settings:
41+
custom:
42+
foo:
43+
type: "module"
44+
description: This is an example usage of a plugin linter.
45+
settings:
46+
message: hello
4647
```
4748
4849
## The Manual Way
4950
5051
- Add a blank-import of your module inside `cmd/golangci-lint/plugins.go`.
5152
- Run `go mod tidy` (the module containing the plugin will be imported).
5253
- Run `make build`.
53-
- Define the plugin inside the configuration `linters-settings.custom` section with the type `module`.
54+
- Define the plugin inside the `linters.settings.custom` section with the type `module`.
5455
- Run your custom version of golangci-lint.
5556

5657
### Configuration Example
5758

5859
```yaml title=.golangci.yml
59-
linters-settings:
60-
custom:
61-
foo:
62-
type: "module"
63-
description: This is an example usage of a plugin linter.
64-
settings:
65-
message: hello
60+
version: "2"
6661
6762
linters:
68-
disable-all: true
63+
default: none
6964
enable:
7065
- foo
66+
settings:
67+
custom:
68+
foo:
69+
type: "module"
70+
description: This is an example usage of a plugin linter.
71+
settings:
72+
message: hello
7173
```
7274

7375
## Reference

Diff for: docs/src/docs/usage/false-positives.mdx

+51-60
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ title: False Positives
33
---
44

55
False positives are inevitable, but we did our best to reduce their count.
6-
For example, we have a default enabled set of [exclude patterns](/usage/configuration#command-line-options).
76

87
If a false positive occurred, you have the several choices.
98

@@ -17,106 +16,98 @@ Otherwise, some linters have dedicated configuration to exclude or disable rules
1716
An example with `staticcheck`:
1817

1918
```yaml
20-
linters-settings:
21-
staticcheck:
22-
checks:
23-
- all
24-
- '-SA1000' # disable the rule SA1000
25-
- '-SA1004' # disable the rule SA1004
19+
linters:
20+
settings:
21+
staticcheck:
22+
checks:
23+
- all
24+
- '-SA1000' # disable the rule SA1000
25+
- '-SA1004' # disable the rule SA1004
2626
```
2727
28-
## Exclude or Skip
28+
## Exclude
2929
3030
### Exclude Issue by Text
3131
32-
Exclude issue by text using command-line option `-e` or config option `issues.exclude`.
33-
It's helpful when you decided to ignore all issues of this type.
34-
Also, you can use `issues.exclude-rules` config option for per-path or per-linter configuration.
35-
36-
In the following example, all the reports that contains the sentences defined in `exclude` are excluded:
37-
38-
```yaml
39-
issues:
40-
exclude:
41-
- "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
42-
- "exported (type|method|function) (.+) should have comment or be unexported"
43-
- "ST1000: at least one file in a package should have a package comment"
44-
```
32+
You can use `linters.exclusions.rules` config option for per-path or per-linter configuration.
4533

4634
In the following example, all the reports from the linters (`linters`) that contains the text (`text`) are excluded:
4735

4836
```yaml
49-
issues:
50-
exclude-rules:
51-
- linters:
52-
- mnd
53-
text: "Magic number: 9"
37+
linters:
38+
exclusions:
39+
rules:
40+
- linters:
41+
- mnd
42+
text: "Magic number: 9"
5443
```
5544

5645
In the following example, all the reports from the linters (`linters`) that originated from the source (`source`) are excluded:
5746

5847
```yaml
59-
issues:
60-
exclude-rules:
61-
- linters:
62-
- lll
63-
source: "^//go:generate "
48+
linters:
49+
exclusions:
50+
rules:
51+
- linters:
52+
- lll
53+
source: "^//go:generate "
6454
```
6555

6656
In the following example, all the reports that contains the text (`text`) in the path (`path`) are excluded:
6757

6858
```yaml
69-
issues:
70-
exclude-rules:
71-
- path: path/to/a/file.go
72-
text: "string `example` has (\\d+) occurrences, make it a constant"
59+
linters:
60+
exclusions:
61+
rules:
62+
- path: path/to/a/file.go
63+
text: "string `example` has (\\d+) occurrences, make it a constant"
7364
```
7465

7566
### Exclude Issues by Path
7667

77-
Exclude issues in path by `issues.exclude-dirs`, `issues.exclude-files` or `issues.exclude-rules` config options.
78-
79-
Beware that the paths that get matched here are relative to the current working directory.
80-
When the configuration contains path patterns that check for specific directories,
81-
the `--path-prefix` parameter can be used to extend the paths before matching.
68+
Exclude issues in path by `linters.exclusions.paths` or `linters.exclusions.rules` config options.
8269

8370
In the following example, all the reports from the linters (`linters`) that concerns the path (`path`) are excluded:
8471

8572
```yaml
86-
issues:
87-
exclude-rules:
88-
- path: '(.+)_test\.go'
89-
linters:
90-
- funlen
91-
- goconst
73+
linters:
74+
exclusions:
75+
rules:
76+
- path: '(.+)_test\.go'
77+
linters:
78+
- funlen
79+
- goconst
9280
```
9381
9482
The opposite, excluding reports **except** for specific paths, is also possible.
9583
In the following example, only test files get checked:
9684
9785
```yaml
98-
issues:
99-
exclude-rules:
100-
- path-except: '(.+)_test\.go'
101-
linters:
102-
- funlen
103-
- goconst
86+
linters:
87+
exclusions:
88+
rules:
89+
- path-except: '(.+)_test\.go'
90+
linters:
91+
- funlen
92+
- goconst
10493
```
10594
106-
In the following example, all the reports related to the files (`exclude-files`) are excluded:
95+
In the following example, all the reports related to the files (`paths`) are excluded:
10796

10897
```yaml
109-
issues:
110-
exclude-files:
111-
- path/to/a/file.go
98+
linters:
99+
exclusions:
100+
paths:
101+
- path/to/a/file.go
112102
```
113103

114-
In the following example, all the reports related to the directories (`exclude-dirs`) are excluded:
104+
In the following example, all the reports related to the directories (`paths`) are excluded:
115105

116106
```yaml
117-
issues:
118-
exclude-dirs:
119-
- path/to/a/dir/
107+
linters:
108+
exclusions:
109+
paths:
110+
- path/to/a/dir/
120111
```
121112

122113
## Nolint Directive

0 commit comments

Comments
 (0)