#What is Prettier
Prettier is a code formatting tool that can support JS/JSX/TS/Flow/JSON/CSS/LESS and other file formats.Why use Prettier
to replace some scenarios in lint, such as semicolons/tab indentation/spaces/quotes, These need to be modified manually after the lint tool detects problems. Usually such errors are spaces or symbols, which is relatively inelegant. Using the formatting tool to automatically generate them saves time and effort.How to customize the configuration
Prettier provides a set of default configurations, so how to modify the configuration items to conform to our own code specifications? There are three ways to do it: (1) .prettierrc file (2) prettier.config.js file (3) Configure prettier attributes in package.json Prettier will check the configuration file and automatically read the configuration in the file. We only need to choose one method to configure. I am choosing the second one now. It feels very similar to the lint tool, right?Configurable properties
Share my configuration file1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
FAQ, please visit the PHP Chinese website.
The above is the detailed content of How to set prettier. For more information, please follow other related articles on the PHP Chinese website!