Skip to content

Commit

Permalink
fix s2 imports being removed
Browse files Browse the repository at this point in the history
  • Loading branch information
reidbarber authored and devongovett committed Sep 30, 2024
1 parent 7d054d4 commit 27e65b4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ exports[`should preserve leading comment if first line is removed 1`] = `
"/*
* Some comment
*/
import { StatusLight } from "@react-spectrum/s2";
import { Button, StatusLight } from "@react-spectrum/s2";
<>
<Button>Test</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ import { style } from "@react-spectrum/s2/style" with { type: "macro" };
`;

exports[`Should leave existing style macros unaffected 1`] = `
"import { style } from "@react-spectrum/s2/style" with { type: "macro" };
"import { TextField } from "@react-spectrum/s2";
import { style } from "@react-spectrum/s2/style" with { type: "macro" };
<TextField label="Name" styles={style({width: 160})} />"
`;
Expand Down
3 changes: 1 addition & 2 deletions packages/dev/codemods/src/s1-to-s2/__tests__/imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ test('should preserve leading comment if first line is removed', `
/*
* Some comment
*/
import {StatusLight} from '@adobe/react-spectrum';
import {Button} from "@react-spectrum/s2";
import {Button, StatusLight} from '@adobe/react-spectrum';
<>
<Button>Test</Button>
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/codemods/src/s1-to-s2/src/codemods/codemod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function transformer(file: FileInfo, api: API, options: Options)
const leadingComments = root.find(j.Program).get('body', 0).node.leadingComments;
traverse(root.paths()[0].node, {
ImportDeclaration(path) {
if (path.node.source.value === '@adobe/react-spectrum' || path.node.source.value.startsWith('@react-spectrum/')) {
if (path.node.source.value === '@adobe/react-spectrum' || (path.node.source.value.startsWith('@react-spectrum/') && path.node.source.value !== '@react-spectrum/s2')) {
lastImportPath = path;
for (let specifier of path.node.specifiers) {
if (specifier.type === 'ImportNamespaceSpecifier') {
Expand Down

0 comments on commit 27e65b4

Please sign in to comment.