← All repositories

prettierprettier

51,664 stars4,662 forksJavaScriptmit0 views
prettier.io

Prettier

Features

  • Extensible ParsersDecouples language-specific parsing logic from the core engine to allow support for multiple programming languages and file types.
  • Parser EnginesA modular architecture that transforms various programming languages into abstract syntax trees to enable uniform style enforcement across different syntaxes.
  • Custom Parser ImplementationsThe formatter supports converting source code into abstract syntax trees using custom logic to support unique file types or specialized language features.
  • In-Place FormattersThe formatter applies formatting changes directly to source files by overwriting the original content to ensure consistent code style across the entire project.
  • Browser FormattingThe formatter enables code string processing in browser environments by loading standalone libraries and language plugins via script tags, module imports, or worker scripts.
  • Indentation SettingsThe formatter allows specifying the number of spaces used for indentation to ensure consistent visual structure across all files in a project.
  • Quote Style ConfigurationsThe formatter allows specifying preferred quote types for strings and automatically adjusts them based on content to maintain clean and readable code.
  • Semicolon Configuration RulesThe formatter provides control over the inclusion of semicolons at the end of statements to ensure consistent syntax and prevent errors.
  • Pretty Printing AlgorithmsTraverses the syntax tree to calculate optimal line breaks and indentation based on a target print width constraint.
  • Formatting ConstraintsThe formatter allows defining a target line length guideline to balance code readability with the constraints of modern development environments and screen sizes.
  • Formatting RulesThe formatter allows enabling or disabling trailing commas in multi-line structures to improve the readability of version control diffs and simplify code maintenance.
  • Ignore DirectivesScans source files for specific comment markers to identify and protect code segments from being modified by the formatter.
  • Code FormattersEliminating manual style debates by automatically reprinting source code to ensure consistent, project-wide visual standards.
  • Formatting VerificationThe formatter provides a verification mode that lists unformatted files and returns specific exit codes to signal success or failure within automated continuous integration pipelines.
  • Source Code FormattersThe formatter provides a core API to format source code strings using specified parser options or by inferring the correct parser from file paths.
  • Continuous Integration Quality ControlsVerifying code style within automated pipelines to ensure that only properly formatted code enters the version control history.
  • Formatting and Linting PipelinesThe formatter supports piping output through both the formatter and linter fix commands to combine style enforcement with automated code correction in one step.
  • Formatting CheckersThe formatter provides a programmatic method to verify whether a source code string is already formatted according to options, returning a boolean result for change detection.
  • Formatting DiagnosticsThe formatter supports reporting formatting discrepancies as linting issues by running the formatter directly within the linting process for immediate feedback.
  • Multi-Language FormattersApplying uniform formatting rules across mixed-language codebases, including embedded content, to maintain a consistent appearance throughout a project.
  • Embedded Code FormattersThe formatter supports loading additional parser plugins to process code embedded within other languages, such as HTML strings inside JavaScript, ensuring consistent style across mixed content.
  • Formatting Rule DefinitionsThe formatter allows defining consistent style guidelines using standard data formats to maintain a uniform appearance across all source files in a project.
  • Configuration ResolutionThe formatter provides a mechanism to resolve configuration settings for specific files by searching directory trees or parsing external configuration files.
  • Configuration Cascade ResolutionsMerges settings from multiple hierarchical files and command-line overrides to determine the final formatting rules for any given file.
  • Configuration Distribution PackagesThe formatter supports distributing shared configuration packages through a registry to make standardized formatting rules available for installation in other projects.
  • Configuration OverridesThe formatter allows applying custom formatting options to specific file subsets or directories to accommodate unique requirements within a larger project structure.
  • Shareable ConfigurationsThe formatter allows installing and referencing shared formatting packages in project files to adopt established team standards while allowing for local overrides.
  • Abstract Syntax Tree TransformationsParses source code into a tree structure, modifies the nodes according to style rules, and reprints the code.
  • Extensible Plugin FrameworksA framework that allows developers to register custom parsers and language support to handle specialized file types or experimental syntax features.
  • Code FormattersA tool that parses source code and reprints it from scratch to enforce a consistent, project-wide visual style.
  • CI Formatting ChecksThe formatter provides utilities for continuous integration pipelines to detect style violations in pull requests and commit necessary fixes automatically.
  • Hierarchical Configuration ResolversA mechanism that resolves hierarchical settings to apply standardized formatting rules while allowing for project-specific overrides and local adjustments.
  • Editor IntegrationsTriggering automatic style fixes directly within text editors on save or via shortcuts to maintain clean code while writing.
  • Cursor Position MappingThe formatter supports mapping cursor positions from unformatted input to the corresponding location in the formatted output, maintaining the user's editing context during the transformation.
  • Formatting AutomationsA set of integrations that trigger automatic code styling during editing, commit, or continuous integration to eliminate manual formatting debates.
  • Pre-commit HooksThe formatter supports running formatting checks on staged files before committing to ensure that only clean and properly styled code enters version control.
  • Editor Formatting IntegrationsThe formatter integrates into text editors and development environments to automatically format source code files according to project-defined style rules during the daily workflow.
  • Vim PluginsThe formatter provides a dedicated Vim plugin that enables manual formatting commands and automatic formatting on file save events within the editor.
  • Incremental Processing CachesStores hashes of file content and configuration to skip redundant processing and improve performance during large-scale formatting tasks.
  • Language Support DefinitionsThe formatter allows registering new languages by specifying the name and the associated parser required to interpret the syntax correctly.
  • Incremental Build CachesThe formatter stores formatting outcomes based on file metadata or content to skip processing unchanged files and accelerate performance during subsequent execution cycles.
  • File Pattern ResolversThe formatter identifies target files for processing by expanding directories and glob patterns while automatically skipping dependency folders and handling special character escaping.
  • Team Configuration StandardsSharing and enforcing unified formatting rules across multiple independent projects to ensure consistent standards across an entire organization.
  • File Metadata InspectionThe formatter provides utilities to determine if a file should be ignored and to identify the appropriate parser based on file paths or URLs.
  • Conflict Resolution StrategiesThe formatter allows disabling conflicting linting rules in configuration files to ensure that formatting rules do not clash with the primary code formatter.