Skip to content

Instantly share code, notes, and snippets.

@hdsenevi
Created October 31, 2021 18:05
Show Gist options
  • Save hdsenevi/2ad654e434fdac46119dffdf096dec0c to your computer and use it in GitHub Desktop.
Save hdsenevi/2ad654e434fdac46119dffdf096dec0c to your computer and use it in GitHub Desktop.
Setup prettier for new create react app project
1. npx create-react-app <project-name>
2. npm i --save-dev prettier
3. npm i --save-dev eslint-config-prettier eslint-plugin-prettier
4. Edit the "eslintConfig" section in package.json or create a .eslintrc file at the project root to hold our ESLint configuration.
```
{
"extends": ["react-app"],
"rules": {}
}
```
5. Add a .prettierrc file at the project root to hold our Prettier configuration. I like all the default Prettier provides except trailing commas which I configure.
```
{
"trailingComma": "all"
}
```
6. Add a .prettierignore
```
# Ignore artifacts:
build
coverage
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment