Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add autofixing #2467
This builds off of #2427, but I thought it would be cleaner and a little easier for me to create a new PR, modifying things as I copy over changes, instead of adding another commit over there. Much of these changes are lifted from that PR and slightly modified.
This illustrates a way I think we could go about implementing autofixing. Here are the key elements:
I tried via the CLI in a little local real-life test case, too, and it seemed to work!
What do you think @stylelint/core? Does this seem like a promising start? Please try it locally and give it some serious scrutiny.
After we all agree on our methodology, we should also try it out in an editor plugin, probably Atom, to ensure that the way we're doing it will work in that context.
I like how you've revamped my proposal. I like how writing fixed files works from CLI and API. Your approach to test rules is what I had in mind, but didn't do :) It's great that you've added more necessary system tests.
Looks too good to be true :)
Very much so!
I think the simplicity of the changes to the rule code and tests is a big win here. It lowers the barrier to contributing autofixing PRs.
Locally it worked great.
This route is looking very promising. The only thing that springs to mind is have we considered how two rules changing the same piece of CSS will work i.e. the "waves" approach in the automutate PoC?
How rules are working currently? One by one or in parallel? If one by one, then there is no problem. If in parallel, then there could be some problems. I don't know if two PostCSS plugins could work simultaneously on one AST.
If rules works in parallel, then we could force them in sync mode if fix enabled, to be safe.
I was looking to ESLint docs and found interesting thing about --fix:
I think we should also disable autofixing in these situations.
Apr 13, 2017
I've merged it. Thank you, everyone! This feature is awesome! Don't release
Added to changelog:
@jeddy3 could you, please, change changelog if necessary?