diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.md b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.md new file mode 100644 index 00000000..9e8f9957 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.md @@ -0,0 +1,18 @@ +### expandableSection-remove-isActive-prop [(#9881)](https://github.com/patternfly/patternfly-react/pull/9881) + +The `isActive` prop has been removed from ExpandableSection. + +#### Examples + +In: + +```jsx +%inputExample% +``` + +Out: + +```jsx +%outputExample% +``` + diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.test.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.test.ts new file mode 100644 index 00000000..4b46541a --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.test.ts @@ -0,0 +1,59 @@ +const ruleTester = require("../../ruletester"); +import * as rule from "./expandableSection-remove-isActive-prop"; + +ruleTester.run("expandableSection-remove-isActive-prop", rule, { + valid: [ + { + code: ``, + }, + { + code: `import { ExpandableSection } from '@patternfly/react-core'; `, + }, + ], + invalid: [ + // importing from react-core + { + code: `import { ExpandableSection } from '@patternfly/react-core'; `, + output: `import { ExpandableSection } from '@patternfly/react-core'; `, + errors: [ + { + message: `The \`isActive\` prop has been removed from ExpandableSection.`, + type: "JSXOpeningElement", + }, + ], + }, + // importing from dist/dynamic + { + code: `import { ExpandableSection } from '@patternfly/react-core/dist/dynamic/components/ExpandableSection'; `, + output: `import { ExpandableSection } from '@patternfly/react-core/dist/dynamic/components/ExpandableSection'; `, + errors: [ + { + message: `The \`isActive\` prop has been removed from ExpandableSection.`, + type: "JSXOpeningElement", + }, + ], + }, + // importing from dist/esm + { + code: `import { ExpandableSection } from '@patternfly/react-core/dist/esm/components/ExpandableSection'; `, + output: `import { ExpandableSection } from '@patternfly/react-core/dist/esm/components/ExpandableSection'; `, + errors: [ + { + message: `The \`isActive\` prop has been removed from ExpandableSection.`, + type: "JSXOpeningElement", + }, + ], + }, + // importing from dist/js + { + code: `import { ExpandableSection } from '@patternfly/react-core/dist/js/components/ExpandableSection'; `, + output: `import { ExpandableSection } from '@patternfly/react-core/dist/js/components/ExpandableSection'; `, + errors: [ + { + message: `The \`isActive\` prop has been removed from ExpandableSection.`, + type: "JSXOpeningElement", + }, + ], + }, + ], +}); diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.ts b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.ts new file mode 100644 index 00000000..9ce0ead6 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.ts @@ -0,0 +1,14 @@ +import { renameProps } from "../../helpers"; + +// https://github.com/patternfly/patternfly-react/pull/9881 +module.exports = { + meta: { fixable: "code" }, + create: renameProps({ + ExpandableSection: { + isActive: { + newName: "", + message: "The `isActive` prop has been removed from ExpandableSection.", + }, + }, + }), +}; diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropInput.tsx b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropInput.tsx new file mode 100644 index 00000000..5d6a66c8 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropInput.tsx @@ -0,0 +1,3 @@ +import { ExpandableSection } from "@patternfly/react-core"; + +export const ExpandableSectionRemoveIsActivePropInput = () => \ No newline at end of file diff --git a/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropOutput.tsx b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropOutput.tsx new file mode 100644 index 00000000..d41c5a29 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropOutput.tsx @@ -0,0 +1,5 @@ +import { ExpandableSection } from "@patternfly/react-core"; + +export const ExpandableSectionRemoveIsActivePropInput = () => ( + +);