Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run eslint --fix AFTER prettier on save #1277

Closed
protoEvangelion opened this issue Mar 25, 2020 · 4 comments
Closed

Run eslint --fix AFTER prettier on save #1277

protoEvangelion opened this issue Mar 25, 2020 · 4 comments
Labels
locked Please open a new issue and fill out the template instead of commenting.

Comments

@protoEvangelion
Copy link

Describe the solution you'd like
Due to company constraints, I'd like to run eslint --fix AFTER this extension runs Prettier.

Now that the prettier eslint integration is deprecated, is there a recommended way to do this? It looks like this has been brought up in the past: #14

Describe alternatives you've considered
I'm using this configuration, however it runs eslint FIRST & then Prettier:

"editor.codeActionsOnSave": {
    "source.fixAll": true,
    "source.fixAll.eslint": true
  },
@ntotten
Copy link
Member

ntotten commented Apr 3, 2020

Unfortunately, this is not possible. The order of operations is controlled by VS Code and formatting is not exposed as a code action. There are multiple issues in vscode about this and hopefully they will resolve soon. One example is here: microsoft/vscode#90220

@ntotten ntotten closed this as completed Apr 3, 2020
@rohit-gohri
Copy link

The march VS Code update allows specifying an array to order codeActionsOnSave: https://code.visualstudio.com/updates/v1_44#_explicit-ordering-for-code-actions-on-save

@rohit-gohri
Copy link

rohit-gohri commented Apr 29, 2020

The march VS Code update allows specifying an array to order codeActionsOnSave: https://code.visualstudio.com/updates/v1_44#_explicit-ordering-for-code-actions-on-save

So this and #870 (comment) gave me an idea for an extension, what if we could run 'Format Document' as a codeActionOnSave?

Checkout https://github.com/rohit-gohri/vscode-format-code-action/

This registers a custom codeAction: source.fixAll.format, which we can use instead of formatOnSave. It'll use whatever default formatter you have setup.

I'm running eslint after prettier with these settings:

  "editor.formatOnSave": false,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.codeActionsOnSave": [
    "source.fixAll.format",
    "source.fixAll.eslint"
  ]

and these extensions:

[
    "esbenp.prettier-vscode",
    "dbaeumer.vscode-eslint",
    "rohit-gohri.format-code-action"
]

I hope this helps anyone coming here.

Might help in #716 and microsoft/vscode#87096 too

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Jul 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

3 participants