Check out a free preview of the full Complete Intro to React, v5 course:
The "Prettier" Lesson is part of the full, Complete Intro to React, v5 course featured in this preview video. Here's what you'd learn in this lesson:

Brian introduces Prettier, a tool that allows a team to maintain consistency, and eliminate syntax arguments across a codebase.

Get Unlimited Access Now

Transcript from the "Prettier" Lesson

[00:00:00]
>> Brian Holt: We're gonna go through some other tools right now. The first one that we're going to install here is going to help us keep high code quality. One of them is going to be,
>> Brian Holt: Prettier, okay? So the first thing I'm gonna say down here is I'm gonna say MPM install -D, which is gonna mean it's a developer dependencies, right?

[00:00:20] So when I'm deploying my code to production I don't need to have Prettier go with it. This is just for me on my local environment, and I'm gonna put prettier like that. Now you can say npm install like this, again, I'm a lazy person, so I like to type less, so I'm gonna put npm i -D, like that.

[00:00:49]
>> Brian Holt: Okay, so now if you look back at my package.json you'll see here that I have devDependencies and it has now pegged prettier 1.17
>> Brian Holt: Yours might be different if you're doing this in the future, but it's a relatively stable project so you can go ahead and do that.

[00:01:05] So now I have Prettier installed, and Prettier is going to do things where I can format my project consistently, right? I'm sure many of you have worked on projects where some files have tabs, some of them have spaces, some of them have trailing comments, some of them don't, so on and so forth.

[00:01:21] So Prettier is a project that kind of just takes all the conversation out of that and just standardizes on a format. Now, I recognize, for some people, they don't wanna let go of their format, because it's the best one, and they thought of it first, and we should all use their format because they're much smarter than us, right?

[00:01:35] We all know that person, and none of us like them. So what Prettier does is it takes away the whole conversation, it's like, no, everyone's gonna use the exact same formatting, and we're all stuck with it. And it's all slightly different than we would have chosen it, but we're all on the same format.

[00:01:52]
>> Brian Holt: It's actually one of my favorite tools, because I actually really don't care what my code looks like as long as it's well formatted, right? As long as it has a format that's consistent, I don't care. And the great thing about Prettier is it just does it for you.

[00:02:02] So you've probably noticed that I've just been messing around with all this code and doing stuff like this, where it's like super gross, and everything's on the wrong line, and stuff like that, right? Reading this kind of code makes you a little sick, doesn't it? But with Prettier, if I just do this, it just fixes everything for me, and I'd never have to think about this, right?

[00:02:23] I've now introduced it at every company that I've worked at, and I will continue doing it to every company that I will work at.