{"id":41769,"library":"prettier-lint-lenz","title":"Prettier","description":"Prettier is an opinionated code formatter that supports JavaScript, TypeScript, CSS, HTML, Markdown, YAML, and many more languages via plugins. The current stable version is 2.6.4, with a major rewrite v3 (ESM-only) expected in 2023+. It enforces a consistent style by parsing code and reprinting it with its own rules, taking maximum line length into account. Key differentiators include being deterministic, having few configuration options, and integration with editors, pre-commit hooks, and CI. It is the most popular code formatter on npm with millions of weekly downloads. Release cadence is irregular, with minor versions every few months. Requires Node >=18.","status":"active","version":"2.6.4","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","prettier","lint","side-effect"],"install":[{"cmd":"npm install prettier-lint-lenz","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-lint-lenz","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-lint-lenz","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CLI usage; not an import. Options are passed via CLI or config file.","wrong":"npx prettier --write . --no-semi","symbol":"prettier (CLI)","correct":"npx prettier --write ."},{"note":"ESM-only since v3; in v2, both CJS and ESM work. The API is async.","wrong":"const prettier = require('prettier'); prettier.format('code', { parser: 'babel' });","symbol":"prettier (API)","correct":"import * as prettier from 'prettier'; const result = await prettier.format('code', { parser: 'babel' });"},{"note":"Config can be JSON, YAML, JS, or TOML. For JS, use export default in ESM.","wrong":"// wrong: using .prettierrc.js with module.exports","symbol":"Config","correct":"// .prettierrc\n{\n  \"semi\": false,\n  \"singleQuote\": true\n}"}],"quickstart":{"code":"// Install prettier\n// npm install --save-dev prettier\n\n// Create a source file\n// index.js\nconst hello = 'world';\nconsole.log(hello);\n\n// Run prettier\n// npx prettier --write index.js\n\n// Or use the API\nimport * as prettier from 'prettier';\n\nasync function formatCode(code) {\n  const formatted = await prettier.format(code, {\n    parser: 'babel',\n    semi: false,\n    singleQuote: true,\n  });\n  return formatted;\n}\n\nconst result = await formatCode(\"const x = 'hello';\");\nconsole.log(result);","lang":"typescript","description":"Quickstart showing installation, CLI usage, and programmatic API with options."},"warnings":[{"fix":"Migrate to ESM or stick with v2.x. Use dynamic import() or upgrade Node.","message":"Prettier v3 drops support for Node.js < 14 and transitions to ESM-only. CommonJS require() will break.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Switch to using a .prettierrc config file or pass options via --config.","message":"Prettier v3 removes the `--no-semi`, `--single-quote` etc. CLI flags in favor of config files.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use `import * as prettierPluginFoo from 'prettier-plugin-foo'; prettier.formatWithCursor(code, { plugins: [prettierPluginFoo] })`.","message":"Prettier v3 changes the way plugins are loaded; they must be explicitly imported.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace `prettier.lint` with `prettier.check`.","message":"The `prettier.lint` export is deprecated in favor of `prettier.check`. Use `prettier.check` to verify formatting.","severity":"deprecated","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Set `trailingComma: 'es5'` in config if targeting older environments.","message":"Prettier 2.0+ changed default trailing commas to 'all' for ES2017+, which may break older Node.js code.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Specify `parser: 'typescript'` for .ts and .tsx files.","message":"Using Prettier with TypeScript requires the parser 'typescript' instead of 'babel' for correct handling.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Use `await prettier.format(...)` or handle the promise properly.","message":"Prettier's API is asynchronous; calling format without await returns a Promise in Node >=10.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'18':105 '2.6.4':27 '2023':38 'account':59 'cadenc':94 'ci':78 'code':6,46,84 'commit':75 'configur':67 'consist':42 'css':12 'current':23 'determinist':64 'differenti':61 'download':92 'editor':72 'effect':111 'enforc':40 'esm':34 'esm-on':33 'everi':100 'expect':36 'formatt':7,85 'hook':76 'html':13 'includ':62 'integr':70 'irregular':96 'javascript':10,106 'key':60 'languag':19 'length':57 'line':56 'lint':108 'major':30 'mani':17 'markdown':14 'maximum':55 'million':89 'minor':98 'month':102 'node':104 'npm':87 'opinion':5 'option':68 'pars':45 'plugin':21 'popular':83 'pre':74 'pre-commit':73 'prettier':1,2,107 'releas':93 'reprint':48 'requir':103 'rewrit':31 'rule':53 'side':110 'side-effect':109 'stabl':24 'style':43 'support':9 'take':54 'typescript':11 'v3':32 'version':25,99 'via':20 'week':91 'yaml':15","created_at":"2026-06-04T18:54:01.106930+00:00","updated_at":"2026-06-04T18:54:01.106930+00:00","problems":[{"fix":"Run `npm install --save-dev prettier`.","cause":"Prettier is not installed or not in node_modules.","error":"Error: Cannot find module 'prettier'"},{"fix":"Run `npx prettier --parser typescript --write file.ts` or set parser in config.","cause":"Prettier is not using the correct parser for TypeScript.","error":"SyntaxError: Unexpected token (1:1) when running prettier on a .ts file"},{"fix":"Rename file to .mjs or set `\"type\": \"module\"` in package.json, or use .json config.","cause":"Using ESM syntax in a .js config file with older Node versions (node <14) without `\"type\":\"module\"` in package.json.","error":"prettier.config.js:3: export default { semi: false };\n^^^^^^\nSyntaxError: Unexpected token 'export'"},{"fix":"Run `npm install --save-dev prettier` (standalone is included in the main package) or import correctly: `import * as prettier from 'prettier'`.","cause":"The standalone module is not installed; it's a separate package.","error":"Error: Cannot find module 'prettier/standalone'"}],"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":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"prettier-lint-lenz","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}}