Skip to content

Commit 1bd82a0

Browse files
authored
fix: use-monopackages codemod should not rewrite S2 imports to v3 (#9846)
1 parent 4f2b248 commit 1bd82a0

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// @ts-ignore
2+
import {defineInlineTest} from 'jscodeshift/dist/testUtils';
3+
import transform from './codemod';
4+
5+
function test(name: string, input: string, output: string) {
6+
defineInlineTest(transform, {}, input, output, name);
7+
}
8+
9+
test(
10+
'rewrites individual react-aria imports',
11+
`
12+
import {useButton} from '@react-aria/button';
13+
`,
14+
`
15+
import { useButton } from "react-aria";
16+
`
17+
);
18+
19+
test(
20+
'rewrites individual react-stately imports',
21+
`
22+
import {useComboBoxState} from '@react-stately/combobox';
23+
`,
24+
`
25+
import { useComboBoxState } from "react-stately";
26+
`
27+
);
28+
29+
test(
30+
'rewrites individual react-spectrum imports',
31+
`
32+
import {Button} from '@react-spectrum/button';
33+
`,
34+
`
35+
import { Button } from "@adobe/react-spectrum";
36+
`
37+
);
38+
39+
test(
40+
'does not re-write S2 imports',
41+
`
42+
import {Button} from '@react-spectrum/s2';
43+
`,
44+
`
45+
import {Button} from '@react-spectrum/s2';
46+
`
47+
);

packages/dev/codemods/src/use-monopackages/src/codemod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const transformer: Transformer = function transformer(file: FileInfo, api: API,
111111
const individualPackageImports = root
112112
.find(j.ImportDeclaration)
113113
.filter((path) => {
114-
return (path.node.source.value as string)?.startsWith(
114+
return path.node.source.value !== '@react-spectrum/s2' && (path.node.source.value as string)?.startsWith(
115115
packages[pkg].individualPrefix
116116
);
117117
});

0 commit comments

Comments
 (0)