#20095·prettier

Drop support for Babel AST

Author: fiskerCreated Sep 17, 2026Updated Sep 17, 2026
Labelsstatus:needs discussionlang:javascripttype:refactor

Currently, we support both Babel and ESTree AST.

The difference can be found here https://babeljs.io/docs/babel-parser#output

Supporting both AST shapes increases maintenance costs.

For example, ChainExpression was not supported for a long time, it was first transformed to Babel AST.

Later, in https://github.com/prettier/prettier/pull/15806, we skipped ChainExpression everywhere; the approach doesn't end well, and it caused problems.

At last, we brought ChainExpression back in #16471 (issue, fixed in multiple PRs), but added lots of code for different ASTs.

My idea is to drop support for Babel AST in v4. Not doing this in a minor version since we have formatAST, this can break it. We also have babel-flow parser, which is not maintained; we don't want to deal with possible changes to it.

If we decide to remove it completely, it will be easier for us to maintain, and since we already tested '__babel_estree' parser, it shouldn't cause problems.

Even if we still want support Babel AST in formatAST, we can add a layer to transform the Babel AST to ESTree AST; luckily, it's easy to distinguish: in Babel AST the root node is File and Program in ESTree.