woldner / VisualLinter

Visual Studio Linter using ESLint.
MIT License
25 stars 3 forks source link

Add option to autofix issues on save #37

Closed bpugh closed 5 years ago

bpugh commented 6 years ago

Installed product versions

Description

The eslint extension for VS Code has an option to run eslint with the --fix parameter on save which will automatically fix any fixable issues in the current file. If this is feasible to implement it would be really nice to have this option in VisualLinter. Thoughts?

Thanks for the great extension!

woldner commented 6 years ago

Hi @bpugh and thanks for the feedback!

This is something I've been meaning to implement sometime soon. It is even listed in the CHANGELOG.md. However It is not as easy to implement as one would think, having to replace the text in the buffer and not mess up Visual Studio features can prove quite difficult.

But since this now has been requested I'll have to take a look, wont I? 😄 I'll keep this issue open and update here when I've reached a conclusion!

giolvani commented 5 years ago

It would be really useful...

I saw in another extension "Format document On Save" that it allows setting a command after saving file, but I was not able to use the eslint on that.

poganytamas commented 5 years ago

Any news on implementing this feature?

cymptom commented 5 years ago

As @giolvani said, the Format Document On Save extension allows you to specify a VS Command to be run on save. So, if it makes it simpler to implement, VisualLinter might only need to expose a VS Command for running ESLint on the active file.

There is a workaround for doing this now, but it's not pretty. It involves configuring a custom VS Command via "External Tools" -- something like this: cmd.exe /c node $(ProjectDir)/node_modules/eslint/bin/eslint.js $(ItemPath) --fix

Then you can have Format Document On Save target that VS Command.

It would be much nicer if VisualLinter registered a command to that effect in VS.

woldner commented 5 years ago

Sorry everyone; but the development of this extension has been suspended. You can read more about it here: https://github.com/jwldnr/VisualLinter#deprecated