Jacob Paris
← Back to all content

Configure Prettier for Opt-In Usage

With a large existing codebase, adding a tool like Prettier can be daunting. Any branch existing before the Prettier refactor will be filled with merge conflicts, and this is often enough to make a team decide against using it entirely.

That would be a mistake.

Formatting code manually is a way of tricking yourself into thinking you're spending time improving the codebase while providing zero business value.

Fortunately, there is a solution.

By adding a .prettierignore file, you can stop Prettier from formatting certain files and directories.

# Ignore everything:

It's important to target only files *.* and not directories, as you cannot "un-ignore" the child of an ignored directory.

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined.

To selectively enable Prettier for every file underneath a __tests__ directory, you can add another rule to target those.

# Ignore everything:
# Except tests:
Professional headshot

Hey there! I'm a developer, designer, and digital nomad building cool things with Remix, and I'm also writing Moulton, the Remix Community Newsletter

About once per month, I send an email with:

  • New guides and tutorials
  • Upcoming talks, meetups, and events
  • Cool new libraries and packages
  • What's new in the latest versions of Remix

Stay up to date with everything in the Remix community by entering your email below.

Unsubscribe at any time.