You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/docs/contributing/new-linters.mdx
+8-10
Original file line number
Diff line number
Diff line change
@@ -16,27 +16,25 @@ After that:
16
16
17
17
1. Implement functional tests for the linter:
18
18
- Add one file into directory `pkg/golinters/{yourlintername}/testdata/`.
19
-
- Run the test to ensure that test fails.
20
-
- Run:
21
-
```bash
22
-
go run ./cmd/golangci-lint/ run --no-config --disable-all --enable={yourlintername} ./pkg/golinters/{yourlintername}/testdata/{yourlintername}.go
23
-
```
24
19
2. Add a new file `pkg/golinters/{yourlintername}/{yourlintername}.go`.
25
-
Look at other linters in this directory.
26
-
Implement linter integration and check that test passes.
20
+
Other linters implementation can help you.
27
21
3. Add the new struct for the linter (which you've implemented in `pkg/golinters/{yourlintername}/{yourlintername}.go`) to the
28
22
list of all supported linters in [`pkg/lint/lintersdb/builder_linter.go`](https://github.com/golangci/golangci-lint/blob/master/pkg/lint/lintersdb/builder_linter.go)
29
23
to the method `LinterBuilder.Build`.
30
24
- Add `WithSince("next_version")`, where `next_version` must be replaced by the next minor version. (ex: v1.2.0 if the current version is v1.1.0)
31
25
4. Find out what options do you need to configure for the linter.
32
26
For example, `nakedret` has only 1 option: [`max-func-lines`](https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml).
33
27
Choose default values to not being annoying for users of golangci-lint. Add configuration options to:
34
-
-[.golangci.reference.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml) - the example of a configuration file.
28
+
-[.golangci.next.reference.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.next.reference.yml): the example of a configuration file.
35
29
You can also add them to [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml)
36
30
if you think that this project needs not default values.
don't forget about `mapstructure`tags for proper configuration files parsing.
39
33
5. Take a look at the example of [pull requests with new linter support](https://github.com/golangci/golangci-lint/pulls?q=is%3Apr+is%3Amerged+label%3A%22linter%3A+new%22).
34
+
6. Run the tests:
35
+
```bash
36
+
go run ./cmd/golangci-lint/ run --no-config --disable-all --enable={yourlintername} ./pkg/golinters/{yourlintername}/testdata/{yourlintername}.go
0 commit comments