Skip to content

Conversation

jonrohan
Copy link
Member

@jonrohan jonrohan commented Sep 12, 2025

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

🦋 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 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
Preview

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.

@primer-css primer-css mentioned this pull request Sep 12, 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.

1 participant