Skip to content

Commit

Permalink
Codemod: don't affect Items in unimplemented collection components (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
reidbarber authored Aug 19, 2024
1 parent cfd890e commit 86eb91f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Does not affect unimplemented collections 1`] = `
"import {Accordion, Item, ActionBarContainer, ActionBar, ListView, ListBox} from '@adobe/react-spectrum';
import {SearchAutocomplete} from '@react-spectrum/autocomplete';
import {StepList} from '@react-spectrum/steplist';
<div>
<SearchAutocomplete>
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</SearchAutocomplete>
<Accordion>
<Item title="One" key="one">One</Item>
<Item title="Two" key="two">Two</Item>
<Item title="Three" key="three">Three</Item>
</Accordion>
<ActionBarContainer height={300} maxWidth="size-6000">
<ListView>
<Item key="photoshop">Adobe Photoshop</Item>
<Item key="illustrator">Adobe Illustrator</Item>
<Item key="xd">Adobe XD</Item>
</ListView>
<ActionBar>
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</ActionBar>
</ActionBarContainer>
<StepList>
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</StepList>
<ListBox>
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</ListBox>
</div>"
`;

exports[`Static - Renames Item to Breadcrumb and adds import 1`] = `
"import {
Breadcrumb,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,43 @@ import {Breadcrumbs, Item, Menu, MenuTrigger, SubmenuTrigger, Button, Section, H
</div>
`);

test('Does not affect unimplemented collections', `
import {Accordion, Item, ActionBarContainer, ActionBar, ListView, ListBox} from '@adobe/react-spectrum';
import {SearchAutocomplete} from '@react-spectrum/autocomplete';
import {StepList} from '@react-spectrum/steplist';
<div>
<SearchAutocomplete>
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</SearchAutocomplete>
<Accordion>
<Item title="One" key="one">One</Item>
<Item title="Two" key="two">Two</Item>
<Item title="Three" key="three">Three</Item>
</Accordion>
<ActionBarContainer height={300} maxWidth="size-6000">
<ListView>
<Item key="photoshop">Adobe Photoshop</Item>
<Item key="illustrator">Adobe Illustrator</Item>
<Item key="xd">Adobe XD</Item>
</ListView>
<ActionBar>
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</ActionBar>
</ActionBarContainer>
<StepList>
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</StepList>
<ListBox>
<Item key="one">One</Item>
<Item key="two">Two</Item>
<Item key="three">Three</Item>
</ListBox>
</div>
`);
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ function updateComponentWithinCollection(
function commentIfParentCollectionNotDetected(
path: NodePath<t.JSXElement>
) {
const collectionItemParents = new Set(['Menu', 'ActionMenu', 'TagGroup', 'Breadcrumbs', 'Picker', 'ComboBox', 'ListBox', 'TabList', 'TabPanels', 'ActionGroup', 'ListBox', 'ListView', 'Collection']);
const collectionItemParents = new Set(['Menu', 'ActionMenu', 'TagGroup', 'Breadcrumbs', 'Picker', 'ComboBox', 'ListBox', 'TabList', 'TabPanels', 'ActionGroup', 'ListBox', 'ListView', 'Collection', 'SearchAutocomplete', 'Accordion', 'ActionBar', 'StepList']);
if (
t.isJSXElement(path.node)
) {
Expand Down

0 comments on commit 86eb91f

Please sign in to comment.