prettier-standard
raw JSON →Prettier-standard is a CLI tool that combines prettierx (a prettier fork) for code formatting with eslint preconfigured with the standard ruleset. Current version 16.4.1 (requires Node >=8) wraps prettierx and eslint to format and optionally lint JavaScript/TypeScript/CSS files. It simplifies setup by eliminating separate eslint config for whitespace, and provides flags like --staged, --changed, --since for git-aware formatting. Since v9.0.0, it uses .prettierrc for config instead of .eslintrc, and v12.0.0 was a complete rewrite without spawning subprocesses, improving speed. It is well-suited for teams wanting standard-compliant code with minimal configuration, but note that it uses prettierx, not upstream prettier, and may have slight formatting differences.
Common errors
error Error: Cannot find module 'prettier-standard' ↓
error prettier-standard: command not found ↓
error SyntaxError: Unexpected token (1:1) while parsing /path/to/file ↓
Warnings
breaking Since v9.0.0, prettier-standard no longer passes code through 'standard --fix'. It uses prettierx instead. ↓
breaking Since v9.0.0, custom configuration happens through .prettierrc instead of .eslintrc. Output matches prettier output. ↓
gotcha --lines flag is experimental; prettier has known issues with range formatting (prettier#4926, prettier#6428). ↓
gotcha This package uses prettierx, not upstream prettier. Formatting may differ slightly from prettier. ↓
Install
npm install prettier-standard yarn add prettier-standard pnpm add prettier-standard Imports
- default wrong
const prettierStandard = require('prettier-standard')correctimport prettierStandard from 'prettier-standard' - run wrong
import run from 'prettier-standard'correctimport { run } from 'prettier-standard' - formatFiles wrong
const { formatFiles } = require('prettier-standard')correctimport { formatFiles } from 'prettier-standard'
Quickstart
// Install globally or locally
npm install -g prettier-standard
// Format all files in project and lint
prettier-standard --lint
// Format only staged files (for precommit hooks)
prettier-standard --staged
// Format changed lines since master
prettier-standard --changed --since master
// Use as a lint-staged step in package.json
"lint-staged": {
"*.{js,jsx,ts,tsx,css}": ["prettier-standard --lint"]
}