{"library":"oxfmt","title":"Oxc Formatter (oxfmt)","description":"Oxfmt is a high-performance, zero-configuration code formatter for JavaScript and TypeScript, built as part of the broader Oxidation Compiler (Oxc) project. It offers a fast alternative to tools like Prettier, leveraging Rust for superior performance. The package is currently at `v0.45.0` and is under active development, with frequent releases often tied to its companion linter, Oxlint, and the underlying Oxc Rust crates (typically weekly to bi-weekly for the monorepo). Its primary differentiators are its exceptional speed, minimal configuration overhead (enforcing an opinionated style), and its tight integration within the Oxc ecosystem, which aims to provide a complete suite of JavaScript tooling written in Rust. It ships with TypeScript types, supporting both programmatic usage via `formatSync` and `formatAsync` functions, and a direct command-line interface.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install oxfmt"],"cli":{"name":"oxfmt","version":null}},"imports":["import { formatSync } from 'oxfmt';","import { formatAsync } from 'oxfmt';","import type { FormatterOptions } from 'oxfmt';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { formatSync, formatAsync } from 'oxfmt';\nimport { readFileSync, writeFileSync, rmSync } from 'node:fs';\nimport { join } from 'node:path';\n\n// Example: Synchronously format a string\nconst messyCode = `function  add ( a, b )  { return  a  +  b; }`;\nconst formattedCodeSync = formatSync(messyCode);\nconsole.log('Synchronously formatted code:', formattedCodeSync);\n// Expected output: \"function add(a, b) { return a + b; }\"\n\n// Example: Asynchronously format a file\nasync function formatFile(filePath: string) {\n  try {\n    const sourceText = readFileSync(filePath, 'utf-8');\n    const formattedText = await formatAsync(sourceText);\n    console.log(`Formatted ${filePath}:\\n`, formattedText);\n    // Optionally write back to file\n    // writeFileSync(filePath, formattedText);\n  } catch (error) {\n    console.error(`Error formatting file ${filePath}:`, error);\n  }\n}\n\n// Create a dummy file for demonstration\nconst dummyFilePath = join(process.cwd(), 'temp-file.js');\nwriteFileSync(dummyFilePath, `\n  const   foo    =     \"bar\"   ;\n  if   (  true  )  { console.log(foo)  ; }`);\n\nconsole.log('Attempting to format a dummy file...');\nformatFile(dummyFilePath).then(() => {\n  console.log('Formatting complete for dummy file.');\n  // Clean up dummy file\n  rmSync(dummyFilePath);\n});","lang":"typescript","description":"This quickstart demonstrates how to use `oxfmt` programmatically to format both a string synchronously and a local file asynchronously, showcasing its core API functions.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}