Skip to content

Commit b91b324

Browse files
authored
docs: improve new linter section (#5066)
1 parent 944e1d8 commit b91b324

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

.github/new-linter-checklist.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ In order for a pull request adding a linter to be reviewed, the linter and the P
1111

1212
- [ ] It must not be a duplicate of another linter or a rule of a linter (the team will help to verify that).
1313
- [ ] It must have a valid license (AGPL is not allowed), and the file must contain the required information by the license, ex: author, year, etc.
14-
- [ ] It must use Go version <= 1.21
14+
- [ ] It must use Go version <= 1.22.0
1515
- [ ] The linter repository must have a CI and tests.
1616
- [ ] It must use [`go/analysis`](https://golangci-lint.run/contributing/new-linters/).
1717
- [ ] It must have a valid tag, ex: `v1.0.0`, `v0.1.0`.
@@ -58,6 +58,7 @@ In order for a pull request adding a linter to be reviewed, the linter and the P
5858
- [ ] The linter should be published as a binary (useful to diagnose bug origins).
5959
- [ ] The linter repository should have a `.gitignore` (IDE files, binaries, OS files, etc. should not be committed)
6060
- [ ] A tag should never be recreated.
61+
- [ ] Use `main` as the default branch name.
6162

6263
---
6364

docs/src/docs/contributing/new-linters.mdx

+8-10
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,25 @@ After that:
1616

1717
1. Implement functional tests for the linter:
1818
- 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-
```
2419
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.
2721
3. Add the new struct for the linter (which you've implemented in `pkg/golinters/{yourlintername}/{yourlintername}.go`) to the
2822
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)
2923
to the method `LinterBuilder.Build`.
3024
- 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)
3125
4. Find out what options do you need to configure for the linter.
3226
For example, `nakedret` has only 1 option: [`max-func-lines`](https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml).
3327
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.
3529
You can also add them to [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml)
3630
if you think that this project needs not default values.
37-
- [config struct](https://github.com/golangci/golangci-lint/blob/master/pkg/config/config.go) -
38-
don't forget about `mapstructure` tag for proper configuration files parsing by [pflag](https://github.com/spf13/pflag).
31+
- [config struct](https://github.com/golangci/golangci-lint/blob/master/pkg/config/config.go):
32+
don't forget about `mapstructure` tags for proper configuration files parsing.
3933
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
37+
```
4038

4139
## How to add a private linter to `golangci-lint`
4240

0 commit comments

Comments
 (0)