diff --git a/packages/eslint-plugin-pf-codemods/lib/rules/v5/table-warn-actionsColumn.js b/packages/eslint-plugin-pf-codemods/lib/rules/v5/table-warn-actionsColumn.js new file mode 100644 index 000000000..9a710c395 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/lib/rules/v5/table-warn-actionsColumn.js @@ -0,0 +1,21 @@ +// https://github.com/patternfly/patternfly-react/pull/8629 +module.exports = { + create: function (context) { + return { + ImportDeclaration(node) { + const TableImport = node.specifiers.find( + (specifier) => + (specifier.imported.name === "Table" || specifier.imported.name === "TableComposable") && + node.source.value === "@patternfly/react-table" + ); + + if (TableImport) { + context.report({ + node, + message: "The ActionsColumn now uses the Next version of Dropdown. The action toggle should now pass a MenuToggle rather than a DropdownToggle, and direction and position properties are now passed under the new popperProps property.", + }); + } + }, + }; + }, +}; diff --git a/packages/eslint-plugin-pf-codemods/test/rules/v5/table-warn-actionsColumn.js b/packages/eslint-plugin-pf-codemods/test/rules/v5/table-warn-actionsColumn.js new file mode 100644 index 000000000..fa53029a1 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/test/rules/v5/table-warn-actionsColumn.js @@ -0,0 +1,31 @@ +const ruleTester = require('../../ruletester'); +const rule = require('../../../lib/rules/v5/table-warn-actionsColumn'); + +ruleTester.run("table-warn-actionsColumn", rule, { + valid: [ + { + code: ``, + }, + { + code: ``, + } + ], + invalid: [ + { + code: `import { Table } from '@patternfly/react-table';`, + output: `import { Table } from '@patternfly/react-table';`, + errors: [{ + message: `The ActionsColumn now uses the Next version of Dropdown. The action toggle should now pass a MenuToggle rather than a DropdownToggle, and direction and position properties are now passed under the new popperProps property.`, + type: "ImportDeclaration", + }] + }, + { + code: `import { TableComposable } from '@patternfly/react-table';`, + output: `import { TableComposable } from '@patternfly/react-table';`, + errors: [{ + message: `The ActionsColumn now uses the Next version of Dropdown. The action toggle should now pass a MenuToggle rather than a DropdownToggle, and direction and position properties are now passed under the new popperProps property.`, + type: "ImportDeclaration", + }] + }, + ] +}); diff --git a/packages/pf-codemods/README.md b/packages/pf-codemods/README.md index 78a775f50..fe037029f 100644 --- a/packages/pf-codemods/README.md +++ b/packages/pf-codemods/README.md @@ -664,11 +664,14 @@ Out: ``` +### table-warn-actionsColumn [(#8629)](https://github.com/patternfly/patternfly-react/pull/8629) + +Table and TableComposable's `ActionsColumn` has been updated to use the newer 'next' version of Dropdown. The toggle passed to the actions column should now be a `MenuToggle` instead of a `DropdownToggle`. The `dropdownPosition`, `dropdownDirection` and `menuAppendTo` properties are removed and `Popper` properties can be passed in using `popperProps` instead (via `direction`, `position`, `appendTo`, etc.). + ### table-warn-thExpandType [(#8634)](https://github.com/patternfly/patternfly-react/pull/8634) `collapseAllAriaLabel` on `ThExpandType` has been updated to a `string` from `''`. Workarounds casting this property to an empty string are no longer required. - ### tableComposable-remove-hasSelectableRowCaption [(#8352)](https://github.com/patternfly/patternfly-react/pull/8352) We've removed the deprecated `hasSelectableRowCaption` prop.