Allow plugins to do range formatting #7639
Labels
area:api
Issues with Prettier's Application Programming Interface
area:plugin api
area:ranges
Issues about formatting/ignoring/etc segments of files
status:needs discussion
Issues needing discussion and a decision to be made before action can be taken
type:enhancement
A potential new feature to be added, or an improvement to how we print something
Environments:
Steps to reproduce:
Currently a Prettier plugin cannot do range formatting correctly, because Prettier core hard codes a list of parsers for
isSourceElement
here, which is used as a predicate for finding the start and end nodes that contain the range - see here.Expected behavior:
Prettier should let its plugins set their own
isSourceElement
or the predicate, so that range formatting can be done by plugins.Actual behavior:
The current predicate always returns
false
, which means that range formatting does not happen for custom parsers.I can open a PR to add this functionality, but I want to check if there's a better solution than I'm not aware of before doing so.
Thank you!
The text was updated successfully, but these errors were encountered: