{"id":20281,"library":"prettier-check","title":"prettier-check","description":"A CLI tool to verify that all files match Prettier code style during CI or testing. Version 2.0.0 requires Node >=4 and a peer dependency on prettier. It forwards all arguments to prettier, making it easy to integrate into npm test scripts. Compared to alternatives like lint-staged, prettier-check focuses solely on checking formatting without auto-fixing, ideal for pre-commit hooks or CI gates.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/hexacta/prettier-check","tags":["javascript","prettier","ci","check","lint","style","formatter","code-style"],"install":[{"cmd":"npm install prettier-check","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-check","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-check","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to perform actual formatting check","package":"prettier","optional":false}],"imports":[{"note":"prettier-check v2 does not support --check flag; all arguments forwarded to prettier.","wrong":"npx prettier-check --check src/**/*.js","symbol":"prettier-check (cli)","correct":"npx prettier-check --single-quote src/**/*.js"},{"note":"prettier-check v2 only returns exit code; for listing files use prettier's --list-different instead.","wrong":"\"check-format\": \"prettier-check --list-different src/**/*.js\"","symbol":"npm script usage","correct":"\"check-format\": \"prettier-check src/**/*.js\""},{"note":"prettier-check is a CLI tool only; cannot be imported programmatically. Use child_process.exec or similar to invoke.","wrong":"const prettierCheck = require('prettier-check');","symbol":"require or import","correct":"not applicable; CLI only"}],"quickstart":{"code":"{\n  \"scripts\": {\n    \"test\": \"prettier-check --single-quote --trailing-comma es5 src/**/*.js\"\n  }\n}","lang":"javascript","description":"Shows how to integrate prettier-check into npm test scripts, passing Prettier options via CLI arguments."},"warnings":[{"fix":"Use prettier --write locally or in pre-commit hooks for auto-formatting.","message":"prettier-check does not auto-fix files; it only returns exit code 1 on mismatch.","severity":"gotcha","affected_versions":"all"},{"fix":"For file listing, switch to prettier --list-different or use prettier-check@1.x.","message":"Version 2.0.0 changed behavior: it no longer lists non-conforming files; exit code only.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update to prettier-check@2.0.0 but note changed behavior.","message":"prettier-check v1 is deprecated; upgrade to v2 for better compatibility with latest prettier.","severity":"deprecated","affected_versions":"<2.0.0"},{"fix":"Use double quotes: \"prettier-check 'src/**/*.js'\" or escape glob.","message":"Glob patterns must be quoted in npm scripts to avoid shell expansion.","severity":"gotcha","affected_versions":"all"},{"fix":"Ensure prettier is listed in devDependencies or installed globally.","message":"prettier must be installed as a dependency; global prettier may not be found.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev prettier","cause":"prettier is not installed or not in node_modules.","error":"Error: Cannot find module 'prettier'"},{"fix":"Double-check glob pattern and ensure files exist. Use quotes in npm scripts: 'src/**/*.js'","cause":"Glob pattern did not match any files due to quoting or path issues.","error":"prettier-check: No files to check"},{"fix":"Update Node to >=4 or use a transpiler like Babel.","cause":"Using ES2015+ syntax (e.g., object spread) in Node <4 without transpilation.","error":"SyntaxError: Unexpected token ...","affected_versions":">=2.0.0"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}