Add optional eslint --fix after prettier #31
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is my proposal to support optional eslint --fix on .js and .jsx files (would be possible .ts and .tsx as well) after applying prettier.
I've been looking for a solution, like prettier-eslint but supporting hooks (I don't find it entirely useful running it only manually) and I didn't find anything that meet my needs.
How to use:
Note: adding --staged is how I find it more useful
This implementation uses eslint CLIEngine API to get the eslint configuration on every js file, and the apply possible fixes. So simple, no messing options, it takes the current eslint config and goes on.
In my case, I love prettier and standard style guide, so I use prettier for every file and after that, just for js ones, I prefer to run the eslint fixer with standard configuration. This became the straightforward solution.
All current tests are passing after my modifications, but I had not enough time to write new ones.
This is a first commit, so if you consider it a useful improvement and its approach I'll take the time to write its tests and refactoring if needed. Otherwise, I'll be maintaining my own fork up to date, cos I find this a very useful tool when working on a team.
I think this could be related to an open issue, but as I'm not sure I'll wait to reference it.