@jmlweb/prettier-config-base 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +153 -3
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @jmlweb/prettier-config-base
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 4a9ece1: Update documentation to use pnpm commands instead of npm
8
+
9
+ ## 1.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 6b73301: Add changelog section with link to CHANGELOG.md in package READMEs
14
+
3
15
  ## 1.0.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -16,9 +16,11 @@
16
16
  ## 📦 Installation
17
17
 
18
18
  ```bash
19
- npm install --save-dev @jmlweb/prettier-config-base prettier
19
+ pnpm add -D @jmlweb/prettier-config-base prettier
20
20
  ```
21
21
 
22
+ > 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
23
+
22
24
  ## 🚀 Quick Start
23
25
 
24
26
  ### Option 1: Using `package.json` (Recommended)
@@ -86,6 +88,38 @@ function greet(user) {
86
88
  }
87
89
  ```
88
90
 
91
+ ## 🤔 Why Use This?
92
+
93
+ > **Philosophy**: Stop arguing about code style. Let Prettier handle formatting so you can focus on writing code.
94
+
95
+ This package provides an opinionated Prettier configuration that prioritizes readability and modern JavaScript conventions. The goal is to eliminate formatting debates and establish consistent code style across all projects.
96
+
97
+ ### Design Decisions
98
+
99
+ **Semicolons (`semi: true`)**: Always use semicolons
100
+
101
+ - **Why**: Prevents ASI (Automatic Semicolon Insertion) edge cases and ambiguity
102
+ - **Trade-off**: Slightly more verbose, but eliminates an entire class of potential bugs
103
+ - **When to override**: If your team strongly prefers semicolon-free style and understands ASI rules
104
+
105
+ **Single Quotes (`singleQuote: true`)**: Use single quotes for strings
106
+
107
+ - **Why**: Consistent with most modern JavaScript codebases and requires less escaping in JSX
108
+ - **Trade-off**: None significant - purely stylistic choice for consistency
109
+ - **When to override**: If working in a codebase that already uses double quotes
110
+
111
+ **Trailing Commas (`trailingComma: 'all'`)**: Add trailing commas everywhere possible
112
+
113
+ - **Why**: Cleaner git diffs (changes only affect modified lines) and easier to add items without modifying previous line
114
+ - **Trade-off**: Slightly unusual for developers from other languages, but widely adopted in modern JS
115
+ - **When to override**: If targeting older environments that don't support trailing commas (rare with modern transpilation)
116
+
117
+ **2 Spaces Indentation (`tabWidth: 2`)**: Use 2 spaces for indentation
118
+
119
+ - **Why**: Balances readability with horizontal space, standard in JavaScript ecosystem
120
+ - **Trade-off**: May feel cramped compared to 4 spaces, but prevents excessive nesting visibility
121
+ - **When to override**: If your team or organization has standardized on 4 spaces
122
+
89
123
  ## 🎯 When to Use
90
124
 
91
125
  Use this package when you want:
@@ -129,8 +163,8 @@ Add formatting scripts to your `package.json`:
129
163
  Then run:
130
164
 
131
165
  ```bash
132
- npm run format # Format all files
133
- npm run format:check # Check formatting without modifying files
166
+ pnpm format # Format all files
167
+ pnpm format:check # Check formatting without modifying files
134
168
  ```
135
169
 
136
170
  ## 📋 Requirements
@@ -153,9 +187,125 @@ See real-world usage examples:
153
187
 
154
188
  ## 🔗 Related Packages
155
189
 
190
+ ### Internal Packages
191
+
156
192
  - [`@jmlweb/prettier-config-tailwind`](../prettier-config-tailwind) - Adds Tailwind CSS class sorting
157
193
  - [`@jmlweb/eslint-config-base`](../eslint-config-base) - ESLint config that works seamlessly with this Prettier config
158
194
 
195
+ ### External Tools
196
+
197
+ - [Prettier](https://prettier.io/) - Opinionated code formatter
198
+ - [ESLint](https://eslint.org/) - Pluggable linting utility (use with eslint-config-prettier to avoid conflicts)
199
+ - [Editor Plugins](https://prettier.io/docs/en/editors.html) - Format on save in VS Code, IntelliJ, and more
200
+
201
+ ## ⚠️ Common Issues
202
+
203
+ > **Note:** This section documents known issues and their solutions. If you encounter a problem not listed here, please [open an issue](https://github.com/jmlweb/tooling/issues/new).
204
+
205
+ ### Conflicts with ESLint
206
+
207
+ **Symptoms:**
208
+
209
+ - Code gets formatted by Prettier then changed back by ESLint auto-fix
210
+ - Linting errors about formatting (quotes, semicolons, etc.)
211
+
212
+ **Cause:**
213
+
214
+ - ESLint has formatting rules that conflict with Prettier
215
+ - Both tools trying to format the same code
216
+
217
+ **Solution:**
218
+
219
+ Install `eslint-config-prettier` to disable conflicting ESLint rules:
220
+
221
+ ```bash
222
+ pnpm add -D eslint-config-prettier
223
+ ```
224
+
225
+ Then add it to your ESLint config (must be last):
226
+
227
+ ```javascript
228
+ // eslint.config.js (flat config)
229
+ import prettier from 'eslint-config-prettier';
230
+
231
+ export default [
232
+ // ... other configs
233
+ prettier, // Must be last!
234
+ ];
235
+ ```
236
+
237
+ Or use [`@jmlweb/eslint-config-base`](../eslint-config-base) which already includes this integration.
238
+
239
+ ### IDE Not Formatting on Save
240
+
241
+ **Symptoms:**
242
+
243
+ - Files don't format automatically when saving
244
+ - Manual format command works but auto-format doesn't
245
+
246
+ **Cause:**
247
+
248
+ - IDE Prettier extension not installed or configured
249
+ - Wrong formatter selected as default
250
+
251
+ **Solution:**
252
+
253
+ For VS Code, install the Prettier extension and add to `.vscode/settings.json`:
254
+
255
+ ```json
256
+ {
257
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
258
+ "editor.formatOnSave": true,
259
+ "[javascript]": {
260
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
261
+ },
262
+ "[typescript]": {
263
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
264
+ }
265
+ }
266
+ ```
267
+
268
+ ### Configuration Not Being Picked Up
269
+
270
+ **Symptoms:**
271
+
272
+ - Prettier uses default settings instead of your config
273
+ - Custom options not applied
274
+
275
+ **Cause:**
276
+
277
+ - Configuration file not in the correct location
278
+ - Multiple config files conflicting
279
+
280
+ **Solution:**
281
+
282
+ 1. Ensure config is in project root (not nested directories)
283
+ 2. Use only one configuration method (package.json OR .prettierrc)
284
+ 3. Check for conflicting configs in parent directories
285
+ 4. Restart your IDE/editor
286
+
287
+ To verify Prettier finds your config:
288
+
289
+ ```bash
290
+ pnpm exec prettier --find-config-path src/index.ts
291
+ ```
292
+
293
+ ## 🔄 Migration Guide
294
+
295
+ ### Upgrading to a New Version
296
+
297
+ > **Note:** If no breaking changes were introduced in a version, it's safe to upgrade without additional steps.
298
+
299
+ **No breaking changes have been introduced yet.** This package follows semantic versioning. When breaking changes are introduced, detailed migration instructions will be provided here.
300
+
301
+ For version history, see the [Changelog](./CHANGELOG.md).
302
+
303
+ **Need Help?** If you encounter issues during migration, please [open an issue](https://github.com/jmlweb/tooling/issues/new).
304
+
305
+ ## 📜 Changelog
306
+
307
+ See [CHANGELOG.md](./CHANGELOG.md) for version history and release notes.
308
+
159
309
  ## 📄 License
160
310
 
161
311
  MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlweb/prettier-config-base",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Base Prettier configuration for jmlweb projects",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",