Summary
Move getLineColumn and findMatchingBrace helper functions from @effect-migrate/preset-basic to @effect-migrate/core utilities for reuse across custom presets.
Motivation
Currently, these helpers are defined in packages/preset-basic/src/helpers.ts:
getLineColumn(content, index) - Converts character index to line/column numbers
findMatchingBrace(content, startIndex) - Finds matching closing brace
Custom presets and rule authors would benefit from having these utilities available from core, avoiding code duplication.
Proposed Solution
- Create
packages/core/src/utils/helpers.ts
- Move
getLineColumn and findMatchingBrace to core
- Export from
packages/core/src/index.ts
- Update
@effect-migrate/preset-basic to import from core
- Add unit tests in
packages/core/test/utils/helpers.test.ts
Benefits
- Promotes DRY (Don't Repeat Yourself)
- Makes custom preset development easier
- Ensures consistent helper implementations across presets
- Reduces bundle size for packages that depend on multiple presets
Files to Change
packages/core/src/utils/helpers.ts (new)
packages/core/src/index.ts (export helpers)
packages/core/test/utils/helpers.test.ts (new)
packages/preset-basic/src/helpers.ts (remove or re-export from core)
packages/preset-basic/src/patterns.ts (update imports)
Acceptance Criteria
Related
Summary
Move
getLineColumnandfindMatchingBracehelper functions from@effect-migrate/preset-basicto@effect-migrate/coreutilities for reuse across custom presets.Motivation
Currently, these helpers are defined in
packages/preset-basic/src/helpers.ts:getLineColumn(content, index)- Converts character index to line/column numbersfindMatchingBrace(content, startIndex)- Finds matching closing braceCustom presets and rule authors would benefit from having these utilities available from core, avoiding code duplication.
Proposed Solution
packages/core/src/utils/helpers.tsgetLineColumnandfindMatchingBraceto corepackages/core/src/index.ts@effect-migrate/preset-basicto import from corepackages/core/test/utils/helpers.test.tsBenefits
Files to Change
packages/core/src/utils/helpers.ts(new)packages/core/src/index.ts(export helpers)packages/core/test/utils/helpers.test.ts(new)packages/preset-basic/src/helpers.ts(remove or re-export from core)packages/preset-basic/src/patterns.ts(update imports)Acceptance Criteria
@effect-migrate/corepreset-basicimports helpers from coreRelated