Skip to content

feat(no-extraneous-dependencies): add exclude option to rule #3198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sf0rman
Copy link

@sf0rman sf0rman commented Jul 9, 2025

Encountered an issue when using redux-ui and importing the nested dependencies @redux-ui/react-<component> and wanted a way to exclude anything like @redux-ui/react-* without having to do it per line or per file which would have other side effects.

Implemented an exclude option to the no-extraneous-dependencies rule.

Copy link

codecov bot commented Jul 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.18%. Comparing base (01c9eb0) to head (369c265).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3198      +/-   ##
==========================================
+ Coverage   82.25%   92.18%   +9.92%     
==========================================
  Files          94       83      -11     
  Lines        4283     3696     -587     
  Branches     1478     1334     -144     
==========================================
- Hits         3523     3407     -116     
+ Misses        760      289     -471     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

I'm confused what you mean by "nested dependencies". If you're using @redux-ui/react-<component>, then it should be in your package.json, no?

Comment on lines +181 to +188
if (!exclude) {
return false;
}

if (Array.isArray(exclude)) {
return exclude.some((pattern) => minimatch(packageName, pattern));
}
return minimatch(packageName, exclude);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (!exclude) {
return false;
}
if (Array.isArray(exclude)) {
return exclude.some((pattern) => minimatch(packageName, pattern));
}
return minimatch(packageName, exclude);
return [].concat(exclude || []).some((pattern) => minimatch(packageName, pattern));

@@ -277,6 +292,7 @@ module.exports = {
packageDir: { type: ['string', 'array'] },
includeInternal: { type: ['boolean'] },
includeTypes: { type: ['boolean'] },
exclude: { type: ['string', 'array'] },
Copy link
Member

Choose a reason for hiding this comment

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

for the array, let's ensure it's unique, and that the items can only be of type string

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

Successfully merging this pull request may close these issues.

2 participants