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

Feature Request: go.lintOnSave = "file" #1931

Closed
jeffb4 opened this issue Sep 17, 2018 · 12 comments
Closed

Feature Request: go.lintOnSave = "file" #1931

jeffb4 opened this issue Sep 17, 2018 · 12 comments

Comments

@jeffb4
Copy link

jeffb4 commented Sep 17, 2018

When using gometalint with all linters enabled, even a package lint can take a significant period of time. It'd be nice to have an additional go.lintOnSave option "file", to only run the linter on the file that was just saved.

@ramya-rao-a
Copy link
Contributor

That sounds like a good idea.
We support the below linters today. Do you know if all of them support running on single files?

            "golint",
            "gometalinter",
            "megacheck",
            "golangci-lint",
            "revive"

PRs for this feature are most welcome. Code Pointers:

@jeffb4
Copy link
Author

jeffb4 commented Sep 18, 2018

golint - supports individual files
gometalinter - allows individual files, but errors when they do not comprise a package
megacheck - allows individual files, but errors when they do not comprise a package
megacheck - allows individual files, but errors when they do not comprise a package
revive - supports individual files

given the general lack of robust support for single files, does this still seem like a good idea @ramya-rao-a ?

@ramya-rao-a
Copy link
Contributor

The event for file save gets fired for one file at a time. Therefore, we won't be falling under the "files not comprising a package" issue. So we should be good to go.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Sep 26, 2018

@jeffb4 If you are working on this, wait a few days till October starts before submitting the PR to win a t-shirt! See https://open.microsoft.com/2018/09/18/hacktoberfest-2018-microsoft/?WT.mc_id=hacktoberfest-twitter-beverst for more details

@brainsnail
Copy link
Contributor

If @jeffb4 isn't working on it. I'd be interested in taking a shot at it.

@ramya-rao-a
Copy link
Contributor

We haven't heard back from @jeffb4, so go ahead @brainsnail.

@brainsnail
Copy link
Contributor

Hey @ramya-rao-a!

I've got something sort-of-working in a branch, but I keep running into "ENOENT: no such file or directory, open '[rootdirectoryofrepo]/.gitmodules' when switching to the file option for lintOnSave. The call stack has the proper linting occurring - I'm declaring a variable and not using it in my Go code, but the lint result isn't it making it back up to the dev instance of VS Code.

I'm not super familiar with the TypeScript / JavaScript workflow, so I apologize if there is an obvious approach to this that I haven't taken yet. Any suggestions?

@ramya-rao-a
Copy link
Contributor

@brainsnail Can you share the link to your branch?

@brainsnail
Copy link
Contributor

@ramya-rao-a Yep, absolutely - https://github.com/brainsnail/vscode-go - I intend to clean up what I added in goLint.ts once I am able to verify the functionality, so this is definitely a WIP.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Oct 3, 2018

cwd is always meant to have the current working directory. Looking at your changes, it has the file path instead when lintOnSave is set to file.

I believe the change should be that lintOnSave is set to file, the file should be passed as an argument. cwd need not be touched.

@ramya-rao-a
Copy link
Contributor

This feature is now out in the latest update to the Go extension (0.6.92). Thanks @brainsnail!

@brainsnail
Copy link
Contributor

Thank you @ramya-rao-a for being so patient and providing guidance as well!

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants