{"id":20342,"library":"prettier-plugin-brace-style","title":"prettier-plugin-brace-style","description":"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.","status":"active","version":"0.10.1","language":"javascript","source_language":"en","source_url":"https://github.com/ony3000/prettier-plugin-brace-style","tags":["javascript","prettier","plugin","brace","style","eslint","stylistic","brace-style","1tbs"],"install":[{"cmd":"npm install prettier-plugin-brace-style","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-plugin-brace-style","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-plugin-brace-style","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Optional peer dependency used for oxc parser support (parses JavaScript/TypeScript faster).","package":"@prettier/plugin-oxc","optional":true},{"reason":"Required peer dependency; the plugin works with Prettier v3 only (v0.8.0 dropped v2 support).","package":"prettier","optional":false},{"reason":"Optional peer dependency for formatting Astro files with brace style.","package":"prettier-plugin-astro","optional":true},{"reason":"Optional peer dependency for formatting Svelte files with brace style.","package":"prettier-plugin-svelte","optional":true}],"imports":[{"note":"The plugin is not imported directly; it's loaded by Prettier via the plugins array in the config file.","wrong":"const braceStylePlugin = require('prettier-plugin-brace-style');\n// Do not import the plugin as a module; it's auto-loaded via plugins config.","symbol":"default","correct":"// In .prettierrc.js or .prettierrc.cjs (CommonJS):\nmodule.exports = { plugins: ['prettier-plugin-brace-style'], braceStyle: 'stroustrup' };"},{"note":"braceStyle is a top-level option in the Prettier config, not an imported symbol.","wrong":"import { braceStyle } from 'prettier-plugin-brace-style'; // This is not an export; it's a config option string.","symbol":"braceStyle option","correct":"// In .prettierrc.mjs (ESM):\nexport default { plugins: ['prettier-plugin-brace-style'], braceStyle: 'allman' };"},{"note":"The plugin only provides a Prettier plugin object; it is not meant to be imported in application code.","wrong":"import PrettierPluginBraceStyle from 'prettier-plugin-brace-style'; // The plugin has no default export for direct use.","symbol":"type: import","correct":"// In a TypeScript config file (e.g., prettier.config.ts):\nimport type { Config } from 'prettier';\nconst config: Config = { plugins: ['prettier-plugin-brace-style'], braceStyle: '1tbs' };\nexport default config;"}],"quickstart":{"code":"// 1. Install:\n// npm install -D prettier prettier-plugin-brace-style\n\n// 2. Create .prettierrc.cjs (CommonJS):\nmodule.exports = {\n  plugins: ['prettier-plugin-brace-style'],\n  braceStyle: 'stroustrup'  // Options: '1tbs' (default), 'stroustrup', 'allman'\n};\n\n// 3. Create test.js:\nfunction foo() {\n  if (condition) {\n    console.log('hello');\n  } else {\n    console.log('world');\n  }\n}\n\n// 4. Run: npx prettier --write test.js\n// Output with 'stroustrup':\n// function foo() {\n//   if (condition) {\n//     console.log('hello');\n//   }\n//   else {\n//     console.log('world');\n//   }\n// }","lang":"javascript","description":"Demonstrates installation, configuration with braceStyle option, and formatting a JavaScript file. Shows how the plugin transforms code to the 'stroustrup' style."},"warnings":[{"fix":"Upgrade to Prettier >=3.0.0 and Node >=18. For legacy projects, stay on v0.7.x (which supports Prettier v2).","message":"Version 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.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"If using v0.4.x or earlier, remove @prettier/sync and upgrade the plugin. Or better, upgrade to the latest version.","message":"For versions <0.5.0, you needed to install @prettier/sync as a dependency. This is no longer required.","severity":"deprecated","affected_versions":"<0.5.0"},{"fix":"Add 'prettier-plugin-merge' as the last plugin in the list to apply plugins sequentially. See the README for an example.","message":"If 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use Prettier overrides to disable the plugin for Markdown and MDX files, as shown in the README.","message":"Markdown 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Install @prettier/plugin-oxc to ensure optimal performance and consistency: npm install -D @prettier/plugin-oxc","message":"The 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.","severity":"gotcha","affected_versions":">=0.9.0"},{"fix":"If using enum declarations, ensure Prettier is updated to v3.6 or later.","message":"When using the plugin with TypeScript, the enum syntax is only fully supported with Prettier >=3.6.","severity":"gotcha","affected_versions":">=0.9.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run: npm install -D prettier-plugin-brace-style (or yarn add --dev prettier-plugin-brace-style)","cause":"The plugin is not installed or not in node_modules.","error":"Cannot find module 'prettier-plugin-brace-style'"},{"fix":"Add 'prettier-plugin-brace-style' to the plugins array in your Prettier config: { plugins: ['prettier-plugin-brace-style'] }","cause":"The plugin is not loaded because it is not listed in the plugins array.","error":"Error: The \"braceStyle\" option is not supported by Prettier"},{"fix":"Ensure Prettier >=3 is installed. If the issue persists, check that the plugin is listed after other conflicting plugins in the plugins array.","cause":"A transition from Prettier v2 to v3 or a misconfiguration with other plugins.","error":"TypeError: Cannot read properties of undefined (reading 'name')","affected_versions":">=0.8.0"},{"fix":"Check supported parsers: babel, typescript, flow, espree, meriyah, css (including SCSS/Less), vue, svelte, angular, html, or use overrides to exclude unsupported files.","cause":"The file uses a language/parser not supported by the plugin.","error":"Error: [prettier-plugin-brace-style] Unsupported parser for file"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}