@@ -17,12 +17,13 @@ Otherwise, some linters have dedicated configuration to exclude or disable rules
17
17
An example with ` staticcheck ` :
18
18
19
19
``` 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
26
27
` ` `
27
28
28
29
## Exclude or Skip
@@ -33,90 +34,83 @@ Exclude issue by text using command-line option `-e` or config option `issues.ex
33
34
It's helpful when you decided to ignore all issues of this type.
34
35
Also, you can use `issues.exclude-rules` config option for per-path or per-linter configuration.
35
36
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
-
46
37
In the following example, all the reports from the linters (`linters`) that contains the text (`text`) are excluded :
47
38
48
39
` ` ` 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"
54
46
` ` `
55
47
56
48
In the following example, all the reports from the linters (`linters`) that originated from the source (`source`) are excluded :
57
49
58
50
` ` ` 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 "
64
57
` ` `
65
58
66
59
In the following example, all the reports that contains the text (`text`) in the path (`path`) are excluded :
67
60
68
61
` ` ` 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"
73
67
```
74
68
75
69
### Exclude Issues by Path
76
70
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.
82
72
83
73
In the following example, all the reports from the linters (` linters ` ) that concerns the path (` path ` ) are excluded:
84
74
85
75
``` 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
92
83
` ` `
93
84
94
85
The opposite, excluding reports **except** for specific paths, is also possible.
95
86
In the following example, only test files get checked:
96
87
97
88
` ` ` 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
104
96
` ` `
105
97
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:
107
99
108
100
` ` ` yaml
109
- issues:
110
- exclude-files:
111
- - path/to/a/file.go
101
+ linters:
102
+ exclusions:
103
+ paths:
104
+ - path/to/a/file.go
112
105
` ` `
113
106
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 :
115
108
116
109
` ` ` yaml
117
110
issues:
118
- exclude-dirs:
119
- - path/to/a/dir/
111
+ exclusions:
112
+ paths:
113
+ - path/to/a/dir/
120
114
` ` `
121
115
122
116
# # Nolint Directive
0 commit comments