npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lform/pretty-code

v2.0.2

Published

Lform code formatting configurations

Downloads

191

Readme

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

  1. Requirements
  2. Installation & Setup
  3. Commands
  4. Updating
  5. PHP Formatting
  6. Supported File Types
  7. Configuration Files
  8. Customization per Project
  9. Troubleshooting
  10. Uninstalling

Requirements

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

Installation & Setup

Installation

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

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

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

# 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

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

Laravel Pint (recommended)

Laravel 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)

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
  1. Copy the baseline config to your project root:
cp node_modules/@lform/pretty-code/.php-cs-fixer.php .php-cs-fixer.php
  1. Update .lintstagedrc.json to replace the Pint rule with PHP CS Fixer:
"*.php": "vendor/bin/php-cs-fixer fix"
  1. Update the pretty:format:pint script in package.json:
"pretty:format:pint": "vendor/bin/php-cs-fixer fix"

Supported File Types

| Extension | Tool | | ----------------------------- | -------- | | 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 | Prettier |

Configuration Files

| File | Description | | -------------------- | ----------------------------------------------------------- | | .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

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

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

  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