Skip to content

Handle access-denied directories during case checks#494

Merged
JounQin merged 1 commit into
un-ts:masterfrom
morgan-coded:fix/483-case-check-access-errors
Jun 22, 2026
Merged

Handle access-denied directories during case checks#494
JounQin merged 1 commit into
un-ts:masterfrom
morgan-coded:fix/483-case-check-access-errors

Conversation

@morgan-coded

@morgan-coded morgan-coded commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

no-unresolved could resolve an import successfully, then crash during its case-sensitive path check if reading an ancestor directory returned EACCES or EPERM.
This treats those access errors as casing being unverifiable while keeping the resolved path valid. Other filesystem errors still throw.
I checked both error cases on Node 22 and Node 26, the full resolve test file passing 40/40, typecheck, build, ESLint, patch-package checks, and git diff --check.
Fixes #483

Copilot AI review requested due to automatic review settings June 22, 2026 01:42
@changeset-bot

changeset-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0bbe774

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-import-x Patch

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

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8832740e-4eba-4c14-916e-0920176c73ce

📥 Commits

Reviewing files that changed from the base of the PR and between ac6ee0b and 0bbe774.

📒 Files selected for processing (3)
  • .changeset/case-check-access-errors.md
  • src/utils/resolve.ts
  • test/utils/resolve.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/case-check-access-errors.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/utils/resolve.spec.ts
  • src/utils/resolve.ts

📝 Walkthrough

Walkthrough

fileExistsWithCaseSync in src/utils/resolve.ts gains a new isDirectoryAccessError predicate and a try/catch around fs.readdirSync that returns true on EACCES/EPERM instead of throwing. Tests cover both error codes with a mocked readdirSync, and a changeset documents the patch.

Changes

Permission-error tolerance in case-sensitive path check

Layer / File(s) Summary
isDirectoryAccessError helper and readdirSync error handling
src/utils/resolve.ts
Adds isDirectoryAccessError to identify EACCES/EPERM error codes, then wraps the fs.readdirSync call in a try/catch that sets result = true on access errors and rethrows everything else.
Parameterized tests and changeset entry
test/utils/resolve.spec.ts, .changeset/case-check-access-errors.md
Adds os import and a new test parameterized over EACCES/EPERM that builds a temp directory tree, spies on fs.readdirSync to throw on a blocked ancestor, asserts fileExistsWithCaseSync returns true, and cleans up via finally. Changeset records the patch bump.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • un-ts/eslint-plugin-import-x#390: Modifies the same fileExistsWithCaseSync function in src/utils/resolve.ts around directory-read and case-insensitive path resolution logic.

Suggested labels

bug

Suggested reviewers

  • JounQin

🐇 A hop through the dirs, but the gate was locked tight,
No EPERM shall crash what resolves just right.
We catch the denied, say "the file is here!"
And lint carries on without shedding a tear.
🌿 Case-check now gentle — the bunny cheers! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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 'Handle access-denied directories during case checks' accurately summarizes the main change: adding graceful handling for access errors (EACCES/EPERM) during case-sensitive path verification.
Linked Issues check ✅ Passed The PR fully addresses issue #483: it implements graceful handling of EACCES and EPERM errors during case-sensitive checks via a new helper function, allowing the lint process to continue rather than crash when ancestor directories cannot be read.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving issue #483: modifications to the case-checking logic, corresponding test coverage, and a changeset entry documenting the fix—with no unrelated alterations detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@codesandbox-ci

codesandbox-ci Bot commented Jun 22, 2026

Copy link
Copy Markdown

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.

@codacy-production

codacy-production Bot commented Jun 22, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 8 complexity · 0 duplication

Metric Results
Complexity 8
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Comment thread CHANGELOG.md Outdated
@morgan-coded morgan-coded force-pushed the fix/483-case-check-access-errors branch from ac6ee0b to 0bbe774 Compare June 22, 2026 03:57
@pkg-pr-new

pkg-pr-new Bot commented Jun 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-import-x@494

commit: 0bbe774

@JounQin JounQin merged commit 1c84235 into un-ts:master Jun 22, 2026
55 checks passed
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.

no-unresolved case-sensitive path check can throw EPERM for imports outside cwd

2 participants