Skip to content

Commit 27e65b4

Browse files
reidbarberdevongovett
authored andcommitted
fix s2 imports being removed
1 parent 7d054d4 commit 27e65b4

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/imports.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ exports[`should preserve leading comment if first line is removed 1`] = `
9292
"/*
9393
* Some comment
9494
*/
95-
import { StatusLight } from "@react-spectrum/s2";
95+
import { Button, StatusLight } from "@react-spectrum/s2";
9696
9797
<>
9898
<Button>Test</Button>

packages/dev/codemods/src/s1-to-s2/__tests__/__snapshots__/styleProps.test.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ import { style } from "@react-spectrum/s2/style" with { type: "macro" };
226226
`;
227227

228228
exports[`Should leave existing style macros unaffected 1`] = `
229-
"import { style } from "@react-spectrum/s2/style" with { type: "macro" };
229+
"import { TextField } from "@react-spectrum/s2";
230+
import { style } from "@react-spectrum/s2/style" with { type: "macro" };
230231
231232
<TextField label="Name" styles={style({width: 160})} />"
232233
`;

packages/dev/codemods/src/s1-to-s2/__tests__/imports.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ test('should preserve leading comment if first line is removed', `
119119
/*
120120
* Some comment
121121
*/
122-
import {StatusLight} from '@adobe/react-spectrum';
123-
import {Button} from "@react-spectrum/s2";
122+
import {Button, StatusLight} from '@adobe/react-spectrum';
124123
125124
<>
126125
<Button>Test</Button>

packages/dev/codemods/src/s1-to-s2/src/codemods/codemod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function transformer(file: FileInfo, api: API, options: Options)
5151
const leadingComments = root.find(j.Program).get('body', 0).node.leadingComments;
5252
traverse(root.paths()[0].node, {
5353
ImportDeclaration(path) {
54-
if (path.node.source.value === '@adobe/react-spectrum' || path.node.source.value.startsWith('@react-spectrum/')) {
54+
if (path.node.source.value === '@adobe/react-spectrum' || (path.node.source.value.startsWith('@react-spectrum/') && path.node.source.value !== '@react-spectrum/s2')) {
5555
lastImportPath = path;
5656
for (let specifier of path.node.specifiers) {
5757
if (specifier.type === 'ImportNamespaceSpecifier') {

0 commit comments

Comments
 (0)