babel-plugin-transform-beautifier

raw JSON →
0.1.1 verified Sat Apr 25 auth: no javascript deprecated

A Babel plugin (v0.1.1) that transforms JavaScript conditional expressions (ternary, logical AND/OR) into if/else statements for improved readability. It is a niche tool focused solely on beautifying ternaries, with no updates since 2021 and low maintenance. Unlike general formatters (Prettier) or codemods (jscodeshift), it performs a specific AST transformation. Intended for build-time use in Babel pipelines.

error Error: Cannot find module 'babel-plugin-transform-beautifier'
cause Package not installed or missing from node_modules.
fix
Run 'npm install --save-dev babel-plugin-transform-beautifier' and check your babel config plugin name.
error Plugin threw: 'babel-plugin-transform-beautifier' is not a valid plugin
cause Using incorrect import syntax or missing plugin name as string.
fix
In babel.config.js, use plugins: ['babel-plugin-transform-beautifier'] (string, not a function or variable).
deprecated Package is unmaintained since 2021. No support for modern Babel (v7.20+). Check for compatibility with your Babel version.
fix Use an alternative like manual refactoring or a custom codemod.
gotcha Only transforms ternary expressions and logical AND/OR in conditional context. Does not beautify other patterns like nested ternaries or switch statements.
fix Review transformed output manually; expected beautification may not apply.
gotcha Plugin may conflict with other Babel plugins that manipulate AST or formatting (e.g., minifiers, other transforms).
fix Ensure plugin order and test output with other plugins in pipeline.
npm install babel-plugin-transform-beautifier
yarn add babel-plugin-transform-beautifier
pnpm add babel-plugin-transform-beautifier

Shows how to install and configure the plugin in a Babel config file to beautify ternaries.

// Install: npm i --save-dev babel-plugin-transform-beautifier
// babel.config.js
module.exports = {
  plugins: ['babel-plugin-transform-beautifier']
}