prettier-check
raw JSON → 1.0.3 verified Sat Apr 25 auth: no javascript
A CLI tool to verify that all source files match Prettier code style, designed for CI integration. Current stable version is 1.0.3. The tool reads a 'checkFiles' pattern from package.json and checks formatting, exiting with non-zero if violations are found. It differs from alternatives by requiring Prettier installed separately and using a config key in package.json. Use it in pre-commit hooks or CI pipelines to enforce consistent code formatting. The package is authored by the same developer as other frontend tools and is under active maintenance.
Common errors
error Error: Cannot find module 'prettier' ↓
cause Prettier is not installed or not in node_modules.
fix
Run 'npm install --save-dev prettier' to install it.
error No files matching pattern ↓
cause The 'checkFiles' patterns do not match any files in the project.
fix
Update the patterns in package.json to match your source files.
Warnings
gotcha The package does not work without 'prettier' installed as a separate dependency. ↓
fix Ensure 'prettier' is in your devDependencies.
gotcha File patterns must be defined in the 'checkFiles' key of package.json, otherwise no files are checked. ↓
fix Add a 'checkFiles' array to package.json with glob patterns.
Install
npm install check-prettier yarn add check-prettier pnpm add check-prettier Imports
- default wrong
require('check-prettier') or import checkPrettier from 'check-prettier'correctnpx check-prettier
Quickstart
npm install --save-dev prettier check-prettier
# In package.json, add:
# "checkFiles": ["src/**/*.js"]
# "scripts": { "lint-prettier": "check-prettier" }
# Then run:
npx check-prettier