diff --git a/packages/eslint-plugin-pf-codemods/lib/rules/v5/multipleFileUpload-add-event-param-to-callback.js b/packages/eslint-plugin-pf-codemods/lib/rules/v5/multipleFileUpload-add-event-param-to-callback.js new file mode 100644 index 000000000..f8744b177 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/lib/rules/v5/multipleFileUpload-add-event-param-to-callback.js @@ -0,0 +1,7 @@ +const { addCallbackParam } = require("../../helpers"); + +// https://github.com/patternfly/patternfly-react/pull/8995 +module.exports = { + meta: { fixable: "code" }, + create: addCallbackParam(["MultipleFileUpload"], { onFileDrop: "_event" }), +}; diff --git a/packages/eslint-plugin-pf-codemods/test/rules/v5/multipleFileUpload-add-event-param-to-callback.js b/packages/eslint-plugin-pf-codemods/test/rules/v5/multipleFileUpload-add-event-param-to-callback.js new file mode 100644 index 000000000..ddb4e8bf8 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/test/rules/v5/multipleFileUpload-add-event-param-to-callback.js @@ -0,0 +1,7 @@ +const { addCallbackParamTester } = require("../../testHelpers"); + +addCallbackParamTester( + "multipleFileUpload-add-event-param-to-callback", + "MultipleFileUpload", + "onFileDrop" +); diff --git a/packages/pf-codemods/README.md b/packages/pf-codemods/README.md index 95838e6ce..f891086d3 100644 --- a/packages/pf-codemods/README.md +++ b/packages/pf-codemods/README.md @@ -1401,6 +1401,32 @@ Out: We've update the `aria-label` prop on MenuItemAction, making it required instead of optional. +### multipleFileUpload-add-event-param-to-callback [(#8995)](https://github.com/patternfly/patternfly-react/pull/8995) + +We've updated the `onFileDrop` prop for MultipleFileUpload so that the `event` parameter is the first parameter. Handlers may require an update. + +#### Examples + +In: + +```jsx + handler(id)} /> +const handler1 = (id) => {}; + +function handler2(id) {}; + +``` + +Out: + +```jsx + handler(id)} /> +const handler1 = (_event, id) => {}; + +function handler2(_event, id) {}; + +``` + ### nav-warn-flyouts-now-inline [(#8628)](https://github.com/patternfly/patternfly-react/pull/8628) The placement Nav flyouts in the DOM has been changed, if you have Nav elements with flyouts you may need to update some selectors or snapshots in your test suites. This rule will raise a warning, but will not make any changes. diff --git a/test/test.tsx b/test/test.tsx index c70eb890a..0d3b93118 100644 --- a/test/test.tsx +++ b/test/test.tsx @@ -172,6 +172,7 @@ const alertVariantOption = AlertVariant.default; + handler(foo)} />