diff --git a/.changeset/soft-bees-explain.md b/.changeset/soft-bees-explain.md new file mode 100644 index 00000000..de011170 --- /dev/null +++ b/.changeset/soft-bees-explain.md @@ -0,0 +1,5 @@ +--- +'eslint-plugin-primer-react': patch +--- + +Adds support for `MarkdownEditor.Footer` in `direct-slot-children` rule diff --git a/src/rules/__tests__/direct-slot-children.test.js b/src/rules/__tests__/direct-slot-children.test.js index 80234ae7..aeb04f33 100644 --- a/src/rules/__tests__/direct-slot-children.test.js +++ b/src/rules/__tests__/direct-slot-children.test.js @@ -22,6 +22,8 @@ ruleTester.run('direct-slot-children', rule, { monaMonalisa Octocat`, `import {ActionList} from '@primer/react'; monaMonalisa Octocat`, + `import {MarkdownEditor} from '@primer/react'; `, + `import {MarkdownEditor} from '@primer/react'; `, {code: `import {Foo} from './Foo';
`, options: [{skipImportCheck: true}]} ], invalid: [ @@ -97,6 +99,24 @@ ruleTester.run('direct-slot-children', rule, { data: {childName: 'ActionList.LeadingVisual', parentName: 'ActionList.Item or ActionList.LinkItem'} } ] + }, + { + code: `import {MarkdownEditor} from '@primer/react';
`, + errors: [ + { + messageId: 'directSlotChildren', + data: {childName: 'MarkdownEditor.Actions', parentName: 'MarkdownEditor or MarkdownEditor.Footer'} + } + ] + }, + { + code: `import {MarkdownEditor} from '@primer/react'; `, + errors: [ + { + messageId: 'directSlotChildren', + data: {childName: 'MarkdownEditor.FooterButton', parentName: 'MarkdownEditor.Footer'} + } + ] } ] }) diff --git a/src/rules/direct-slot-children.js b/src/rules/direct-slot-children.js index 799152ea..e40dbc86 100644 --- a/src/rules/direct-slot-children.js +++ b/src/rules/direct-slot-children.js @@ -12,7 +12,8 @@ const slotParentToChildMap = { 'TreeView.Item': ['TreeView.LeadingVisual', 'TreeView.TrailingVisual'], RadioGroup: ['RadioGroup.Label', 'RadioGroup.Caption', 'RadioGroup.Validation'], CheckboxGroup: ['CheckboxGroup.Label', 'CheckboxGroup.Caption', 'CheckboxGroup.Validation'], - MarkdownEditor: ['MarkdownEditor.Toolbar', 'MarkdownEditor.Actions', 'MarkdownEditor.Label'] + MarkdownEditor: ['MarkdownEditor.Toolbar', 'MarkdownEditor.Actions', 'MarkdownEditor.Label'], + 'MarkdownEditor.Footer': ['MarkdownEditor.Actions', 'MarkdownEditor.FooterButton'] } const slotChildToParentMap = Object.entries(slotParentToChildMap).reduce((acc, [parent, children]) => {