- What is Prettier?
- Install
- Why Prettier?
- Prettier vs. Linters
- Option Philosophy
- Rationale
- CLI
- API
- Browser
- Plugins (Beta)
- Pre-commit Hook
- Watching For Changes
- Integrating with Linters
- Ignoring Code
- Options
- Configuration File
- Editor Integration
- WebStorm Setup
- Vim Setup
- Technical Details
- Related Projects
Technical Details
This printer is a fork of recast's printer with its algorithm replaced by the one described by Wadler in "A prettier printer". There still may be leftover code from recast that needs to be cleaned up.
The basic idea is that the printer takes an AST and returns an intermediate representation of the output, and the printer uses that to generate a string. The advantage is that the printer can "measure" the IR and see if the output is going to fit on a line, and break if not.
This means that most of the logic of printing an AST involves generating an abstract representation of the output involving certain commands. For example, concat(["(", line, arg, line ")"])
would represent a concatenation of opening parens, an argument, and closing parens. But if that doesn't fit on one line, the printer can break where line
is specified.
More (rough) details can be found in commands.md.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论