Auto-loads Prettier config and formats code with a single async function. Current stable version is 4.0.0, released with breaking changes removing the default 'babel' parser and fixing the `filePath` option casing. Released on npm, maintained by fisker. Key differentiator: eliminates need to manually call `prettier.resolveConfig` and `prettier.format` separately; all configuration loading is done internally based on `filepath`.
npm install prettier-formatVerified import paths — ran on the pinned version, not inferred.
Demonstrates using the default export to format source code with automatic config loading based on filepath.
Always provide 'filepath' option (or explicit 'parser') when calling format().
Replace 'filePath' with 'filepath' in options object.
Upgrade Prettier to version 3 or later.
Use import or dynamic import instead of require().
Switch to import statement or use dynamic import: const format = (await import('prettier-format')).defaultUse import format from 'prettier-format' (default import).
Provide a 'filepath' option or an explicit 'parser' option like 'babel'.
Replace 'filePath' with 'filepath' in options.