-
-
Notifications
You must be signed in to change notification settings - Fork 69
feat: throw error on malformed tsconfig reference #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 03c97f3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis change introduces a new error handling feature for the package Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant R as unrsResolve()
participant C as TSCONFIG_NOT_FOUND_REGEXP
participant E as Error Handler
U->>R: Call resolver function
R->>R: Execute resolving logic
R->>R: Check if result.error matches C
alt Error matches malformed tsconfig
R->>E: Throw new error with message
E-->>U: Return error response
else Error does not match
R-->>U: Return normal result
end
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (7)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces error handling for malformed tsconfig references by throwing an error when a tsconfig file isn’t found. The key changes include:
- Updating tests to include a new test case for a malformed tsconfig reference.
- Enhancing the resolver in src/index.ts to throw an error when the tsconfig is not found.
- Adding a new constant (TSCONFIG_NOT_FOUND_REGEXP) to define the expected error pattern.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
File | Description |
---|---|
tests/unit/unit.spec.ts | Adds tests for pnp functionality and malformed tsconfig handling. |
src/index.ts | Checks error messages and throws an error when the tsconfig is missing. |
src/constants.ts | Introduces a new regexp constant for matching tsconfig not found errors. |
Files not reviewed (1)
- tests/unit/malformed-reference/tsconfig.json: Language not supported
Comments suppressed due to low confidence (1)
src/index.ts:54
- Rethrowing the error with a new Error(result.error) may lose context from the original error. Consider preserving the original error by using the Error's cause property (e.g., new Error(result.error, { cause: result.error })) if supported.
if (TSCONFIG_NOT_FOUND_REGEXP.test(result.error)) {
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
commit: |
size-limit report 📦
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #423 +/- ##
==========================================
+ Coverage 57.41% 63.58% +6.16%
==========================================
Files 6 6
Lines 364 368 +4
Branches 29 48 +19
==========================================
+ Hits 209 234 +25
+ Misses 155 134 -21 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| datasource | package | from | to | | ---------- | --------------------------------- | ----- | ----- | | npm | eslint-import-resolver-typescript | 4.2.2 | 4.3.1 | ## [v4.3.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#431) ##### Patch Changes - [#425](import-js/eslint-import-resolver-typescript#425) [`2ced0ba`](import-js/eslint-import-resolver-typescript@2ced0ba) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `unrs-resolver` to v1.3.3 ## [v4.3.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#430) ##### Minor Changes - [#423](import-js/eslint-import-resolver-typescript#423) [`2fcb947`](import-js/eslint-import-resolver-typescript@2fcb947) Thanks [@JounQin](https://github.com/JounQin)! - feat: throw error on malformed `tsconfig` reference ## [v4.2.7](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#427) ##### Patch Changes - [`aeb558f`](import-js/eslint-import-resolver-typescript@aeb558f) Thanks [@JounQin](https://github.com/JounQin)! - fix: add missing `index.d.cts` file ## [v4.2.6](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#426) ##### Patch Changes - [#417](import-js/eslint-import-resolver-typescript#417) [`c3f678b`](import-js/eslint-import-resolver-typescript@c3f678b) Thanks [@JounQin](https://github.com/JounQin)! - fix: `require` entry types, add `module-sync` entry ## [v4.2.5](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#425) ##### Patch Changes - [#410](import-js/eslint-import-resolver-typescript#410) [`ec59d22`](import-js/eslint-import-resolver-typescript@ec59d22) Thanks [@JounQin](https://github.com/JounQin)! - fix: absolute path aliasing should not be skipped ## [v4.2.4](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#424) ##### Patch Changes - [#407](import-js/eslint-import-resolver-typescript#407) [`6b183ff`](import-js/eslint-import-resolver-typescript@6b183ff) Thanks [@JounQin](https://github.com/JounQin)! - chore: migrate to rebranding `unrs-resolver` with new targets supported: - `i686-pc-windows-msvc` - `armv7-unknown-linux-musleabihf` - `powerpc64le-unknown-linux-gnu` - `s390x-unknown-linux-gnu` ## [v4.2.3](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#423) ##### Patch Changes - [#402](import-js/eslint-import-resolver-typescript#402) [`f21bf15`](import-js/eslint-import-resolver-typescript@f21bf15) Thanks [@SunsetTechuila](https://github.com/SunsetTechuila)! - fix: don't resolve not implemented node modules in `bun` `is-bun-module` is marked as `dependency`, again, for correctness, see [`isBunImplementedNodeModule`](https://github.com/SunsetTechuila/is-bun-module#isbunimplementednodemodulemodulename-bunversion) for more details For `Bun` users: you don't need to install `is-bun-module` any more but `bun: true` option is still required if you're running without `bun --bun` nor [`run#bun`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun) enabled
| datasource | package | from | to | | ---------- | --------------------------------- | ----- | ----- | | npm | eslint-import-resolver-typescript | 4.2.2 | 4.3.1 | ## [v4.3.1](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#431) ##### Patch Changes - [#425](import-js/eslint-import-resolver-typescript#425) [`2ced0ba`](import-js/eslint-import-resolver-typescript@2ced0ba) Thanks [@JounQin](https://github.com/JounQin)! - chore: bump `unrs-resolver` to v1.3.3 ## [v4.3.0](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#430) ##### Minor Changes - [#423](import-js/eslint-import-resolver-typescript#423) [`2fcb947`](import-js/eslint-import-resolver-typescript@2fcb947) Thanks [@JounQin](https://github.com/JounQin)! - feat: throw error on malformed `tsconfig` reference ## [v4.2.7](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#427) ##### Patch Changes - [`aeb558f`](import-js/eslint-import-resolver-typescript@aeb558f) Thanks [@JounQin](https://github.com/JounQin)! - fix: add missing `index.d.cts` file ## [v4.2.6](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#426) ##### Patch Changes - [#417](import-js/eslint-import-resolver-typescript#417) [`c3f678b`](import-js/eslint-import-resolver-typescript@c3f678b) Thanks [@JounQin](https://github.com/JounQin)! - fix: `require` entry types, add `module-sync` entry ## [v4.2.5](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#425) ##### Patch Changes - [#410](import-js/eslint-import-resolver-typescript#410) [`ec59d22`](import-js/eslint-import-resolver-typescript@ec59d22) Thanks [@JounQin](https://github.com/JounQin)! - fix: absolute path aliasing should not be skipped ## [v4.2.4](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#424) ##### Patch Changes - [#407](import-js/eslint-import-resolver-typescript#407) [`6b183ff`](import-js/eslint-import-resolver-typescript@6b183ff) Thanks [@JounQin](https://github.com/JounQin)! - chore: migrate to rebranding `unrs-resolver` with new targets supported: - `i686-pc-windows-msvc` - `armv7-unknown-linux-musleabihf` - `powerpc64le-unknown-linux-gnu` - `s390x-unknown-linux-gnu` ## [v4.2.3](https://github.com/import-js/eslint-import-resolver-typescript/blob/HEAD/CHANGELOG.md#423) ##### Patch Changes - [#402](import-js/eslint-import-resolver-typescript#402) [`f21bf15`](import-js/eslint-import-resolver-typescript@f21bf15) Thanks [@SunsetTechuila](https://github.com/SunsetTechuila)! - fix: don't resolve not implemented node modules in `bun` `is-bun-module` is marked as `dependency`, again, for correctness, see [`isBunImplementedNodeModule`](https://github.com/SunsetTechuila/is-bun-module#isbunimplementednodemodulemodulename-bunversion) for more details For `Bun` users: you don't need to install `is-bun-module` any more but `bun: true` option is still required if you're running without `bun --bun` nor [`run#bun`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun) enabled
close #415
Summary by CodeRabbit
./lib/index.js
from "1.4kB" to "1.5kB".