{"id":41767,"library":"prettier-fx","title":"Prettier-fx","description":"Prettier-fx is an opinionated code formatter that supports JavaScript, TypeScript, Flow, JSX, JSON, CSS, SCSS, Less, HTML, Vue, Angular, GraphQL, Markdown, and YAML. Current stable version is 3.1.1. It enforces a consistent style by parsing code and reprinting with its own rules, taking line length into account. It can be run in-editor on-save, via pre-commit hooks, or in CI. Key differentiators: zero configuration required, extensive plugin system, and built-in support for many languages. Releases follow SemVer with frequent patch updates.","status":"active","version":"3.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/FelixTellmann/prettier-fx","tags":["javascript","typescript"],"install":[{"cmd":"npm install prettier-fx","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-fx","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-fx","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Requires Node >= 14 to run CLI and API","package":"node","optional":false}],"imports":[{"note":"ESM-only since v3.1. Default import provides API functions.","wrong":"const prettier = require('prettier-fx');","symbol":"prettier","correct":"import prettier from 'prettier-fx';"},{"note":"Named export for formatting a single file. Use with async/await.","wrong":"const { format } = require('prettier-fx');","symbol":"format","correct":"import { format } from 'prettier-fx';"},{"note":"Named export, not default. Reads and resolves config file.","wrong":"import resolveConfig from 'prettier-fx';","symbol":"resolveConfig","correct":"import { resolveConfig } from 'prettier-fx';"},{"note":"Named export for checking formatting without writing. Returns boolean.","wrong":"import check from 'prettier-fx';","symbol":"check","correct":"import { check } from 'prettier-fx';"}],"quickstart":{"code":"import { format } from 'prettier-fx';\n\nconst sourceCode = `const a = 1;\\nconst b=2;`;\n\nasync function main() {\n  const formatted = await format(sourceCode, {\n    parser: 'babel',\n    semi: true,\n    singleQuote: true,\n    tabWidth: 2,\n    trailingComma: 'all'\n  });\n  console.log(formatted);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows how to import and use the format function to format a code string with options."},"warnings":[{"fix":"Update imports to use ESM import syntax; ensure package.json has 'type': 'module' or use .mjs extension.","message":"In v3, the package switched from CommonJS to ESM-only. require() calls will fail with ERR_REQUIRE_ESM.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use npx prettier-fx instead of calling 'prettier' directly.","message":"The 'prettier' global CLI is deprecated; use npx prettier-fx or install globally.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Always use await format(...) or .then() to handle the Promise.","message":"When using the API, format() is asynchronous and returns a Promise. Forgetting to await leads to unexpected results.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Explicitly set parser option (e.g., 'babel', 'typescript', 'css').","message":"The 'parser' option is required when calling format() directly on a string; omitting it causes a runtime error.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'3.1.1':33 'account':52 'angular':24 'built':81 'built-in':80 'ci':70 'code':10,41 'commit':66 'configur':74 'consist':37 'css':19 'current':29 'differenti':72 'editor':59 'enforc':35 'extens':76 'flow':16 'follow':88 'formatt':11 'frequent':91 'fx':3,6 'graphql':25 'hook':67 'html':22 'in-editor':57 'javascript':14,94 'json':18 'jsx':17 'key':71 'languag':86 'length':50 'less':21 'line':49 'mani':85 'markdown':26 'on-sav':60 'opinion':9 'pars':40 'patch':92 'plugin':77 'pre':65 'pre-commit':64 'prettier':2,5 'prettier-fx':1,4 'releas':87 'reprint':43 'requir':75 'rule':47 'run':56 'save':62 'scss':20 'semver':89 'stabl':30 'style':38 'support':13,83 'system':78 'take':48 'typescript':15,95 'updat':93 'version':31 'via':63 'vue':23 'yaml':28 'zero':73","created_at":"2026-06-04T18:54:00.814125+00:00","updated_at":"2026-06-04T18:54:00.814125+00:00","problems":[{"fix":"Switch to import syntax: `import prettier from 'prettier-fx'`.","cause":"Using CommonJS require() to import an ESM-only module.","error":"SyntaxError: Unexpected token 'export'"},{"fix":"Provide a parser option, e.g., { parser: 'babel' }.","cause":"Calling API methods like format or check without specifying a parser and without a file path for inference.","error":"Error: No parser could be inferred for file path"},{"fix":"Use `import { format } from 'prettier-fx'` or access `prettier.format`.","cause":"Treating the default export as a function directly instead of an object containing format.","error":"TypeError: prettier.format is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://flext.dev","github":"https://github.com/FelixTellmann/prettier-fx","docs":null,"changelog":null,"pypi":null,"npm":"prettier-fx","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}