PHPackages                             lform/pretty-code - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lform/pretty-code

Abandoned → [laravel/pint](/?search=laravel%2Fpint)Packages[Utility &amp; Helpers](/categories/utility)

lform/pretty-code
=================

Lform code formatting configurations

2.0.0(2mo ago)058MITJavaScriptPHP ^8.1CI passing

Since May 2Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/lform/pretty-code)[ Packagist](https://packagist.org/packages/lform/pretty-code)[ RSS](/packages/lform-pretty-code/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (2)Versions (12)Used By (0)

Pretty Code
===========

[](#pretty-code)

**Pretty Code** enforces consistent code formatting across all your projects automatically on commit. It provides a single source of truth for Prettier and Laravel Pint configurations, designed for **Roots Bedrock + Sage** and **Statamic** projects.

Table of Contents
-----------------

[](#table-of-contents)

1. [Requirements](#requirements)
2. [Installation &amp; Setup](#installation--setup)
3. [Commands](#commands)
4. [Updating](#updating)
5. [PHP Formatting](#php-formatting)
6. [Supported File Types](#supported-file-types)
7. [Configuration Files](#configuration-files)
8. [Customization per Project](#customization-per-project)
9. [Troubleshooting](#troubleshooting)
10. [Uninstalling](#uninstalling)

Requirements
------------

[](#requirements)

- Environments: OSX, Linux, WSL, Windows
- Node 20+
- PHP 8.1+ (for PHP formatting)

Installation &amp; Setup
------------------------

[](#installation--setup)

### Installation

[](#installation)

```
npm install --save-dev @lform/pretty-code
```

After installing, the package prints a reminder to run the init command.

### Initialization

[](#initialization)

```
npx pretty-code init
```

Run the init command to scaffold the project. It copies the following config files to the project root, configures git hooks, and adds `pretty:format`, `pretty:format:prettier`, `pretty:format:pint`, and `pretty:check` scripts to `package.json`:

- `.prettierrc.json`, `.prettierignore`
- `.lintstagedrc.json`
- `.editorconfig`
- `.githooks/`
- `pint.json`

Existing config files are overwritten — use `git diff` to review changes before committing. Pass `--suggest` to write new configs as suggestion files alongside your existing ones instead. In `--suggest` mode, Pretty Code does not update your git hooks path or rewrite `package.json` scripts:

```
npx pretty-code init --suggest
```

This writes:

- `.lintstagedrc.suggestions.json`
- `.prettierrc.suggestions.json`
- `.prettierignore.suggestions`
- `.editorconfig.suggestions`
- `pint.suggestions.json`
- `.githooks.suggestions/`

Commands
--------

[](#commands)

```
# Run all formatters
npm run pretty:format

# Prettier only — JS, CSS, HTML, Blade, Antlers, JSON, YAML, etc.
npm run pretty:format:prettier

# Pint only — PHP files
npm run pretty:format:pint

# Check formatting without writing (useful in CI)
npm run pretty:check
```

Updating
--------

[](#updating)

When a new version of Pretty Code is released, update the package then run:

```
npm update @lform/pretty-code
npx pretty-code update
```

This overwrites your config files with the latest package versions. Use `git diff` to review and selectively revert any changes you want to keep. Pass `--suggest` to write updated configs as `.suggestions.*` files instead:

```
npx pretty-code update --suggest
```

PHP Formatting
--------------

[](#php-formatting)

### Laravel Pint (recommended)

[](#laravel-pint-recommended)

[Laravel Pint](https://laravel.com/docs/pint) is the recommended PHP formatter and is included by default in both **Roots Bedrock + Sage** and **Statamic** — no separate install needed for those projects. The `pint.json` config file is copied to your project root during `init`.

### PHP CS Fixer (alternative)

[](#php-cs-fixer-alternative)

For projects that cannot use Laravel Pint, a `.php-cs-fixer.php` baseline configuration is included in the package as a reference. To use it:

1. Install PHP CS Fixer:

```
composer require --dev friendsofphp/php-cs-fixer
```

2. Copy the baseline config to your project root:

```
cp node_modules/@lform/pretty-code/.php-cs-fixer.php .php-cs-fixer.php
```

3. Update `.lintstagedrc.json` to replace the Pint rule with PHP CS Fixer:

```
"*.php": "vendor/bin/php-cs-fixer fix"
```

4. Update the `pretty:format:pint` script in `package.json`:

```
"pretty:format:pint": "vendor/bin/php-cs-fixer fix"
```

Supported File Types
--------------------

[](#supported-file-types)

ExtensionTool`php`Pint`blade.php`Prettier`antlers.html`, `antlers.php`Prettier`js`, `jsx`, `ts`, `tsx`Prettier`css`, `scss`, `pcss`Prettier`html`, `htm`Prettier`json`Prettier`yaml`, `yml`PrettierConfiguration Files
-------------------

[](#configuration-files)

FileDescription`.prettierrc.json`Prettier configuration`.prettierignore`Files excluded from Prettier`.lintstagedrc.json`Pre-commit hook rules`.editorconfig`Editor-wide formatting defaults`.githooks/`Git hook scripts`pint.json`Laravel Pint configuration`.php-cs-fixer.php`PHP CS Fixer baseline (reference — copy manually if needed)Customization Per Project
-------------------------

[](#customization-per-project)

To customize formatting for a specific project, copy the relevant config file from `node_modules/@lform/pretty-code/` to the project root and modify it as needed. Only copy what you need — copied files will no longer receive updates from the package manager.

To undo a customization, delete the project-level config file and it will fall back to the package default.

Troubleshooting
---------------

[](#troubleshooting)

### Disconnecting &amp; Reconnecting the Git Hook

[](#disconnecting--reconnecting-the-git-hook)

If you need to disable or re-enable the automated pre-commit hook:

```
# Disable:
git config core.hooksPath ".git/hooks"

# Re-enable:
git config core.hooksPath ".githooks"
```

Uninstalling
------------

[](#uninstalling)

1. Delete any config files copied to the project root
2. Delete the `.githooks` directory
3. Run `git config core.hooksPath .git/hooks`
4. Run `npm remove @lform/pretty-code`
5. Remove the `pretty:format`, `pretty:format:prettier`, `pretty:format:pint`, and `pretty:check` scripts from `package.json`

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance85

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~102 days

Recently: every ~169 days

Total

8

Last Release

78d ago

Major Versions

1.2.0 → 2.0.02026-04-17

PHP version history (3 changes)1.0.0PHP &gt;=8.0

1.0.1PHP ^7.4|^8.0

2.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31044312?v=4)[Lform Design](/maintainers/lform)[@lform](https://github.com/lform)

---

Top Contributors

[![innoscience](https://avatars.githubusercontent.com/u/6894281?v=4)](https://github.com/innoscience "innoscience (50 commits)")[![Code-Derek](https://avatars.githubusercontent.com/u/66320617?v=4)](https://github.com/Code-Derek "Code-Derek (4 commits)")

### Embed Badge

![Health badge](/badges/lform-pretty-code/health.svg)

```
[![Health](https://phpackages.com/badges/lform-pretty-code/health.svg)](https://phpackages.com/packages/lform-pretty-code)
```

###  Alternatives

[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87718.9k56](/packages/ticketswap-phpstan-error-formatter)[shopsys/coding-standards

Coding standards definition compatible with PSR-2

20280.7k20](/packages/shopsys-coding-standards)[ec-europa/toolkit

Toolkit packaged for Drupal projects based on Robo.

40252.8k34](/packages/ec-europa-toolkit)[ergebnis/rector-rules

Provides rules for rector/rector.

10245.6k51](/packages/ergebnis-rector-rules)[lipemat/phpstan-wordpress

Phpstan extension for working with WordPress

1462.8k1](/packages/lipemat-phpstan-wordpress)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
