LLazyEmail / LLazyEmail/markdown-regex
next steps
- Dominant language
- JavaScript
- Stars
- 11
- Forks
- 3
- Avg merge
- 4h 51m
- Merged PRs (30d)
- 20
Description
Here’s an honest assessment of where **markdown-regex** stands right now and how to improve it.
---
## Current state (snapshot)
### What’s working well
- **Clear purpose** — a small set of regex constants for Markdown, used by the email pipeline. Scope is understandable.
- **Modern packaging direction** — TypeScript + tsup, dual CJS/ESM/IIFE, proper `exports` map. That’s the right foundation for a 2.x.
- **Platform-agnostic newlines** — removing the `os` dependency was the single most important correctness fix.
- **Docs & metadata** — README, CHANGELOG, types, examples are in better shape than most small utility libs.
- **CI skeleton** — Actions are on v7; typecheck → build → test is the right order.
### What’s still messy
| Area | Problem |
|------|---------|
| **Dual source of truth** | TypeScript under `src/**/*.ts` *and* leftover JS (`src/index.js`, `src/tags/*.js`, `src/tags.js`, `src/list.js`, `src/chat/`). Jest and humans don’t know which is canonical. |
| **Incomplete rename** | `REGEXP_EM` → `REGEXP_ITALIC` is done in TS, but many tests and legacy files still say `EM`. |
| **Test suite** | Dozens of tiny folders (`tests/em/`, `tests/hr/`, …), some broken, some duplicated (`empty-blockqoute` typo, `olga`). Core tests were fixed by *ignoring* the rest — that’s a stopgap, not a strategy. |
| **Regex quality** | Patterns are still simplistic (headers need a leading newline, italic needs surrounding whitespace, HR is dashes-only, lists are limited). Fine for a controlled email pipeline; weak as a general Markdown toolkit. |
| **Lockfile / install** | Full `package-lock.json` never landed cleanly; CI uses `npm install` instead of `npm ci`. |
| **Dead config** | `.gitpod.yml`, `babel.config.js`, `rollup.config.mjs`, old ESLint/Babel wiring still hanging around. |
| **Version story** | Still `2.0.0-beta.1` with breaking renames and packaging changes — needs a clear “this is 2.0” moment. |
Overall: the *direction* is good; the *repo hygiene* is mid-migration and feels half-finished.
---
## How to improve (prioritized)
### 1. Finish the migration (high impact, low design risk)
1. Delete all legacy JS that duplicates TS (`src/**/*.js` that mirror `.ts`, flat `src/tags.js` / `src/list.js`, `src/chat/`).
2. Delete dead config: `.gitpod.yml`, `babel.config.js`, `rollup.config.mjs`, old jest config if unused.
3. Finish `REGEXP_EM` → `REGEXP_ITALIC` everywhere (or add a temporary deprecated alias `REGEXP_EM = REGEXP_ITALIC` for one minor version).
4. Commit a real `package-lock.json` and switch CI back to `npm ci`.
5. Make **one** test entrypoint strategy:
- Prefer tests that import from **`dist/`** (proves the published artifact).
- Or use `ts-jest` / Vitest against `src/` — pick one, don’t mix.
### 2. Stabilize and shrink the test suite
- Keep: smoke test, one solid integration test, one edge-case file per major pattern (or a single well-organized suite).
- Drop or rewrite the many one-assertion folders; they’re noise and currently ignored.
- Always reset `lastIndex` on global regexes (or stop using the `g` flag where you only `.test()`).
- Add fixtures with both `\n` and `\r\n`.
### 3. Decide the product boundary
Be explicit in the README:
> These patterns are **good enough for our email Markdown subset**, not a full CommonMark/GFM parser.
Then either:
- **A)** Keep them simple and document limitations, or
- **B)** Gradually harden the important ones (headers, links, images, lists, strong/italic) against a small fixture set from CommonMark.
Don’t pretend it’s a general Markdown engine unless you invest in that.
### 4. Custom tags / addons (your stated future)
Structure it now so it doesn’t rot:
```text
src/
core/ # current tags + lists
addons/ # future custom patterns
index.ts # re-exports core
```
Optional package exports later:
```json
"exports": {
".": "...",
"./addons": "..."
}
```
Keep addons pure regex constants — same rules as core.
### 5. Tooling polish
- **Vitest** instead of Jest (faster, native ESM/TS, less config) — optional but nice.
- Single lint stack (ESLint flat config *or* Biome); drop Babel-era parsers.
- `sideEffects: false` (already there) + verify tree-shaking of individual exports.
- Publish with provenance / trusted publishing when you leave beta.
### 6. Release discipline
- Ship **2.0.0** once lockfile + dead-code cleanup + rename are done.
- Changelog: packaging break, newline behavior, `REGEXP_EM` → `REGEXP_ITALIC`.
- Tag and publish; don’t linger on `beta.1` while main is already the new world.
---
## Suggested near-term sequence
1. Merge the open CI / EM-cleanup PRs.
2. One “repo hygiene” PR: delete legacy JS + dead configs + leftover `em` files.
3. Regenerate and commit `package-lock.json`; switch workflows to `npm ci`.
4. Collapse tests to a small green suite against `dist/`.
5. Tag `v2.0.0`.
6. Only then: addons folder + any regex hardening you actually need for email.
---
**Bottom line:** The architecture choice (TS + tsup + pure regex constants) is sound. The repo is still carrying a previous generation of files and tests, which is why Actions keep failing and why the codebase feels noisier than the problem deserves. Finishing the migration and cutting dead weight will do more for quality than any new feature.
Contributor guide
Research direction
Start by inventorying the duplicate files under src/**/*.js and src/**/*.ts, then inspect .gitpod.yml, babel.config.js, rollup.config.mjs, package-lock.json, and the CI workflow. Break the assessment into focused migration tasks and verify the chosen test entrypoint, rename cleanup, installation mode, and remaining configuration. Done means the migration has one source of truth and the proposed checks pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, javascript, rollup, typescript
- Domain
- build-system, testing, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100