Skip to content

Commit 821d0f2

Browse files
authored
fix: add storybook demos to eslint config (#1958)
1 parent bbe1263 commit 821d0f2

File tree

41 files changed

+124
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+124
-103
lines changed

eslint.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,14 @@ export default [
5656
'no-console': 'off',
5757
'react/button-has-type': 'off'
5858
}
59+
},
60+
{
61+
files: ['packages/*/demo/**/*.{ts,tsx}'],
62+
ignores: ['packages/.template/**/*.{ts,tsx}'],
63+
...typescriptPlugin,
64+
rules: {
65+
...typescriptRules,
66+
'react/no-array-index-key': 'off'
67+
}
5968
}
6069
];

packages/accordions/demo/stories/AccordionStory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const AccordionStory: Story<IArgs> = ({ sections, ...args }: IArgs) => (
5454
<Accordion.Section key={index}>
5555
<Accordion.Header>
5656
<Accordion.Label>{section.headerLabel}</Accordion.Label>
57-
{args.hasIconButtons && <IconButtons isCompact={args.isCompact || false} />}
57+
{!!args.hasIconButtons && <IconButtons isCompact={args.isCompact || false} />}
5858
</Accordion.Header>
5959
<Accordion.Panel>{section.panel}</Accordion.Panel>
6060
</Accordion.Section>

packages/accordions/demo/stories/TimelineStory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const TimelineStory: StoryFn<IArgs> = ({ items, surfaceColor, ...args })
3636
icon={args.hasIcon ? <Icon /> : undefined}
3737
surfaceColor={surfaceColor}
3838
>
39-
{args.hasOppositeContent && (
39+
{!!args.hasOppositeContent && (
4040
<Timeline.OppositeContent>
4141
<Span hue="grey">{item.description}</Span>
4242
</Timeline.OppositeContent>

packages/avatars/demo/~patterns/stories/StatusMenuStory.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ export const StatusMenuStory: Story = ({ isCompact }) => {
2929
<Grid.Row style={{ height: 'calc(100vh - 80px)' }}>
3030
<Grid.Col textAlign="center" alignSelf="center">
3131
<Menu
32-
button={props => (
33-
<StyledIconButton {...props} aria-label="Select status">
34-
<Avatar status={selectedType} size={isCompact ? 'small' : 'medium'}>
35-
<img alt="Example User" src="images/avatars/chrome.png" />
36-
</Avatar>
37-
</StyledIconButton>
38-
)}
32+
button={
33+
/* eslint-disable-next-line react/no-unstable-nested-components */
34+
props => (
35+
<StyledIconButton {...props} aria-label="Select status">
36+
<Avatar status={selectedType} size={isCompact ? 'small' : 'medium'}>
37+
<img alt="Example User" src="images/avatars/chrome.png" />
38+
</Avatar>
39+
</StyledIconButton>
40+
)
41+
}
3942
onChange={onChange}
4043
isCompact={isCompact}
4144
>

packages/buttons/demo/stories/ButtonStory.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ export const ButtonStory: Story<IArgs> = ({
2626
...args
2727
}) => (
2828
<Button {...args}>
29-
{hasStartIcon && (
29+
{!!hasStartIcon && (
3030
<Button.StartIcon isRotated={isStartIconRotated}>
3131
<StartIcon />
3232
</Button.StartIcon>
3333
)}
3434
{args.children}
35-
{hasEndIcon && (
35+
{!!hasEndIcon && (
3636
<Button.EndIcon isRotated={isEndIconRotated}>
3737
<EndIcon />
3838
</Button.EndIcon>

packages/chrome/demo/stories/ChromeStory.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ export const ChromeStory: Story<IArgs> = ({
117117
return (
118118
<Chrome {...args} style={{ margin: `-${DEFAULT_THEME.space.xl}` }}>
119119
<SkipNav targetId="main-content">{skipNav}</SkipNav>
120-
{hasNav && (
120+
{!!hasNav && (
121121
<Nav isExpanded={isExpanded} aria-label="Nav">
122-
{hasLogo && (
122+
{!!hasLogo && (
123123
<Nav.Item hasLogo product={product}>
124124
<Nav.ItemIcon>{product ? PRODUCT_ICONS[product] : <ProductIcon />}</Nav.ItemIcon>
125125
<Nav.ItemText>Nav Logo</Nav.ItemText>
@@ -139,7 +139,7 @@ export const ChromeStory: Story<IArgs> = ({
139139
</Nav.Item>
140140
))}
141141
</Nav.List>
142-
{hasBrandmark && (
142+
{!!hasBrandmark && (
143143
<Nav.Item hasBrandmark>
144144
<Nav.ItemIcon>
145145
<BrandmarkIcon />
@@ -151,9 +151,9 @@ export const ChromeStory: Story<IArgs> = ({
151151
)}
152152

153153
<Body>
154-
{hasHeader && (
154+
{!!hasHeader && (
155155
<Header isStandalone={!hasNav}>
156-
{hasLogo && (
156+
{!!hasLogo && (
157157
<Header.Item hasLogo product={product}>
158158
<Header.ItemIcon>
159159
{product ? PRODUCT_ICONS[product] : <ProductIcon />}
@@ -169,7 +169,7 @@ export const ChromeStory: Story<IArgs> = ({
169169
maxY={item.maxY}
170170
isRound={item.isRound}
171171
>
172-
{item.hasIcon && (
172+
{!!item.hasIcon && (
173173
<Header.ItemIcon>
174174
{HEADER_ICONS[HEADER_ICONS.length - headerItems.length + index] || (
175175
<HeaderIcon />
@@ -180,7 +180,7 @@ export const ChromeStory: Story<IArgs> = ({
180180
</Header.ItemWrapper>
181181
) : (
182182
<Header.Item key={index} maxX={item.maxX} maxY={item.maxY} isRound={item.isRound}>
183-
{item.hasIcon && (
183+
{!!item.hasIcon && (
184184
<Header.ItemIcon>
185185
{HEADER_ICONS[HEADER_ICONS.length - headerItems.length + index] || (
186186
<HeaderIcon />
@@ -210,9 +210,9 @@ export const ChromeStory: Story<IArgs> = ({
210210
{...args}
211211
/>
212212
</Content>
213-
{hasFooter && (
213+
{!!hasFooter && (
214214
<Footer>
215-
{footerItems &&
215+
{!!footerItems &&
216216
footerItems.map(({ text, type }, index) => (
217217
<Footer.Item key={index}>
218218
<Button isBasic={type === 'basic'} isPrimary={type === 'primary'}>

packages/chrome/demo/stories/SheetStory.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ export const SheetComponent = ({
4545
...props
4646
}: ISheetComponentProps) => (
4747
<Sheet {...props}>
48-
{hasHeader && (
48+
{!!hasHeader && (
4949
<Sheet.Header>
50-
{hasTitle && <Sheet.Title>{title}</Sheet.Title>}
51-
{hasDescription && <Sheet.Description>{description}</Sheet.Description>}
50+
{!!hasTitle && <Sheet.Title>{title}</Sheet.Title>}
51+
{!!hasDescription && <Sheet.Description>{description}</Sheet.Description>}
5252
</Sheet.Header>
5353
)}
5454
{hasBody ? <Sheet.Body>{body}</Sheet.Body> : body}
55-
{hasFooter && (
55+
{!!hasFooter && (
5656
<Sheet.Footer isCompact={isCompact}>
57-
{footerItems &&
57+
{!!footerItems &&
5858
footerItems.map(({ text, type }, index) => (
5959
<Sheet.FooterItem key={index}>
6060
<Button
@@ -69,7 +69,7 @@ export const SheetComponent = ({
6969
))}
7070
</Sheet.Footer>
7171
)}
72-
{hasClose && <Sheet.Close onClick={onClick} />}
72+
{!!hasClose && <Sheet.Close onClick={onClick} />}
7373
</Sheet>
7474
);
7575

packages/datepickers/demo/stories/DatePickerStory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const DatePickerStory: Story<IArgs> = ({
4141
<DatePicker {...args} formatDate={formatDate} isCompact={isCompact}>
4242
<Input isCompact={isCompact} validation={validation} />
4343
</DatePicker>
44-
{hasMessage && (
44+
{!!hasMessage && (
4545
<Field.Message validation={validation} validationLabel={validationLabel}>
4646
{message}
4747
</Field.Message>

packages/draggable/demo/stories/DraggableStory.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface IArgs extends IDraggableProps {
1515

1616
export const DraggableStory: Story<IArgs> = ({ hasGrip, children, ...args }) => (
1717
<Draggable {...args}>
18-
{hasGrip && <Draggable.Grip />}
19-
{children && <Draggable.Content>{children}</Draggable.Content>}
18+
{!!hasGrip && <Draggable.Grip />}
19+
{!!children && <Draggable.Content>{children}</Draggable.Content>}
2020
</Draggable>
2121
);

packages/draggable/demo/stories/DropzoneStory.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ interface IArgs extends IDropzoneProps {
1717

1818
export const DropzoneStory: Story<IArgs> = ({ children, hasIcon, ...args }) => (
1919
<Dropzone {...args}>
20-
{hasIcon && (
20+
{!!hasIcon && (
2121
<Dropzone.Icon>
2222
<ReplaceIcon />
2323
</Dropzone.Icon>
2424
)}
25-
{children && <Dropzone.Message>{children}</Dropzone.Message>}
25+
{!!children && <Dropzone.Message>{children}</Dropzone.Message>}
2626
</Dropzone>
2727
);

0 commit comments

Comments
 (0)