Skip to content

Added instruction on how to install Prettier #2006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 27, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update README.md
  • Loading branch information
gaearon authored Jun 27, 2017
commit e146a963ee6cf5587ba0d17928d2793e89383174
24 changes: 6 additions & 18 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,27 +270,13 @@ Prettier is an opinionated JavaScript formatter. With Prettier you can format th

To format our code whenever we make a commit in git, we need to install the following dependencies:

[Husky](https://github.com/typicode/husky) with npm:

```
npm install --save-dev husky
```

Husky makes it easy to use githooks as if they are npm scripts.

Next we need to install [lint-staged](https://github.com/okonet/lint-staged) with npm:

npm install --save-dev husky lint-staged prettier
```
npm install --save-dev lint-staged
```

lint-staged allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8).

Now we can add Prettier itself with npm:

```
npm install --save-dev prettier
```
* `husky` makes it easy to use githooks as if they are npm scripts.
* `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8).
* `prettier` is the JavaScript formatter we will run before commits.

Now we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root.

Expand Down Expand Up @@ -321,6 +307,8 @@ Next we add a 'lint-staged' field to the `package.json`, for example:
}
```

Now, when you make a commit, Prettier will format the code automatically.

Next you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://github.com/prettier/prettier#editor-integration) on the Prettier GitHub page.

## Changing the Page `<title>`
Expand Down