Format Code Action
Run eslint extension after the prettier extension in VS Code. Or the other way around, whatever way you want.
Requires VS Code 1.44+
formatOnSave and use the
source.fixAll.format codeAction in whatever order you want with VS Code settings:
This runs 'Format Document' with the default formatter (in this case prettier).
Or for specific lanuage only:
"editor.codeActionsOnSave": ["source.fixAll.format", "source.fixAll.eslint"]
I created this so I could use prettier and eslint together in the editor, in a specific order (eslint after prettier). Earlier prettier was setup to run on save and eslint as a codeAction with:
This would often lead to prettier being run after eslint and eslint errors still being present.
Since the March 2020 (v1.44) update, VS Code allows setting
codeActionsOnSave as an array. This allows setting the order of the codeActions.
The extension uses the
CodeActionProvider api to implement a simple code action that runs 'Format Document' on the current file. This allows us to disable
formatOnSave and use it as a codeAction instead in a specific order with other extensions.
VS Code API
Based on Microsoft's code-actions-sample
formatting by Danil Polshin from the Noun Project.