Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit f78d12d

Browse files
mgechevramya-rao-a
authored andcommitted
Add support for revive as lintTool (#1699)
1 parent 896ff76 commit f78d12d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This extension adds rich language support for the Go language to VS Code, includ
1818
- Workspace symbol search (using `go-symbols`)
1919
- Rename (using `gorename`. Note: For Undo after rename to work in Windows you need to have `diff` tool in your path)
2020
- Build-on-save (using `go build` and `go test`)
21-
- Lint-on-save (using `golint` or `gometalinter` or `megacheck` or `golangci-lint`)
21+
- Lint-on-save (using `golint` or `gometalinter` or `megacheck` or `golangci-lint` or `revive`)
2222
- Format on save as well as format manually (using `goreturns` or `goimports` or `gofmt`)
2323
- Generate unit tests skeleton (using `gotests`)
2424
- Add Imports (using `gopkgs`)
@@ -98,6 +98,14 @@ You can configure golangci-lint with `go.lintFlags`, for example to show issues
9898
"go.lintFlags": ["--enable-all", "--new"],
9999
```
100100

101+
An alternative of golint is [revive](https://github.com/mgechev/revive). It is extensible, configurable, provides superset of the rules of golint, and has significantly better performance.
102+
103+
To configure revive, use:
104+
105+
```javascript
106+
"go.lintFlags": ["--exclude vendor/...", "--config=${workspaceRoot}/config.toml"]
107+
```
108+
101109
Finally, the result of those linters will show right in the code (locations with suggestions will be underlined),
102110
as well as in the output pane.
103111

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@
522522
"golint",
523523
"gometalinter",
524524
"megacheck",
525-
"golangci-lint"
525+
"golangci-lint",
526+
"revive"
526527
]
527528
},
528529
"go.lintFlags": {

src/goInstallTools.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const allTools: { [key: string]: string } = {
3939
'gometalinter': 'github.com/alecthomas/gometalinter',
4040
'megacheck': 'honnef.co/go/tools/...',
4141
'golangci-lint': 'github.com/golangci/golangci-lint/cmd/golangci-lint',
42+
'revive': 'github.com/mgechev/revive',
4243
'go-langserver': 'github.com/sourcegraph/go-langserver',
4344
'dlv': 'github.com/derekparker/delve/cmd/dlv',
4445
'fillstruct': 'github.com/davidrjenni/reftools/cmd/fillstruct'
@@ -61,6 +62,7 @@ const importantTools = [
6162
'gometalinter',
6263
'megacheck',
6364
'golangci-lint',
65+
'revive',
6466
'dlv'
6567
];
6668

@@ -118,6 +120,10 @@ function getTools(goVersion: SemVersion): string[] {
118120
tools.push('golangci-lint');
119121
}
120122

123+
if (goConfig['lintTool'] === 'revive') {
124+
tools.push('revive');
125+
}
126+
121127
if (goConfig['useLanguageServer'] && process.platform !== 'win32') {
122128
tools.push('go-langserver');
123129
}

0 commit comments

Comments
 (0)