@dimensional-innovations/tool-config 1.0.0
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/LICENSE +21 -0
- package/README.md +646 -0
- package/bin/setup-tool-config.js +675 -0
- package/package.json +168 -0
- package/src/detectors.js +261 -0
- package/src/index.js +64 -0
- package/src/tools/eslint/index.js +287 -0
- package/src/tools/eslint/presets/base.js +82 -0
- package/src/tools/eslint/presets/environments/browser.js +16 -0
- package/src/tools/eslint/presets/environments/node.js +21 -0
- package/src/tools/eslint/presets/environments/universal.js +18 -0
- package/src/tools/eslint/presets/frameworks/angular.js +74 -0
- package/src/tools/eslint/presets/frameworks/astro.js +38 -0
- package/src/tools/eslint/presets/frameworks/node.js +57 -0
- package/src/tools/eslint/presets/frameworks/react.js +76 -0
- package/src/tools/eslint/presets/frameworks/solid.js +45 -0
- package/src/tools/eslint/presets/frameworks/svelte.js +78 -0
- package/src/tools/eslint/presets/frameworks/vanilla.js +16 -0
- package/src/tools/eslint/presets/frameworks/vue.js +125 -0
- package/src/tools/eslint/presets/imports.js +41 -0
- package/src/tools/eslint/presets/typescript.js +131 -0
- package/src/tools/prettier/README.md +398 -0
- package/src/tools/prettier/index.js +114 -0
- package/src/tools/prettier/presets/base.js +36 -0
- package/src/tools/prettier/presets/frameworks/astro.js +15 -0
- package/src/tools/prettier/presets/frameworks/react.js +15 -0
- package/src/tools/prettier/presets/frameworks/svelte.js +22 -0
- package/src/tools/prettier/presets/frameworks/vanilla.js +13 -0
- package/src/tools/prettier/presets/frameworks/vue.js +20 -0
- package/src/tools/prettier/presets/prettierignore.js +56 -0
- package/src/tools/semantic-release/CI_SETUP.md +66 -0
- package/src/tools/semantic-release/README.md +533 -0
- package/src/tools/semantic-release/index.js +130 -0
- package/src/tools/semantic-release/presets/default.js +37 -0
- package/src/tools/semantic-release/presets/library.js +58 -0
- package/src/tools/semantic-release/presets/monorepo.js +48 -0
- package/src/tools/semantic-release/templates/.gitlab-ci.yml +85 -0
- package/src/tools/semantic-release/templates/bitbucket-pipelines.yml +100 -0
- package/src/tools/semantic-release/templates/github-workflow.yml +107 -0
- package/src/tools/stylelint/README.md +425 -0
- package/src/tools/stylelint/index.js +191 -0
- package/src/tools/stylelint/presets/base.js +50 -0
- package/src/tools/stylelint/presets/css-modules.js +43 -0
- package/src/tools/stylelint/presets/frameworks/react.js +18 -0
- package/src/tools/stylelint/presets/frameworks/svelte.js +28 -0
- package/src/tools/stylelint/presets/frameworks/vanilla.js +14 -0
- package/src/tools/stylelint/presets/frameworks/vue.js +38 -0
- package/src/tools/stylelint/presets/scss.js +83 -0
- package/src/tools/stylelint/presets/tailwind.js +49 -0
- package/src/utils/package-reader.js +42 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
# Prettier Configuration
|
|
2
|
+
|
|
3
|
+
Framework-aware Prettier configuration with sensible, opinionated defaults.
|
|
4
|
+
|
|
5
|
+
## Philosophy
|
|
6
|
+
|
|
7
|
+
This Prettier configuration is designed to:
|
|
8
|
+
|
|
9
|
+
- **Work out of the box** - Zero configuration needed for all supported frameworks
|
|
10
|
+
- **Be opinionated** - Strong defaults that eliminate bikeshedding
|
|
11
|
+
- **Stay minimal** - Only the essential plugins for each framework
|
|
12
|
+
- **Remain overridable** - All settings can be customized
|
|
13
|
+
|
|
14
|
+
## Base Configuration
|
|
15
|
+
|
|
16
|
+
The base preset applies to all frameworks:
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
{
|
|
20
|
+
semi: false, // No semicolons (cleaner syntax)
|
|
21
|
+
singleQuote: true, // Single quotes (except in JSX)
|
|
22
|
+
trailingComma: 'none', // No trailing commas (simpler diffs)
|
|
23
|
+
printWidth: 100, // 100 character lines (readable but not too long)
|
|
24
|
+
tabWidth: 2, // 2 space indentation (standard)
|
|
25
|
+
useTabs: false, // Spaces over tabs
|
|
26
|
+
arrowParens: 'avoid', // Avoid unnecessary parentheses in arrow functions
|
|
27
|
+
bracketSpacing: true, // Space inside object braces
|
|
28
|
+
endOfLine: 'lf' // Unix line endings
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Framework-Specific Behavior
|
|
33
|
+
|
|
34
|
+
### Vue.js
|
|
35
|
+
|
|
36
|
+
**Plugin Required**: `prettier-plugin-vue`
|
|
37
|
+
|
|
38
|
+
**Additional Options**:
|
|
39
|
+
|
|
40
|
+
- `vueIndentScriptAndStyle: false` - Keep `<script>` and `<style>` aligned with `<template>`
|
|
41
|
+
- `htmlWhitespaceSensitivity: 'ignore'` - Prevent Vue template whitespace issues
|
|
42
|
+
|
|
43
|
+
**Installation**:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install --save-dev prettier-plugin-vue
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**Example**:
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
// prettier.config.js
|
|
53
|
+
import { createConfig } from '@dimensional-innovations/tool-config'
|
|
54
|
+
export default createConfig('prettier')
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### React / Solid.js
|
|
58
|
+
|
|
59
|
+
**No Plugin Required** - Prettier has built-in JSX support
|
|
60
|
+
|
|
61
|
+
**Additional Options**:
|
|
62
|
+
|
|
63
|
+
- `jsxSingleQuote: false` - Use double quotes in JSX attributes (React convention)
|
|
64
|
+
- `bracketSameLine: false` - Put closing bracket on new line
|
|
65
|
+
|
|
66
|
+
**Works with**:
|
|
67
|
+
|
|
68
|
+
- React 18+
|
|
69
|
+
- Solid.js 1+
|
|
70
|
+
- Any JSX-based framework
|
|
71
|
+
|
|
72
|
+
### Svelte
|
|
73
|
+
|
|
74
|
+
**Plugin Required**: `prettier-plugin-svelte`
|
|
75
|
+
|
|
76
|
+
**Additional Options**:
|
|
77
|
+
|
|
78
|
+
- `svelteSortOrder: 'options-scripts-markup-styles'` - Standard component block order
|
|
79
|
+
- `svelteStrictMode: false` - Allow flexible syntax
|
|
80
|
+
- `svelteIndentScriptAndStyle: true` - Indent script and style tags
|
|
81
|
+
|
|
82
|
+
**Installation**:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm install --save-dev prettier-plugin-svelte
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Svelte 5 Support**: Fully compatible with Svelte 5 runes (`$state`, `$derived`, etc.)
|
|
89
|
+
|
|
90
|
+
### Astro
|
|
91
|
+
|
|
92
|
+
**Plugin Required**: `prettier-plugin-astro`
|
|
93
|
+
|
|
94
|
+
**Installation**:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install --save-dev prettier-plugin-astro
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Automatic Formatting**: The Astro plugin handles all `.astro` file formatting automatically
|
|
101
|
+
|
|
102
|
+
### Angular / Vanilla JS / Node.js
|
|
103
|
+
|
|
104
|
+
**No Framework-Specific Configuration** - Uses base preset only
|
|
105
|
+
|
|
106
|
+
No plugins or special options needed. Works perfectly for:
|
|
107
|
+
|
|
108
|
+
- Angular 17+
|
|
109
|
+
- Vanilla JavaScript projects
|
|
110
|
+
- Node.js backends
|
|
111
|
+
- TypeScript projects
|
|
112
|
+
|
|
113
|
+
## Usage
|
|
114
|
+
|
|
115
|
+
### Basic Setup
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
// prettier.config.js
|
|
119
|
+
import { createConfig } from '@dimensional-innovations/tool-config'
|
|
120
|
+
|
|
121
|
+
export default createConfig('prettier')
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Explicit Framework
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
// prettier.config.js
|
|
128
|
+
import { createConfig } from '@dimensional-innovations/tool-config'
|
|
129
|
+
|
|
130
|
+
export default createConfig('prettier', {
|
|
131
|
+
framework: 'vue' // 'react' | 'vue' | 'svelte' | 'solid' | 'astro' | 'angular' | 'node' | 'vanilla'
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### With Overrides
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
// prettier.config.js
|
|
139
|
+
import { createConfig } from '@dimensional-innovations/tool-config'
|
|
140
|
+
|
|
141
|
+
export default createConfig('prettier', {
|
|
142
|
+
framework: 'auto',
|
|
143
|
+
printWidth: 120,
|
|
144
|
+
semi: true
|
|
145
|
+
})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Common Overrides
|
|
149
|
+
|
|
150
|
+
### Use semicolons
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
export default createConfig('prettier', {
|
|
154
|
+
semi: true
|
|
155
|
+
})
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Use double quotes everywhere
|
|
159
|
+
|
|
160
|
+
```javascript
|
|
161
|
+
export default createConfig('prettier', {
|
|
162
|
+
singleQuote: false
|
|
163
|
+
})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Enable trailing commas
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
export default createConfig('prettier', {
|
|
170
|
+
trailingComma: 'all' // or 'es5'
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Wider print width
|
|
175
|
+
|
|
176
|
+
```javascript
|
|
177
|
+
export default createConfig('prettier', {
|
|
178
|
+
printWidth: 120
|
|
179
|
+
})
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## NPM Scripts
|
|
183
|
+
|
|
184
|
+
Add these scripts to your `package.json`:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"scripts": {
|
|
189
|
+
"format": "prettier --write .",
|
|
190
|
+
"format:check": "prettier --check ."
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Then run:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npm run prettier:fix # Format all files
|
|
199
|
+
npm run prettier # Check formatting without writing
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## VSCode Integration
|
|
203
|
+
|
|
204
|
+
Install the Prettier extension and add to `.vscode/settings.json`:
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
209
|
+
"editor.formatOnSave": true,
|
|
210
|
+
"[javascript]": {
|
|
211
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
212
|
+
},
|
|
213
|
+
"[typescript]": {
|
|
214
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
215
|
+
},
|
|
216
|
+
"[vue]": {
|
|
217
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
218
|
+
},
|
|
219
|
+
"[svelte]": {
|
|
220
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Ignoring Files
|
|
226
|
+
|
|
227
|
+
Create a `.prettierignore` file:
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
# Build outputs
|
|
231
|
+
dist/
|
|
232
|
+
build/
|
|
233
|
+
.next/
|
|
234
|
+
.nuxt/
|
|
235
|
+
.output/
|
|
236
|
+
|
|
237
|
+
# Dependencies
|
|
238
|
+
node_modules/
|
|
239
|
+
|
|
240
|
+
# Generated files
|
|
241
|
+
*.min.js
|
|
242
|
+
*.min.css
|
|
243
|
+
coverage/
|
|
244
|
+
|
|
245
|
+
# Config files that might have specific formatting
|
|
246
|
+
package-lock.json
|
|
247
|
+
pnpm-lock.yaml
|
|
248
|
+
yarn.lock
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Integration with ESLint
|
|
252
|
+
|
|
253
|
+
This package deliberately **does not** integrate Prettier with ESLint. They remain separate tools:
|
|
254
|
+
|
|
255
|
+
- **ESLint**: Code quality and correctness
|
|
256
|
+
- **Prettier**: Code formatting
|
|
257
|
+
|
|
258
|
+
Run them separately:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
npm run lint && npm run prettier:fix
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Troubleshooting
|
|
265
|
+
|
|
266
|
+
### Plugin not found error
|
|
267
|
+
|
|
268
|
+
If you see errors like `Cannot find module 'prettier-plugin-svelte'`:
|
|
269
|
+
|
|
270
|
+
1. Install the required plugin:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
npm install --save-dev prettier-plugin-svelte
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
2. Or specify a framework that doesn't need plugins:
|
|
277
|
+
```javascript
|
|
278
|
+
export default createConfig('prettier', { framework: 'react' })
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Config not being detected
|
|
282
|
+
|
|
283
|
+
Make sure your config file is named correctly:
|
|
284
|
+
|
|
285
|
+
- `prettier.config.js` ✓
|
|
286
|
+
- `prettier.config.mjs` ✓
|
|
287
|
+
- `.prettierrc.js` ✓
|
|
288
|
+
- `.prettierrc.mjs` ✓
|
|
289
|
+
|
|
290
|
+
And uses ES modules (since your package.json has `"type": "module"`).
|
|
291
|
+
|
|
292
|
+
### Formatting conflicts
|
|
293
|
+
|
|
294
|
+
If ESLint and Prettier disagree:
|
|
295
|
+
|
|
296
|
+
1. **This shouldn't happen** - The ESLint config is designed to work with Prettier
|
|
297
|
+
2. If it does, check your custom ESLint rules
|
|
298
|
+
3. ESLint handles code quality, Prettier handles formatting - they shouldn't overlap
|
|
299
|
+
|
|
300
|
+
## Design Decisions
|
|
301
|
+
|
|
302
|
+
### Why no semicolons?
|
|
303
|
+
|
|
304
|
+
Semicolons are optional in JavaScript due to Automatic Semicolon Insertion (ASI). Omitting them:
|
|
305
|
+
|
|
306
|
+
- Reduces visual noise
|
|
307
|
+
- Aligns with modern JavaScript trends
|
|
308
|
+
- Works perfectly with proper tooling
|
|
309
|
+
|
|
310
|
+
If you prefer semicolons, override with `semi: true`.
|
|
311
|
+
|
|
312
|
+
### Why single quotes?
|
|
313
|
+
|
|
314
|
+
Single quotes:
|
|
315
|
+
|
|
316
|
+
- Are more common in modern JavaScript
|
|
317
|
+
- Align with the ESLint configuration
|
|
318
|
+
- Are easier to type (no Shift key needed)
|
|
319
|
+
|
|
320
|
+
**Exception**: JSX attributes use double quotes (React convention).
|
|
321
|
+
|
|
322
|
+
### Why no trailing commas?
|
|
323
|
+
|
|
324
|
+
While trailing commas have benefits (cleaner diffs), we default to `none` because:
|
|
325
|
+
|
|
326
|
+
- Simpler visual appearance
|
|
327
|
+
- Aligns with base ESLint config
|
|
328
|
+
- Easy to override if you prefer `'all'` or `'es5'`
|
|
329
|
+
|
|
330
|
+
### Why printWidth 100?
|
|
331
|
+
|
|
332
|
+
100 characters is a sweet spot:
|
|
333
|
+
|
|
334
|
+
- Modern monitors can easily display this
|
|
335
|
+
- Allows side-by-side diffs
|
|
336
|
+
- Not so wide that code becomes hard to read
|
|
337
|
+
- Works well with nested structures
|
|
338
|
+
|
|
339
|
+
## Migration from Other Configs
|
|
340
|
+
|
|
341
|
+
### From Standard Prettier
|
|
342
|
+
|
|
343
|
+
If you're migrating from default Prettier settings:
|
|
344
|
+
|
|
345
|
+
**Main differences**:
|
|
346
|
+
|
|
347
|
+
- `semi`: `true` → `false`
|
|
348
|
+
- `trailingComma`: `'es5'` → `'none'`
|
|
349
|
+
|
|
350
|
+
**No changes to**:
|
|
351
|
+
|
|
352
|
+
- `singleQuote: true` (same)
|
|
353
|
+
- `printWidth: 100` (we use 100, default is 80)
|
|
354
|
+
- `tabWidth: 2` (same)
|
|
355
|
+
|
|
356
|
+
### From Airbnb
|
|
357
|
+
|
|
358
|
+
Airbnb typically uses:
|
|
359
|
+
|
|
360
|
+
- `semi: true` (we use `false`)
|
|
361
|
+
- `singleQuote: true` (same)
|
|
362
|
+
- `trailingComma: 'all'` (we use `'none'`)
|
|
363
|
+
|
|
364
|
+
Override if needed:
|
|
365
|
+
|
|
366
|
+
```javascript
|
|
367
|
+
export default createConfig('prettier', {
|
|
368
|
+
semi: true,
|
|
369
|
+
trailingComma: 'all'
|
|
370
|
+
})
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## Examples
|
|
374
|
+
|
|
375
|
+
See the `examples/` directory for working examples with all 8 supported frameworks:
|
|
376
|
+
|
|
377
|
+
- [examples/react-app/](../../../examples/react-app/)
|
|
378
|
+
- [examples/vue-app/](../../../examples/vue-app/)
|
|
379
|
+
- [examples/svelte-app/](../../../examples/svelte-app/)
|
|
380
|
+
- [examples/solid-app/](../../../examples/solid-app/)
|
|
381
|
+
- [examples/astro-app/](../../../examples/astro-app/)
|
|
382
|
+
- [examples/angular-app/](../../../examples/angular-app/)
|
|
383
|
+
- [examples/vanilla-js/](../../../examples/vanilla-js/)
|
|
384
|
+
- [examples/node-backend/](../../../examples/node-backend/)
|
|
385
|
+
|
|
386
|
+
Each example includes:
|
|
387
|
+
|
|
388
|
+
- `prettier.config.js` - Configuration file
|
|
389
|
+
- `package.json` - With format scripts
|
|
390
|
+
- Sample code demonstrating formatting
|
|
391
|
+
|
|
392
|
+
## Resources
|
|
393
|
+
|
|
394
|
+
- [Prettier Documentation](https://prettier.io/docs/en/)
|
|
395
|
+
- [Prettier Playground](https://prettier.io/playground/)
|
|
396
|
+
- [prettier-plugin-vue](https://github.com/prettier/prettier-plugin-vue)
|
|
397
|
+
- [prettier-plugin-svelte](https://github.com/sveltejs/prettier-plugin-svelte)
|
|
398
|
+
- [prettier-plugin-astro](https://github.com/withastro/prettier-plugin-astro)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prettier configuration factory
|
|
3
|
+
*
|
|
4
|
+
* Creates Prettier configurations with framework-aware defaults and auto-detection.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { autoDetect } from '../../detectors.js'
|
|
8
|
+
|
|
9
|
+
import basePreset from './presets/base.js'
|
|
10
|
+
import astroPreset from './presets/frameworks/astro.js'
|
|
11
|
+
import reactPreset from './presets/frameworks/react.js'
|
|
12
|
+
import sveltePreset from './presets/frameworks/svelte.js'
|
|
13
|
+
import vanillaPreset from './presets/frameworks/vanilla.js'
|
|
14
|
+
import vuePreset from './presets/frameworks/vue.js'
|
|
15
|
+
import { prettierIgnoreContent } from './presets/prettierignore.js'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Create a Prettier configuration
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} options - Configuration options
|
|
21
|
+
* @param {string} [options.framework='auto'] - Framework to configure for
|
|
22
|
+
* @param {string} [options.cwd=process.cwd()] - Working directory for auto-detection
|
|
23
|
+
* @param {...any} [options.overrides] - User overrides to merge into final config
|
|
24
|
+
* @returns {Object} Prettier configuration object
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Auto-detect framework
|
|
28
|
+
* export default createPrettierConfig();
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Explicit framework
|
|
32
|
+
* export default createPrettierConfig({ framework: 'vue' });
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // With overrides
|
|
36
|
+
* export default createPrettierConfig({
|
|
37
|
+
* framework: 'react',
|
|
38
|
+
* printWidth: 120,
|
|
39
|
+
* semi: true
|
|
40
|
+
* });
|
|
41
|
+
*/
|
|
42
|
+
export function createPrettierConfig(options = {}) {
|
|
43
|
+
const { framework: explicitFramework = 'auto', cwd = process.cwd(), ...userOverrides } = options
|
|
44
|
+
|
|
45
|
+
// Auto-detect framework if needed
|
|
46
|
+
const framework = explicitFramework === 'auto' ? autoDetect(cwd).framework : explicitFramework
|
|
47
|
+
|
|
48
|
+
// Start with base configuration
|
|
49
|
+
const config = { ...basePreset }
|
|
50
|
+
|
|
51
|
+
// Apply framework-specific preset
|
|
52
|
+
switch (framework) {
|
|
53
|
+
case 'vue': {
|
|
54
|
+
Object.assign(config, vuePreset)
|
|
55
|
+
console.warn('📝 Prettier: Detected Vue.js - using Vue plugin')
|
|
56
|
+
break
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
case 'react': {
|
|
60
|
+
Object.assign(config, reactPreset)
|
|
61
|
+
console.warn('📝 Prettier: Detected React - using JSX conventions')
|
|
62
|
+
break
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
case 'solid': {
|
|
66
|
+
// Solid uses same JSX conventions as React
|
|
67
|
+
Object.assign(config, reactPreset)
|
|
68
|
+
console.warn('📝 Prettier: Detected Solid.js - using JSX conventions')
|
|
69
|
+
break
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
case 'svelte': {
|
|
73
|
+
Object.assign(config, sveltePreset)
|
|
74
|
+
console.warn('📝 Prettier: Detected Svelte - using Svelte plugin')
|
|
75
|
+
break
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
case 'astro': {
|
|
79
|
+
Object.assign(config, astroPreset)
|
|
80
|
+
console.warn('📝 Prettier: Detected Astro - using Astro plugin')
|
|
81
|
+
break
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
case 'angular':
|
|
85
|
+
case 'node':
|
|
86
|
+
case 'vanilla': {
|
|
87
|
+
// These frameworks use base config with no additions
|
|
88
|
+
Object.assign(config, vanillaPreset)
|
|
89
|
+
console.warn(`📝 Prettier: Detected ${framework} - using base configuration`)
|
|
90
|
+
break
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
default: {
|
|
94
|
+
console.warn(`⚠️ Unknown framework "${framework}", using base configuration`)
|
|
95
|
+
Object.assign(config, vanillaPreset)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Apply user overrides
|
|
100
|
+
Object.assign(config, userOverrides)
|
|
101
|
+
|
|
102
|
+
return config
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get the default .prettierignore content
|
|
107
|
+
* @returns {string} .prettierignore file content
|
|
108
|
+
*/
|
|
109
|
+
export function getPrettierIgnore() {
|
|
110
|
+
return prettierIgnoreContent
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export { prettierIgnoreContent }
|
|
114
|
+
export default createPrettierConfig
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Prettier preset
|
|
3
|
+
*
|
|
4
|
+
* Opinionated defaults aligned with CLAUDE.md style guide:
|
|
5
|
+
* - No semicolons (cleaner syntax)
|
|
6
|
+
* - Single quotes (consistent with ESLint config)
|
|
7
|
+
* - No trailing commas (simpler diffs)
|
|
8
|
+
* - 100 character line width (readable but not too long)
|
|
9
|
+
* - 2 space indentation (standard)
|
|
10
|
+
* - LF line endings (Unix standard)
|
|
11
|
+
*
|
|
12
|
+
* These settings work universally across all frameworks and can be
|
|
13
|
+
* overridden by framework-specific presets or user configuration.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
// Code style
|
|
18
|
+
semi: false,
|
|
19
|
+
singleQuote: true,
|
|
20
|
+
trailingComma: 'none',
|
|
21
|
+
|
|
22
|
+
// Line formatting
|
|
23
|
+
printWidth: 100,
|
|
24
|
+
tabWidth: 2,
|
|
25
|
+
useTabs: false,
|
|
26
|
+
proseWrap: 'preserve',
|
|
27
|
+
|
|
28
|
+
// Syntax preferences
|
|
29
|
+
arrowParens: 'avoid',
|
|
30
|
+
bracketSpacing: true,
|
|
31
|
+
bracketSameLine: false,
|
|
32
|
+
singleAttributePerLine: true,
|
|
33
|
+
|
|
34
|
+
// Line endings
|
|
35
|
+
endOfLine: 'lf'
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astro-specific Prettier preset
|
|
3
|
+
*
|
|
4
|
+
* Configures Prettier for Astro components (.astro files)
|
|
5
|
+
*
|
|
6
|
+
* Requires: prettier-plugin-astro (optional peer dependency)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
// Use Astro plugin for .astro files
|
|
11
|
+
plugins: ['prettier-plugin-astro']
|
|
12
|
+
|
|
13
|
+
// Astro plugin handles all formatting automatically
|
|
14
|
+
// No additional options needed
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React/Solid-specific Prettier preset
|
|
3
|
+
*
|
|
4
|
+
* Configures Prettier for JSX files used in React and Solid.js projects
|
|
5
|
+
*
|
|
6
|
+
* No plugins required - Prettier has built-in JSX support via babel parser
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
// JSX-specific options
|
|
11
|
+
// Use double quotes in JSX attributes (React convention)
|
|
12
|
+
jsxSingleQuote: false
|
|
13
|
+
|
|
14
|
+
// Note: bracketSameLine is now in base preset
|
|
15
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Svelte-specific Prettier preset
|
|
3
|
+
*
|
|
4
|
+
* Configures Prettier for Svelte components (.svelte files)
|
|
5
|
+
*
|
|
6
|
+
* Requires: prettier-plugin-svelte (optional peer dependency)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
// Use Svelte plugin for .svelte files
|
|
11
|
+
plugins: ['prettier-plugin-svelte'],
|
|
12
|
+
|
|
13
|
+
// Component block ordering: options, scripts, markup, styles
|
|
14
|
+
// This is the standard Svelte convention
|
|
15
|
+
svelteSortOrder: 'options-scripts-markup-styles',
|
|
16
|
+
|
|
17
|
+
// Don't enforce strict mode (allow flexibility)
|
|
18
|
+
svelteStrictMode: false,
|
|
19
|
+
|
|
20
|
+
// Indent <script> and <style> tags for consistency
|
|
21
|
+
svelteIndentScriptAndStyle: true
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vanilla JavaScript/Node.js/Angular Prettier preset
|
|
3
|
+
*
|
|
4
|
+
* For frameworks that don't need special Prettier configuration,
|
|
5
|
+
* this preset is essentially empty and relies on the base preset.
|
|
6
|
+
*
|
|
7
|
+
* Used for: Vanilla JS, Node.js backends, Angular projects
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
// No framework-specific options needed
|
|
12
|
+
// Base preset provides everything required
|
|
13
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue-specific Prettier preset
|
|
3
|
+
*
|
|
4
|
+
* Configures Prettier for Vue 3 Single File Components (.vue files)
|
|
5
|
+
*
|
|
6
|
+
* Requires: prettier-plugin-vue (optional peer dependency)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
// Use Vue plugin for .vue files
|
|
11
|
+
plugins: ['prettier-plugin-vue'],
|
|
12
|
+
|
|
13
|
+
// Don't indent <script> and <style> tags
|
|
14
|
+
// This keeps them aligned with <template> for consistency
|
|
15
|
+
vueIndentScriptAndStyle: false,
|
|
16
|
+
|
|
17
|
+
// Ignore whitespace sensitivity in HTML
|
|
18
|
+
// Prevents issues with Vue's template whitespace handling
|
|
19
|
+
htmlWhitespaceSensitivity: 'ignore'
|
|
20
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default .prettierignore content
|
|
3
|
+
*
|
|
4
|
+
* Ignores common build outputs, dependencies, and generated files
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const prettierIgnoreContent = `# Dependencies
|
|
8
|
+
node_modules/
|
|
9
|
+
.pnp/
|
|
10
|
+
.pnp.js
|
|
11
|
+
|
|
12
|
+
# Build outputs
|
|
13
|
+
dist/
|
|
14
|
+
build/
|
|
15
|
+
out/
|
|
16
|
+
.next/
|
|
17
|
+
.nuxt/
|
|
18
|
+
.output/
|
|
19
|
+
.vercel/
|
|
20
|
+
.netlify/
|
|
21
|
+
|
|
22
|
+
# Coverage
|
|
23
|
+
coverage/
|
|
24
|
+
.nyc_output/
|
|
25
|
+
*.lcov
|
|
26
|
+
|
|
27
|
+
# Lock files
|
|
28
|
+
package-lock.json
|
|
29
|
+
pnpm-lock.json
|
|
30
|
+
yarn.lock
|
|
31
|
+
bun.lockb
|
|
32
|
+
|
|
33
|
+
# Generated files
|
|
34
|
+
CHANGELOG.md
|
|
35
|
+
|
|
36
|
+
# Cache directories
|
|
37
|
+
.cache/
|
|
38
|
+
.parcel-cache/
|
|
39
|
+
.turbo/
|
|
40
|
+
.vite/
|
|
41
|
+
|
|
42
|
+
# Environment files (may contain secrets)
|
|
43
|
+
.env
|
|
44
|
+
.env.local
|
|
45
|
+
.env.*.local
|
|
46
|
+
|
|
47
|
+
# IDE
|
|
48
|
+
.vscode/
|
|
49
|
+
.idea/
|
|
50
|
+
|
|
51
|
+
# OS files
|
|
52
|
+
.DS_Store
|
|
53
|
+
Thumbs.db
|
|
54
|
+
`
|
|
55
|
+
|
|
56
|
+
export default prettierIgnoreContent
|