const ruleTester = require("../../ruletester"); import * as rule from "./emptyStateHeader-move-into-emptyState"; ruleTester.run("emptyStateHeader-move-into-emptyState", rule, { valid: [ { code: ``, }, { code: ``, }, { code: `} />`, }, { code: `import { EmptyState } from '@patternfly/react-core'; `, }, { // without an EmptyStateHeader or Title text code: `import { EmptyState } from "@patternfly/react-core"; Foo bar`, }, ], invalid: [ { // with all EmptyStateHeader props code: `import { EmptyState, EmptyStateHeader, EmptyStateIcon, CubesIcon } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( } titleClassName="custom-empty-state-title-class" titleText="Empty state" /> ); `, output: `import { EmptyState, EmptyStateHeader, EmptyStateIcon, CubesIcon } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props. Additionally, the EmptyStateIcon component now wraps content passed to the icon prop automatically.`, type: "JSXElement", }, ], }, { // without any optional EmptyStateHeader props code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props.`, type: "JSXElement", }, ], }, { // without any EmptyStateHeader props or children code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props.`, type: "JSXElement", }, ], }, { // without any EmptyStateHeader props but with children as text code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Foo bar ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props.`, type: "JSXElement", }, ], }, { // without any EmptyStateHeader props but with children as single JSXElement code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => (

Foo bar

); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Foo bar}> ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props.`, type: "JSXElement", }, ], }, { // without any EmptyStateHeader props but with children as single JSXExpressionContainer code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; const title = "Some title"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( {title} ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; const title = "Some title"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props.`, type: "JSXElement", }, ], }, { // without any EmptyStateHeader props but with children consisting of multiple elements code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; const title = "Some title"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( {title} followed by some text ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; const title = "Some title"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( {title} followed by some text }> ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props.`, type: "JSXElement", }, ], }, { // with both titleText and children code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Foo ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Foo ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props. Because the children for EmptyStateHeader are now inaccessible you must remove either the children or the titleText prop, then you can rerun this codemod.`, type: "JSXElement", }, ], }, { // with the color prop on the EmptyStateIcon code: `import { EmptyState, EmptyStateHeader, EmptyStateIcon, CubesIcon } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( } /> ); `, output: `import { EmptyState, EmptyStateHeader, EmptyStateIcon, CubesIcon } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `The color prop on EmptyStateIcon has been removed. We suggest using the new status prop on EmptyState to apply colors to the icon.`, type: "JSXElement", }, { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props. Additionally, the EmptyStateIcon component now wraps content passed to the icon prop automatically.`, type: "JSXElement", }, ], }, { // with a string expression for the heading className prop code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props.`, type: "JSXElement", }, ], }, { // with icon prop value not being wrapped in EmptyStateIcon (default import) code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon'; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( } titleText="Empty state" /> ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon'; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props. Additionally, the EmptyStateIcon component now wraps content passed to the icon prop automatically.`, type: "JSXElement", }, ], }, { // with icon prop value not being wrapped in EmptyStateIcon (classic import) code: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; import { CubesIcon } from '@patternfly/react-icons'; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( } titleText="Empty state" /> ); `, output: `import { EmptyState, EmptyStateHeader, } from "@patternfly/react-core"; import { CubesIcon } from '@patternfly/react-icons'; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props. Additionally, the EmptyStateIcon component now wraps content passed to the icon prop automatically.`, type: "JSXElement", }, ], }, { // with a Title child and no EmptyStateHeader code: `import { EmptyState, EmptyStateBody, Title } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Title text Body ); `, output: `import { EmptyState, EmptyStateBody, Title } from "@patternfly/react-core"; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Title text }> Body ); `, errors: [ { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props.`, type: "JSXElement", }, ], }, { // with Title and EmptyStateIcon children and no EmptyStateHeader code: `import { EmptyState, EmptyStateBody, EmptyStateIcon, Title } from "@patternfly/react-core"; import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon'; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Title text Body ); `, output: `import { EmptyState, EmptyStateBody, EmptyStateIcon, Title } from "@patternfly/react-core"; import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon'; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Title text } icon={CubesIcon}> Body ); `, errors: [ { message: `The color prop on EmptyStateIcon has been removed. We suggest using the new status prop on EmptyState to apply colors to the icon.`, type: "JSXElement", }, { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props. Additionally, the EmptyStateIcon component now wraps content passed to the icon prop automatically.`, type: "JSXElement", }, ], }, { // with EmptyStateHeader and EmptyStateIcon children code: `import { EmptyState, EmptyStateBody, EmptyStateHeader, EmptyStateIcon } from "@patternfly/react-core"; import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon'; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Foo Body ); `, output: `import { EmptyState, EmptyStateBody, EmptyStateHeader, EmptyStateIcon } from "@patternfly/react-core"; import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon'; export const EmptyStateHeaderMoveIntoEmptyStateInput = () => ( Body ); `, errors: [ { message: `The color prop on EmptyStateIcon has been removed. We suggest using the new status prop on EmptyState to apply colors to the icon.`, type: "JSXElement", }, { message: `EmptyStateHeader has been moved inside of the EmptyState component and is now only customizable using props. Additionally, the EmptyStateIcon component now wraps content passed to the icon prop automatically.`, type: "JSXElement", }, ], }, ], });