From 1ac98192eb56bf46f2dbe86d4f52b337242a0697 Mon Sep 17 00:00:00 2001 From: YuanboXue-Amber Date: Tue, 23 Jan 2024 23:11:47 +0100 Subject: [PATCH 1/6] update test --- .../AvatarGroupPopover/AvatarGroupPopover.test.tsx | 3 +++ .../react-card/src/components/Card/Card.test.tsx | 3 +++ .../react-checkbox/src/components/Checkbox/Checkbox.test.tsx | 3 +++ .../react-combobox/src/components/Combobox/Combobox.test.tsx | 3 +++ .../react-combobox/src/components/Dropdown/Dropdown.test.tsx | 3 +++ .../react-combobox/src/components/Listbox/Listbox.test.tsx | 5 +++++ .../react-input/src/components/Input/Input.test.tsx | 3 +++ .../react-menu/src/components/MenuList/MenuList.test.tsx | 5 +++++ .../react-popover/src/components/Popover/Popover.test.tsx | 5 +++++ .../react-radio/src/components/Radio/Radio.test.tsx | 3 +++ .../src/components/RadioGroup/RadioGroup.test.tsx | 5 +++++ .../src/components/SearchBox/SearchBox.test.tsx | 3 +++ .../react-select/src/components/Select/Select.test.tsx | 5 +++++ .../react-slider/src/components/Slider/Slider.test.tsx | 5 +++++ .../src/components/SpinButton/SpinButton.test.tsx | 5 +++++ .../react-switch/src/components/Switch/Switch.test.tsx | 3 +++ .../react-table/src/components/DataGrid/DataGrid.test.tsx | 3 +++ .../react-tabs/src/components/TabList/TabList.test.tsx | 5 +++++ .../react-tags/src/components/TagGroup/TagGroup.test.tsx | 5 ----- .../react-textarea/src/components/Textarea/Textarea.test.tsx | 5 +++++ .../src/components/TimePicker/TimePicker.test.tsx | 3 +++ .../react-toolbar/src/components/Toolbar/Toolbar.test.tsx | 5 +++++ .../react-tooltip/src/components/Tooltip/Tooltip.test.tsx | 5 +++++ packages/react-conformance/src/defaultTests.tsx | 4 ++-- packages/react-conformance/src/types.ts | 2 +- .../react-focus/src/components/FocusZone/FocusZone.test.tsx | 3 --- 26 files changed, 91 insertions(+), 11 deletions(-) diff --git a/packages/react-components/react-avatar/src/components/AvatarGroupPopover/AvatarGroupPopover.test.tsx b/packages/react-components/react-avatar/src/components/AvatarGroupPopover/AvatarGroupPopover.test.tsx index ddec3ad5a3ca72..4c8f9d23ea7a88 100644 --- a/packages/react-components/react-avatar/src/components/AvatarGroupPopover/AvatarGroupPopover.test.tsx +++ b/packages/react-components/react-avatar/src/components/AvatarGroupPopover/AvatarGroupPopover.test.tsx @@ -47,6 +47,9 @@ describe('AvatarGroupPopover', () => { getPortalElement: getPopoverSurfaceElement, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onOpenChange'], + }, }, requiredProps: { children: ( diff --git a/packages/react-components/react-card/src/components/Card/Card.test.tsx b/packages/react-components/react-card/src/components/Card/Card.test.tsx index f229f0d0a136af..d839509184a018 100644 --- a/packages/react-components/react-card/src/components/Card/Card.test.tsx +++ b/packages/react-components/react-card/src/components/Card/Card.test.tsx @@ -30,6 +30,9 @@ describe('Card', () => { }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onSelectionChange'], + }, }, disabledTests: ['component-has-static-classname-exported'], }); diff --git a/packages/react-components/react-checkbox/src/components/Checkbox/Checkbox.test.tsx b/packages/react-components/react-checkbox/src/components/Checkbox/Checkbox.test.tsx index 7622960c2508b5..6b2cc0aae7b66e 100644 --- a/packages/react-components/react-checkbox/src/components/Checkbox/Checkbox.test.tsx +++ b/packages/react-components/react-checkbox/src/components/Checkbox/Checkbox.test.tsx @@ -23,6 +23,9 @@ describe('Checkbox', () => { props: { label: 'Test Label' }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, }, }); diff --git a/packages/react-components/react-combobox/src/components/Combobox/Combobox.test.tsx b/packages/react-components/react-combobox/src/components/Combobox/Combobox.test.tsx index 42b235a167397b..1c5b2fc79f1155 100644 --- a/packages/react-components/react-combobox/src/components/Combobox/Combobox.test.tsx +++ b/packages/react-components/react-combobox/src/components/Combobox/Combobox.test.tsx @@ -34,6 +34,9 @@ describe('Combobox', () => { }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onOpenChange', 'onOptionSelect'], + }, }, }); diff --git a/packages/react-components/react-combobox/src/components/Dropdown/Dropdown.test.tsx b/packages/react-components/react-combobox/src/components/Dropdown/Dropdown.test.tsx index 2f5ff10d48b2cb..9d1a962a3d7e43 100644 --- a/packages/react-components/react-combobox/src/components/Dropdown/Dropdown.test.tsx +++ b/packages/react-components/react-combobox/src/components/Dropdown/Dropdown.test.tsx @@ -34,6 +34,9 @@ describe('Dropdown', () => { }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onOpenChange', 'onOptionSelect'], + }, }, }); diff --git a/packages/react-components/react-combobox/src/components/Listbox/Listbox.test.tsx b/packages/react-components/react-combobox/src/components/Listbox/Listbox.test.tsx index 74dc329dc0e1a5..7860e49ce111a1 100644 --- a/packages/react-components/react-combobox/src/components/Listbox/Listbox.test.tsx +++ b/packages/react-components/react-combobox/src/components/Listbox/Listbox.test.tsx @@ -8,6 +8,11 @@ describe('Listbox', () => { isConformant({ Component: Listbox, displayName: 'Listbox', + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onOptionSelect'], + }, + }, }); it('renders a default state', () => { diff --git a/packages/react-components/react-input/src/components/Input/Input.test.tsx b/packages/react-components/react-input/src/components/Input/Input.test.tsx index 6a7490113e2970..380283446d5609 100644 --- a/packages/react-components/react-input/src/components/Input/Input.test.tsx +++ b/packages/react-components/react-input/src/components/Input/Input.test.tsx @@ -31,6 +31,9 @@ describe('Input', () => { }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, }, }); diff --git a/packages/react-components/react-menu/src/components/MenuList/MenuList.test.tsx b/packages/react-components/react-menu/src/components/MenuList/MenuList.test.tsx index f0042809ed799b..e93ab7834050cd 100644 --- a/packages/react-components/react-menu/src/components/MenuList/MenuList.test.tsx +++ b/packages/react-components/react-menu/src/components/MenuList/MenuList.test.tsx @@ -14,6 +14,11 @@ describe('MenuList', () => { // MenuTrigger does not have own styles 'make-styles-overrides-win', ], + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onCheckedValueChange'], + }, + }, }); /** diff --git a/packages/react-components/react-popover/src/components/Popover/Popover.test.tsx b/packages/react-components/react-popover/src/components/Popover/Popover.test.tsx index 680621a2dac2bf..7a5c20e00b5086 100644 --- a/packages/react-components/react-popover/src/components/Popover/Popover.test.tsx +++ b/packages/react-components/react-popover/src/components/Popover/Popover.test.tsx @@ -18,6 +18,11 @@ describe('Popover', () => { // Popover does not have own styles 'make-styles-overrides-win', ], + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onOpenChange'], + }, + }, }); /** diff --git a/packages/react-components/react-radio/src/components/Radio/Radio.test.tsx b/packages/react-components/react-radio/src/components/Radio/Radio.test.tsx index d98005e9cc299d..371184516bfc46 100644 --- a/packages/react-components/react-radio/src/components/Radio/Radio.test.tsx +++ b/packages/react-components/react-radio/src/components/Radio/Radio.test.tsx @@ -19,6 +19,9 @@ describe('Radio', () => { }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, }, }); diff --git a/packages/react-components/react-radio/src/components/RadioGroup/RadioGroup.test.tsx b/packages/react-components/react-radio/src/components/RadioGroup/RadioGroup.test.tsx index be6c43cd0186fd..4bde168c1f3aa4 100644 --- a/packages/react-components/react-radio/src/components/RadioGroup/RadioGroup.test.tsx +++ b/packages/react-components/react-radio/src/components/RadioGroup/RadioGroup.test.tsx @@ -10,6 +10,11 @@ describe('RadioGroup', () => { isConformant({ Component: RadioGroup, displayName: 'RadioGroup', + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, + }, }); it('renders a default state', () => { diff --git a/packages/react-components/react-search-preview/src/components/SearchBox/SearchBox.test.tsx b/packages/react-components/react-search-preview/src/components/SearchBox/SearchBox.test.tsx index bfa34201119d9f..f7f70b116c8a11 100644 --- a/packages/react-components/react-search-preview/src/components/SearchBox/SearchBox.test.tsx +++ b/packages/react-components/react-search-preview/src/components/SearchBox/SearchBox.test.tsx @@ -43,6 +43,9 @@ describe('SearchBox', () => { }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, }, }); diff --git a/packages/react-components/react-select/src/components/Select/Select.test.tsx b/packages/react-components/react-select/src/components/Select/Select.test.tsx index 340fa50200b106..9d87dcc1d1d48a 100644 --- a/packages/react-components/react-select/src/components/Select/Select.test.tsx +++ b/packages/react-components/react-select/src/components/Select/Select.test.tsx @@ -9,6 +9,11 @@ describe('Select', () => { Component: Select, displayName: 'Select', primarySlot: 'select', + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, + }, }); // Note for Select tests: avoid using getByRole; diff --git a/packages/react-components/react-slider/src/components/Slider/Slider.test.tsx b/packages/react-components/react-slider/src/components/Slider/Slider.test.tsx index 9b74ad031b3a7e..1fd9865719a06f 100644 --- a/packages/react-components/react-slider/src/components/Slider/Slider.test.tsx +++ b/packages/react-components/react-slider/src/components/Slider/Slider.test.tsx @@ -10,6 +10,11 @@ describe('Slider', () => { Component: Slider, displayName: 'Slider', primarySlot: 'input', + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, + }, }); afterEach(() => { diff --git a/packages/react-components/react-spinbutton/src/components/SpinButton/SpinButton.test.tsx b/packages/react-components/react-spinbutton/src/components/SpinButton/SpinButton.test.tsx index 958241a87a9b83..eac38bd4502cfb 100644 --- a/packages/react-components/react-spinbutton/src/components/SpinButton/SpinButton.test.tsx +++ b/packages/react-components/react-spinbutton/src/components/SpinButton/SpinButton.test.tsx @@ -15,6 +15,11 @@ describe('SpinButton', () => { Component: SpinButton, displayName: 'SpinButton', primarySlot: 'input', + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, + }, }); it('renders a default uncontrolled state', () => { diff --git a/packages/react-components/react-switch/src/components/Switch/Switch.test.tsx b/packages/react-components/react-switch/src/components/Switch/Switch.test.tsx index 7542185f7dcd50..f2a13c7f70af4c 100644 --- a/packages/react-components/react-switch/src/components/Switch/Switch.test.tsx +++ b/packages/react-components/react-switch/src/components/Switch/Switch.test.tsx @@ -19,6 +19,9 @@ describe('Switch', () => { }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, }, }); diff --git a/packages/react-components/react-table/src/components/DataGrid/DataGrid.test.tsx b/packages/react-components/react-table/src/components/DataGrid/DataGrid.test.tsx index c62522261bf30e..3e06055b48bfda 100644 --- a/packages/react-components/react-table/src/components/DataGrid/DataGrid.test.tsx +++ b/packages/react-components/react-table/src/components/DataGrid/DataGrid.test.tsx @@ -43,6 +43,9 @@ describe('DataGrid', () => { 'make-styles-overrides-win': { callCount: 2, }, + 'consistent-callback-args': { + legacyCallbacks: ['onSortChange', 'onSelectionChange', 'onColumnResize'], + }, }, // TODO: https://github.com/microsoft/fluentui/issues/19618 // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/react-components/react-tabs/src/components/TabList/TabList.test.tsx b/packages/react-components/react-tabs/src/components/TabList/TabList.test.tsx index fabfe96585e0cf..c29fb4b9d5c127 100644 --- a/packages/react-components/react-tabs/src/components/TabList/TabList.test.tsx +++ b/packages/react-components/react-tabs/src/components/TabList/TabList.test.tsx @@ -8,6 +8,11 @@ describe('TabList', () => { isConformant({ Component: TabList, displayName: 'TabList', + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onTabSelect'], + }, + }, }); it('renders with tabs', () => { diff --git a/packages/react-components/react-tags/src/components/TagGroup/TagGroup.test.tsx b/packages/react-components/react-tags/src/components/TagGroup/TagGroup.test.tsx index 8350c0135e570e..e10c37da9b7a06 100644 --- a/packages/react-components/react-tags/src/components/TagGroup/TagGroup.test.tsx +++ b/packages/react-components/react-tags/src/components/TagGroup/TagGroup.test.tsx @@ -8,11 +8,6 @@ describe('TagGroup', () => { isConformant({ Component: TagGroup, displayName: 'TagGroup', - testOptions: { - 'consistent-callback-args': { - ignoreProps: ['onDismiss'], // onDismiss uses generics, this test does not support that - }, - }, }); it('should invoke onDismiss when clicking on children Tag', () => { diff --git a/packages/react-components/react-textarea/src/components/Textarea/Textarea.test.tsx b/packages/react-components/react-textarea/src/components/Textarea/Textarea.test.tsx index 0e83f9b9f51d8f..222cd1e6d6d640 100644 --- a/packages/react-components/react-textarea/src/components/Textarea/Textarea.test.tsx +++ b/packages/react-components/react-textarea/src/components/Textarea/Textarea.test.tsx @@ -22,6 +22,11 @@ describe('Textarea', () => { Component: Textarea, displayName: 'Textarea', primarySlot: 'textarea', + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onChange'], + }, + }, }); // TODO create visual regression tests in /apps/vr-tests diff --git a/packages/react-components/react-timepicker-compat/src/components/TimePicker/TimePicker.test.tsx b/packages/react-components/react-timepicker-compat/src/components/TimePicker/TimePicker.test.tsx index 927bc8f5f69a4f..fb7b6a87cb5d09 100644 --- a/packages/react-components/react-timepicker-compat/src/components/TimePicker/TimePicker.test.tsx +++ b/packages/react-components/react-timepicker-compat/src/components/TimePicker/TimePicker.test.tsx @@ -36,6 +36,9 @@ describe('TimePicker', () => { }, }, ], + 'consistent-callback-args': { + legacyCallbacks: ['onOpenChange', 'onTimeChange'], + }, }, }); diff --git a/packages/react-components/react-toolbar/src/components/Toolbar/Toolbar.test.tsx b/packages/react-components/react-toolbar/src/components/Toolbar/Toolbar.test.tsx index 5987ed558f22d4..4644513758d9ab 100644 --- a/packages/react-components/react-toolbar/src/components/Toolbar/Toolbar.test.tsx +++ b/packages/react-components/react-toolbar/src/components/Toolbar/Toolbar.test.tsx @@ -7,6 +7,11 @@ describe('Toolbar', () => { isConformant({ Component: Toolbar, displayName: 'Toolbar', + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onCheckedValueChange'], + }, + }, }); // TODO add more tests here, and create visual regression tests in /apps/vr-tests diff --git a/packages/react-components/react-tooltip/src/components/Tooltip/Tooltip.test.tsx b/packages/react-components/react-tooltip/src/components/Tooltip/Tooltip.test.tsx index c619fb61be6ab7..024765a0623e49 100644 --- a/packages/react-components/react-tooltip/src/components/Tooltip/Tooltip.test.tsx +++ b/packages/react-components/react-tooltip/src/components/Tooltip/Tooltip.test.tsx @@ -39,6 +39,11 @@ describe('Tooltip', () => { 'component-has-root-ref', 'component-handles-classname', ], + testOptions: { + 'consistent-callback-args': { + legacyCallbacks: ['onVisibleChange'], + }, + }, }); afterEach(() => { diff --git a/packages/react-conformance/src/defaultTests.tsx b/packages/react-conformance/src/defaultTests.tsx index 1eb5d36d7013fb..2be92344a23cb4 100644 --- a/packages/react-conformance/src/defaultTests.tsx +++ b/packages/react-conformance/src/defaultTests.tsx @@ -450,10 +450,10 @@ export const defaultTests: DefaultTestObject = { const { testOptions = {} } = testInfo; const propNames = Object.keys(componentInfo.props); - const ignoreProps = testOptions['consistent-callback-args']?.ignoreProps || []; + const legacyCallbacks = testOptions['consistent-callback-args']?.legacyCallbacks || []; const invalidProps = propNames.reduce>((errors, propName) => { - if (!ignoreProps.includes(propName) && CALLBACK_REGEX.test(propName)) { + if (legacyCallbacks.includes(propName) && CALLBACK_REGEX.test(propName)) { const propInfo = componentInfo.props[propName]; if (!propInfo.declarations) { diff --git a/packages/react-conformance/src/types.ts b/packages/react-conformance/src/types.ts index 95ab76f99cd23a..7be4364ee27472 100644 --- a/packages/react-conformance/src/types.ts +++ b/packages/react-conformance/src/types.ts @@ -12,7 +12,7 @@ export interface TestOptions { ignoreProps?: string[]; }; 'consistent-callback-args'?: { - ignoreProps?: string[]; + legacyCallbacks?: string[]; }; 'has-static-classnames'?: { props: { diff --git a/packages/react-focus/src/components/FocusZone/FocusZone.test.tsx b/packages/react-focus/src/components/FocusZone/FocusZone.test.tsx index 89b91c313a8872..86e2675c0fc7bf 100644 --- a/packages/react-focus/src/components/FocusZone/FocusZone.test.tsx +++ b/packages/react-focus/src/components/FocusZone/FocusZone.test.tsx @@ -91,9 +91,6 @@ describe('FocusZone', () => { elementRefName: 'elementRef', testOptions: { 'consistent-callback-names': { ignoreProps: ['onActiveElementChanged'] }, - 'consistent-callback-args': { - ignoreProps: ['onActiveElementChanged', 'onBeforeFocus', 'onFocusNotification', 'onFocus'], - }, }, }); From 3bb793030315b013fcc67af5e5a40f82622123f1 Mon Sep 17 00:00:00 2001 From: YuanboXue-Amber Date: Wed, 24 Jan 2024 11:43:41 +0100 Subject: [PATCH 2/6] api + changelog --- ...t-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json | 7 +++++++ packages/react-conformance/etc/react-conformance.api.md | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 change/@fluentui-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json diff --git a/change/@fluentui-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json b/change/@fluentui-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json new file mode 100644 index 00000000000000..6eec4d19e39ab9 --- /dev/null +++ b/change/@fluentui-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "BREAKING CHANGE: change `consistent-callback-args` test option", + "packageName": "@fluentui/react-conformance", + "email": "yuanboxue@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react-conformance/etc/react-conformance.api.md b/packages/react-conformance/etc/react-conformance.api.md index d4d2f8e30a3913..54f699334c6732 100644 --- a/packages/react-conformance/etc/react-conformance.api.md +++ b/packages/react-conformance/etc/react-conformance.api.md @@ -56,7 +56,7 @@ export interface TestOptions { }; // (undocumented) 'consistent-callback-args'?: { - ignoreProps?: string[]; + legacyCallbacks?: string[]; }; // (undocumented) 'consistent-callback-names'?: { From a5e58d30534eab60cec8c87359550ff720cf8da1 Mon Sep 17 00:00:00 2001 From: YuanboXue-Amber Date: Wed, 24 Jan 2024 11:44:17 +0100 Subject: [PATCH 3/6] changelog --- ...-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change/@fluentui-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json b/change/@fluentui-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json index 6eec4d19e39ab9..6abf6db1c4db74 100644 --- a/change/@fluentui-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json +++ b/change/@fluentui-react-conformance-49d283fb-c0d3-4de1-9478-33cb86abe5ca.json @@ -1,6 +1,6 @@ { "type": "minor", - "comment": "BREAKING CHANGE: change `consistent-callback-args` test option", + "comment": "BREAKING CHANGE: change `consistent-callback-args` test option to test selected props instead of ignoring props", "packageName": "@fluentui/react-conformance", "email": "yuanboxue@microsoft.com", "dependentChangeType": "patch" From 8d049549d06fc4c815149f0ea992865937736cf5 Mon Sep 17 00:00:00 2001 From: YuanboXue-Amber Date: Wed, 24 Jan 2024 13:02:30 +0100 Subject: [PATCH 4/6] fix test --- .../src/components/List/List/List.test.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/packages/react-components/react-migration-v0-v9/src/components/List/List/List.test.tsx b/packages/react-components/react-migration-v0-v9/src/components/List/List/List.test.tsx index 12b7b83f095946..51b18e80259b42 100644 --- a/packages/react-components/react-migration-v0-v9/src/components/List/List/List.test.tsx +++ b/packages/react-components/react-migration-v0-v9/src/components/List/List/List.test.tsx @@ -12,12 +12,6 @@ describe('List', () => { // Disabled because this should be ItemLayout's responsibility, but it doesn't render those. // Adding them there now might not be safe. disabledTests: ['component-has-static-classnames-object', 'has-docblock', 'has-top-level-file'], - testOptions: { - 'consistent-callback-args': { - // onSelectionChange has an eventArgument which is React.SyntheticEvent. This throws an error during testing - ignoreProps: ['onSelectionChange'], - }, - }, }); // TODO add more tests here, and create visual regression tests in /apps/vr-tests From 4a376c6e36bfc09f1449536a293abe2ebb6dfa4e Mon Sep 17 00:00:00 2001 From: Amber Date: Thu, 25 Jan 2024 11:43:55 +0100 Subject: [PATCH 5/6] Update packages/react-conformance/src/defaultTests.tsx Co-authored-by: Ben Howell <48106640+behowell@users.noreply.github.com> --- packages/react-conformance/src/defaultTests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-conformance/src/defaultTests.tsx b/packages/react-conformance/src/defaultTests.tsx index 2be92344a23cb4..e39ac54b3d9d39 100644 --- a/packages/react-conformance/src/defaultTests.tsx +++ b/packages/react-conformance/src/defaultTests.tsx @@ -453,7 +453,7 @@ export const defaultTests: DefaultTestObject = { const legacyCallbacks = testOptions['consistent-callback-args']?.legacyCallbacks || []; const invalidProps = propNames.reduce>((errors, propName) => { - if (legacyCallbacks.includes(propName) && CALLBACK_REGEX.test(propName)) { + if (legacyCallbacks.includes(propName)) { const propInfo = componentInfo.props[propName]; if (!propInfo.declarations) { From f38659a3e5da1213cdd0eea584d5dc6081915699 Mon Sep 17 00:00:00 2001 From: YuanboXue-Amber Date: Thu, 25 Jan 2024 11:50:42 +0100 Subject: [PATCH 6/6] add error for invalid option --- packages/react-conformance/src/defaultTests.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/react-conformance/src/defaultTests.tsx b/packages/react-conformance/src/defaultTests.tsx index e39ac54b3d9d39..3d1d540aecc3ec 100644 --- a/packages/react-conformance/src/defaultTests.tsx +++ b/packages/react-conformance/src/defaultTests.tsx @@ -452,6 +452,17 @@ export const defaultTests: DefaultTestObject = { const propNames = Object.keys(componentInfo.props); const legacyCallbacks = testOptions['consistent-callback-args']?.legacyCallbacks || []; + // verify that legacyCallbacks option contains real props: + const legacyCallbacksNotInProp = legacyCallbacks.filter(legacyCallback => !propNames.includes(legacyCallback)); + if (legacyCallbacksNotInProp.length) { + throw new Error( + [ + `Option "consistent-callback-args.legacyCallbacks" contains "${legacyCallbacksNotInProp.join(', ')}" prop,`, + 'which is not present in component props.', + ].join(' '), + ); + } + const invalidProps = propNames.reduce>((errors, propName) => { if (legacyCallbacks.includes(propName)) { const propInfo = componentInfo.props[propName];