Registry / web-framework / prettier-plugin-brace-style

prettier-plugin-brace-style

JSON →
library0.10.1jsnpmunverified

A Prettier plugin that applies ESLint's brace-style rules (1tbs, stroustrup, allman) to code formatting. Current stable version is 0.10.1, released on 2025-04-02. It supports JavaScript, TypeScript, JSX, TSX, Flow, CSS, SCSS, Less, Vue, Svelte, Angular, and HTML via Prettier's parsers. It requires Prettier >=3 and Node >=18. Key differentiators: directly enforces brace style as a Prettier plugin, works across multiple languages, and can be combined with other plugins using prettier-plugin-merge. It uses @prettier/plugin-oxc for oxc parser support, and optionally integrates with prettier-plugin-astro and prettier-plugin-svelte for those frameworks.

npm install prettier-plugin-brace-style
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-BR
P
prettier-plugin-brace-style
web-frameworkjavascriptv0.10.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
// In .prettierrc.js or .prettierrc.cjs (CommonJS): module.exports = { plugins: ['prettier-plugin-brace-style'], braceStyle: 'stroustrup' };
const braceStylePlugin = require('prettier-plugin-brace-style'); // Do not import the plugin as a module; it's auto-loaded via plugins config.
The plugin is not imported directly; it's loaded by Prettier via the plugins array in the config file.
braceStyle option
// In .prettierrc.mjs (ESM): export default { plugins: ['prettier-plugin-brace-style'], braceStyle: 'allman' };
import { braceStyle } from 'prettier-plugin-brace-style'; // This is not an export; it's a config option string.
braceStyle is a top-level option in the Prettier config, not an imported symbol.
type: import
// In a TypeScript config file (e.g., prettier.config.ts): import type { Config } from 'prettier'; const config: Config = { plugins: ['prettier-plugin-brace-style'], braceStyle: '1tbs' }; export default config;
import PrettierPluginBraceStyle from 'prettier-plugin-brace-style'; // The plugin has no default export for direct use.
The plugin only provides a Prettier plugin object; it is not meant to be imported in application code.

Demonstrates installation, configuration with braceStyle option, and formatting a JavaScript file. Shows how the plugin transforms code to the 'stroustrup' style.

// 1. Install: // npm install -D prettier prettier-plugin-brace-style // 2. Create .prettierrc.cjs (CommonJS): module.exports = { plugins: ['prettier-plugin-brace-style'], braceStyle: 'stroustrup' // Options: '1tbs' (default), 'stroustrup', 'allman' }; // 3. Create test.js: function foo() { if (condition) { console.log('hello'); } else { console.log('world'); } } // 4. Run: npx prettier --write test.js // Output with 'stroustrup': // function foo() { // if (condition) { // console.log('hello'); // } // else { // console.log('world'); // } // }
Debug
Known issues
breakingVersion 0.8.0 dropped support for Prettier v2 and Node <18. If you are on Prettier v2 or Node 16, upgrading will break your setup.
fix
Upgrade to Prettier >=3.0.0 and Node >=18. For legacy projects, stay on v0.7.x (which supports Prettier v2).
affects: >=0.8.0
deprecatedFor versions <0.5.0, you needed to install @prettier/sync as a dependency. This is no longer required.
fix
If using v0.4.x or earlier, remove @prettier/sync and upgrade the plugin. Or better, upgrade to the latest version.
affects: <0.5.0
gotchaIf multiple Prettier plugins handle the same file type, only the last plugin in the plugins array is used. This can cause brace style not to be applied if another plugin takes precedence.
fix
Add 'prettier-plugin-merge' as the last plugin in the list to apply plugins sequentially. See the README for an example.
affects: all
gotchaMarkdown and MDX files are not supported by this plugin, but it may still affect code blocks inside them if a supported language is detected. This can cause unintended formatting.
fix
Use Prettier overrides to disable the plugin for Markdown and MDX files, as shown in the README.
affects: all
gotchaThe plugin relies on @prettier/plugin-oxc as an optional peer dependency for oxc parser support. If not installed, it may fall back to a slower parser or produce different results.
fix
Install @prettier/plugin-oxc to ensure optimal performance and consistency: npm install -D @prettier/plugin-oxc
affects: >=0.9.0
gotchaWhen using the plugin with TypeScript, the enum syntax is only fully supported with Prettier >=3.6.
fix
If using enum declarations, ensure Prettier is updated to v3.6 or later.
affects: >=0.9.0
Errors
Common errors & fixes
Cannot find module 'prettier-plugin-brace-style'
The plugin is not installed or not in node_modules.
fix
Run: npm install -D prettier-plugin-brace-style (or yarn add --dev prettier-plugin-brace-style)
Error: The "braceStyle" option is not supported by Prettier
The plugin is not loaded because it is not listed in the plugins array.
fix
Add 'prettier-plugin-brace-style' to the plugins array in your Prettier config: { plugins: ['prettier-plugin-brace-style'] }
TypeError: Cannot read properties of undefined (reading 'name')
A transition from Prettier v2 to v3 or a misconfiguration with other plugins.
fix
Ensure Prettier >=3 is installed. If the issue persists, check that the plugin is listed after other conflicting plugins in the plugins array.
Error: [prettier-plugin-brace-style] Unsupported parser for file
The file uses a language/parser not supported by the plugin.
fix
Check supported parsers: babel, typescript, flow, espree, meriyah, css (including SCSS/Less), vue, svelte, angular, html, or use overrides to exclude unsupported files.
Upgrade
Version history
0.10.1latest on npm
Audit
Dependencies
@prettier/plugin-oxcoptionalOptional peer dependency used for oxc parser support (parses JavaScript/TypeScript faster).
prettierrequiredRequired peer dependency; the plugin works with Prettier v3 only (v0.8.0 dropped v2 support).
prettier-plugin-astrooptionalOptional peer dependency for formatting Astro files with brace style.
prettier-plugin-svelteoptionalOptional peer dependency for formatting Svelte files with brace style.
Agent activity
4 hits · last 30 days
node
4
Resources
prettier-plugin-brace-style — npm install prettier-plugin-brace-style · libregistry