{"id":20316,"library":"prettier-elastic","title":"prettier-elastic","description":"A fork of Prettier (v3.2.5) that customizes formatting for `var`, `let`, and `const` declarations by aligning variable names in multi-declaration statements. It provides an alternative style where commas appear at the start of continuation lines, aligning values vertically. The package supports all Prettier languages (JavaScript, TypeScript, CSS, HTML, etc.) and is maintained by medikoo. It tracks upstream Prettier releases and includes TypeScript type definitions. Key differentiator: solves dissatisfaction with Prettier's default declaration alignment, offering a more tabular format without plugins.","status":"active","version":"3.2.5","language":"javascript","source_language":"en","source_url":"https://github.com/medikoo/prettier-elastic","tags":["javascript","typescript"],"install":[{"cmd":"npm install prettier-elastic","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-elastic","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-elastic","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import is recommended; the package also supports CommonJS. The format function is the same API as Prettier.","wrong":"const prettier = require('prettier-elastic'); prettier.format(src, opts);","symbol":"format","correct":"import { format } from 'prettier-elastic'"},{"note":"check function returns a boolean; use with --check CLI flag.","wrong":"const { check } = require('prettier-elastic');","symbol":"check","correct":"import { check } from 'prettier-elastic'"},{"note":"Default export is an object with format, check, resolveConfig, etc. ESM default import works.","wrong":"const prettier = require('prettier-elastic');","symbol":"default (package)","correct":"import prettier from 'prettier-elastic'"},{"note":"Available in both ESM and CJS; same as upstream.","wrong":"","symbol":"formatWithCursor","correct":"import { formatWithCursor } from 'prettier-elastic'"},{"note":"Async function; works identically to Prettier's resolveConfig.","wrong":"const { resolveConfig } = require('prettier-elastic');","symbol":"resolveConfig","correct":"import { resolveConfig } from 'prettier-elastic'"}],"quickstart":{"code":"import { format } from 'prettier-elastic';\n\nconst code = `var eloBar = require(\"elo-bar\"),\n  foo = require(\"foo\"),\n  otherThing = require(\"other-thing\");`;\n\nconst formatted = format(code, { parser: 'babel' });\nconsole.log(formatted);\n// Output:\n// var eloBar     = require(\"elo-bar\")\n//   , foo        = require(\"foo\")\n//   , otherThing = require(\"other-thing\");","lang":"typescript","description":"Demonstrates the core formatting difference: var declarations with aligned equals and comma-first line continuation."},"warnings":[{"fix":"Do not use this if standard Prettier behavior is required. Alternatively, use 'prettier' package and configure plugins.","message":"This is a fork with different output than standard Prettier for var/let/const multi-declarations.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use 'tabWidth' and 'useTabs' in your prettier config instead of --use-tabs.","message":"Deprecated '--use-tabs' option may behave differently; prefer 'tabWidth' and 'useTabs' config.","severity":"deprecated","affected_versions":"<3.0.0"},{"fix":"Run: npm install prettier-elastic and import from 'prettier-elastic'.","message":"The package name is 'prettier-elastic', not 'prettier'. Installing the wrong package will not give the custom formatting.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Verify behavior against expected Prettier version via tests.","message":"Version numbers do not necessarily match upstream Prettier; check changelog for exact mapping.","severity":"gotcha","affected_versions":">=3.0.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 prettier-elastic. Then import correctly: import { format } from 'prettier-elastic'.","cause":"Package not installed or wrong import path in ESM.","error":"Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'prettier-elastic'"},{"fix":"Use: const prettier = require('prettier-elastic'); correctly exports format as a method.","cause":"Using default import incorrectly in CommonJS.","error":"TypeError: prettier.format is not a function"},{"fix":"Add 'type': 'module' to package.json, or use require() syntax.","cause":"Using ESM import in a CommonJS file without 'type': 'module'.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Ensure @babel/parser is installed, or use parser: 'babel' which is built-in.","cause":"Plugin resolution issue; likely missing parser dependencies.","error":"Error: Cannot find module './parser-babel'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}