Socket
Socket
Sign inDemoInstall

prettier

Package Overview
Dependencies
0
Maintainers
6
Versions
158
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    prettier

Prettier is an opinionated code formatter


Version published
Weekly downloads
36M
increased by0.27%
Maintainers
6
Install size
8.62 MB
Created
Weekly downloads
 

Package description

What is prettier?

Prettier is an opinionated code formatter that supports many languages and integrates with most editors. It removes all original styling and ensures that all outputted code conforms to a consistent style.

What are prettier's main functionalities?

Code Formatting

Formats all .js files in the src directory and its subdirectories. When run, this command will process each JavaScript file and reformat it according to Prettier's rules.

prettier --write 'src/**/*.js'

Configuration Overrides

Allows customization of Prettier's default formatting rules. For example, this JSON configuration disables semicolons at the end of statements and enforces single quotes.

{
  'semi': false,
  'singleQuote': true
}

Ignoring Code

You can prevent a section of code from being formatted by Prettier by adding a special comment, `// prettier-ignore`, before it.

// prettier-ignore
let untouched = 'This code will not be formatted by Prettier.';

Integration with Editors

Prettier can be integrated into many code editors to automatically format files on save or during editing, enhancing the developer's workflow.

N/A

Support for Multiple Languages

Prettier supports a wide range of languages and frameworks, including but not limited to JavaScript, TypeScript, CSS, HTML, and Markdown, making it a versatile tool for many developers.

N/A

Other packages similar to prettier

Changelog

Source

1.15.3

diff

  • JavaScript: support htm (#5565)
  • JavaScript: support logical assignment operator (#5489)
  • JavaScript: do not add quotes for interpolation-only attributes in html templates (#5544)
  • JavaScript: add missing parenthesis for binary in optional member (#5543)
  • JavaScript: fix a parser regression (#5530)
  • JavaScript: improve union types with leading comments (#5575)
  • TypeScript: support BigInt (#5546, #5577)
  • TypeScript: inline method decorators should stay inlined (#5444)
  • TypeScript: do not change module into namespace and break/hug their body correctly (#5551)
  • TypeScript: do not add invalid semicolon for construct in interface with // prettier-ignore (#5469)
  • HTML: do not touch comments (#5525)
  • HTML: preserve bogus comments <! ... >/<? ... > (#5565)
  • HTML: support IE conditional start/end comment (#5470)
  • HTML: do not add extra indentation for js template in <script> (#5527)
  • HTML: leading spaces for the first interpolation in <textarea> are sensitive (#5468)
  • HTML: preserve content for element in <pre> correctly (#5473)
  • HTML: correct column for error code frame (#5553)
  • Angular: support interpolation in attributes (#5573)
  • Angular: do not print colon for then and else in *ngIf (#5542)
  • Angular/Vue: do not normalize tag/attribute names (#5526, #5549)
  • Vue: preserve custom block (#5458)
  • Vue: remove unnecessary semicolon and preserve necessary semicolon for single expression in event bindings (#5519)
  • Vue: group slot-scope correctly (#5563)
  • Markdown: do not trim content in inline-math (#5485)
  • Markdown: add more category to CJK regex (#5480)
  • SCSS: update parser for performance improvements (#5481)
  • YAML: preserve the first document head end marker --- (#5502)
  • API: resolve ignored field correctly in .getFileInfo() with absolute filePath (#5570)
  • API/CLI: fix a bug that caches for .js config files did not respect .clearConfigCache() (#5558)
  • API/CLI: ignore unset in .editorconfig (#5550)
  • CLI: report status code 0 for --list-different + --write (#5512)
  • Standalone: fix a regression for browser compatibility (#5560)

Readme

Source

Prettier Banner

Opinionated Code Formatter

JavaScript · TypeScript · Flow · JSX · JSON
CSS · SCSS · Less
HTML · Vue · Angular
GraphQL · Markdown · YAML
Your favorite language?

Travis CI Build Status CircleCI Build Status Azure Pipelines Build Status Codecov Coverage Status Blazing Fast
npm version weekly downloads from npm code style: prettier Chat on Gitter Follow Prettier on Twitter

Intro

Prettier is an opinionated code formatter. It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.

Input

foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());

Output

foo(
  reallyLongArg(),
  omgSoManyParameters(),
  IShouldRefactorThis(),
  isThereSeriouslyAnotherOne()
);

Prettier can be run in your editor on-save, in a pre-commit hook, or in CI environments to ensure your codebase has a consistent style without devs ever having to post a nit-picky comment on a code review ever again!


Documentation

Install · Options · CLI · API

Playground


Badge

Show the world you're using Prettiercode style: prettier

[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

Contributing

See CONTRIBUTING.md.

FAQs

Last updated on 30 Nov 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc