<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>代码风格 on PlumePHP</title><link>https://plumephp.com/tags/%E4%BB%A3%E7%A0%81%E9%A3%8E%E6%A0%BC/</link><description>Recent content in 代码风格 on PlumePHP</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Mon, 28 Sep 2026 13:00:00 +0800</lastBuildDate><atom:link href="https://plumephp.com/tags/%E4%BB%A3%E7%A0%81%E9%A3%8E%E6%A0%BC/index.xml" rel="self" type="application/rss+xml"/><item><title>代码格式化器：AST 感知的格式化架构与工具对比</title><link>https://plumephp.com/others-code-formatter/</link><pubDate>Mon, 28 Sep 2026 13:00:00 +0800</pubDate><guid>https://plumephp.com/others-code-formatter/</guid><description>&lt;h2 id="引言"&gt;引言&lt;/h2&gt;
&lt;p&gt;「你的代码风格和我不同」——这是每个团队都吵过的架。代码格式化器的价值不是「把代码变好看」，而是&lt;strong&gt;用确定性消灭争论&lt;/strong&gt;：格式化器是唯一正确输出，谁都不用再就「缩进几个空格」辩论。本文把格式化器从「配置一下」讲到「懂原理」：先讲格式化的两类架构（文本级 vs AST 级）的差异，再深入 AST 感知格式化的完整流水线（parse → format → print），接着讲打印算法——Prettier 的文档模型（Doc）如何解决「换行决策」，再讲配置与自定义（格式化范围/自定义插件）、格式化与 Lint 的分工、CI 与提交钩子落地，最后对比主流工具（Prettier/Black/gofmt/Rustfmt）的设计哲学与适用场景。&lt;/p&gt;</description></item></channel></rss>