Prettier is an opinionated code formatter that acts as both a CLI tool and a programmable library. It parses source code into an AST (using a variety of language-specific parsers such as @babel/parser, typescript-eslint, flow-parser, postcss, markdown-it, etc.), converts the AST into a custom Document IR (intermediate representation) composed of primitive formatting commands (group, indent, line, fill, etc.), and then prints the Document IR into a formatted string. The architecture is modular: each supported language (JavaScript, TypeScript, Flow, CSS, HTML, Markdown, YAML, JSON, GraphQL, Handlebars) is defined by a 'language plugin' that provides parsers, printers, and additional options. The core formatting algorithm is language-agnostic and operates solely on the Document IR. Key entry points are the CLI (bin/prettier.cjs) and the JavaScript API (src/index.js). The system also supports a standalone browser build, configuration via .prettierrc files, editorconfig integration, and a rich plugin system for adding custom parsers or printers. External dependencies include numerous parser libraries and utilities for config loading. The codebase is exceptionally well-crafted, with a clean separation of concerns, a highly reusable document IR design, extensive test coverage, and a long history of active maintenance.
Black is the uncompromising Python code formatter. It is a CLI tool that automatically reformats Python source code to a consistent style, with a focus on determinism and minimal configuration. The repository contains the core formatting engine, a HTTP server (blackd) for on-demand formatting, a GitHub Action for CI integration, and a Vim plugin. The architecture is modular: parsing uses a forked lib2to3 parser (blib2to3) for lenient syntax handling, then a visitor-based line generator produces formatted lines, with specialized transformers for strings, brackets, and comments. It supports Jupyter notebooks, line-range formatting, caching, and parallel execution. The codebase is exceptionally well-tested with hundreds of edge-case test files and a comprehensive test suite. It demonstrates high craftsmanship in areas like tree manipulation, concurrency patterns, and string normalization.
This repository is the primary implementation of the Sway programming language and its toolchain, targeting the Fuel blockchain. It contains a full compiler pipeline (lexer, parser, AST, semantic analysis, IR with optimization passes, and code generation for the FuelVM), a package manager CLI (`forc`), a language server (`sway-lsp`), a code formatter (`swayfmt`), a debugger (`forc-debug`), a documentation generator (`forc-doc`), and a migration tool (`forc-migrate`). The standard library (`sway-lib-std`) provides essential blockchain primitives (assets, storage, crypto, etc.). The architecture is modular, with separate crates for the AST (`sway-ast`), IR (`sway-ir`), parsing (`sway-parse`), core compiler logic (`sway-core`), and error handling (`sway-error`). In production, developers use `forc` to build, test, and deploy Sway smart contracts, scripts, and predicates to the Fuel network. The LSP provides IDE features like completions, go-to-definition, and inlay hints. The formatter ensures consistent code style. The debugger enables step-through debugging of on-chain logic. The compiler supports multiple backends (FuelVM primary, EVM experimental) and includes advanced optimizations such as constant folding, dead code elimination, common subexpression elimination, and register allocation. Key entry points include `forc/src/main.rs` (CLI dispatcher), `sway-core/src/lib.rs` (compiler core), `sway-lsp/src/server.rs` (LSP server), and `swayfmt/src/lib.rs` (formatter). External dependencies include the Fuel protocol libraries (`fuel-core`, `fuel-vm`, `fuels-rs`), IPFS for package resolution, and standard Rust ecosystem crates. The repository is production-grade with extensive end-to-end tests, benchmarking infrastructure, and CI workflows.
Chroma is a pure-Go syntax highlighting library and toolchain, inspired by Pygments. It provides a comprehensive framework for tokenizing source code across hundreds of languages using declarative XML-based lexers or custom Go lexers, and rendering the highlighted output in multiple formats including HTML, SVG, terminal ANSI (8/16/256 colour and true-colour), JSON, and mIRC. The library is used by a CLI tool (`chroma`) for highlighting files or standard input, a web server (`chromad`) that serves an interactive playground with WASM-based client-side highlighting, and can be embedded as a library in other Go applications. Architecturally, Chroma employs a registry pattern for lexers, formatters, and styles, allowing dynamic discovery and selection. Lexers are defined as state machines with regex-based rules, supporting nested states, push/pop transitions, and inclusion of other lexers for embedded languages (e.g., PHP in HTML). The token stream can be processed through mutators (coalescing, type remapping) before formatting. Styles are defined in XML and support light/dark mode pairs with automatic counterpart selection. Key entry points include the `quick.Quick.Highlight()` convenience function, the CLI in `cmd/chroma/main.go`, the web server in `cmd/chromad/main.go`, and the WASM module in `cmd/libchromawasm/main.go`. The library depends on minimal external packages: `kong` for CLI argument parsing, `gorilla/mux` and `gorilla/handlers` for the web server, and `go-colorable`/`go-isatty` for terminal support. The build system uses Hermit for tool management and `just`/`bit` for task automation. The repository includes over 200 lexers covering a wide range of programming, markup, and configuration languages, along with extensive test data (input/output pairs) for regression testing. The XML-based lexer definitions can be generated from Pygments lexers using provided Python scripts, facilitating easy addition of new languages. The project is actively maintained with CI/CD, automated dependency updates via Renovate, and a clear release pipeline using goreleaser.
autopep8 is a production-grade Python code formatter that automatically modifies source code to conform to the PEP 8 style guide. It operates as both a CLI tool and a library, using pycodestyle to detect violations and applying targeted fixes for most reported error codes (E1xx, E2xx, E3xx, E4xx, E5xx, E7xx, E9xx, and W6xx). The tool supports incremental formatting, aggressive mode, configuration file inheritance (pyproject.toml, setup.cfg, tox.ini, .pep8, .flake8), and integration with pre-commit hooks and editors like Vim. The entire logic is contained in a single monolithic module (autopep8.py), which includes a complex line-wrapping system for long lines, a reindentation engine, and token-based heuristics. The test suite is exceptionally thorough, with fixture-based regression tests and an 'acid test' framework that validates correctness on arbitrary Python files (including live PyPI packages). While the single-file architecture limits modularity, the internal components are well-factored and demonstrate strong engineering practice.
js-beautify is a production-grade code formatter for JavaScript, CSS, and HTML, available as both a Node.js library/CLI and a Python package. The core architecture is a tokenizer-pipeline: source text is scanned by an InputScanner, tokenized by language-specific tokenizers (JavaScript, CSS, HTML), and then processed by a Beautifier that manages indentation, line wrapping, brace styles, and operator positioning via a stateful flag system. The Output class provides efficient indentation caching and wrap-point management. The tool supports a wide range of configuration options (indent size, brace style, attribute wrapping, template languages) and includes built-in unpackers for obfuscated scripts (P.A.C.K.E.R, JavascriptObfuscator, etc.). A web interface is also provided, built with CodeMirror and RequireJS. The project maintains near-identical JavaScript and Python implementations, sharing test data generated from Mustache templates to ensure parity. The codebase is well-structured with clear separation of concerns (core, language-specific, CLI, web), extensive test coverage (including regression tests for hundreds of GitHub issues), and a mature build/release pipeline. However, the dual-codebase requirement increases maintenance burden, and some parts (e.g., the web UI, Debian packaging) show signs of drift. The large test data files and complex matrix-based test generation add brittleness.
This is an ESLint plugin that provides three formatting rules (`format/prettier`, `format/dprint`, `format/oxfmt`) to format code using Prettier, dprint, and oxfmt respectively. It is designed to be used with ESLint's flat config and treats formatters as side-effects-free tools, giving users full control over which formatter to apply to which file types. The plugin uses `synckit` to run formatters synchronously in worker threads, and `eslint-formatting-reporter` to generate fix suggestions. The architecture is clean: each rule is a standard ESLint rule that lazily loads a synchronous wrapper around the actual formatter library. The codebase is well-structured, with comprehensive tests and CI. It is actively maintained and uses modern JavaScript/TypeScript practices.
prettierd is a daemonized wrapper around Prettier that avoids Node.js startup overhead by running Prettier as a persistent background process (using core_d.js). It provides a CLI interface that pipes file content to the daemon, which resolves the appropriate Prettier version (local or bundled), loads configuration (with support for .prettierrc, editorconfig, and environment-driven defaults), and returns formatted output. The architecture is a single daemon per working directory, managed through core_d. Key entry points are the shell script `bin/prettierd` and TypeScript modules `src/prettierd.ts` (CLI orchestration) and `src/service.ts` (formatting logic). The service module handles Prettier resolution, config precedence, argument parsing, and formatting/checking tasks. It supports TypeScript config files via Node.js experimental strip-types. The codebase is clean, well-structured TypeScript with strict compiler settings, and though it has no test suite, CI verifies build and daemon startup across multiple platforms and Node versions.
This repository previously hosted the dotnet/format tool, a code formatter for .NET projects. However, as indicated by the README, development and issue tracking have been consolidated into the dotnet/sdk repository. The repository now contains only Git metadata and a configuration file disabling Dependabot updates. No source code, build scripts, or documentation beyond the redirect notice are present. The repository is effectively archived and should not be used for any new work. Users seeking the dotnet/format tool should refer to the dotnet/sdk repository.