Skip to content

Commit 6fef8bb

Browse files
authored
Merge pull request #74 from primer/tylerjdev/adjust-direct-slot-children-rule
Add `MarkdownEditor.Footer` support in `direct-slot-children` rule
2 parents 5dce101 + c07df5c commit 6fef8bb

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

.changeset/soft-bees-explain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-primer-react': patch
3+
---
4+
5+
Adds support for `MarkdownEditor.Footer` in `direct-slot-children` rule

src/rules/__tests__/direct-slot-children.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ ruleTester.run('direct-slot-children', rule, {
2222
<ActionList.Item><ActionList.LeadingVisual> <Avatar src="https://github.com/mona.png" /></ActionList.LeadingVisual>mona<ActionList.Description>Monalisa Octocat</ActionList.Description></ActionList.Item>`,
2323
`import {ActionList} from '@primer/react';
2424
<ActionList.LinkItem><ActionList.LeadingVisual></ActionList.LeadingVisual>mona<ActionList.Description>Monalisa Octocat</ActionList.Description></ActionList.LinkItem>`,
25+
`import {MarkdownEditor} from '@primer/react'; <MarkdownEditor><MarkdownEditor.Footer><MarkdownEditor.Actions></MarkdownEditor.Actions></MarkdownEditor.Footer></MarkdownEditor>`,
26+
`import {MarkdownEditor} from '@primer/react'; <MarkdownEditor><MarkdownEditor.Footer><MarkdownEditor.FooterButton></MarkdownEditor.FooterButton></MarkdownEditor.Footer></MarkdownEditor>`,
2527
{code: `import {Foo} from './Foo'; <Foo><div><Foo.Bar></Foo.Bar></div></Foo>`, options: [{skipImportCheck: true}]}
2628
],
2729
invalid: [
@@ -97,6 +99,24 @@ ruleTester.run('direct-slot-children', rule, {
9799
data: {childName: 'ActionList.LeadingVisual', parentName: 'ActionList.Item or ActionList.LinkItem'}
98100
}
99101
]
102+
},
103+
{
104+
code: `import {MarkdownEditor} from '@primer/react'; <MarkdownEditor><div><MarkdownEditor.Actions></MarkdownEditor.Actions></div></MarkdownEditor>`,
105+
errors: [
106+
{
107+
messageId: 'directSlotChildren',
108+
data: {childName: 'MarkdownEditor.Actions', parentName: 'MarkdownEditor or MarkdownEditor.Footer'}
109+
}
110+
]
111+
},
112+
{
113+
code: `import {MarkdownEditor} from '@primer/react'; <MarkdownEditor><MarkdownEditor.FooterButton></MarkdownEditor.FooterButton></MarkdownEditor>`,
114+
errors: [
115+
{
116+
messageId: 'directSlotChildren',
117+
data: {childName: 'MarkdownEditor.FooterButton', parentName: 'MarkdownEditor.Footer'}
118+
}
119+
]
100120
}
101121
]
102122
})

src/rules/direct-slot-children.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const slotParentToChildMap = {
1212
'TreeView.Item': ['TreeView.LeadingVisual', 'TreeView.TrailingVisual'],
1313
RadioGroup: ['RadioGroup.Label', 'RadioGroup.Caption', 'RadioGroup.Validation'],
1414
CheckboxGroup: ['CheckboxGroup.Label', 'CheckboxGroup.Caption', 'CheckboxGroup.Validation'],
15-
MarkdownEditor: ['MarkdownEditor.Toolbar', 'MarkdownEditor.Actions', 'MarkdownEditor.Label']
15+
MarkdownEditor: ['MarkdownEditor.Toolbar', 'MarkdownEditor.Actions', 'MarkdownEditor.Label'],
16+
'MarkdownEditor.Footer': ['MarkdownEditor.Actions', 'MarkdownEditor.FooterButton']
1617
}
1718

1819
const slotChildToParentMap = Object.entries(slotParentToChildMap).reduce((acc, [parent, children]) => {

0 commit comments

Comments
 (0)