Introduce `Prettier` class
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Motivation:
Currently we save everything, include .originalText, .tokens in options, and pass through all functions.
Idea:
Add Prettier class,
-
Prettier#constructor(text, options):
Save all original input, strip BOM, strip hashbang, strip frontMatter, etc -
Prettier#parse():
get aParseResult, not onlyast, but alsotext(different with originalText, the text actually pass to parser),comments,tokens,parseService,traverse,visitorKeysetc, and save toPrettierinstance. -
Prettier#attachComments():
getAttachedComments, with attach information, stop saving to AST. -
Prettier#format():
async version ofPrettier#formatSync(), replacesPrettier#formatSync()when we are ready to turn everything into async. -
Prettier#formatSync():
same as currentprettier.formatWithCursor, we may consider split it into two stepsast-to-doc,doc-to-text.
Just some basic idea, maybe we can also have Language class
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the current prettier.formatWithCursor flow and how originalText, tokens, and options pass through the parsing and formatting functions. Review the proposed Prettier lifecycle and ParseResult contents, then clarify the design and confirm that the completed work preserves parsing metadata, comment attachment, and sync/async formatting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100