Skip to content

Conversation

@liuliu-dev
Copy link
Contributor

Extends the no-unnecessary-components rule to work with components imported from @primer/styled-react, not just @primer/react. Fixes #468

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

🦋 Changeset detected

Latest commit: c5bc58d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-primer-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@liuliu-dev liuliu-dev marked this pull request as ready for review December 15, 2025 23:54
@liuliu-dev liuliu-dev requested a review from a team as a code owner December 15, 2025 23:54
@liuliu-dev liuliu-dev requested review from Copilot and pksjce December 15, 2025 23:54
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 extends the no-unnecessary-components ESLint rule to support components imported from @primer/styled-react in addition to @primer/react. This enhancement addresses issue #468 by updating the utility function isPrimerComponent to recognize imports from both packages.

  • Updated the regex pattern in isPrimerComponent to match both @primer/react and @primer/styled-react imports
  • Added test cases to validate the rule works correctly with @primer/styled-react imports
  • Added a changeset documenting this patch-level fix

Reviewed changes

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

File Description
src/utils/is-primer-component.js Updated regex to match @primer/styled-react imports and updated JSDoc comment
src/rules/tests/no-unnecessary-components.test.js Added valid and invalid test cases for @primer/styled-react imports
.changeset/dark-jobs-type.md Added changeset entry for the patch fix

@liuliu-dev liuliu-dev marked this pull request as draft December 16, 2025 18:36
@liuliu-dev liuliu-dev removed the request for review from pksjce December 16, 2025 18:36
@liuliu-dev liuliu-dev marked this pull request as ready for review December 16, 2025 18:45
Copy link
Member

@francinelucca francinelucca left a comment

Choose a reason for hiding this comment

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

LGTM, @liuliu-dev let's make sure the canary version passes integration checks before merging 🙏🏽

@liuliu-dev
Copy link
Contributor Author

@francinelucca Thanks for the heads up!
Integration tests passed here: https://github.com/github/github-ui/pull/9016, we do need to make a small change in github-ui for it to pass: https://github.com/github/github-ui/pull/9027

@liuliu-dev liuliu-dev merged commit 1e0f943 into main Dec 17, 2025
11 checks passed
@liuliu-dev liuliu-dev deleted the liuliu/include-styled-react-in-no-unnecessary-components-rule branch December 17, 2025 19:23
@primer primer bot mentioned this pull request Dec 17, 2025
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.

isPrimerComponent excludes components imported from @primer/styled-react

3 participants