|
| 1 | +# 🌽 @codecorn/prettier-guide-community 🌍 |
| 2 | + |
| 3 | +> 🪶 Minimal, reliable Prettier setup for VSCode + npm + CI + Git hooks. |
| 4 | +> Predictable formatting, zero noise, team-friendly and community-driven. <br> |
| 5 | +> Avoid conflicts, ignore only what’s necessary, and standardize across repos. |
| 6 | +
|
| 7 | +--- |
| 8 | + |
| 9 | +[](#) |
| 10 | +[](https://github.com/CodeCornTech/prettier-guide-community/stargazers) |
| 11 | +[](https://github.com/CodeCornTech/prettier-guide-community/issues) |
| 12 | +[](./LICENSE) |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +> If this guide helps you, **please leave a ⭐ star** and/or open a PR! |
| 17 | +
|
| 18 | +## TL;DR |
| 19 | + |
| 20 | +```bash |
| 21 | +npm i -D prettier |
| 22 | +npm set-script format "prettier --write ." |
| 23 | +npm set-script "format:check" "prettier --check ." |
| 24 | +``` |
| 25 | + |
| 26 | +`.prettierrc.json` |
| 27 | + |
| 28 | +```json |
| 29 | +{ |
| 30 | + "$schema": "https://json.schemastore.org/prettierrc", |
| 31 | + "tabWidth": 2, |
| 32 | + "useTabs": false, |
| 33 | + "printWidth": 100, |
| 34 | + "singleQuote": false, |
| 35 | + "trailingComma": "es5", |
| 36 | + "semi": true, |
| 37 | + "endOfLine": "lf" |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | +`.prettierignore` |
| 42 | + |
| 43 | +``` |
| 44 | +node_modules |
| 45 | +dist |
| 46 | +build |
| 47 | +coverage |
| 48 | +.vscode |
| 49 | +.DS_Store |
| 50 | +``` |
| 51 | + |
| 52 | +`.vscode/settings.json` |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "editor.defaultFormatter": "esbenp.prettier-vscode", |
| 57 | + "editor.formatOnSave": true, |
| 58 | + "prettier.requireConfig": true, |
| 59 | + "files.eol": "\n" |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +## Properly ignoring |
| 64 | + |
| 65 | +- **Single line** |
| 66 | + |
| 67 | + ```js |
| 68 | + // prettier-ignore |
| 69 | + const x={a:1,b:2} |
| 70 | + ``` |
| 71 | + |
| 72 | +- **Block** |
| 73 | + |
| 74 | + ```js |
| 75 | + // prettier-ignore-start |
| 76 | + function demo() { |
| 77 | + return 1; |
| 78 | + } |
| 79 | + const x = { a: 1, b: 2 }; |
| 80 | + // prettier-ignore-end |
| 81 | + ``` |
| 82 | + |
| 83 | +- **Whole file** (must be first line) |
| 84 | + |
| 85 | + ```js |
| 86 | + // prettier-ignore-file |
| 87 | + ``` |
| 88 | + |
| 89 | +> For JS/TS use `//` (not `/* */`). Avoid _Format Selection_ if you rely on ignores: prefer **Format on Save** / **Format Document**. |
| 90 | +
|
| 91 | +## ESLint (optional) |
| 92 | + |
| 93 | +```bash |
| 94 | +npm i -D eslint-config-prettier eslint-plugin-prettier |
| 95 | +``` |
| 96 | + |
| 97 | +Minimal `.eslintrc`: |
| 98 | + |
| 99 | +```json |
| 100 | +{ |
| 101 | + "extends": ["eslint:recommended", "plugin:prettier/recommended"] |
| 102 | +} |
| 103 | +``` |
| 104 | + |
| 105 | +## CI (GitHub Actions, optional) |
| 106 | + |
| 107 | +`.github/workflows/prettier.yml` |
| 108 | + |
| 109 | +```yaml |
| 110 | +name: Prettier |
| 111 | +on: { pull_request: {}, push: { branches: [main] } } |
| 112 | +jobs: |
| 113 | + check: |
| 114 | + runs-on: ubuntu-latest |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@v4 |
| 117 | + - uses: actions/setup-node@v4 |
| 118 | + with: { node-version: 20 } |
| 119 | + - run: npm ci || npm i |
| 120 | + - run: npm run format:check |
| 121 | +``` |
| 122 | +
|
| 123 | +## Quick troubleshooting |
| 124 | +
|
| 125 | +1. Status bar should show **Prettier** as the formatter. |
| 126 | +2. With `prettier.requireConfig: true` you need a nearby `.prettierrc`. |
| 127 | +3. `.editorconfig` may override EOL/indent — align or remove it. |
| 128 | +4. Disable competing formatters (Beautify, Biome/Rome, ESLint formatter). |
| 129 | +5. Parsers are auto-detected (JS/TS → `babel`/`babel-ts`; HTML/CSS/JSON/MD built-in). |
| 130 | +6. Don’t format files outside workspace or in subfolders with different configs. |
| 131 | + |
| 132 | +Happy formatting! 🚀 |
| 133 | + |
| 134 | +## 🌍 Languages |
| 135 | + |
| 136 | +🌐 🇮🇹 IT — 🇬🇧 EN |
| 137 | +Want to add more languages? **Contributions are welcome!** |
| 138 | + |
| 139 | +## 📝 License |
| 140 | + |
| 141 | +MIT © [CodeCorn™](https://codecorn.it) — Distributed under the [MIT](../LICENSE) license. |
| 142 | + |
| 143 | +### ⭐ Support |
| 144 | + |
| 145 | +If this was useful, **star the repo** and share it with your team. |
| 146 | + |
| 147 | +### 🤝 Contribute |
| 148 | + |
| 149 | +PRs welcome. Open an issue for proposals/bugs. Thanks! |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +### ⭐ Support the Project |
| 154 | + |
| 155 | +If this guide helped you, **leave a star ⭐ on GitHub** and help us grow the CodeCorn community! |
| 156 | + |
| 157 | +[](https://github.com/CodeCornTech/prettier-guide-community/stargazers) |
| 158 | +[](https://github.com/CodeCornTech/prettier-guide-community/fork) |
| 159 | + |
| 160 | +--- |
| 161 | + |
| 162 | +## 🧭 Maintainer |
| 163 | + |
| 164 | +<div style="display: flex; justify-content: space-between; align-items: center;"> |
| 165 | + <div> |
| 166 | + <p><strong>👨💻 Federico Girolami</strong></p> |
| 167 | + <p><strong>Full Stack Developer</strong> | <strong>System Integrator</strong> | <strong>Digital Solution Architect</strong> 🚀</p> |
| 168 | + <p>📫 <strong>Get in Touch</strong></p> |
| 169 | + <p>🌐 <strong>Website</strong>: <a href="https://codecorn.it">codecorn.it</a> *(Under Construction)*</p> |
| 170 | + <p>📧 <strong>Email</strong>: <a href="mailto:[email protected]">[email protected]</a></p> |
| 171 | + <p>🐙 <strong>GitHub</strong>: <a href="https://github.com/fgirolami29">github.com/fgirolami29</a></p> |
| 172 | + </div> |
| 173 | + <div style="text-align: center;"> |
| 174 | + <a href="https://www.codecorn.it"> |
| 175 | + <img src="https://codecorn.it/wp-content/uploads/2025/05/CODECORN-trasp-qhite.png" alt="Code Corn Logo" width="250px" height="90px" style="margin-top:0;margin-bottom:20px;"/> |
| 176 | + </a> |
| 177 | + <a href="https://github.com/fgirolami29"> |
| 178 | + <img src="https://avatars.githubusercontent.com/u/68548715?s=200&v=4" alt="Federico Girolami Avatar" style="border-radius: 50%; width: 125px; height: 125px;border: 5px solid gold" /> |
| 179 | + </a> |
| 180 | + </div> |
| 181 | +</div> |
0 commit comments