deterministic code formatting with ast-based reprinting
Parses source code into an abstract syntax tree (AST) and re-prints it according to fixed formatting rules, ensuring consistent style across JavaScript, TypeScript, CSS, HTML, JSON, Markdown, and GraphQL. Unlike regex-based formatters, this approach preserves code semantics while enforcing maximum line length constraints, indentation, spacing, and bracket placement through a unified rule engine that applies identically across all supported languages.
Unique: Uses language-specific parsers and a unified printing algorithm that re-renders code from AST rather than applying regex transformations, ensuring structural correctness and consistent output across 8+ languages without special-case rules per language
vs alternatives: More reliable than ESLint/Prettier combinations because it separates formatting (Prettier) from linting (ESLint), avoiding rule conflicts and ensuring deterministic output that doesn't vary based on code patterns
vs code formatter pipeline integration with automatic save triggering
Integrates into VS Code's native formatter API as the designated `editor.defaultFormatter` for specified languages, enabling automatic code formatting on file save when `editor.formatOnSave` is enabled. The extension hooks into VS Code's document save lifecycle, intercepts the save event, invokes Prettier's formatting engine on the file content, and writes the formatted result back to the editor buffer without requiring manual command invocation.
Unique: Leverages VS Code's native `editor.defaultFormatter` API and document save lifecycle hooks rather than implementing a custom command palette or sidebar UI, making it seamless within the standard editor workflow with zero additional UI overhead
vs alternatives: More transparent than manual formatting commands because it operates silently on save, whereas competitors like Prettier CLI require explicit invocation or pre-commit hook setup
semicolon insertion and removal with language-aware rules
Automatically inserts or removes semicolons at statement ends based on a configurable setting (`semi` option, default: true). The formatter uses AST analysis to determine where semicolons are syntactically required or optional, avoiding incorrect removal in edge cases (e.g., statements starting with `[` or `(`). Language-specific rules apply (e.g., CSS and JSON have different semicolon conventions than JavaScript).
Unique: Uses AST analysis to safely insert or remove semicolons while respecting language conventions and avoiding ASI (Automatic Semicolon Insertion) bugs. Handles edge cases where semicolon removal could break code.
vs alternatives: More reliable than regex-based semicolon removal (respects syntax); more flexible than formatters with fixed semicolon rules; prevents ASI-related bugs that manual formatting might miss.
indentation normalization with configurable tab width and style
Normalizes indentation across code by enforcing a consistent tab width (default: 2 spaces, configurable via `tabWidth` setting) and indentation style (spaces or tabs, configurable via `useTabs` setting). The formatter re-indents all nested code blocks, function arguments, and multi-line expressions to match the configured style, eliminating mixed indentation and inconsistent nesting levels.
Unique: Normalizes indentation across all code blocks and nested structures using configurable tab width and style (spaces or tabs). Applies consistent indentation to function arguments, multi-line expressions, and nested blocks.
vs alternatives: More comprehensive than formatters that only fix top-level indentation; more flexible than formatters with fixed indentation rules; eliminates mixed indentation without manual cleanup.
trailing comma insertion and removal with language-specific rules
Automatically inserts or removes trailing commas in multi-line arrays, objects, function parameters, and imports based on a configurable setting (`trailingComma` option with values: `none`, `es5`, `all`). The formatter uses AST analysis to identify multi-line structures and applies language-specific rules (e.g., trailing commas are valid in modern JavaScript but not in older versions). This reduces diff noise in version control and prevents syntax errors when adding new items.
Unique: Uses AST analysis to identify multi-line structures and apply language-specific trailing comma rules. Supports three modes (`none`, `es5`, `all`) to accommodate different JavaScript versions and team preferences.
vs alternatives: More intelligent than regex-based comma insertion (respects syntax); more flexible than formatters with fixed trailing comma rules; reduces version control diff noise compared to no trailing commas.
bracket spacing and object literal formatting
Automatically normalizes spacing around brackets and braces in object literals, imports, and destructuring assignments based on configurable settings (`bracketSpacing` for `{ }` spacing, `bracketSameLine` for closing bracket placement). The formatter ensures consistent spacing (e.g., `{ foo: 'bar' }` vs `{foo: 'bar'}`) and places closing brackets on the same line or new line based on configuration. This eliminates spacing inconsistencies in object-heavy code.
Unique: Normalizes spacing around brackets and braces in object literals, imports, and destructuring with configurable spacing and placement rules. Applies consistent formatting across all bracket-heavy code.
vs alternatives: More flexible than formatters with fixed bracket spacing rules; more consistent than manual formatting; eliminates spacing-related code review comments.
multi-version prettier resolution with local-first precedence
Implements a three-tier version resolution strategy that prioritizes local project installations of Prettier (in `node_modules/prettier`), falls back to globally installed modules if `prettier.resolveGlobalModules` is enabled, and finally uses a bundled Prettier 3.x as a last-resort fallback. This approach ensures projects can pin specific Prettier versions in `package.json` while allowing developers to use global installations for consistency across projects, with transparent version detection and reporting.
Unique: Implements explicit three-tier precedence (local > global > bundled) with configurable global resolution opt-in, allowing projects to enforce version pinning while developers retain flexibility, rather than always using a single bundled version like some competitors
vs alternatives: More flexible than formatters that only use bundled versions because it respects project-level version pinning, enabling teams to enforce specific Prettier versions without requiring pre-commit hooks or CI/CD validation
project configuration file discovery and application
Automatically discovers and applies Prettier configuration from project-level files (`.prettierrc`, `.prettierrc.json`, `.prettierrc.yaml`, `prettier.config.js`, or `package.json` with `prettier` key) without requiring manual configuration in VS Code settings. The extension uses Prettier's native configuration resolution algorithm, which searches from the current file's directory up the directory tree until a configuration file is found, enabling per-project formatting rules that apply consistently across all team members.
Unique: Delegates configuration discovery to Prettier's native algorithm rather than implementing custom VS Code settings parsing, ensuring configuration behavior matches Prettier CLI and other tools, with automatic directory traversal to find nearest configuration file
vs alternatives: More maintainable than storing formatting rules in VS Code workspace settings because configuration lives in version control and applies consistently across all tools (CLI, CI/CD, editors) that use Prettier
+6 more capabilities