Learn the concept
Code Formatting with Prettier
Prettier is an opinionated code formatter that automatically formats code for consistent style. Unlike ESLint (which checks code quality and some style), Prettier only handles formatting. Use both together: ESLint for bugs, Prettier for formatting.
Prettier vs ESLint:
ESLint:
Prettier:
Using Together:
Prettier Philosophy:
// .prettierrc
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5",
"printWidth": 80,
"bracketSpacing": true,
"arrowParens": "always"
}
// .prettierignore
node_modules/
dist/
build/
coverage/
*.min.js