From dc63a37cac6fa30f561ffbb2379d56f1c31d510a Mon Sep 17 00:00:00 2001 From: mfrances Date: Fri, 7 Feb 2025 13:51:24 -0500 Subject: [PATCH 1/2] feat(ExpandableSection): remove isActive prop --- .../expandableSection-remove-isActive-prop.md | 18 +++++++++++++ ...ndableSection-remove-isActive-prop.test.ts | 25 +++++++++++++++++++ .../expandableSection-remove-isActive-prop.ts | 14 +++++++++++ ...pandableSectionRemoveIsActivePropInput.tsx | 3 +++ ...andableSectionRemoveIsActivePropOutput.tsx | 5 ++++ 5 files changed, 65 insertions(+) create mode 100644 packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.md create mode 100644 packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.test.ts create mode 100644 packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.ts create mode 100644 packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropInput.tsx create mode 100644 packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropOutput.tsx 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..43e535a9 --- /dev/null +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSection-remove-isActive-prop.test.ts @@ -0,0 +1,25 @@ +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: [ + { + 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", + }, + ], + }, + ], +}); 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..ec9934c1 --- /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 = () => ( + +); From bbf8e8b7917a4e869f104f24caa1ade9a01aed0e Mon Sep 17 00:00:00 2001 From: mfrances Date: Tue, 11 Feb 2025 16:44:24 -0500 Subject: [PATCH 2/2] mimic output and test other imports --- ...ndableSection-remove-isActive-prop.test.ts | 34 +++++++++++++++++++ ...andableSectionRemoveIsActivePropOutput.tsx | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) 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 index 43e535a9..4b46541a 100644 --- 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 @@ -11,6 +11,7 @@ ruleTester.run("expandableSection-remove-isActive-prop", rule, { }, ], invalid: [ + // importing from react-core { code: `import { ExpandableSection } from '@patternfly/react-core'; `, output: `import { ExpandableSection } from '@patternfly/react-core'; `, @@ -21,5 +22,38 @@ ruleTester.run("expandableSection-remove-isActive-prop", rule, { }, ], }, + // 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/expandableSectionRemoveIsActivePropOutput.tsx b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropOutput.tsx index ec9934c1..d41c5a29 100644 --- a/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropOutput.tsx +++ b/packages/eslint-plugin-pf-codemods/src/rules/v6/expandableSectionRemoveIsActiveProp/expandableSectionRemoveIsActivePropOutput.tsx @@ -1,5 +1,5 @@ import { ExpandableSection } from "@patternfly/react-core"; export const ExpandableSectionRemoveIsActivePropInput = () => ( - + );