Skip to content

Commit 71b0ad4

Browse files
chore: wip
1 parent 62024d3 commit 71b0ad4

File tree

6 files changed

+1770
-26
lines changed

6 files changed

+1770
-26
lines changed

TODO.md

Lines changed: 95 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,29 @@ Based on code analysis, these are the likely bottlenecks:
492492
493493
### Bun Plugin
494494
495-
- [ ] **Error handling** - `bun-plugin/src/index.ts` doesn't handle generation errors gracefully.
496-
497-
- [ ] **Incremental mode** - Add support for only regenerating changed files.
498-
499-
- [ ] **Build events** - Emit events for build tooling integration.
495+
- [x] **Error handling** - ✅ Enhanced `bun-plugin/src/index.ts` with:
496+
- `DtsxPluginError` class with error codes (CONFIG_ERROR, GENERATION_ERROR, FILE_ERROR, CACHE_ERROR, TIMEOUT_ERROR)
497+
- `wrapError()` for categorizing errors
498+
- Detailed error logging with code, message, context
499+
- `continueOnError` option for graceful degradation
500+
- `verbose` option for stack traces
501+
502+
- [x] **Incremental mode** - ✅ Added incremental build support:
503+
- `incremental` option to enable
504+
- `cacheDir` option (default: '.dtsx-cache')
505+
- `IncrementalCache` class with manifest management
506+
- Content hashing for change detection
507+
- Config hash for cache invalidation
508+
- `clearCache()` function to reset cache
509+
510+
- [x] **Build events** - ✅ Added build event system:
511+
- `BuildEventEmitter` class for event handling
512+
- Event types: 'start', 'progress', 'file', 'complete', 'error'
513+
- `on` option for registering listeners
514+
- `BuildEvent` interface with type, timestamp, data
515+
- `dtsWatch()` helper for watch mode with incremental
516+
- `dtsCheck()` helper for type checking only
517+
- `timeout` option for generation timeout
500518
501519
### Future Plugins
502520
@@ -690,17 +708,36 @@ Based on test fixtures analysis:
690708
691709
## 🎨 Output Quality & Formatting
692710
693-
- [ ] **Consistent newlines** - Ensure consistent line endings (LF vs CRLF).
694-
695-
- [ ] **Trailing newline** - Always end files with a single newline.
696-
697-
- [ ] **Import grouping** - Group imports by source (node:, external, internal).
698-
699-
- [ ] **Declaration ordering** - Consistent ordering (types, interfaces, classes, functions, variables).
700-
701-
- [ ] **Whitespace normalization** - Remove excessive blank lines in output.
702-
703-
- [ ] **Comment preservation fidelity** - Ensure JSDoc tags are preserved exactly.
711+
- [x] **Consistent newlines** - ✅ Implemented in `src/output-normalizer.ts`:
712+
- `normalizeLineEndings()` - Convert to LF or CRLF
713+
- `detectLineEnding()` - Auto-detect current line ending style
714+
- `LineEnding` type: 'lf' | 'crlf' | 'auto'
715+
716+
- [x] **Trailing newline** - ✅ Implemented in `src/output-normalizer.ts`:
717+
- `ensureTrailingNewline()` - Ensure single trailing newline
718+
- `trailingNewline` and `insertFinalNewline` options
719+
720+
- [x] **Import grouping** - ✅ Implemented in `src/output-normalizer.ts`:
721+
- `processImports()` - Group and sort imports
722+
- Groups: builtin, external, scoped, internal, parent, sibling, index, type
723+
- `ImportGrouping` config with separateGroups, alphabetize options
724+
- Integrates with existing `src/import-sorter.ts`
725+
726+
- [x] **Declaration ordering** - ✅ Implemented in `src/output-normalizer.ts`:
727+
- `orderDeclarations()` - Sort by declaration kind
728+
- `DeclarationOrder` config with kinds, alphabetize, groupExports
729+
- Default order: import, type, interface, enum, class, function, variable, export, module, namespace
730+
731+
- [x] **Whitespace normalization** - ✅ Implemented in `src/output-normalizer.ts`:
732+
- `removeTrailingWhitespace()` - Strip trailing spaces/tabs from lines
733+
- `normalizeBlankLines()` - Limit consecutive blank lines
734+
- `normalizeIndent()` - Consistent indentation (spaces/tabs)
735+
- `maxBlankLines` option (default: 1)
736+
737+
- [x] **Comment preservation fidelity** - ✅ Implemented in `src/output-normalizer.ts`:
738+
- `preserveCommentFormatting()` - Preserve JSDoc, block, and line comments
739+
- `preserveComments` option (default: true)
740+
- JSDoc tags preserved exactly as written
704741
705742
---
706743
@@ -1240,6 +1277,48 @@ Based on test fixtures analysis:
12401277
12411278
**Total tests: 304** (up from 277)
12421279
1280+
#### Latest Features (November 27, 2025 - Session 13)
1281+
1282+
- **Bun Plugin Improvements** - `packages/bun-plugin/src/index.ts`
1283+
- `DtsxPluginError` class with error codes (CONFIG_ERROR, GENERATION_ERROR, FILE_ERROR, CACHE_ERROR, TIMEOUT_ERROR)
1284+
- `wrapError()` for categorizing and wrapping errors
1285+
- `IncrementalCache` class with manifest management
1286+
- `BuildEventEmitter` for event handling
1287+
- Event types: start, progress, file, complete, error
1288+
- `dtsWatch()` - Watch mode with incremental builds
1289+
- `dtsCheck()` - Type checking only
1290+
- `clearCache()` - Clear incremental cache
1291+
- Options: incremental, cacheDir, on, timeout, continueOnError, verbose
1292+
1293+
- **Output Normalizer** - `src/output-normalizer.ts` (NEW)
1294+
- `normalizeOutput()` - Full normalization pipeline
1295+
- `normalizeLineEndings()` - LF/CRLF conversion
1296+
- `detectLineEnding()` - Auto-detect line ending style
1297+
- `removeTrailingWhitespace()` - Strip trailing whitespace
1298+
- `normalizeBlankLines()` - Limit consecutive blank lines
1299+
- `ensureTrailingNewline()` - Ensure single trailing newline
1300+
- `normalizeIndent()` - Consistent indentation (spaces/tabs)
1301+
- `processImports()` - Group and sort imports by type
1302+
- `orderDeclarations()` - Sort by declaration kind
1303+
- `preserveCommentFormatting()` - Preserve JSDoc and comments
1304+
- `createOutputNormalizer()` - Factory function
1305+
- Presets: default, minimal, strict, windows, tabs
1306+
- Types: LineEnding, ImportGroupType, DeclarationOrder, OutputNormalizerConfig
1307+
1308+
- **`test/output-normalizer.test.ts`** - Output normalizer tests (47 tests)
1309+
- Line ending normalization
1310+
- Trailing whitespace removal
1311+
- Blank line normalization
1312+
- Trailing newline handling
1313+
- Indentation normalization
1314+
- Import processing and grouping
1315+
- Declaration ordering
1316+
- Comment preservation
1317+
- Preset configurations
1318+
- Edge cases
1319+
1320+
**Total tests: 351** (up from 304)
1321+
12431322
---
12441323
12451324
*Last updated: November 27, 2025*

0 commit comments

Comments
 (0)