Skip to content

fix(linter/import-no-cycle): avoid traversal-order false negatives with type-only edges#19267

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/02-11-fix_linter_import-no-cycle_avoid_traversal-order_false_negatives_with_type-only_edges_fix_import_no-cycle_false_negatives_reported_in_issue_19245_by_adjusting_module_graph_traversal_semantics
Feb 11, 2026
Merged

fix(linter/import-no-cycle): avoid traversal-order false negatives with type-only edges#19267
graphite-app[bot] merged 1 commit intomainfrom
c/02-11-fix_linter_import-no-cycle_avoid_traversal-order_false_negatives_with_type-only_edges_fix_import_no-cycle_false_negatives_reported_in_issue_19245_by_adjusting_module_graph_traversal_semantics

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Feb 11, 2026

Root cause:
ModuleGraphVisitor marked a module as traversed before applying the rule
filter. For no-cycle with ignoreTypes: true, a type-only edge could claim
a node first, then a later value edge to the same node was skipped. Because
sibling import iteration order is filename-dependent, this produced
deterministic-but-order-sensitive misses.

Before:

parent
  -> type-only edge to X      (filtered out by rule)
       [X added to traversed too early]
  -> value edge to X
       [skipped: already traversed]
  => real cycle can be missed

After:

parent
  -> type-only edge to X
       [filtered out first, not marked traversed]
  -> value edge to X
       [accepted, then marked traversed]
  => cycle path remains discoverable

Changes included:

fixes #19245

AI disclosure: this commit was prepared with AI assistance and reviewed.

Copy link
Contributor Author

camc314 commented Feb 11, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Feb 11, 2026
@camc314 camc314 force-pushed the c/02-11-fix_linter_import-no-cycle_avoid_traversal-order_false_negatives_with_type-only_edges_fix_import_no-cycle_false_negatives_reported_in_issue_19245_by_adjusting_module_graph_traversal_semantics branch from 5f2bf93 to 2eeb280 Compare February 11, 2026 14:25
@camc314 camc314 changed the title fix(linter/import-no-cycle): avoid traversal-order false negatives with type-only edges Fix import/no-cycle false negatives reported in issue #19245 by adjusting module graph traversal semantics. fix(linter/import-no-cycle): avoid traversal-order false negatives with type-only edges Feb 11, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/02-11-fix_linter_import-no-cycle_avoid_traversal-order_false_negatives_with_type-only_edges_fix_import_no-cycle_false_negatives_reported_in_issue_19245_by_adjusting_module_graph_traversal_semantics (2a47617) with main (e5baf60)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camc314 camc314 self-assigned this Feb 11, 2026
@camc314 camc314 marked this pull request as ready for review February 11, 2026 14:49
Copilot AI review requested due to automatic review settings February 11, 2026 14:49
@camc314 camc314 force-pushed the c/02-11-fix_linter_import-no-cycle_avoid_traversal-order_false_negatives_with_type-only_edges_fix_import_no-cycle_false_negatives_reported_in_issue_19245_by_adjusting_module_graph_traversal_semantics branch from 2eeb280 to 2a47617 Compare February 11, 2026 14:49
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Feb 11, 2026
Copy link
Contributor Author

camc314 commented Feb 11, 2026

Merge activity

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes import/no-cycle traversal-order false negatives when ignoreTypes: true by ensuring modules are only marked traversed after the rule-specific edge filter accepts the edge, so filtered type-only edges can’t “claim” a node and block later value-edge traversal.

Changes:

  • Move traversed insertion in ModuleGraphVisitor to occur after the filter check.
  • Add a regression scenario for issue #19245 plus a new TypeScript fixture set.
  • Update the import_no_cycle snapshot for the new test output.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/oxc_linter/src/module_graph_visitor.rs Fixes traversal bookkeeping by applying the filter before marking nodes as traversed.
crates/oxc_linter/src/rules/import/no_cycle.rs Adds a new failing test case intended to reproduce #19245.
crates/oxc_linter/src/snapshots/import_no_cycle.snap Updates snapshots to include the new test output.
crates/oxc_linter/fixtures/import/cycles/typescript/issue_19245/simpleInterestLoanManager.ts New TS fixture module for #19245 reproduction.
crates/oxc_linter/fixtures/import/cycles/typescript/issue_19245/installmentLoanManager.ts New TS fixture module for #19245 reproduction.
crates/oxc_linter/fixtures/import/cycles/typescript/issue_19245/dataReport/avenAccountDataReportManager.ts New TS fixture module for #19245 reproduction.
crates/oxc_linter/fixtures/import/cycles/typescript/issue_19245/balanceSweepDetailsManager.ts New TS fixture entrypoint for #19245 reproduction.
crates/oxc_linter/fixtures/import/cycles/typescript/issue_19245/aaaInternal.ts New TS fixture module for filename-order path in #19245 reproduction.

…th type-only edges (#19267)

Root cause:
`ModuleGraphVisitor` marked a module as `traversed` before applying the rule
filter. For `no-cycle` with `ignoreTypes: true`, a type-only edge could claim
a node first, then a later value edge to the same node was skipped. Because
sibling import iteration order is filename-dependent, this produced
deterministic-but-order-sensitive misses.

Before:
```text
parent
  -> type-only edge to X      (filtered out by rule)
       [X added to traversed too early]
  -> value edge to X
       [skipped: already traversed]
  => real cycle can be missed
```

After:
```text
parent
  -> type-only edge to X
       [filtered out first, not marked traversed]
  -> value edge to X
       [accepted, then marked traversed]
  => cycle path remains discoverable
```

Changes included:
- Move `traversed` insertion to run after `filter` in `ModuleGraphVisitor`.
- Add a dedicated regression test for issue #19245.
- Add TS fixture set reproducing the filename/type-only branch scenario.
- Add snapshot asserting the cycle diagnostic is emitted.

fixes #19245

AI disclosure: this commit was prepared with AI assistance and reviewed.
@graphite-app graphite-app bot force-pushed the c/02-11-fix_linter_import-no-cycle_avoid_traversal-order_false_negatives_with_type-only_edges_fix_import_no-cycle_false_negatives_reported_in_issue_19245_by_adjusting_module_graph_traversal_semantics branch from 2a47617 to f16f2b6 Compare February 11, 2026 14:58
@graphite-app graphite-app bot merged commit f16f2b6 into main Feb 11, 2026
21 checks passed
@graphite-app graphite-app bot deleted the c/02-11-fix_linter_import-no-cycle_avoid_traversal-order_false_negatives_with_type-only_edges_fix_import_no-cycle_false_negatives_reported_in_issue_19245_by_adjusting_module_graph_traversal_semantics branch February 11, 2026 15:03
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 11, 2026
camc314 added a commit that referenced this pull request Feb 12, 2026
# Oxlint
### 🚀 Features

- ebb80b3 ast: Add `node_id` field to all AST struct nodes (#18138)
(Boshen)
- 2879fc5 linter: Implement fixer for unicorn/prefer-math-trunc (#19275)
(camc314)
- a204eda linter: Implement fixer for unicorn/no-typeof-undefined
(#19274) (camc314)
- ab46d9c linter: Implement typescript/class-literal-property-style
(#19252) (Vincent R)
- 1a61f58 linter: Implement typescript/no-invalid-void-type (#19242)
(Vincent R)

### 🐛 Bug Fixes

- 45adda2 oxlint/lsp: Use blocking stdio in Oxlint (#19292)
(overlookmotel)
- 05bc855 linter/import: Count unique module sources in max-dependencies
(#19270) (camc314)
- 8566b44 linter: Check for preceeding token in math trunc fixer
(#19277) (camc314)
- f16f2b6 linter/import-no-cycle: Avoid traversal-order false negatives
with type-only edges (#19267) (camc314)
- d4937e7 linter: Recognize module-scoped callback refs as stable in
exhaustive-deps (#19220) (Sreetam Das)
- 140c9bd linter: Detect fallthrough from `default` when it is not the
last case (#19261) (Boshen)
- 740a009 linter: Accept digits after 'use' in hook names (#19254)
(Sreetam Das)
- 31b562f linter: Update `import/no-named-as-default` to allow named
import if equivalent to the default import (#19100) (connorshea)
- 79c82cc linter: Avoid applying object-level docs to nested object
methods in require-param (#19231) (camc314)

### ⚡ Performance

- 5670291 linter/class-literal-property-style: Avoid unneeded string
allocations (#19262) (camc314)
# Oxfmt
### 🚀 Features

- ebb80b3 ast: Add `node_id` field to all AST struct nodes (#18138)
(Boshen)

### 🐛 Bug Fixes

- 1957908 formatter: Avoid unnecessary parentheses for string literal in
labeled statement (#19272) (Dunqing)

Co-authored-by: camc314 <[email protected]>
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
…th type-only edges (oxc-project#19267)

Root cause:
`ModuleGraphVisitor` marked a module as `traversed` before applying the rule
filter. For `no-cycle` with `ignoreTypes: true`, a type-only edge could claim
a node first, then a later value edge to the same node was skipped. Because
sibling import iteration order is filename-dependent, this produced
deterministic-but-order-sensitive misses.

Before:
```text
parent
  -> type-only edge to X      (filtered out by rule)
       [X added to traversed too early]
  -> value edge to X
       [skipped: already traversed]
  => real cycle can be missed
```

After:
```text
parent
  -> type-only edge to X
       [filtered out first, not marked traversed]
  -> value edge to X
       [accepted, then marked traversed]
  => cycle path remains discoverable
```

Changes included:
- Move `traversed` insertion to run after `filter` in `ModuleGraphVisitor`.
- Add a dedicated regression test for issue oxc-project#19245.
- Add TS fixture set reproducing the filename/type-only branch scenario.
- Add snapshot asserting the cycle diagnostic is emitted.

fixes oxc-project#19245

AI disclosure: this commit was prepared with AI assistance and reviewed.
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
# Oxlint
### 🚀 Features

- ebb80b3 ast: Add `node_id` field to all AST struct nodes (oxc-project#18138)
(Boshen)
- 2879fc5 linter: Implement fixer for unicorn/prefer-math-trunc (oxc-project#19275)
(camc314)
- a204eda linter: Implement fixer for unicorn/no-typeof-undefined
(oxc-project#19274) (camc314)
- ab46d9c linter: Implement typescript/class-literal-property-style
(oxc-project#19252) (Vincent R)
- 1a61f58 linter: Implement typescript/no-invalid-void-type (oxc-project#19242)
(Vincent R)

### 🐛 Bug Fixes

- 45adda2 oxlint/lsp: Use blocking stdio in Oxlint (oxc-project#19292)
(overlookmotel)
- 05bc855 linter/import: Count unique module sources in max-dependencies
(oxc-project#19270) (camc314)
- 8566b44 linter: Check for preceeding token in math trunc fixer
(oxc-project#19277) (camc314)
- f16f2b6 linter/import-no-cycle: Avoid traversal-order false negatives
with type-only edges (oxc-project#19267) (camc314)
- d4937e7 linter: Recognize module-scoped callback refs as stable in
exhaustive-deps (oxc-project#19220) (Sreetam Das)
- 140c9bd linter: Detect fallthrough from `default` when it is not the
last case (oxc-project#19261) (Boshen)
- 740a009 linter: Accept digits after 'use' in hook names (oxc-project#19254)
(Sreetam Das)
- 31b562f linter: Update `import/no-named-as-default` to allow named
import if equivalent to the default import (oxc-project#19100) (connorshea)
- 79c82cc linter: Avoid applying object-level docs to nested object
methods in require-param (oxc-project#19231) (camc314)

### ⚡ Performance

- 5670291 linter/class-literal-property-style: Avoid unneeded string
allocations (oxc-project#19262) (camc314)
# Oxfmt
### 🚀 Features

- ebb80b3 ast: Add `node_id` field to all AST struct nodes (oxc-project#18138)
(Boshen)

### 🐛 Bug Fixes

- 1957908 formatter: Avoid unnecessary parentheses for string literal in
labeled statement (oxc-project#19272) (Dunqing)

Co-authored-by: camc314 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: import/no-cycle false negative depends on filename/traversal order with type-only import path

1 participant

Comments