Skip to content

Conversation

@HaukeSchnau
Copy link

@HaukeSchnau HaukeSchnau commented Nov 14, 2025

Summary

  • port ESLint’s import/no-extraneous-dependencies rule into oxc_linter, resolving the nearest package.json, honoring includeInternal/includeTypes toggles, glob-based allowances for dev/optional/peer/bundled dependencies, and skipping Node built-ins/internal modules by regex
  • accept packageDir as either a string or an array to stay compatible with ESLint config, add the required fast-glob dependency, and register the rule in the generated runner and rule list
  • add fixtures plus lint snapshots so coverage captures the new rule and document the upstream rule reference inside the implementation

Testing

  • cargo test -p oxc_linter import::no-extraneous-dependencies
  • just test

Port eslint-plugin-import's extraneous dependency check so oxlint flags missing or miscategorized packages using project package.json files. Adds fixtures, snapshots, registration, and the regex dependency. Tests: cargo test -p oxc_linter no_extraneous_dependencies -- --nocapture.
Copilot AI review requested due to automatic review settings November 14, 2025 13:55
@HaukeSchnau HaukeSchnau requested a review from camc314 as a code owner November 14, 2025 13:55
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 14, 2025

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.

@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Nov 14, 2025
Copilot finished reviewing on behalf of HaukeSchnau November 14, 2025 13:59
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 implements the ESLint import/no-extraneous-dependencies rule for oxc_linter, ensuring that all imported modules are declared in the nearest package.json file. The implementation resolves package.json files, supports multiple dependency types (dev, optional, peer, bundled), and provides glob-based file pattern matching for configuration.

Key changes:

  • Added comprehensive dependency validation logic that checks imports/requires against package.json declarations
  • Implemented support for packageDir configuration (string or array) to specify custom package.json locations
  • Added includeInternal and includeTypes options with regex-based internal module detection

Reviewed Changes

Copilot reviewed 8 out of 13 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
crates/oxc_linter/src/rules/import/no_extraneous_dependencies.rs Main rule implementation with AST visitors, package.json parsing, and dependency classification logic
crates/oxc_linter/src/rules.rs Registers the new rule in the import plugin module
crates/oxc_linter/src/generated/rule_runner_impls.rs Auto-generated runner configuration for the rule
crates/oxc_linter/Cargo.toml Adds regex dependency for internal module pattern matching
Cargo.toml Adds regex 1.12.2 to workspace dependencies
Cargo.lock Updates lock file with regex dependency
crates/oxc_linter/src/snapshots/import_no_extraneous_dependencies.snap Snapshot tests for standard dependency violations
crates/oxc_linter/src/snapshots/import_no_extraneous_dependencies@_glob.snap Snapshot tests for glob pattern matching
crates/oxc_linter/fixtures/import/no_extraneous_dependencies/package.json Test fixture with various dependency types
crates/oxc_linter/fixtures/import/no_extraneous_dependencies/custom_pkg/package.json Test fixture for custom packageDir configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copilot reviewed 6 out of 10 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants