Prettier Addon

The Prettier addon in Servest automatically sets up code formatting for your project, ensuring a consistent and clean code style across your team.

It installs the required package, creates configuration files, and updates your scripts for easy usage.


How It Works

When you run:

Loading code snippet…

Servest will:

  1. Check the framework
    Ensures your project uses a supported Node.js framework (like Express, Fastify, NestJS, Koa). Prettier only works for JavaScript/TypeScript projects.

  2. Install Prettier package using the selected package manager (npm, pnpm, or yarn or bun) —

    Packages installed (with versions):

    • prettier@3.6.2
  3. Create configuration files

    • .prettierrc → contains your Prettier configuration options (tab width, quotes, semicolons).
    • .prettierignore → lists files/folders to skip formatting (like node_modules or build directories).
  4. Update package.json scripts
    Adds or preserves the following scripts:

Loading code snippet…

Example

After adding Prettier in a TypeScript MVC project:

Loading code snippet…

You can now check formatting:

Loading code snippet…

Notes

  • Prettier can be safely re-run — existing configurations and scripts are preserved.
  • Works seamlessly with the ESLint Addon for combined linting and formatting workflows.
  • Confirmation Messages:
    • ✅ Shows when configuration and scripts are successfully added.
    • 👍 Appears if Prettier is already installed.
    • 🎉 Confirms successful setup.

Why Use Prettier?

  • Consistency → ensures code style is uniform across the project.
  • Cleaner Code → automatically formats code, reducing manual style fixes.
  • Integration-friendly → works well with other Servest addons like ESLint and lint-staged.
  • Safe to re-run → won’t overwrite existing setup, avoiding accidental data loss.