diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.test.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.test.ts
index 85a01d4db..7697a4891 100644
--- a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.test.ts
+++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.test.ts
@@ -6,88 +6,99 @@ const renameMap = {
invalidObjectBodyText: "bodyText",
};
-const errors = Object.entries(renameMap).map(([oldName, newName]) => ({
- message: `The ${oldName} prop for InvalidObject has been renamed to ${newName}.`,
- type: "JSXOpeningElement",
-}));
+const getErrors = (component: string) =>
+ Object.entries(renameMap).map(([oldName, newName]) => ({
+ message: `The ${oldName} prop for ${component} has been renamed to ${newName}.`,
+ type: "JSXOpeningElement",
+ }));
-ruleTester.run("component-groups-invalidObject-rename-props", rule, {
- valid: [
+const components = ["InvalidObject", "MissingPage"];
+
+const valid = components
+ .map((component) => [
{
- code: ``,
+ code: `<${component} invalidObjectTitleText="" />`,
},
{
- code: ``,
+ code: `<${component} invalidObjectBodyText="" />`,
},
{
- code: `import { InvalidObject } from '@patternfly/react-component-groups'; `,
+ code: `import { ${component} } from '@patternfly/react-component-groups'; <${component} someOtherProp />`,
},
- ],
- invalid: [
+ ])
+ .flat();
+
+const invalid = components
+ .map((component) => [
{
- code: `import { InvalidObject } from '@patternfly/react-component-groups';
- `,
- output: `import { InvalidObject } from '@patternfly/react-component-groups';
- `,
- errors,
+ code: `import { ${component} } from '@patternfly/react-component-groups';
+ <${component}
+ invalidObjectTitleText="Sample title text"
+ invalidObjectBodyText="Sample body text"
+ />`,
+ output: `import { ${component} } from '@patternfly/react-component-groups';
+ <${component}
+ titleText="Sample title text"
+ bodyText="Sample body text"
+ />`,
+ errors: getErrors(component),
},
{
- code: `import InvalidObject from '@patternfly/react-component-groups/dist/cjs/InvalidObject/index';
- `,
- output: `import InvalidObject from '@patternfly/react-component-groups/dist/cjs/InvalidObject/index';
- `,
- errors,
+ code: `import ${component} from '@patternfly/react-component-groups/dist/cjs/${component}/index';
+ <${component}
+ invalidObjectTitleText="Sample title text"
+ invalidObjectBodyText="Sample body text"
+ />`,
+ output: `import ${component} from '@patternfly/react-component-groups/dist/cjs/${component}/index';
+ <${component}
+ titleText="Sample title text"
+ bodyText="Sample body text"
+ />`,
+ errors: getErrors(component),
},
{
- code: `import InvalidObject from '@patternfly/react-component-groups/dist/esm/InvalidObject/index';
- `,
- output: `import InvalidObject from '@patternfly/react-component-groups/dist/esm/InvalidObject/index';
- `,
- errors,
+ code: `import ${component} from '@patternfly/react-component-groups/dist/esm/${component}/index';
+ <${component}
+ invalidObjectTitleText="Sample title text"
+ invalidObjectBodyText="Sample body text"
+ />`,
+ output: `import ${component} from '@patternfly/react-component-groups/dist/esm/${component}/index';
+ <${component}
+ titleText="Sample title text"
+ bodyText="Sample body text"
+ />`,
+ errors: getErrors(component),
},
{
- code: `import InvalidObject from '@patternfly/react-component-groups/dist/dynamic/InvalidObject';
- `,
- output: `import InvalidObject from '@patternfly/react-component-groups/dist/dynamic/InvalidObject';
- `,
- errors,
+ code: `import ${component} from '@patternfly/react-component-groups/dist/dynamic/${component}';
+ <${component}
+ invalidObjectTitleText="Sample title text"
+ invalidObjectBodyText="Sample body text"
+ />`,
+ output: `import ${component} from '@patternfly/react-component-groups/dist/dynamic/${component}';
+ <${component}
+ titleText="Sample title text"
+ bodyText="Sample body text"
+ />`,
+ errors: getErrors(component),
},
{
- code: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/InvalidObject';
- `,
- output: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/InvalidObject';
- `,
- errors,
+ code: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/${component}';
+ `,
+ output: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/${component}';
+ `,
+ errors: getErrors(component),
},
- ],
+ ])
+ .flat();
+
+ruleTester.run("component-groups-invalidObject-rename-props", rule, {
+ valid,
+ invalid,
});
diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.ts
index 7c5946978..4d80af822 100644
--- a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.ts
+++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.ts
@@ -3,20 +3,27 @@ import { Renames } from "../../helpers/renameSinglePropOnNode";
// https://github.com/patternfly/react-component-groups/pull/145
-const formatMessage = (oldPropName: string, newPropName: string) =>
- `The ${oldPropName} prop for InvalidObject has been renamed to ${newPropName}.`;
+const formatMessage = (
+ component: string,
+ oldPropName: string,
+ newPropName: string
+) =>
+ `The ${oldPropName} prop for ${component} has been renamed to ${newPropName}.`;
-const renames: Renames = {
- InvalidObject: {
- invalidObjectTitleText: {
- newName: "titleText",
- message: formatMessage("invalidObjectTitleText", "titleText"),
- },
- invalidObjectBodyText: {
- newName: "bodyText",
- message: formatMessage("invalidObjectBodyText", "bodyText"),
- },
+const getPropsRenames = (component: string) => ({
+ invalidObjectTitleText: {
+ newName: "titleText",
+ message: formatMessage(component, "invalidObjectTitleText", "titleText"),
+ },
+ invalidObjectBodyText: {
+ newName: "bodyText",
+ message: formatMessage(component, "invalidObjectBodyText", "bodyText"),
},
+});
+
+const renames: Renames = {
+ InvalidObject: getPropsRenames("InvalidObject"),
+ MissingPage: getPropsRenames("MissingPage"),
};
module.exports = {
diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.md b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.md
new file mode 100644
index 000000000..7711eadea
--- /dev/null
+++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.md
@@ -0,0 +1,18 @@
+### component-groups-invalidObject-rename-to-missingPage [(react-component-groups/#313)](https://github.com/patternfly/react-component-groups/pull/313)
+
+In react-component-groups, we've renamed InvalidObject component to MissingPage
+
+#### Examples
+
+In:
+
+```jsx
+%inputExample%
+```
+
+Out:
+
+```jsx
+%outputExample%
+```
+
diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.test.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.test.ts
new file mode 100644
index 000000000..c3179d6fc
--- /dev/null
+++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.test.ts
@@ -0,0 +1,57 @@
+const ruleTester = require("../../ruletester");
+import * as rule from "./component-groups-invalidObject-rename-to-missingPage";
+
+const errors = [
+ {
+ message: `InvalidObject has been renamed to MissingPage.`,
+ type: "JSXOpeningElement",
+ },
+];
+
+ruleTester.run("component-groups-invalidObject-rename-to-missingPage", rule, {
+ valid: [
+ // missing import
+ {
+ code: ``,
+ },
+ // import from wrong package
+ {
+ code: `import { InvalidObject } from '@patternfly/react-core'; `,
+ },
+ ],
+ invalid: [
+ {
+ code: `import { InvalidObject } from '@patternfly/react-component-groups'; `,
+ output: `import { MissingPage } from '@patternfly/react-component-groups'; `,
+ errors,
+ },
+ // named import with alias
+ {
+ code: `import { InvalidObject as InvObj } from '@patternfly/react-component-groups'; `,
+ output: `import { MissingPage as InvObj } from '@patternfly/react-component-groups'; `,
+ errors,
+ },
+ // default imports
+ {
+ code: `import InvalidObject from '@patternfly/react-component-groups/dist/cjs/InvalidObject/index'; `,
+ output: `import MissingPage from '@patternfly/react-component-groups/dist/cjs/MissingPage/index'; `,
+ errors,
+ },
+ {
+ code: `import InvalidObject from '@patternfly/react-component-groups/dist/esm/InvalidObject/index'; `,
+ output: `import MissingPage from '@patternfly/react-component-groups/dist/esm/MissingPage/index'; `,
+ errors,
+ },
+ {
+ code: `import InvalidObject from '@patternfly/react-component-groups/dist/dynamic/InvalidObject'; `,
+ output: `import MissingPage from '@patternfly/react-component-groups/dist/dynamic/MissingPage'; `,
+ errors,
+ },
+ // default import with name not matching the component name
+ {
+ code: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/InvalidObject'; `,
+ output: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/MissingPage'; `,
+ errors,
+ },
+ ],
+});
diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.ts
new file mode 100644
index 000000000..0483ecf76
--- /dev/null
+++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.ts
@@ -0,0 +1,12 @@
+import { renameComponent } from "../../helpers/renameComponent";
+
+// https://github.com/patternfly/react-component-groups/pull/313
+module.exports = {
+ meta: { fixable: "code" },
+ create: renameComponent(
+ {
+ InvalidObject: "MissingPage",
+ },
+ "@patternfly/react-component-groups"
+ ),
+};
diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/componentGroupsInvalidObjectRenameToMissingPageInput.tsx b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/componentGroupsInvalidObjectRenameToMissingPageInput.tsx
new file mode 100644
index 000000000..7ffe08897
--- /dev/null
+++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/componentGroupsInvalidObjectRenameToMissingPageInput.tsx
@@ -0,0 +1,4 @@
+import { InvalidObject } from "@patternfly/react-component-groups";
+
+export const ComponentGroupsInvalidObjectRenameToMissingPageInput =
+ () => ;
diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/componentGroupsInvalidObjectRenameToMissingPageOutput.tsx b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/componentGroupsInvalidObjectRenameToMissingPageOutput.tsx
new file mode 100644
index 000000000..d4e150cf3
--- /dev/null
+++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/componentGroupsInvalidObjectRenameToMissingPage/componentGroupsInvalidObjectRenameToMissingPageOutput.tsx
@@ -0,0 +1,4 @@
+import { MissingPage } from "@patternfly/react-component-groups";
+
+export const ComponentGroupsInvalidObjectRenameToMissingPageInput =
+ () => ;