@jmlweb/prettier-config-base 1.0.3 → 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.
- package/CHANGELOG.md +6 -0
- package/README.md +37 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
## 📦 Installation
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
|
|
19
|
+
pnpm add -D @jmlweb/prettier-config-base prettier
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
> 💡 **Upgrading from a previous version?** See the [Migration Guide](#-migration-guide) for breaking changes and upgrade instructions.
|
|
@@ -88,6 +88,38 @@ function greet(user) {
|
|
|
88
88
|
}
|
|
89
89
|
```
|
|
90
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
|
+
|
|
91
123
|
## 🎯 When to Use
|
|
92
124
|
|
|
93
125
|
Use this package when you want:
|
|
@@ -131,8 +163,8 @@ Add formatting scripts to your `package.json`:
|
|
|
131
163
|
Then run:
|
|
132
164
|
|
|
133
165
|
```bash
|
|
134
|
-
|
|
135
|
-
|
|
166
|
+
pnpm format # Format all files
|
|
167
|
+
pnpm format:check # Check formatting without modifying files
|
|
136
168
|
```
|
|
137
169
|
|
|
138
170
|
## 📋 Requirements
|
|
@@ -187,7 +219,7 @@ See real-world usage examples:
|
|
|
187
219
|
Install `eslint-config-prettier` to disable conflicting ESLint rules:
|
|
188
220
|
|
|
189
221
|
```bash
|
|
190
|
-
|
|
222
|
+
pnpm add -D eslint-config-prettier
|
|
191
223
|
```
|
|
192
224
|
|
|
193
225
|
Then add it to your ESLint config (must be last):
|
|
@@ -255,7 +287,7 @@ For VS Code, install the Prettier extension and add to `.vscode/settings.json`:
|
|
|
255
287
|
To verify Prettier finds your config:
|
|
256
288
|
|
|
257
289
|
```bash
|
|
258
|
-
|
|
290
|
+
pnpm exec prettier --find-config-path src/index.ts
|
|
259
291
|
```
|
|
260
292
|
|
|
261
293
|
## 🔄 Migration Guide
|