Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix for deprecated and experimental import paths #410

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

Merged
jonrohan merged 2 commits into main from fix_for_alternate_paths
Sep 12, 2025

Conversation

@jonrohan
Copy link
Member

@jonrohan jonrohan commented Sep 12, 2025
edited
Loading

This is a fix to the use-styled-react-import plugin. It was missing transforming Octicon and Dialog and I found the reason was that these components came from deprecated and experimental import paths

Copy link

changeset-bot bot commented Sep 12, 2025
edited
Loading

🦋 Changeset detected

Latest commit: 0159ee3

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

Fixes deprecated and experimental import paths in eslint-plugin-primer-react.
@jonrohan jonrohan marked this pull request as ready for review September 12, 2025 17:45
@jonrohan jonrohan requested a review from a team as a code owner September 12, 2025 17:45
@jonrohan jonrohan merged commit f3e47b1 into main Sep 12, 2025
9 checks passed
@jonrohan jonrohan deleted the fix_for_alternate_paths branch September 12, 2025 17:46
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 use-styled-react-import ESLint rule to properly handle deprecated and experimental import paths from Primer React. The rule was missing transformations for components like Octicon and Dialog because they were imported from subpaths like @primer/react/deprecated and @primer/react/experimental.

  • Updates import detection logic to handle subpaths using startsWith() checks
  • Modifies path transformation to preserve subpath structure when converting between @primer/react and @primer/styled-react
  • Adds comprehensive test coverage for the new subpath functionality

Reviewed Changes

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

File Description
src/rules/use-styled-react-import.js Enhanced import detection and path transformation logic to support subpaths
src/rules/tests/use-styled-react-import.test.js Added test cases for experimental and deprecated import paths
.changeset/cyan-carrots-boil.md Added changeset documenting the fix
Comments suppressed due to low confidence (1)

src/rules/tests/use-styled-react-import.test.js:55

  • [nitpick] The existing test case structure was modified unnecessarily. The original compact error format was more readable than expanding it to multiple lines.
 {
 messageId: 'useStyledReactImport',
 data: {componentName: 'Box'},
 },

styledUtilities.has(importedName)
) {
primerReactImports.set(importedName, {node, specifier})
primerReactImports.set(importedName, {node, specifier, importSource})
Copy link

Copilot AI Sep 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding a comment explaining why importSource is now stored in the import info object, as this change enables proper subpath handling in the fix functions.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot Copilot left review comments

@TylerJDev TylerJDev Awaiting requested review from TylerJDev TylerJDev is a code owner automatically assigned from primer/engineer-reviewers

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /