Skip to content

v2.0.0: Full TypeScript modernization#10

Merged
cardil merged 8 commits into
developfrom
feature/2x-overhaul
Jul 14, 2026
Merged

v2.0.0: Full TypeScript modernization#10
cardil merged 8 commits into
developfrom
feature/2x-overhaul

Conversation

@cardil

@cardil cardil commented Jul 14, 2026

Copy link
Copy Markdown
Member

Complete rewrite of eid.js for 2026.

Changes

  • TypeScript: Source migrated from ES5 to strict TypeScript with full type declarations
  • Build: Gulp 3 + Browserify replaced with tsup (ESM + CJS + IIFE browser bundle)
  • Tests: Mocha + expect.js replaced with Vitest (59 tests, 100% coverage)
  • Lint: ESLint 1.x replaced with Biome
  • CI: Travis CI replaced with GitHub Actions (Node 20 + 22)
  • Error.cause: All exceptions support ES2022 cause chaining. tryToExecute preserves original error as .cause
  • Exports: Dual ESM/CJS via package.json exports field, IIFE bundle for browsers via unpkg
  • Dropped: Bower, Gulp, Travis CI, Node < 20

Breaking changes

  • Minimum Node.js version: 20
  • ESM is the primary module format (import instead of require, CJS still supported)
  • Bower support removed
  • tryToExecute now sets caught error as .cause (previously stringified into message only)

Assisted-by: 🤖 claude-opus-4-6@default

Summary by CodeRabbit

  • New Features

    • Released version 2.0 with a TypeScript-based API and modern ESM, CommonJS, and browser builds.
    • Added configurable exception identifiers, runtime exception types, precondition checks, and error-cause support.
    • Added Node.js 20+ support and updated package installation and module usage guidance.
  • Documentation

    • Rewrote the README with updated usage examples, API guidance, requirements, and release information.
  • Chores

    • Replaced legacy build and testing workflows with modern linting, testing, coverage, and build automation.

cardil added 6 commits July 14, 2026 22:45
Replace Gulp/Browserify/Mocha with tsup/Vitest/Biome.
package.json v2.0.0, ESM+CJS dual exports, Node 20+.
tsconfig.json strict, ES2022 target.

Assisted-by: 🤖 claude-opus-4-6@default
Eid, exceptions, preconditions rewritten as typed classes.
ES2022 Error.cause support in all exception constructors.
tryToExecute preserves original error as cause.

Assisted-by: 🤖 claude-opus-4-6@default
59 tests, 100% coverage. Mocha+expect.js replaced with Vitest.
Added cause chaining tests for exceptions and tryToExecute.

Assisted-by: 🤖 claude-opus-4-6@default
Node 20+22 matrix, lint/test/build jobs.
Concurrency control, timeout protection.

Assisted-by: 🤖 claude-opus-4-6@default
Drop gulp/, bower.json, .travis.yml, dist/, gulpfile.js.
Drop old lib/ and test/ (replaced by src/).

Assisted-by: 🤖 claude-opus-4-6@default
Defensive programming framing, ESM/CJS/browser examples.
Error.cause docs, rewritten EidPreconditions section.
Drop Bower, update badges to GitHub Actions.

Assisted-by: 🤖 claude-opus-4-6@default
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@cardil, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 37 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2aa88408-b3fa-4432-83ba-13e0be7e9e2e

📥 Commits

Reviewing files that changed from the base of the PR and between 80f34b5 and 1eb3017.

📒 Files selected for processing (5)
  • .github/workflows/ci.yml
  • package.json
  • src/eid.ts
  • src/index.ts
  • src/preconditions.ts
📝 Walkthrough

Walkthrough

The project is rewritten from legacy JavaScript/Gulp modules to a TypeScript library with EID formatting, typed exceptions, precondition helpers, ESM/CJS/IIFE builds, Vitest coverage, Biome linting, updated packaging, CI, and documentation.

Changes

EID modernization

Layer / File(s) Summary
EID identity and formatting
src/eid.ts, src/__tests__/eid.test.ts
Adds configurable EID formatting, generated unique identifiers, getters, log-message formatting, and comprehensive Vitest coverage.
Exceptions and preconditions
src/exceptions.ts, src/preconditions.ts, src/__tests__/exceptions.test.ts, src/__tests__/preconditions.test.ts
Adds typed EID exception classes, cause propagation, null/state/index validation, and supplier error wrapping with tests.
Public exports and package build
src/index.ts, package.json, tsconfig.json, tsup.config.ts, vitest.config.ts, biome.json
Defines public exports, updates package metadata to version 2.0.0, and configures ESM/CJS/IIFE builds, declarations, coverage, and linting.
CI and documentation
.github/workflows/ci.yml, README.md, .gitignore
Adds lint, test, and build CI jobs; documents the TypeScript package; and updates ignored artifacts. Legacy Gulp, Travis, Bower, and JavaScript test files are removed.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant EidPreconditions
  participant Eid
  participant EidRuntimeException
  Application->>EidPreconditions: checkArgument or tryToExecute
  EidPreconditions->>Eid: normalize eid
  EidPreconditions->>EidRuntimeException: create typed exception
  EidRuntimeException-->>Application: throw with formatted eid and cause
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: a v2.0.0 modernization to TypeScript and the new toolchain.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/2x-overhaul

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (2)
tsconfig.json (1)

20-22: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Include tests for type checking.

Since tsup strictly bundles the src/index.ts entry point and does not rely on tsconfig.json's exclusion rules to shape the dist directory, you can safely drop src/**/*.test.ts from the exclude array. This allows tsc --noEmit to also validate the types inside your test suites.

🛠️ Proposed fix
   "include": ["src"],
-  "exclude": ["node_modules", "dist", "src/**/*.test.ts"]
+  "exclude": ["node_modules", "dist"]
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tsconfig.json` around lines 20 - 22, Update the tsconfig.json exclude list by
removing the src/**/*.test.ts pattern, while preserving node_modules and dist
exclusions, so tsc --noEmit type-checks the test suites.
src/__tests__/preconditions.test.ts (1)

189-201: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test the exact boundary condition for checkElementIndex.

To prevent regressions of the off-by-one bounds logic, consider adding a test case that specifically verifies that index === size appropriately throws an EidIndexOutOfBoundsException.

🧪 Proposed test case addition
     describe("giving a invalid index value of 6, and size of 2", () => {
       it("should throw EidIndexOutOfBoundsException", () => {
         let caught: unknown;
         try {
           EidPreconditions.checkElementIndex(6, 2, eid);
         } catch (e) {
           caught = e;
         }
         expect(caught).toBeInstanceOf(EidIndexOutOfBoundsException);
         expect(String(caught)).toMatch(eidRegex);
       });
     });
+
+    describe("giving a boundary index value of 2, and size of 2", () => {
+      it("should throw EidIndexOutOfBoundsException", () => {
+        let caught: unknown;
+        try {
+          EidPreconditions.checkElementIndex(2, 2, eid);
+        } catch (e) {
+          caught = e;
+        }
+        expect(caught).toBeInstanceOf(EidIndexOutOfBoundsException);
+        expect(String(caught)).toMatch(eidRegex);
+      });
+    });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/__tests__/preconditions.test.ts` around lines 189 - 201, Add a
boundary-focused test alongside the existing invalid-index case in the
`checkElementIndex` tests, invoking `EidPreconditions.checkElementIndex` with
`index` equal to `size` and asserting it throws `EidIndexOutOfBoundsException`
with the expected `eidRegex` message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yml:
- Line 19: Update all checkout steps in .github/workflows/ci.yml at lines 19-19,
35-35, and 49-49 by adding a with block that sets persist-credentials to false;
apply the same configuration to each actions/checkout@v4 step.
- Around line 1-13: Add a top-level permissions block to the CI workflow
configuration, granting only contents: read. Place it alongside the existing
workflow-level name, triggers, and concurrency settings so all jobs inherit the
least-privilege permission without changing job behavior.

In `@package.json`:
- Around line 25-35: Add a dedicated type-check script to the package scripts
using tsc --noEmit, then include that script in the prepublishOnly pipeline
alongside lint, test, and build so TypeScript errors are validated before
publishing.
- Around line 10-18: Update the package exports map so the import condition
resolves the ESM declaration file and the require condition resolves the
tsup-generated CJS declaration file. Keep the existing runtime targets
unchanged, and place each condition-specific types entry within its
corresponding import or require branch rather than using one shared top-level
types path.

In `@src/eid.ts`:
- Around line 28-32: Update format in the EID class to replace template
placeholders in a single pass rather than reducing with sequential
String.replace calls. Ensure injected argument values containing “%s” are not
rescanned or consumed as placeholders, while each original template placeholder
uses its corresponding argument.

In `@src/index.ts`:
- Around line 38-48: Update the backward-compatibility block in src/index.ts to
explicitly assign the existing preconditions and exceptions objects onto the Eid
class/default export as Eid.preconditions and Eid.exceptions, while preserving
the named exports and current exception mappings.

In `@src/preconditions.ts`:
- Around line 45-47: Update isIndexAndSizeIllegal so the upper-bound check
rejects indices equal to size by using an inclusive boundary, while preserving
rejection of negative indices.

---

Nitpick comments:
In `@src/__tests__/preconditions.test.ts`:
- Around line 189-201: Add a boundary-focused test alongside the existing
invalid-index case in the `checkElementIndex` tests, invoking
`EidPreconditions.checkElementIndex` with `index` equal to `size` and asserting
it throws `EidIndexOutOfBoundsException` with the expected `eidRegex` message.

In `@tsconfig.json`:
- Around line 20-22: Update the tsconfig.json exclude list by removing the
src/**/*.test.ts pattern, while preserving node_modules and dist exclusions, so
tsc --noEmit type-checks the test suites.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3954088a-59b5-4050-849e-31abd003ca9d

📥 Commits

Reviewing files that changed from the base of the PR and between e4c8df6 and 80f34b5.

⛔ Files ignored due to path filters (5)
  • dist/browser/index.html is excluded by !**/dist/**
  • dist/browser/toplevel/eid.js is excluded by !**/dist/**
  • dist/browser/toplevel/eid.min.js is excluded by !**/dist/**, !**/*.min.js
  • dist/browser/toplevel/eid.min.js.map is excluded by !**/dist/**, !**/*.map, !**/*.min.js.map
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (31)
  • .github/workflows/ci.yml
  • .gitignore
  • .travis.yml
  • README.md
  • biome.json
  • bower.json
  • gulp/build.js
  • gulp/build/toplevel.js
  • gulp/clean.js
  • gulp/config.js
  • gulp/serve.js
  • gulp/tests.js
  • gulpfile.js
  • lib/eid.js
  • lib/eid/eid.js
  • lib/eid/exceptions.js
  • lib/eid/preconditions.js
  • package.json
  • src/__tests__/eid.test.ts
  • src/__tests__/exceptions.test.ts
  • src/__tests__/preconditions.test.ts
  • src/eid.ts
  • src/exceptions.ts
  • src/index.ts
  • src/preconditions.ts
  • test/eid.js
  • test/eid/exceptions.js
  • test/eid/preconditions.js
  • tsconfig.json
  • tsup.config.ts
  • vitest.config.ts
💤 Files with no reviewable changes (16)
  • lib/eid.js
  • bower.json
  • .travis.yml
  • test/eid/exceptions.js
  • gulp/build/toplevel.js
  • gulp/clean.js
  • gulp/build.js
  • lib/eid/exceptions.js
  • gulp/tests.js
  • gulpfile.js
  • gulp/config.js
  • gulp/serve.js
  • test/eid.js
  • test/eid/preconditions.js
  • lib/eid/eid.js
  • lib/eid/preconditions.js

Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml
Comment thread package.json
Comment thread package.json
Comment thread src/eid.ts
Comment thread src/index.ts Outdated
Comment thread src/preconditions.ts
cardil added 2 commits July 14, 2026 23:07
CI: add permissions: contents: read, persist-credentials: false.
package.json: nested types in exports for CJS/ESM, add typecheck script.
eid.ts: fix %s injection in JFormatter (single-pass replace).
preconditions.ts: fix off-by-one in checkElementIndex (index >= size).
index.ts: remove misleading backward compat block.

Assisted-by: 🤖 claude-opus-4-6@default
Attach preconditions and exceptions as static properties on Eid class.
Legacy consumers using Eid.preconditions.checkNotNull() still work.

Assisted-by: 🤖 claude-opus-4-6@default
@cardil cardil merged commit 4cc0ffc into develop Jul 14, 2026
6 checks passed
@cardil cardil deleted the feature/2x-overhaul branch July 14, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant