Skip to content

Commit 10408d8

Browse files
authored
Enable direct-slot-children rule (#3063)
* Bump eslint-plugin-primer-react * Fix errors * Add eslint disable
1 parent 7e4f771 commit 10408d8

File tree

9 files changed

+25
-24
lines changed

9 files changed

+25
-24
lines changed

.eslintrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module.exports = {
9999
'import/no-namespace': 'off',
100100
'import/no-named-as-default': 'off',
101101
'import/no-named-as-default-member': 'off',
102+
'primer-react/direct-slot-children': ['error', {skipImportCheck: true}],
102103
'no-unused-vars': [
103104
'error',
104105
{
@@ -137,6 +138,7 @@ module.exports = {
137138
'import/no-deprecated': 'off',
138139
'import/no-named-as-default': 'off',
139140
'import/no-named-as-default-member': 'off',
141+
'primer-react/direct-slot-children': ['error', {skipImportCheck: true}],
140142
'no-restricted-imports': [
141143
'error',
142144
{

docs/components/ThemeReferenceTree.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@ const getLeadingVisual = property => {
2222
const propertyStr = property.toString()
2323
if (isColor(propertyStr)) {
2424
return (
25-
<TreeView.LeadingVisual>
26-
<Box
27-
bg={`${propertyStr}`}
28-
width={16}
29-
height={16}
30-
borderRadius={1}
31-
boxShadow="inset 0px 0px 0px 1px rgba(0,0,0,0.125)"
32-
/>
33-
</TreeView.LeadingVisual>
25+
<Box
26+
bg={`${propertyStr}`}
27+
width={16}
28+
height={16}
29+
borderRadius={1}
30+
boxShadow="inset 0px 0px 0px 1px rgba(0,0,0,0.125)"
31+
/>
3432
)
3533
} else {
3634
return null
@@ -55,7 +53,7 @@ function RecursiveTree({property, propertyName, isRootTreeItem = false}) {
5553
if (isLeafItem) {
5654
return (
5755
<TreeView.Item>
58-
{getLeadingVisual(property)}
56+
<TreeView.LeadingVisual>{getLeadingVisual(property)}</TreeView.LeadingVisual>
5957
<Text fontWeight="bold">{propertyName}</Text> : <Text>{property && property.toString()}</Text>
6058
</TreeView.Item>
6159
)

docs/src/@primer/gatsby-theme-doctocat/components/live-preview-wrapper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function ThemeSwitcher() {
1111
return (
1212
<ActionMenu>
1313
<ActionMenu.Button aria-label="Select field type">{selectedItem?.name}</ActionMenu.Button>
14+
{/* eslint-disable-next-line primer-react/no-system-props */}
1415
<ActionMenu.Overlay width="medium">
1516
<ActionList selectionVariant="single">
1617
{items.map((type, index) => (

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
"eslint-plugin-mdx": "2.0.5",
193193
"eslint-plugin-playwright": "0.12.0",
194194
"eslint-plugin-prettier": "4.2.1",
195-
"eslint-plugin-primer-react": "1.0.1",
195+
"eslint-plugin-primer-react": "2.0.2",
196196
"eslint-plugin-react": "7.32.2",
197197
"eslint-plugin-react-hooks": "4.6.0",
198198
"eslint-plugin-storybook": "0.6.11",

src/ActionList/ActionList.features.stories.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ export const ChildWithSideEffects = () => {
365365
return () => window.clearInterval(interval)
366366
}, [])
367367

368-
return <ActionList.Description>{seconds} seconds passed</ActionList.Description>
368+
return <>{seconds} seconds passed</>
369369
}
370370

371371
return (
@@ -375,7 +375,9 @@ export const ChildWithSideEffects = () => {
375375
<Avatar src={`https://avatars.githubusercontent.com/${user.login}`} />
376376
</ActionList.LeadingVisual>
377377
{user.login}
378-
<SideEffectDescription />
378+
<ActionList.Description>
379+
<SideEffectDescription />
380+
</ActionList.Description>
379381
</ActionList.Item>
380382
</ActionList>
381383
)

src/SplitPageLayout/SplitPageLayout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const Header: React.FC<React.PropsWithChildren<SplitPageLayoutHeaderProps
4141
divider = 'line',
4242
...props
4343
}) => {
44+
// eslint-disable-next-line primer-react/direct-slot-children
4445
return <PageLayout.Header padding={padding} divider={divider} {...props} />
4546
}
4647

@@ -87,6 +88,7 @@ export const Footer: React.FC<React.PropsWithChildren<SplitPageLayoutFooterProps
8788
divider = 'line',
8889
...props
8990
}) => {
91+
// eslint-disable-next-line primer-react/direct-slot-children
9092
return <PageLayout.Footer padding={padding} divider={divider} {...props} />
9193
}
9294

src/__tests__/CheckboxOrRadioGroup.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ describe('CheckboxOrRadioGroup', () => {
190190

191191
render(
192192
<CheckboxOrRadioGroup>
193-
<FormControl.Label>{INPUT_GROUP_LABEL}</FormControl.Label>
194193
<FormControl>
195194
<FormControl.Label>Choice one</FormControl.Label>
196195
<TextInput />

src/stories/Autocomplete.stories.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,6 @@ export const InOverlayWithCustomScrollContainerRef = (args: FormControlArgs<Auto
703703
side="inside-top"
704704
renderAnchor={props => <Button {...props}>open overlay</Button>}
705705
>
706-
<FormControl.Label htmlFor="autocompleteInput" id="autocompleteLabel" visuallyHidden>
707-
Pick tags
708-
</FormControl.Label>
709706
<Autocomplete>
710707
<Box display="flex" flexDirection="column" height="100%">
711708
<Box borderWidth={0} borderBottomWidth={1} borderColor="border.default" borderStyle="solid">

0 commit comments

Comments
 (0)