← Back to Pull requests

fix(no-restricted-paths): resolve glob `except` patterns against `basePath` #626

Closed
unknown closed this pull request without merging on Nov 12, 2026 08:54 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 05:51 UTC
Author

Closes #615

target and from are resolved against basePath before matching, but glob except patterns were matched as written against the absolute import path. So:

  • a relative glob like ./src/lib/allowed/ never matched anything, so the exception did nothing

  • a leading (e.g. /lib/allowed/) stopped matching once the project lived under a dot-directory like ~/.worktrees/project, because minimatch's skips dot segments
  • Now each glob exception is matched both as written (as before) and resolved with path.resolve(basePath, except), the same as from. Matching both keeps every pattern that worked before working, e.g. /two/ when from points outside basePath (../server//). A leading ! is taken off before resolving and applied to the result, so !/three/ still means "not under three".

    Tests:

  • valid: except: ['./test/fixtures/restricted-paths/server/two/'] with a glob from (fails on main)

  • valid: same with a custom basePath and from: 'server//', except: ['server/two/'] (fails on main)

  • invalid: both configs still report an import outside the exception

  • valid: except: ['/two/'] with basePath = client and from: '../server//' (works on main, guards against resolving only)

  • valid + invalid: except: ['!/three/'] (negation kept)
  • The docs now say glob exceptions are resolved against basePath. Added a patch changeset. yarn test (3976) and yarn lint pass.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Fixed no-restricted-paths so glob-based exceptions are matched both as written and relative to the configured base path.
    Improved support for negated exception patterns, including repeated ! characters, so they do not incorrectly exempt restricted imports.
    Exception matching now includes dotfiles.
    Documentation
    * Clarified that glob-based exceptions are matched as written and relative to the configured base path.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 267 lines (+200 / -67) across 3 files Reviewer: thekhegay Review duration: 183m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.39) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 267 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.334
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #626"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.4% (MEDIUM) · Higher = larger blast radius
    39.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17% · Safe to merge
    17%