Skip to content

Commit 487aee9

Browse files
committed
docs: clean old examples
1 parent 474ac3e commit 487aee9

File tree

4 files changed

+83
-89
lines changed

4 files changed

+83
-89
lines changed

.golangci.reference.yml

Lines changed: 6 additions & 5 deletions
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

docs/src/docs/plugins/go-plugins.mdx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,19 @@ If you're looking for instructions on how to configure your own custom linter, t
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.
5151
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+
linters:
54+
settings:
55+
custom:
56+
example:
57+
path: /example.so
58+
description: The description of the linter
59+
original-url: github.com/golangci/example-linter
60+
settings: # Settings are optional.
61+
one: Foo
62+
two:
63+
- name: Bar
64+
three:
65+
name: Bar
6566
```
6667
6768
That is all the configuration that is required to run a custom linter in your project.

docs/src/docs/plugins/module-plugins.mdx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,17 @@ 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
41-
4234
linters:
43-
disable-all: true
35+
default: none
4436
enable:
4537
- foo
38+
settings:
39+
custom:
40+
foo:
41+
type: "module"
42+
description: This is an example usage of a plugin linter.
43+
settings:
44+
message: hello
4645
```
4746
4847
## The Manual Way
@@ -56,18 +55,17 @@ linters:
5655
### Configuration Example
5756

5857
```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
66-
6758
linters:
68-
disable-all: true
59+
default: none
6960
enable:
7061
- foo
62+
settings:
63+
custom:
64+
foo:
65+
type: "module"
66+
description: This is an example usage of a plugin linter.
67+
settings:
68+
message: hello
7169
```
7270

7371
## Reference

docs/src/docs/usage/false-positives.mdx

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ Otherwise, some linters have dedicated configuration to exclude or disable rules
1717
An example with `staticcheck`:
1818

1919
```yaml
20-
linters-settings:
21-
staticcheck:
22-
checks:
23-
- all
24-
- '-SA1000' # disable the rule SA1000
25-
- '-SA1004' # disable the rule SA1004
20+
linters:
21+
settings:
22+
staticcheck:
23+
checks:
24+
- all
25+
- '-SA1000' # disable the rule SA1000
26+
- '-SA1004' # disable the rule SA1004
2627
```
2728
2829
## Exclude or Skip
@@ -33,90 +34,83 @@ Exclude issue by text using command-line option `-e` or config option `issues.ex
3334
It's helpful when you decided to ignore all issues of this type.
3435
Also, you can use `issues.exclude-rules` config option for per-path or per-linter configuration.
3536

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-
```
45-
4637
In the following example, all the reports from the linters (`linters`) that contains the text (`text`) are excluded:
4738

4839
```yaml
49-
issues:
50-
exclude-rules:
51-
- linters:
52-
- mnd
53-
text: "Magic number: 9"
40+
linters:
41+
exclusions:
42+
rules:
43+
- linters:
44+
- mnd
45+
text: "Magic number: 9"
5446
```
5547

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

5850
```yaml
59-
issues:
60-
exclude-rules:
61-
- linters:
62-
- lll
63-
source: "^//go:generate "
51+
linters:
52+
exclusions:
53+
rules:
54+
- linters:
55+
- lll
56+
source: "^//go:generate "
6457
```
6558

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

6861
```yaml
69-
issues:
70-
exclude-rules:
71-
- path: path/to/a/file.go
72-
text: "string `example` has (\\d+) occurrences, make it a constant"
62+
linters:
63+
exclusions:
64+
rules:
65+
- path: path/to/a/file.go
66+
text: "string `example` has (\\d+) occurrences, make it a constant"
7367
```
7468

7569
### Exclude Issues by Path
7670

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.
71+
Exclude issues in path by `linters.exclusions.paths`, or `issues.exclude-rules` config options.
8272

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

8575
```yaml
86-
issues:
87-
exclude-rules:
88-
- path: '(.+)_test\.go'
89-
linters:
90-
- funlen
91-
- goconst
76+
linters:
77+
exclusions:
78+
rules:
79+
- path: '(.+)_test\.go'
80+
linters:
81+
- funlen
82+
- goconst
9283
```
9384
9485
The opposite, excluding reports **except** for specific paths, is also possible.
9586
In the following example, only test files get checked:
9687
9788
```yaml
98-
issues:
99-
exclude-rules:
100-
- path-except: '(.+)_test\.go'
101-
linters:
102-
- funlen
103-
- goconst
89+
linters:
90+
exclusions:
91+
rules:
92+
- path-except: '(.+)_test\.go'
93+
linters:
94+
- funlen
95+
- goconst
10496
```
10597
106-
In the following example, all the reports related to the files (`exclude-files`) are excluded:
98+
In the following example, all the reports related to the files (`paths`) are excluded:
10799

108100
```yaml
109-
issues:
110-
exclude-files:
111-
- path/to/a/file.go
101+
linters:
102+
exclusions:
103+
paths:
104+
- path/to/a/file.go
112105
```
113106

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

116109
```yaml
117110
issues:
118-
exclude-dirs:
119-
- path/to/a/dir/
111+
exclusions:
112+
paths:
113+
- path/to/a/dir/
120114
```
121115

122116
## Nolint Directive

0 commit comments

Comments
 (0)