Skip to content

fix(linter/import): count unique module sources in max-dependencies#19270

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/02-11-fix_linter_import_count_unique_module_sources_in_max-dependencies
Feb 12, 2026
Merged

fix(linter/import): count unique module sources in max-dependencies#19270
graphite-app[bot] merged 1 commit intomainfrom
c/02-11-fix_linter_import_count_unique_module_sources_in_max-dependencies

Conversation

@camc314
Copy link
Contributor

@camc314 camc314 commented Feb 11, 2026

fixes #19120

@camc314 camc314 marked this pull request as ready for review February 11, 2026 15:22
Copilot AI review requested due to automatic review settings February 11, 2026 15:22
@github-actions github-actions bot added A-linter Area - Linter C-bug Category - Bug labels Feb 11, 2026
@camc314
Copy link
Contributor Author

camc314 commented Feb 11, 2026

@connorshea mind reviewing if you have time? Thanks

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

This PR fixes the import/max-dependencies lint rule so that it counts unique module sources (e.g., './foo') instead of counting individual import specifiers, aligning behavior with eslint-plugin-import and resolving oxc issue #19120.

Changes:

  • Update MaxDependencies to track unique module_request sources via a set, rather than using import_entries.len().
  • Improve diagnostic labeling to point at the first import that exceeds the configured maximum.
  • Update/add tests and snapshots to cover the “multiple specifiers from same module counts once” behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/oxc_linter/src/rules/import/max_dependencies.rs Switch counting logic to unique module sources (with correct handling for ignoreTypeImports) and update tests accordingly.
crates/oxc_linter/src/snapshots/import_max_dependencies.snap Update snapshot output to match the new “first exceeding dependency” span/label location.

@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_count_unique_module_sources_in_max-dependencies (0b3f692) with main (8bef2c3)2

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.

  2. No successful run was found on main (87a6724) during the generation of this report, so 8bef2c3 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@connorshea
Copy link
Member

I added one more test case to ensure an all-inline-type-imports import doesn't get counted, LGTM :)

@connorshea connorshea added the 0-merge Merge with Graphite Merge Queue label Feb 12, 2026
Copy link
Member

connorshea commented Feb 12, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/02-11-fix_linter_import_count_unique_module_sources_in_max-dependencies branch from 0b3f692 to 05bc855 Compare February 12, 2026 00:31
@graphite-app graphite-app bot merged commit 05bc855 into main Feb 12, 2026
21 checks passed
@graphite-app graphite-app bot deleted the c/02-11-fix_linter_import_count_unique_module_sources_in_max-dependencies branch February 12, 2026 00:36
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 12, 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
# 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/max-dependencies rule counts individual import specifiers instead of unique module sources

2 participants

Comments