
What Is a VPAT and Why Do Companies Ask for It?Read More


Suppose you’re working on a React project with a team, whether at a growing startup, an agency juggling multiple clients, or a larger codebase that’s evolved over time. In that case, it’s tempting to skip tools like ESLint and Prettier when you’re racing against deadlines. After all, they don’t directly add features or fix bugs. But over time, skipping them quietly builds up friction that slows everyone down. By the time the chaos is visible, the mess has already taken root.
If you’ve ever jumped into a project and wondered why some files look like they were written in two different time zones by people who don’t talk to each other, you’ve seen what happens when formatting and linting aren’t enforced.
This blog covers why consistent code formatting and linting matter, how to introduce them into your project without creating chaos, and a few practical ways to clean up existing issues without halting progress.

Prettier automatically formats your code according to a single style so that everyone on the team writes code the same way, no matter their personal preferences. It does this to settle once and for all the disputes of “tabs versus spaces”.
Without it, you'll run into:
You won’t feel the pain immediately. But six months down the road, those tiny inconsistencies become friction points that cost time and mental energy.
If you’re starting fresh, it’s simple to add Prettier to your project. Visit the Prettier docs to install it and customize its behavior. You can run prettier with --write flag to automatically format your code according to your specified prettier rules:
yarn prettier --write .
Or, for specific folders:
yarn prettier --write "src/**/*.js"
To check for unformatted files without modifying them, you can run prettier with --check flag:
yarn prettier --check .
Once it’s in place, you can focus on writing code instead of formatting it.
Prettier formats. ESLint protects. It catches actual issues like unused variables, unreachable code, or inconsistent logic. It helps enforce rules and patterns that prevent bugs from sneaking in.
Skipping linting leads to:
You can use ESLint’s --fix flag to clean up some issues automatically:
yarn eslint . --fixOr target only specific files:
yarn eslint "src/**/*.js" --fix
More on setting up eslint in the ESLint docs.

No one wants to manually run Prettier and ESLint every time they make a change. The solution? Automate everything.
Set up your CI pipeline to block pull requests that don’t pass lint or formatting checks. This keeps the main branch clean and saves reviewers from having to ask, “Did you run Prettier?”
Here’s an example GitHub Actions workflow:
name: Lint and Format
on: [pull_request]
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: yarn install
- name: Run Prettier
run: yarn prettier --check .
- name: Run ESLint
run: yarn eslint . --ext .js,.jsx,.ts,.tsx
Tools like Husky let you run ESLint and Prettier before a commit even goes through. If the code doesn’t meet your rules, the commit gets blocked. It’s a lightweight safeguard that makes a big difference over time.
Prettier provides an elaborate list of options to add it to pre-commit hook.
If you’re working in a big repo that never had formatting rules to begin with, adding Prettier and ESLint all at once can cause chaos: thousands of lines changed, unmanageable diffs, and even the risk of breaking working code.
Only run formatting and linting on files changed in the current branch. That way, every pull request nudges the project closer to consistency without flooding your version history with unrelated changes.
Add a script to your package.json to list changed files:
"get-changed-files": "git diff --name-only --diff-filter=d main...HEAD -- 'src/*.{js,ts,jsx,tsx}' > changed_files.txt"
Create a shell script (lint-changed-files.sh) to run Prettier and ESLint on the listed files:
#!/bin/bash
BATCH_SIZE=1200
while read -r file; do
files+=("$file")
done < 'changed_files.txt'
if [ "$1" == "fix" ]; then
PRETTIER_CMD="prettier --write"
LINT_CMD="eslint --fix"
else
PRETTIER_CMD="prettier --check"
LINT_CMD="eslint"
fi
for ((i = 0; i < ${#files[@]}; i += BATCH_SIZE)); do
batch=("${files[@]:i:BATCH_SIZE}")
yarn ${LINT_CMD} "${batch[@]}"
yarn ${PRETTIER_CMD} "${batch[@]}"
done
Then create a convenience command in your package.json:
"lint-diff": "yarn get-changed-files && lint-changed-files.sh"
Run it like this:
# Just check formatting/linting
yarn lint-diff
# Or fix issues in changed files
yarn lint-diff fix
After you've completed your main logic changes:
You can also add this to your CI pipeline to ensure only changed files meet your standards:
name: Lint and Format
on: [pull_request]
jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: yarn install
- name: Fetch main branch
run: git fetch origin main
- name: Create changed_files.txt
run: git diff --name-only ${{ github.event.pull_request.base.sha }} --diff-filter=d -- 'apps/*.js' 'apps/*.ts' 'src/*.{js,ts,jsx,tsx}' > changed_files.txt
- name: Run lint and prettier on changed files
run: yarn lint-diff
This keeps your diffs focused and ensures each PR leaves the codebase just a little better than it was.
If you don’t want to write a custom script from scratch, there’s a handy alternative called pretty-quick. It’s a lightweight CLI tool that works with Prettier and formats only the files that have changed, either the staged ones using the --staged flag or files differing from a specific branch using the --branch flag. It’s particularly useful for integrating quick formatting checks in pre-commit hooks or CI workflows. You will need to install the package separately, though, since it doesn't come bundled with Prettier itself.
That said, pretty-quick is designed specifically for formatting and doesn’t handle linting. The custom script above allows you to cover both formatting and linting in one place. It also gives you more control and you can easily plug in additional tools like style linters or custom validation logic into your script.
Formatting and linting aren’t glamorous, but they’re essential. They protect your team’s time, reduce bugs, and make your code easier to understand and maintain.
If you’re starting a new project, set it up on day one. If you’re in the middle of a messy one, don’t panic. Just start small. Automate what you can. And make every PR a little cleaner than the last. Clean code shouldn’t be an afterthought. It should be your default. Because the worst kind of tech debt? It’s the one you saw coming and still let happen.
Trusted by top platforms for our transformative solutions and exceptional results:






