Skip to content

exclude same-scope dependencies from the dependency scoring check - #2939

Merged
Simek merged 3 commits into
react-native-community:mainfrom
cpruijsen:fix/issue-2871
Oct 29, 2026
Merged

Simek merged 3 commits into
react-native-community:mainfrom
cpruijsen:fix/issue-2871

Conversation

@cpruijsen

@cpruijsen cpruijsen commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Why & how

Fixes #2871

The "Has a lot of dependencies" check now ignores dependencies from the package's own npm scope. The stored dependencies count is unchanged, so the card, sorting, statistics and API still show the raw total.

  • scripts/fetch-github-data.ts counts dependencies that share the package scope and stores them as an optional github.stats.sameScopeDependencies, written only when greater than zero.
  • util/scoring.ts uses dependencies - sameScopeDependencies > 25. Entries without the field score as before.
  • types/index.ts adds the optional field.
  • The mocked fetch test is removed.

assets/data.json now has sameScopeDependencies on the 141 scoped packages that have same-scope dependencies, with dependencies refreshed on those entries so the pair is consistent. I did not refresh other stats, to keep the data diff to the new field. Across the data set, only @impulse-ui-native/toolkit changes score: all 35 of its dependencies are @impulse-ui-native/*, so it loses the penalty and goes from 20 to 30. Every other package with more than 25 dependencies keeps it.

Checklist

  • Documented how you found or replicated the issue.
  • Explained how you fixed the issue or built the feature.
  • Described how to use or verify the change.

@Simek Simek left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't want to apply this tweak globally, since the dependencies data is used in multiple places.

Only the check logic in https://github.com/react-native-community/directory/blob/main/util/scoring.ts should be updated.

@cpruijsen

Copy link
Copy Markdown
Contributor Author

Thanks, makes sense. The count also drives the card, sorting and stats, so I'll leave it alone.

One snag: the scoring check only gets github.stats.dependencies as a number, so util/scoring.ts can't tell which dependencies share the package scope. Two options:

  1. Add a separate github.stats.sameScopeDependencies count at fetch time, and have the check use dependencies - sameScopeDependencies.
  2. Store the dependency names and filter in scoring.ts (makes data.json bigger).

I'd go with 1. Which do you prefer?

@Simek

Simek commented Oct 28, 2026

Copy link
Copy Markdown
Member

Let's go with an additional field for same scope dependencies count, and make it an optional, so we do not store 2k+ keys with 0 value. Also, please regenerate the local data, so it contains new field.

Also, let's remove mocked test, we test things using local data present in repository instead, so we can see the impact on whole data set, not only on once case in isolation.

@cpruijsen cpruijsen changed the title exclude same-scope packages from dependency count exclude same-scope dependencies from the dependency scoring check Oct 28, 2026
Comment thread util/scoring.ts Resolved

@Simek Simek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the quick update! 🙏 Tested the changes locally locally, LGTM! 🚀

@Simek
Simek merged commit f3abf78 into react-native-community:main Oct 29, 2026
2 checks passed
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.

Dependencies counting

2 participants