Skip to content

Allow fixing a whole file or project#222

Open
antew wants to merge 1 commit intostil4m:masterfrom
antew:feature/fix-all-cli
Open

Allow fixing a whole file or project#222
antew wants to merge 1 commit intostil4m:masterfrom
antew:feature/fix-all-cli

Conversation

@antew
Copy link
Contributor

@antew antew commented Oct 29, 2019

This came about from integration with the language server so that we could have a "Fix all issues in this file" action, it seemed like it would be nice to have in the CLI tool, so I also added some options for that.

  • To fix a single file: elm-analyse --fix src/Main.elm or elm-analyse -f src/Main.elm

fix-file

  • To fix an entire project: elm-analyse --fix-all

fix-all

  • Less verbose logging when running in CLI mode, it now replaces the output of each line for info messages, and prints other messages on newlines. I'm not sure if belongs along with this PR, if you aren't a fan I can remove it :)

When fixing a file it will apply a single fix, then re-analyze the file, and apply the next fix. I tried fixing files from the bottom up, but ran into issues when there were multiple issues on one line, like in an import list with a few unused variables.

- To fix a single file: `elm-analyse --fix src/Main.elm` or `elm-analyse -f src/Main.elm`
- To fix an entire project: `elm-analyse --fix-all`
- Less verbose logging when running in CLI mode, it now replaces the output of each line for info messages, and prints other messages on newlines.

When fixing a file it will apply a single fix, then re-analyze the file, and apply the next fix. I tried fixing files from the bottom up, but ran into issues when there were multiple issues on one line, like in an import list with a few unused variables.

I extracted the quick fixing code out into a separate module
@razzeee
Copy link
Contributor

razzeee commented Jan 3, 2020

Can we move this forward?

@michaeljones
Copy link

My colleague came across the fix-all flag by finding & running the install from his vim/language-server setup. It allowed us to use elm-analyse to quickly fix 600/750 errors we had automatically and was a life-saver for speeding up adoption in the code base.

@antew antew changed the title Allow fixing a while file or project Allow fixing a whole file or project Jan 9, 2020
@maca
Copy link

maca commented Apr 24, 2020

Hi @antew I am confused, I've installed elm-analyse from your branch and neither the --fix or the --fix-all flag seem to have any effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants