Skip to content

fix: respect tsconfig exclude patterns in project ownership checks#46

Merged
EladBezalel merged 3 commits intomainfrom
fix/tsconfig-exclude-filtering
Mar 23, 2026
Merged

fix: respect tsconfig exclude patterns in project ownership checks#46
EladBezalel merged 3 commits intomainfrom
fix/tsconfig-exclude-filtering

Conversation

@EladBezalel
Copy link
Copy Markdown
Collaborator

@EladBezalel EladBezalel commented Mar 22, 2026

Summary

  • Parse each project's tsconfig exclude patterns (with extends chain support) to determine which files are excluded from the project's production source set
  • Filter ProjectIndex::get_package_names_by_path so that excluded files (e.g. *.stories.tsx, *.spec.ts) don't count toward marking a project as affected
  • All files are still parsed and included in the import index for cross-file reference accuracy — only the ownership check is filtered

Problem

Domino uses WalkDir to collect all .ts/.tsx/.js/.jsx files regardless of tsconfig excludes. When a transitive type dependency chain reaches a project solely through an excluded file (like a .stories.tsx), domino incorrectly marks that project as affected. Traf avoids this by using addSourceFilesFromTsConfig which respects each project's tsconfig include/exclude patterns.

Key design decision

The filtering happens at the project ownership level, not at file parsing. All files still get parsed and indexed for import graph accuracy. When a reference chain reaches a file and we ask "which project owns this?", excluded files are filtered out.

Interaction with PR #22

PR #22 adds include-pattern matching for direct test file changes. When rebasing #22 on top of this, note that ProjectIndex::get_package_names_by_path now filters by tsconfig excludes. Include-pattern matching for direct changes should use an unfiltered lookup to avoid suppressing detection of changed test files that are excluded from tsconfig. A get_package_names_by_path_unfiltered method may be needed.

Test plan

  • cargo clippy --all-targets --all-features — clean
  • cargo fmt --all -- --check — clean
  • cargo test --lib — 169 tests pass (7 new tsconfig + utils tests)
  • Integration test: stories file excluded by tsconfig does NOT cause project to be affected
  • Integration test: non-excluded source file importing same symbol DOES cause project to be affected

Closes #45

Made with Cursor

Summary by CodeRabbit

  • New Features

    • Tool now respects TypeScript tsconfig exclude patterns (including inherited/extended configs and JSONC), preventing false positives from excluded files.
  • Tests

    • Added integration and unit tests covering exclude parsing and affected-package detection.
  • Chores

    • CI release step now refreshes and commits the lockfile; several optional native packages were restored in package.json.

Domino's file discovery includes all .ts/.tsx/.js/.jsx files regardless
of tsconfig exclude patterns, causing false positives when transitive
type dependency chains reach a project solely through excluded files
(e.g. stories, specs). Traf avoids this by using addSourceFilesFromTsConfig
which respects each project's tsconfig include/exclude.

Add tsconfig exclude filtering to ProjectIndex so that files excluded
by a project's tsconfig don't count toward marking that project as
affected. All files are still parsed and included in the import index
for cross-file reference accuracy — only the ownership check is filtered.

Closes #45

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 22, 2026

Warning

Rate limit exceeded

@EladBezalel has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 51 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0506cb25-44d1-497c-b818-bd34a7cda351

📥 Commits

Reviewing files that changed from the base of the PR and between 9815edd and acea9d1.

📒 Files selected for processing (1)
  • src/tsconfig.rs
📝 Walkthrough

Walkthrough

ProjectIndex now loads per-project tsconfig excludes (via a new tsconfig module) and uses them to filter which files count as owned by a package when resolving package names by path; callsites and tests updated to pass cwd into ProjectIndex::new.

Changes

Cohort / File(s) Summary
Module declarations
src/lib.rs, src/main.rs
Exported/declared the new tsconfig module.
Tsconfig parser
src/tsconfig.rs
New TsconfigExcludes implementation: JSONC stripping, extends resolution with cycle/dpth guards, compile-to-glob::Pattern, parse(), is_excluded(), pattern_count(), and unit tests covering inheritance, overrides, circular extends, and scope handling.
Project index integration
src/utils.rs
ProjectIndex::new signature now accepts cwd; builds per-project TsconfigExcludes map and skips projects whose tsconfig excludes a queried file in get_package_names_by_path. Tests updated/added.
Callsite update
src/core.rs
Updated ProjectIndex::new call to pass (&config.projects, &config.cwd).
Integration tests
tests/integration_test.rs
Added two integration tests validating that tsconfig excludes prevent false-positive affected-project markings and do not suppress real dependencies.
CI workflow
.github/workflows/CI.yml
yarn install added to push-version step and yarn.lock staged for the version commit.
Package manifest
package.json
Reordered/added several optionalDependencies entries (@front-ops/domino-*, @oxc-node/core-*) without functional code changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I nibble on tsconfig rows, then hop away with glee,
Skipping stories and specs that shouldn't count for me.
I prune the false alarms with a soft, clever knack,
Now affected lists are tidy — I bounce right back! 🥕✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: implementing tsconfig exclude pattern filtering in project ownership checks.
Linked Issues check ✅ Passed All coding objectives from issue #45 are met: tsconfig parsing with extends support, project ownership filtering based on exclude patterns, unfiltered indexing, fallback behavior, and comprehensive test coverage.
Out of Scope Changes check ✅ Passed The CI/lockfile changes in .github/workflows/CI.yml and package.json are minor maintenance updates to keep dependencies in sync and appear reasonably related to version management.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tsconfig-exclude-filtering

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.

Tip

You can enable review details to help with troubleshooting, context usage and more.

Enable the reviews.review_details setting to include review details such as the model used, the time taken for each step and more in the review comments.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 6 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/tsconfig.rs">

<violation number="1" location="src/tsconfig.rs:47">
P2: Inherited excludes are matched against the child tsconfig directory, which misinterprets parent-defined relative exclude paths.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread src/tsconfig.rs
/// `extends` chain. Returns `None` if the tsconfig doesn't exist, can't be
/// parsed, or has no exclude patterns.
pub fn parse(tsconfig_path: &Path, cwd: &Path) -> Option<Self> {
let base_dir = tsconfig_path.parent()?.to_path_buf();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: Inherited excludes are matched against the child tsconfig directory, which misinterprets parent-defined relative exclude paths.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/tsconfig.rs, line 47:

<comment>Inherited excludes are matched against the child tsconfig directory, which misinterprets parent-defined relative exclude paths.</comment>

<file context>
@@ -0,0 +1,372 @@
+  /// `extends` chain. Returns `None` if the tsconfig doesn't exist, can't be
+  /// parsed, or has no exclude patterns.
+  pub fn parse(tsconfig_path: &Path, cwd: &Path) -> Option<Self> {
+    let base_dir = tsconfig_path.parent()?.to_path_buf();
+
+    let excludes = collect_excludes(tsconfig_path);
</file context>

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/tsconfig.rs (1)

131-140: Note: npm package extends are intentionally not resolved.

The function only handles relative paths (. or / prefixes). Extends like "extends": "@nx/js/tsconfig-lib" are skipped, which means exclude patterns won't be inherited from npm packages. This is a reasonable simplification given the feature's scope of filtering local project files.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/tsconfig.rs` around lines 131 - 140, The resolve_extends function
currently only resolves relative/absolute specifiers and returns None for
package-style extends (e.g., "@nx/js/tsconfig-lib"); update the code by adding a
clear doc comment above fn resolve_extends explaining that npm package "extends"
are intentionally not resolved (so exclude patterns from npm packages are not
inherited), why this simplification was chosen, and optionally add a TODO
comment or a unit test reference to track future support; leave the function
logic as-is (checking starts_with '.' or '/') and ensure the comment references
resolve_extends by name.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/tsconfig.rs`:
- Around line 131-140: The resolve_extends function currently only resolves
relative/absolute specifiers and returns None for package-style extends (e.g.,
"@nx/js/tsconfig-lib"); update the code by adding a clear doc comment above fn
resolve_extends explaining that npm package "extends" are intentionally not
resolved (so exclude patterns from npm packages are not inherited), why this
simplification was chosen, and optionally add a TODO comment or a unit test
reference to track future support; leave the function logic as-is (checking
starts_with '.' or '/') and ensure the comment references resolve_extends by
name.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fca7d52e-b0d5-4e40-8bf7-5ad621cba60d

📥 Commits

Reviewing files that changed from the base of the PR and between 81652ef and 84aff04.

📒 Files selected for processing (6)
  • src/core.rs
  • src/lib.rs
  • src/main.rs
  • src/tsconfig.rs
  • src/utils.rs
  • tests/integration_test.rs

The 1.0.1 version bump added @front-ops/domino-* optionalDependencies
to package.json but didn't regenerate yarn.lock, causing
yarn install --frozen-lockfile to fail in CI.

Also update CI.yml to run yarn install before committing version bumps
so the lockfile stays in sync on future releases.

Made-with: Cursor
Add doc comment to resolve_extends explaining the intentional omission
of npm package-style extends resolution and cross-referencing the
equivalent logic in resolve_options.rs.

Made-with: Cursor
@EladBezalel EladBezalel merged commit e3af613 into main Mar 23, 2026
25 checks passed
@EladBezalel EladBezalel deleted the fix/tsconfig-exclude-filtering branch March 23, 2026 08:22
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.

fix: respect tsconfig exclude patterns in file discovery

1 participant