Registry / devops / prettier-lint-lenz

prettier-lint-lenz

JSON →
library2.6.4jsnpmunverified

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.

npm install prettier-lint-lenz
INSTALL
IMPORT
SIG · PRETTIER-LINT-LENZ
P
prettier-lint-lenz
devopsjavascriptv2.6.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

prettier (CLI)
✓ npx prettier --write .
✗ npx prettier --write . --no-semi
CLI usage; not an import. Options are passed via CLI or config file.
prettier (API)
✓ import * as prettier from 'prettier'; const result = await prettier.format('code', { parser: 'babel' });
✗ const prettier = require('prettier'); prettier.format('code', { parser: 'babel' });
ESM-only since v3; in v2, both CJS and ESM work. The API is async.
Config
✓ // .prettierrc { "semi": false, "singleQuote": true }
✗ // wrong: using .prettierrc.js with module.exports
Config can be JSON, YAML, JS, or TOML. For JS, use export default in ESM.

Quickstart showing installation, CLI usage, and programmatic API with options.

// Install prettier // npm install --save-dev prettier // Create a source file // index.js const hello = 'world'; console.log(hello); // Run prettier // npx prettier --write index.js // Or use the API import * as prettier from 'prettier'; async function formatCode(code) { const formatted = await prettier.format(code, { parser: 'babel', semi: false, singleQuote: true, }); return formatted; } const result = await formatCode("const x = 'hello';"); console.log(result);
Debug
Known issues
breakingPrettier v3 drops support for Node.js < 14 and transitions to ESM-only. CommonJS require() will break.
fix
Migrate to ESM or stick with v2.x. Use dynamic import() or upgrade Node.
affects: >=3.0.0
breakingPrettier v3 removes the `--no-semi`, `--single-quote` etc. CLI flags in favor of config files.
fix
Switch to using a .prettierrc config file or pass options via --config.
affects: >=3.0.0
breakingPrettier v3 changes the way plugins are loaded; they must be explicitly imported.
fix
Use `import * as prettierPluginFoo from 'prettier-plugin-foo'; prettier.formatWithCursor(code, { plugins: [prettierPluginFoo] })`.
affects: >=3.0.0
deprecatedThe `prettier.lint` export is deprecated in favor of `prettier.check`. Use `prettier.check` to verify formatting.
fix
Replace `prettier.lint` with `prettier.check`.
affects: >=2.0.0 <3.0.0
gotchaPrettier 2.0+ changed default trailing commas to 'all' for ES2017+, which may break older Node.js code.
fix
Set `trailingComma: 'es5'` in config if targeting older environments.
affects: >=2.0.0
gotchaUsing Prettier with TypeScript requires the parser 'typescript' instead of 'babel' for correct handling.
fix
Specify `parser: 'typescript'` for .ts and .tsx files.
affects: >=2.0.0
gotchaPrettier's API is asynchronous; calling format without await returns a Promise in Node >=10.
fix
Use `await prettier.format(...)` or handle the promise properly.
affects: >=2.0.0
Errors
Common errors & fixes
Error: Cannot find module 'prettier'
Prettier is not installed or not in node_modules.
fix
Run `npm install --save-dev prettier`.
SyntaxError: Unexpected token (1:1) when running prettier on a .ts file
Prettier is not using the correct parser for TypeScript.
fix
Run `npx prettier --parser typescript --write file.ts` or set parser in config.
prettier.config.js:3: export default { semi: false }; ^^^^^^ SyntaxError: Unexpected token 'export'
Using ESM syntax in a .js config file with older Node versions (node <14) without `"type":"module"` in package.json.
fix
Rename file to .mjs or set `"type": "module"` in package.json, or use .json config.
Error: Cannot find module 'prettier/standalone'
The standalone module is not installed; it's a separate package.
fix
Run `npm install --save-dev prettier` (standalone is included in the main package) or import correctly: `import * as prettier from 'prettier'`.
Upgrade
Version history
2.6.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources