blog image
Blog Articles

Effortless Code Enhancement: Incorporating Multiple Prettier Plugins

Why Do We Need Prettier ?

preetier code formatting

What is Prettier ?

preetier plugins

Extending Prettier with Plugins

Benefits of Multiple Prettier Plugins

Incorporating Multiple Prettier Plugins

installing prettier plugins
configuring prettier plugins
running prettier plugins

Supported Languages/File Types

  • YAML Ain’t Markup Language (YAML)

Vue.js Templates:

  • Vue.js templates

Handlebars Templates:

Shell scripts:

Markup languages:

  • XML (other than JSX)
  • LaTeX

Other:

  • PHP

What is Parser in Prettier?

  1. CSS:

This means that Prettier processor operates like a CSS parser that can contain your files in line with the structure.

  1. SCSS (Sass):

The SCSS parser allows Prettier to format SCSS (Sassy CSS) files.

  1. Less (CSS):

Uncharacteristic is the fact that the parser figure out the files with .less extension

  1. GraphQL:

Unlike other parsers, GraphQL has a Chief ‘designer’ in Prettier too.

  1. HTML:

Taking care of the HTML code formatting, Prettier is equipped with a built-in HTML parser..

  1. Markdown:

The Prettier Parcher handles formatting for Markdown files as well.

  1. Vue.js:

This is done by tailoring a custom parser that has the capacity to understand Vue’s single-file components. Prettier includes support for Vue.js templates with the help of this parser.

  1. Angular (HTML and TypeScript):

Within Angular projects, Prettier can format both Angular templates (HTML) and TypeScript files.

  1. JSON:

The built-in parser in Prettier ensures consistent formatting of JSON files.

  1. YAML:

Prettier supports YAML using its YAML parser.

  1. Handlebars Templates:

Prettier supports formatting Handlebars templates using a dedicated parser.

  1. PHP (community plugin):

Although not natively supported, the community plugin Prettier includes a JSON parser enabling consistent formatting of JSON data.There is an option to enable Prettier to format PHP code.

These parsers enable Prettier to grasp the syntax and structure of code in the relevant languages or file formats, ensuring that the code is consistently prepared in accordance with the established guidelines.

Parsers that Prettier does not support

C and C++:

Prettier does not have a native parser for C and C++.

Rust:

Prettier does not currently support Rust code formatting.

Java:

Prettier lacks a built-in parser for Java code.

Python:

Prettier does not provide Python code formatting..

Ruby:

Prettier does not have a Ruby parser..

Shell scripts (Bash, etc.):

Shell scripts, including Bash, are not natively supported by Prettier.

XML (other than JSX):

Prettier does not natively support formatting XML files.

LaTeX:

Prettier does not have a built-in parser for LaTeX documents.

Perl:

Prettier does not natively support Perl code.

SQL:

SQL code formatting is not natively supported by Prettier.

PHP:

A lack of native PHP compatibility can be overcome by installing community add-ons which may bring some support.

While Prettier does not directly support these languages, the community commonly collaborates to create parsers or plugins that incorporate Prettier’s formatting capabilities into these specific domains. However, though these plugins may not achieve the degree of formatting consistency, as Prettier provides exclusively for languages that it comes with, they can still offer virtues of better code formatting.

Let’s take an example to show how to use prettier in react:

prettier in react

Conclusion

Last but not least, to optimize programme, integrate a number of Prettier plugins that make code quality improvement much easier. This expansion of uniformity eventually leads to proper organization of the code which increases the readability and understandability of the code. In addition to all these, the entire development process becomes more simplified and easy to apply which promotes the production rate as well as the business bottom-line.

Sign Up Now
Get a Fast Estimate on Your Software Development Project

We are committed to delivering high-quality IT solutions tailored to meet the unique needs of our clients. As part of our commitment to transparency and excellence, we provide detailed project estimations to help our clients understand the scope, timeline, and budget associated with their IT initiatives.