Skip to content

Commit

Permalink
Update polaris-no-bare-stack-item to use LegacyStack
Browse files Browse the repository at this point in the history
  • Loading branch information
laurkim committed Mar 9, 2023
1 parent 628417a commit e7e21bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
meta: {
docs: {
description:
'Disallow the use of Polaris’s `Stack.Item` without any custom props.',
'Disallow the use of Polaris’s `LegacyStack.Item` without any custom props.',
category: 'Best Practices',
recommended: true,
uri: docsUrl('polaris-no-bare-stack-item'),
Expand All @@ -17,13 +17,13 @@ module.exports = {
JSXElement(node) {
const component = polarisComponentFromJSX(node, context);
if (
component === 'Stack.Item' &&
component === 'LegacyStack.Item' &&
node.openingElement.attributes.length === 0
) {
context.report({
node,
message:
'You don’t need to wrap content in a Stack.Item unless you need to customize one of its props.',
'You don’t need to wrap content in a LegacyStack.Item unless you need to customize one of its props.',
});
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@ const errors = [
{
type: 'JSXElement',
message:
'You don’t need to wrap content in a Stack.Item unless you need to customize one of its props.',
'You don’t need to wrap content in a LegacyStack.Item unless you need to customize one of its props.',
},
];

ruleTester.run('polaris-no-bare-stack-item', rule, {
valid: [
{
code: `
import {Stack} from '@shopify/polaris';
<Stack>Content</Stack>;
import {LegacyStack} from '@shopify/polaris';
<LegacyStack>Content</LegacyStack>;
`,
filename: fixtureFile('polaris-app/index.js'),
parserOptions,
},
{
code: `
import {Stack} from '@shopify/polaris';
<Stack>Content<Stack.Item fill>More content</Stack.Item></Stack>;
import {LegacyStack} from '@shopify/polaris';
<LegacyStack>Content<LegacyStack.Item fill>More content</LegacyStack.Item></LegacyStack>;
`,
filename: fixtureFile('polaris-app/index.js'),
parserOptions,
},
{
code: `
import {Stack} from 'other-module';
<Stack><Stack.Item>Content</Stack.Item></Stack>;
import {LegacyStack} from 'other-module';
<LegacyStack><LegacyStack.Item>Content</LegacyStack.Item></LegacyStack>;
`,
filename: fixtureFile('polaris-app/index.js'),
parserOptions,
},
{
code: `
import {Stack} from '@shopify/polaris';
<Stack.Item fill>Content</Stack.Item>;
import {LegacyStack} from '@shopify/polaris';
<LegacyStack.Item fill>Content</LegacyStack.Item>;
`,
filename: fixtureFile('polaris-app/index.js'),
parserOptions,
Expand All @@ -56,17 +56,17 @@ ruleTester.run('polaris-no-bare-stack-item', rule, {
invalid: [
{
code: `
import {Stack} from '@shopify/polaris';
<Stack><Stack.Item>Content</Stack.Item></Stack>;
import {LegacyStack} from '@shopify/polaris';
<LegacyStack><LegacyStack.Item>Content</LegacyStack.Item></LegacyStack>;
`,
filename: fixtureFile('polaris-app/index.js'),
parserOptions,
errors,
},
{
code: `
import {Stack} from '@shopify/polaris';
<Stack.Item>Content</Stack.Item>;
import {LegacyStack} from '@shopify/polaris';
<LegacyStack.Item>Content</LegacyStack.Item>;
`,
filename: fixtureFile('polaris-app/index.js'),
parserOptions,
Expand All @@ -75,7 +75,7 @@ ruleTester.run('polaris-no-bare-stack-item', rule, {
{
code: `
import * as P from '@shopify/polaris';
<P.Stack.Item>Content</P.Stack.Item>;
<P.LegacyStack.Item>Content</P.LegacyStack.Item>;
`,
filename: fixtureFile('polaris-app/index.js'),
parserOptions,
Expand Down

0 comments on commit e7e21bc

Please sign in to comment.