This linter checks argument order of test assertion. The expected-like variable name must be placed before the actual-like variable name.
For example:
require.Equal(t, expectNum, actualNum) // pass
require.Equal(t, actualNum, expectNum) // warn
In VScode:
git clone https://github.com/JiaheEatingOut/expectfirst
cd expectfirst
make build
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
(Install golangci-lint and custom linter locally, so that they are compile with the exact same stack, it's related to how Go plugins work.)- Add the below configs to your project
.golingci.yml
linters-settings:
custom:
expectfirst:
path: "<LINTER_FOLDER>/expectfirst.so"
linters:
enable:
- expectfirst
- Ready to Go!
Add more rules:
- Add rule to
pkg/analyzer/
- Add test to
testdata/
- Run
make test
- Update
.golangci.yml