🪶 Minimal, reliable Prettier setup for VSCode + npm + CI + Git hooks.
Predictable formatting, zero noise, team-friendly and community-driven.
Avoid conflicts, ignore only what’s necessary, and standardize across repos.
If this guide helps you, please leave a ⭐ star and/or open a PR!
npm i -D prettier
npm set-script format "prettier --write ."
npm set-script "format:check" "prettier --check .".prettierrc.json
{
"$schema": "https://json.schemastore.org/prettierrc",
"tabWidth": 2,
"useTabs": false,
"printWidth": 100,
"singleQuote": false,
"trailingComma": "es5",
"semi": true,
"endOfLine": "lf"
}.prettierignore
node_modules
dist
build
coverage
.vscode
.DS_Store
.vscode/settings.json
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"prettier.requireConfig": true,
"files.eol": "\n"
}-
Single line
// prettier-ignore const x={a:1,b:2}
-
Block
// prettier-ignore-start function demo() { return 1; } const x = { a: 1, b: 2 }; // prettier-ignore-end
-
Whole file (must be first line)
// prettier-ignore-file
For JS/TS use
//(not/* */). Avoid Format Selection if you rely on ignores: prefer Format on Save / Format Document.
npm i -D eslint-config-prettier eslint-plugin-prettierMinimal .eslintrc:
{
"extends": ["eslint:recommended", "plugin:prettier/recommended"]
}.github/workflows/prettier.yml
name: Prettier
on: { pull_request: {}, push: { branches: [main] } }
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm ci || npm i
- run: npm run format:check- Status bar should show Prettier as the formatter.
- With
prettier.requireConfig: trueyou need a nearby.prettierrc. .editorconfigmay override EOL/indent — align or remove it.- Disable competing formatters (Beautify, Biome/Rome, ESLint formatter).
- Parsers are auto-detected (JS/TS →
babel/babel-ts; HTML/CSS/JSON/MD built-in). - Don’t format files outside workspace or in subfolders with different configs.
Happy formatting! 🚀
🌐 🇮🇹 IT — 🇬🇧 EN Want to add more languages? Contributions are welcome!
MIT © CodeCorn™ — Distributed under the MIT license.
If this was useful, star the repo and share it with your team.
PRs welcome. Open an issue for proposals/bugs. Thanks!
If this guide helped you, leave a star ⭐ on GitHub and help us grow the CodeCorn community!
👨💻 Federico Girolami
Full Stack Developer | System Integrator | Digital Solution Architect 🚀
📫 Get in Touch
🌐 Website: codecorn.it *(Under Construction)*
📧 Email: f.girolami@codecorn.it
🐙 GitHub: github.com/fgirolami29