From f146a55580c1f9d990cec6c33c468a95656c99b6 Mon Sep 17 00:00:00 2001 From: jpb06 Date: Sun, 18 Jan 2026 15:22:15 +0100 Subject: [PATCH] chore: resolve code smells --- .github/workflows/ci.yml | 4 - pnpm-lock.yaml | 144 +++++++++--------- src/capture-errors.test.ts | 21 +-- src/capture-errors.ts | 13 +- src/examples/without-spans.test.ts | 2 +- src/logic/path/strip-cwd-path.ts | 4 +- .../maybe-print-spans-timeline.ts | 9 +- .../format-spans-at-timeline.ts | 2 +- .../get-error-location-from-file-path.ts | 2 +- src/source-maps/transform-raw-error.ts | 5 +- src/tests/util/collect-error-details.util.ts | 2 +- 11 files changed, 90 insertions(+), 118 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 072aa23..9ead084 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,10 +10,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -permissions: - actions: write - contents: read - jobs: lint: name: ⬣ Lint diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa071ee..7acea1c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -90,13 +90,13 @@ packages: resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==} engines: {node: '>=6.9.0'} - '@babel/parser@7.28.5': - resolution: {integrity: sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==} + '@babel/parser@7.28.6': + resolution: {integrity: sha512-TeR9zWR18BvbfPmGbLampPMW+uW1NZnJlRuuHso8i87QZNq2JRF9i6RgxRqtEq+wQGsS19NNTWr2duhnE49mfQ==} engines: {node: '>=6.0.0'} hasBin: true - '@babel/types@7.28.5': - resolution: {integrity: sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==} + '@babel/types@7.28.6': + resolution: {integrity: sha512-0ZrskXVEHSWIqZM/sQZ4EV3jZJXRkio/WCxaqKZP1g//CEWEPSfeZFcms4XeKBCHU0ZKnIkdJeU/kF+eRp5lBg==} engines: {node: '>=6.9.0'} '@bcoe/v8-coverage@1.0.2': @@ -449,86 +449,86 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@parcel/watcher-android-arm64@2.5.1': - resolution: {integrity: sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==} + '@parcel/watcher-android-arm64@2.5.4': + resolution: {integrity: sha512-hoh0vx4v+b3BNI7Cjoy2/B0ARqcwVNrzN/n7DLq9ZB4I3lrsvhrkCViJyfTj/Qi5xM9YFiH4AmHGK6pgH1ss7g==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [android] - '@parcel/watcher-darwin-arm64@2.5.1': - resolution: {integrity: sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==} + '@parcel/watcher-darwin-arm64@2.5.4': + resolution: {integrity: sha512-kphKy377pZiWpAOyTgQYPE5/XEKVMaj6VUjKT5VkNyUJlr2qZAn8gIc7CPzx+kbhvqHDT9d7EqdOqRXT6vk0zw==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [darwin] - '@parcel/watcher-darwin-x64@2.5.1': - resolution: {integrity: sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==} + '@parcel/watcher-darwin-x64@2.5.4': + resolution: {integrity: sha512-UKaQFhCtNJW1A9YyVz3Ju7ydf6QgrpNQfRZ35wNKUhTQ3dxJ/3MULXN5JN/0Z80V/KUBDGa3RZaKq1EQT2a2gg==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [darwin] - '@parcel/watcher-freebsd-x64@2.5.1': - resolution: {integrity: sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==} + '@parcel/watcher-freebsd-x64@2.5.4': + resolution: {integrity: sha512-Dib0Wv3Ow/m2/ttvLdeI2DBXloO7t3Z0oCp4bAb2aqyqOjKPPGrg10pMJJAQ7tt8P4V2rwYwywkDhUia/FgS+Q==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [freebsd] - '@parcel/watcher-linux-arm-glibc@2.5.1': - resolution: {integrity: sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==} + '@parcel/watcher-linux-arm-glibc@2.5.4': + resolution: {integrity: sha512-I5Vb769pdf7Q7Sf4KNy8Pogl/URRCKu9ImMmnVKYayhynuyGYMzuI4UOWnegQNa2sGpsPSbzDsqbHNMyeyPCgw==} engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] - '@parcel/watcher-linux-arm-musl@2.5.1': - resolution: {integrity: sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==} + '@parcel/watcher-linux-arm-musl@2.5.4': + resolution: {integrity: sha512-kGO8RPvVrcAotV4QcWh8kZuHr9bXi9a3bSZw7kFarYR0+fGliU7hd/zevhjw8fnvIKG3J9EO5G6sXNGCSNMYPQ==} engines: {node: '>= 10.0.0'} cpu: [arm] os: [linux] - '@parcel/watcher-linux-arm64-glibc@2.5.1': - resolution: {integrity: sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==} + '@parcel/watcher-linux-arm64-glibc@2.5.4': + resolution: {integrity: sha512-KU75aooXhqGFY2W5/p8DYYHt4hrjHZod8AhcGAmhzPn/etTa+lYCDB2b1sJy3sWJ8ahFVTdy+EbqSBvMx3iFlw==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] - '@parcel/watcher-linux-arm64-musl@2.5.1': - resolution: {integrity: sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==} + '@parcel/watcher-linux-arm64-musl@2.5.4': + resolution: {integrity: sha512-Qx8uNiIekVutnzbVdrgSanM+cbpDD3boB1f8vMtnuG5Zau4/bdDbXyKwIn0ToqFhIuob73bcxV9NwRm04/hzHQ==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [linux] - '@parcel/watcher-linux-x64-glibc@2.5.1': - resolution: {integrity: sha512-GcESn8NZySmfwlTsIur+49yDqSny2IhPeZfXunQi48DMugKeZ7uy1FX83pO0X22sHntJ4Ub+9k34XQCX+oHt2A==} + '@parcel/watcher-linux-x64-glibc@2.5.4': + resolution: {integrity: sha512-UYBQvhYmgAv61LNUn24qGQdjtycFBKSK3EXr72DbJqX9aaLbtCOO8+1SkKhD/GNiJ97ExgcHBrukcYhVjrnogA==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] - '@parcel/watcher-linux-x64-musl@2.5.1': - resolution: {integrity: sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==} + '@parcel/watcher-linux-x64-musl@2.5.4': + resolution: {integrity: sha512-YoRWCVgxv8akZrMhdyVi6/TyoeeMkQ0PGGOf2E4omODrvd1wxniXP+DBynKoHryStks7l+fDAMUBRzqNHrVOpg==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [linux] - '@parcel/watcher-win32-arm64@2.5.1': - resolution: {integrity: sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==} + '@parcel/watcher-win32-arm64@2.5.4': + resolution: {integrity: sha512-iby+D/YNXWkiQNYcIhg8P5hSjzXEHaQrk2SLrWOUD7VeC4Ohu0WQvmV+HDJokZVJ2UjJ4AGXW3bx7Lls9Ln4TQ==} engines: {node: '>= 10.0.0'} cpu: [arm64] os: [win32] - '@parcel/watcher-win32-ia32@2.5.1': - resolution: {integrity: sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==} + '@parcel/watcher-win32-ia32@2.5.4': + resolution: {integrity: sha512-vQN+KIReG0a2ZDpVv8cgddlf67J8hk1WfZMMP7sMeZmJRSmEax5xNDNWKdgqSe2brOKTQQAs3aCCUal2qBHAyg==} engines: {node: '>= 10.0.0'} cpu: [ia32] os: [win32] - '@parcel/watcher-win32-x64@2.5.1': - resolution: {integrity: sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==} + '@parcel/watcher-win32-x64@2.5.4': + resolution: {integrity: sha512-3A6efb6BOKwyw7yk9ro2vus2YTt2nvcd56AuzxdMiVOxL9umDyN5PKkKfZ/gZ9row41SjVmTVQNWQhaRRGpOKw==} engines: {node: '>= 10.0.0'} cpu: [x64] os: [win32] - '@parcel/watcher@2.5.1': - resolution: {integrity: sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==} + '@parcel/watcher@2.5.4': + resolution: {integrity: sha512-WYa2tUVV5HiArWPB3ydlOc4R2ivq0IDrlqhMi3l7mVsFEXNcTfxYFPIHXHXIh/ca/y/V5N4E1zecyxdIBjYnkQ==} engines: {node: '>= 10.0.0'} '@pkgjs/parseargs@0.11.0': @@ -830,11 +830,6 @@ packages: resolution: {integrity: sha512-gPqh0mKTPvaUZGAuHbrBUYKZWBNAeHG7TU3QH5EhVwPMyKvmfJaNXhcD2jTcXsJRRcffuho4vaYweu80dRrMGA==} engines: {node: '>=18'} - detect-libc@1.0.3: - resolution: {integrity: sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==} - engines: {node: '>=0.10'} - hasBin: true - detect-libc@2.1.2: resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} engines: {node: '>=8'} @@ -1554,11 +1549,11 @@ snapshots: '@babel/helper-validator-identifier@7.28.5': {} - '@babel/parser@7.28.5': + '@babel/parser@7.28.6': dependencies: - '@babel/types': 7.28.5 + '@babel/types': 7.28.6 - '@babel/types@7.28.5': + '@babel/types@7.28.6': dependencies: '@babel/helper-string-parser': 7.27.1 '@babel/helper-validator-identifier': 7.28.5 @@ -1621,7 +1616,7 @@ snapshots: '@effect/platform': 0.94.1(effect@3.19.14) '@effect/rpc': 0.73.0(@effect/platform@0.94.1(effect@3.19.14))(effect@3.19.14) '@effect/sql': 0.49.0(@effect/experimental@0.58.0(@effect/platform@0.94.1(effect@3.19.14))(effect@3.19.14))(@effect/platform@0.94.1(effect@3.19.14))(effect@3.19.14) - '@parcel/watcher': 2.5.1 + '@parcel/watcher': 2.5.4 effect: 3.19.14 multipasta: 0.2.7 ws: 8.19.0 @@ -1810,65 +1805,65 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.20.1 - '@parcel/watcher-android-arm64@2.5.1': + '@parcel/watcher-android-arm64@2.5.4': optional: true - '@parcel/watcher-darwin-arm64@2.5.1': + '@parcel/watcher-darwin-arm64@2.5.4': optional: true - '@parcel/watcher-darwin-x64@2.5.1': + '@parcel/watcher-darwin-x64@2.5.4': optional: true - '@parcel/watcher-freebsd-x64@2.5.1': + '@parcel/watcher-freebsd-x64@2.5.4': optional: true - '@parcel/watcher-linux-arm-glibc@2.5.1': + '@parcel/watcher-linux-arm-glibc@2.5.4': optional: true - '@parcel/watcher-linux-arm-musl@2.5.1': + '@parcel/watcher-linux-arm-musl@2.5.4': optional: true - '@parcel/watcher-linux-arm64-glibc@2.5.1': + '@parcel/watcher-linux-arm64-glibc@2.5.4': optional: true - '@parcel/watcher-linux-arm64-musl@2.5.1': + '@parcel/watcher-linux-arm64-musl@2.5.4': optional: true - '@parcel/watcher-linux-x64-glibc@2.5.1': + '@parcel/watcher-linux-x64-glibc@2.5.4': optional: true - '@parcel/watcher-linux-x64-musl@2.5.1': + '@parcel/watcher-linux-x64-musl@2.5.4': optional: true - '@parcel/watcher-win32-arm64@2.5.1': + '@parcel/watcher-win32-arm64@2.5.4': optional: true - '@parcel/watcher-win32-ia32@2.5.1': + '@parcel/watcher-win32-ia32@2.5.4': optional: true - '@parcel/watcher-win32-x64@2.5.1': + '@parcel/watcher-win32-x64@2.5.4': optional: true - '@parcel/watcher@2.5.1': + '@parcel/watcher@2.5.4': dependencies: - detect-libc: 1.0.3 + detect-libc: 2.1.2 is-glob: 4.0.3 - micromatch: 4.0.8 node-addon-api: 7.1.1 + picomatch: 4.0.3 optionalDependencies: - '@parcel/watcher-android-arm64': 2.5.1 - '@parcel/watcher-darwin-arm64': 2.5.1 - '@parcel/watcher-darwin-x64': 2.5.1 - '@parcel/watcher-freebsd-x64': 2.5.1 - '@parcel/watcher-linux-arm-glibc': 2.5.1 - '@parcel/watcher-linux-arm-musl': 2.5.1 - '@parcel/watcher-linux-arm64-glibc': 2.5.1 - '@parcel/watcher-linux-arm64-musl': 2.5.1 - '@parcel/watcher-linux-x64-glibc': 2.5.1 - '@parcel/watcher-linux-x64-musl': 2.5.1 - '@parcel/watcher-win32-arm64': 2.5.1 - '@parcel/watcher-win32-ia32': 2.5.1 - '@parcel/watcher-win32-x64': 2.5.1 + '@parcel/watcher-android-arm64': 2.5.4 + '@parcel/watcher-darwin-arm64': 2.5.4 + '@parcel/watcher-darwin-x64': 2.5.4 + '@parcel/watcher-freebsd-x64': 2.5.4 + '@parcel/watcher-linux-arm-glibc': 2.5.4 + '@parcel/watcher-linux-arm-musl': 2.5.4 + '@parcel/watcher-linux-arm64-glibc': 2.5.4 + '@parcel/watcher-linux-arm64-musl': 2.5.4 + '@parcel/watcher-linux-x64-glibc': 2.5.4 + '@parcel/watcher-linux-x64-musl': 2.5.4 + '@parcel/watcher-win32-arm64': 2.5.4 + '@parcel/watcher-win32-ia32': 2.5.4 + '@parcel/watcher-win32-x64': 2.5.4 '@pkgjs/parseargs@0.11.0': optional: true @@ -2153,10 +2148,7 @@ snapshots: presentable-error: 0.0.1 slash: 5.1.0 - detect-libc@1.0.3: {} - - detect-libc@2.1.2: - optional: true + detect-libc@2.1.2: {} eastasianwidth@0.2.0: {} @@ -2392,8 +2384,8 @@ snapshots: magicast@0.3.5: dependencies: - '@babel/parser': 7.28.5 - '@babel/types': 7.28.5 + '@babel/parser': 7.28.6 + '@babel/types': 7.28.6 source-map-js: 1.2.1 make-dir@4.0.0: diff --git a/src/capture-errors.test.ts b/src/capture-errors.test.ts index 78011b7..b608481 100644 --- a/src/capture-errors.test.ts +++ b/src/capture-errors.test.ts @@ -18,12 +18,7 @@ describe('captureErrors function', () => { const cause = await effectCause(task); const result = await Effect.runPromise( - pipe( - captureErrors(cause, { - stripCwd: false, - }), - Effect.provide(NodeFileSystem.layer), - ), + pipe(captureErrors(cause, false), Effect.provide(NodeFileSystem.layer)), ); expect(result.interrupted).toBe(false); @@ -60,12 +55,7 @@ describe('captureErrors function', () => { const cause = await effectCause(task); const result = await Effect.runPromise( - pipe( - captureErrors(cause, { - stripCwd: false, - }), - Effect.provide(NodeFileSystem.layer), - ), + pipe(captureErrors(cause, false), Effect.provide(NodeFileSystem.layer)), ); expect(result.interrupted).toBe(false); @@ -80,12 +70,7 @@ describe('captureErrors function', () => { const cause = await effectCause(Effect.interrupt); const result = await Effect.runPromise( - pipe( - captureErrors(cause, { - stripCwd: false, - }), - Effect.provide(NodeFileSystem.layer), - ), + pipe(captureErrors(cause, false), Effect.provide(NodeFileSystem.layer)), ); expect(result).toStrictEqual({ diff --git a/src/capture-errors.ts b/src/capture-errors.ts index 1b71e78..666ca5e 100644 --- a/src/capture-errors.ts +++ b/src/capture-errors.ts @@ -27,15 +27,9 @@ export interface CapturedErrors { errors: ErrorData[]; } -export interface CaptureErrorsOptions { - stripCwd?: boolean; -} - export const captureErrors = ( cause: Cause, - options: CaptureErrorsOptions = { - stripCwd: true, - }, + stripCwd?: boolean, ): Effect.Effect< CapturedErrors, PlatformError | JsonParsingError, @@ -50,7 +44,10 @@ export const captureErrors = ( } const rawErrors = captureErrorsFrom(cause); - const errors = yield* Effect.forEach(rawErrors, transformRawError(options)); + const errors = yield* Effect.forEach( + rawErrors, + transformRawError(stripCwd), + ); return { interrupted: false, diff --git a/src/examples/without-spans.test.ts b/src/examples/without-spans.test.ts index b46f7b6..5144bff 100644 --- a/src/examples/without-spans.test.ts +++ b/src/examples/without-spans.test.ts @@ -122,7 +122,7 @@ describe('without-spans task', () => { expect(raw).not.toContain('Sources 🕵️'); expect(raw).toContain('Node Stacktrace 🚨'); expect(message).toMatch( - /│ at catcher (.*\/effect-errors\/src\/examples\/without-spans.ts:14:17)/, + /│ at catcher (.*\/src\/examples\/without-spans.ts:14:17)/, ); }); }); diff --git a/src/logic/path/strip-cwd-path.ts b/src/logic/path/strip-cwd-path.ts index 5001714..6755965 100644 --- a/src/logic/path/strip-cwd-path.ts +++ b/src/logic/path/strip-cwd-path.ts @@ -1,5 +1,7 @@ const cwdRegex = - global.process !== undefined ? new RegExp(global.process.cwd(), 'g') : null; + globalThis.process === undefined + ? null + : new RegExp(globalThis.process.cwd(), 'g'); export const stripCwdPath = (path: string): string => cwdRegex === null ? path : path.replace(cwdRegex, '.'); diff --git a/src/pretty-printing/captured-errors/maybe-print-spans-timeline.ts b/src/pretty-printing/captured-errors/maybe-print-spans-timeline.ts index 0617781..ac7ead8 100644 --- a/src/pretty-printing/captured-errors/maybe-print-spans-timeline.ts +++ b/src/pretty-printing/captured-errors/maybe-print-spans-timeline.ts @@ -25,11 +25,12 @@ export const maybePrintSpansTimeline = ( const maybeCircle = isFirstEntry ? `\r\n${color.gray('◯')}\r\n` : ''; const trailing = spanStackTrailingChar(isLastEntry); - const filePath = ` ${stripCwd !== undefined ? color.underline(color.bold(stripCwdPath(name))) : color.underline(name)}`; + const filePath = ` ${stripCwd === undefined ? color.underline(name) : color.underline(color.bold(stripCwdPath(name)))}`; const duration = - durationInMilliseconds !== undefined - ? color.gray(formatSpanDuration(durationInMilliseconds, isLastEntry)) - : ''; + durationInMilliseconds === undefined + ? '' + : color.gray(formatSpanDuration(durationInMilliseconds, isLastEntry)); + const formattedAttributes = formatSpanAttributes(attributes, isLastEntry); const timelineEntry = color.white( diff --git a/src/pretty-printing/failures/spans-timeline/format-spans-at-timeline.ts b/src/pretty-printing/failures/spans-timeline/format-spans-at-timeline.ts index 525b30c..a4e28cc 100644 --- a/src/pretty-printing/failures/spans-timeline/format-spans-at-timeline.ts +++ b/src/pretty-printing/failures/spans-timeline/format-spans-at-timeline.ts @@ -31,7 +31,7 @@ export const formatSpansAsTimeline = ( const maybeCircle = isFirstEntry ? `\r\n${color.gray('◯')}` : ''; const trailing = spanStackTrailingChar(isLastEntry); - const filePath = ` ${stripCwd !== undefined ? color.underline(color.bold(stripCwdPath(name))) : color.underline(name)}`; + const filePath = ` ${stripCwd === undefined ? color.underline(name) : color.underline(color.bold(stripCwdPath(name)))}`; const duration = color.gray(getSpanDuration(status, isLastEntry)); const message = `${maybeCircle}\r\n${trailing}${color.gray('─')}${filePath}${duration}${formattedAttributes}`; diff --git a/src/source-maps/get-error-location-from-file-path.ts b/src/source-maps/get-error-location-from-file-path.ts index 051630e..15d61d2 100644 --- a/src/source-maps/get-error-location-from-file-path.ts +++ b/src/source-maps/get-error-location-from-file-path.ts @@ -10,7 +10,7 @@ export const getErrorLocationFrom = ( sourceFile: string, ): ErrorLocation | undefined => { const regex = sourceFileWithMapPointerRegex.exec(sourceFile); - if (regex === null || regex.length !== 7) { + if (regex?.length !== 7) { return; } diff --git a/src/source-maps/transform-raw-error.ts b/src/source-maps/transform-raw-error.ts index f9fac59..a78cc43 100644 --- a/src/source-maps/transform-raw-error.ts +++ b/src/source-maps/transform-raw-error.ts @@ -3,13 +3,12 @@ import { Effect, pipe } from 'effect'; import { stripCwdPath } from '@logic/path'; import { stackAtRegex } from '@logic/stack'; -import type { CaptureErrorsOptions } from '../capture-errors.js'; import type { PrettyError } from '../types/pretty-error.type.js'; import { getSourcesFromSpan } from './get-sources-from-span.js'; import { getSourcesFromStack } from './get-sources-from-stack.js'; export const transformRawError = - ({ stripCwd }: CaptureErrorsOptions) => + (stripCwd?: boolean) => ({ message, stack: maybeStack, @@ -27,7 +26,7 @@ export const transformRawError = let stack: string | undefined; if (maybeStack !== undefined) { - stack = stripCwd === true ? stripCwdPath(maybeStack) : maybeStack; + stack = stripCwd === false ? maybeStack : stripCwdPath(maybeStack); } return { diff --git a/src/tests/util/collect-error-details.util.ts b/src/tests/util/collect-error-details.util.ts index e987419..dd0870e 100644 --- a/src/tests/util/collect-error-details.util.ts +++ b/src/tests/util/collect-error-details.util.ts @@ -11,7 +11,7 @@ export const collectErrorDetails = (cause: Cause) => pipe( Effect.gen(function* () { - const errors = yield* captureErrors(cause, {}); + const errors = yield* captureErrors(cause); const message = prettyPrintFromCapturedErrors(errors, options);