Skip to content

Commit 8877ea5

Browse files
fix(scripts): Fix bug in readme builder and update readme (#846)
1 parent 972cd63 commit 8877ea5

File tree

4 files changed

+136
-21
lines changed

4 files changed

+136
-21
lines changed

packages/pf-codemods/README.md

Lines changed: 132 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Hey PatternFly-React devs! `pf-codemods` is an eslint wrapper to update @patternfly/react-core@5.x.x code to 6.x.x.
44

55
We hope these rules and their autofixers will help you more quickly adopt our breaking changes. These rules are not designed to fix all build errors, but they can help to fix easy ones as well as point out the more complicated ones and offer suggestions on how you might go about fixing them.
6-
6+
77
If you have any hardcoded Patternfly class names in your project (i.e. pf-c-button) you also might want to see if our [class-name-updater package](./packages/class-name-updater/README.md) would be helpful for you.
88

99
## Usage
@@ -455,7 +455,7 @@ In:
455455
import { Chip } from '@patternfly/react-core/deprecated';
456456

457457
export const ChipReplaceWithLabelInput = () => (
458-
<Chip onClick={handleClick} badge={badge}>
458+
<Chip onClick={handleClick} badge={badge} numChips={3}>
459459
This is a chip
460460
</Chip>
461461
);
@@ -467,7 +467,7 @@ Out:
467467
import { Label } from '@patternfly/react-core';
468468

469469
export const ChipReplaceWithLabelInput = () => (
470-
<Label variant="outline" onClose={handleClick}>
470+
<Label variant="outline" onClose={handleClick} numLabels={3}>
471471
This is a chip
472472
{badge}
473473
</Label>
@@ -611,6 +611,31 @@ export const ComponentGroupsErrorStateRenamePropsInput = () => (
611611
```
612612

613613

614+
### component-groups-invalidObjectProps-rename-to-missingPageProps [(react-component-groups/#313)](https://github.com/patternfly/react-component-groups/pull/313)
615+
616+
In react-component-groups, we've renamed InvalidObjectProps interface to MissingPageProps
617+
618+
#### Examples
619+
620+
In:
621+
622+
```jsx
623+
import { InvalidObjectProps } from "@patternfly/react-component-groups";
624+
625+
const props: InvalidObjectProps;
626+
interface CustomProps extends InvalidObjectProps {}
627+
```
628+
629+
Out:
630+
631+
```jsx
632+
import { MissingPageProps } from "@patternfly/react-component-groups";
633+
634+
const props: MissingPageProps;
635+
interface CustomProps extends MissingPageProps {}
636+
```
637+
638+
614639
### component-groups-invalidObject-rename-props [(react-component-groups/#145)](https://github.com/patternfly/react-component-groups/pull/145)
615640

616641
In react-component-groups, we've renamed InvalidObject's props `invalidObjectTitleText` to `titleText` and `invalidObjectBodyText` to `bodyText`.
@@ -1190,6 +1215,96 @@ Out:
11901215
import { EmptyStateHeader, EmptyStateIcon } from "@patternfly/react-core";
11911216
```
11921217

1218+
### enable-animations
1219+
1220+
This rule adds the `hasAnimations` prop to PatternFly components that support animations. This is an optional enhancement that enables smoother transitions and animations in your UI components.
1221+
1222+
**⚠️ Important:** Enabling animations may change the DOM structure of some components. This could affect CSS selectors, testing queries, or other code that relies on the specific DOM structure. Review your code after enabling animations to ensure compatibility.
1223+
1224+
The following components will have `hasAnimations` added:
1225+
- AlertGroup
1226+
- DualListSelector (only when `isTree` prop has a truthy value)
1227+
- FormFieldGroupExpandable
1228+
- SearchInputExpandable
1229+
- TreeView
1230+
- Table (from @patternfly/react-table)
1231+
1232+
**Note:** For DualListSelector, the `hasAnimations` prop will only be added when the `isTree` prop is present and has a truthy value (e.g., `isTree`, `isTree={true}`, `isTree="yes"`, `isTree={1}`). It will not be added when `isTree` is falsy (e.g., `isTree={false}`, `isTree=""`, `isTree={0}`) or when the `isTree` prop is not present at all.
1233+
1234+
This rule can only run using the `--only enable-animations` option.
1235+
1236+
#### Examples
1237+
1238+
In:
1239+
1240+
```jsx
1241+
import { AlertGroup, TreeView, DualListSelector, SearchInputExpandable, FormFieldGroupExpandable } from "@patternfly/react-core";
1242+
import { Table } from "@patternfly/react-table";
1243+
1244+
export const EnableAnimationsInput = () => (
1245+
<>
1246+
<AlertGroup isLiveRegion>
1247+
{/* alerts */}
1248+
</AlertGroup>
1249+
<TreeView />
1250+
<DualListSelector />
1251+
<DualListSelector isTree />
1252+
<DualListSelector isTree={true} />
1253+
<DualListSelector isTree={false} />
1254+
<SearchInputExpandable />
1255+
<FormFieldGroupExpandable />
1256+
<Table />
1257+
</>
1258+
);
1259+
```
1260+
1261+
Out:
1262+
1263+
```jsx
1264+
import { AlertGroup, TreeView, DualListSelector, SearchInputExpandable, FormFieldGroupExpandable } from "@patternfly/react-core";
1265+
import { Table } from "@patternfly/react-table";
1266+
1267+
export const EnableAnimationsOutput = () => (
1268+
<>
1269+
<AlertGroup hasAnimations isLiveRegion>
1270+
{/* alerts */}
1271+
</AlertGroup>
1272+
<TreeView hasAnimations />
1273+
<DualListSelector />
1274+
<DualListSelector isTree hasAnimations />
1275+
<DualListSelector isTree={true} hasAnimations />
1276+
<DualListSelector isTree={false} />
1277+
<SearchInputExpandable hasAnimations />
1278+
<FormFieldGroupExpandable hasAnimations />
1279+
<Table hasAnimations />
1280+
</>
1281+
);
1282+
```
1283+
### expandableSection-remove-isActive-prop [(#9881)](https://github.com/patternfly/patternfly-react/pull/9881)
1284+
1285+
The `isActive` prop has been removed from ExpandableSection.
1286+
1287+
#### Examples
1288+
1289+
In:
1290+
1291+
```jsx
1292+
import { ExpandableSection } from "@patternfly/react-core";
1293+
1294+
export const ExpandableSectionRemoveIsActivePropInput = () => <ExpandableSection isActive />
1295+
```
1296+
1297+
Out:
1298+
1299+
```jsx
1300+
import { ExpandableSection } from "@patternfly/react-core";
1301+
1302+
export const ExpandableSectionRemoveIsActivePropInput = () => (
1303+
<ExpandableSection />
1304+
);
1305+
```
1306+
1307+
11931308
### formFiledGroupHeaderTitleTextObject-renamed [(#10016)](https://github.com/patternfly/patternfly-react/pull/10016)
11941309

11951310
There was a typo in FormFiledGroupHeaderTitleTextObject interface. It was renamed to the intended FormFieldGroupHeaderTitleTextObject.
@@ -1352,6 +1467,10 @@ export const LabelRemoveIsOverflowLabelInput2 = () => (
13521467
);
13531468
```
13541469

1470+
### logViewer-moved-styles [(#70)](https://github.com/patternfly/react-log-viewer/pull/70)
1471+
1472+
The stylesheet for LogViewer has been moved out of the PatternFly package and into LogViewer itself. You may need to update stylesheet imports or import the stylesheet manually.
1473+
13551474
### loginMainFooterLinksItem-structure-updated [(#10107)](https://github.com/patternfly/patternfly-react/pull/10107)
13561475

13571476
LoginMainFooterLinksItem structure has changed. Instead of passing it many properties, everything is now passed in a children component directly.
@@ -1396,10 +1515,6 @@ export const LoginMainFooterLinksItemStructureUpdatedInput = () => (
13961515

13971516
The markup for LoginMainHeader - which is used internally within LoginPage - has been updated, now using a `div` wrapper instead of a `header` element wrapper.
13981517

1399-
### logViewer-moved-styles [(#70)](https://github.com/patternfly/react-log-viewer/pull/70)
1400-
1401-
The stylesheet for LogViewer has been moved out of the PatternFly package and into LogViewer itself. You may need to update stylesheet imports or import the stylesheet manually.
1402-
14031518
### masthead-name-changes [(#10809)](https://github.com/patternfly/patternfly-react/pull/10809)
14041519

14051520
Our old implementation of `MastheadBrand` has been renamed to `MastheadLogo`, which must be wrapped by our new implementation of `MastheadBrand`."
@@ -1618,15 +1733,13 @@ Our previous implementation of Modal has been deprecated. This rule will update
16181733
In:
16191734

16201735
```jsx
1621-
import { Modal } from "@patternfly/react-core";
1736+
import { Modal, ModalProps } from "@patternfly/react-core";
16221737
```
16231738

16241739
Out:
16251740

16261741
```jsx
1627-
import {
1628-
Modal
1629-
} from '@patternfly/react-core/deprecated';
1742+
import { Modal, ModalProps } from "@patternfly/react-core/deprecated";
16301743
```
16311744

16321745
### modalNext-promoted [(#10358)](https://github.com/patternfly/patternfly-react/pull/10358)
@@ -1752,14 +1865,6 @@ export const NoDuplicateImportSpecifiersInput = () => (
17521865
);
17531866
```
17541867

1755-
### notificationBadge-warn-markup-change [(#10020)](https://github.com/patternfly/patternfly-react/pull/10020)
1756-
1757-
The markup for NotificationBadge has changed, as it now uses stateful button internally.
1758-
1759-
### notificationDrawerHeader-warn-update-markup [(#10378)](https://github.com/patternfly/patternfly-react/pull/10378)
1760-
1761-
NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native `h1` element.
1762-
17631868
### no-unused-imports-v6
17641869

17651870
PatternFly imports that are unused imports should be removed.
@@ -1783,6 +1888,14 @@ export const NoUnusedImportsInput = () => <Bar />;
17831888
```
17841889

17851890

1891+
### notificationBadge-warn-markup-change [(#10020)](https://github.com/patternfly/patternfly-react/pull/10020)
1892+
1893+
The markup for NotificationBadge has changed, as it now uses stateful button internally.
1894+
1895+
### notificationDrawerHeader-warn-update-markup [(#10378)](https://github.com/patternfly/patternfly-react/pull/10378)
1896+
1897+
NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native `h1` element.
1898+
17861899
### pageBreadcrumbAndSection-warn-updated-wrapperLogic [(#10650)](https://github.com/patternfly/patternfly-react/pull/10650)
17871900

17881901
The `isWidthLimited` prop on PageBreadcrumb and PageSection will no longer determine whether the children of either component are wrapped in a PageBody. Instead the new `hasBodyWrapper` prop must be used. By default this new prop is set to true. Running the fix for this rule will apply `hasBodyWrapper` with the same value as the `isWidthLimited` prop or false if `isWidthLimited` is not passed.

packages/pf-codemods/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@typescript-eslint/parser": "^7.3.1",
2020
"commander": "^5.1.0",
2121
"eslint": "^7.3.0 || ^8.56.0",
22+
"glob": "^11.0.0",
2223
"inquirer": "^12.3.2",
2324
"typescript": "^5.4.2"
2425
}

packages/pf-codemods/scripts/buildReadme.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import glob from "glob";
1+
import { sync } from "glob";
22
import { join } from "path";
33
import { readdir, readFile, writeFile } from "fs/promises";
44

@@ -9,7 +9,7 @@ const rulePath = require
99
const baseReadMePath = join(process.cwd(), "scripts", "baseReadMe.md");
1010
const baseReadMeContent = readFile(baseReadMePath, "utf-8");
1111

12-
const v6RuleDirs = glob.sync(join(rulePath, "*"));
12+
const v6RuleDirs = sync(join(rulePath, "*")).sort();
1313

1414
const builtReadMes = v6RuleDirs.map(async (ruleDir) => {
1515
const files = await readdir(ruleDir);

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ __metadata:
10121012
"@typescript-eslint/parser": "npm:^7.3.1"
10131013
commander: "npm:^5.1.0"
10141014
eslint: "npm:^7.3.0 || ^8.56.0"
1015+
glob: "npm:^11.0.0"
10151016
inquirer: "npm:^12.3.2"
10161017
typescript: "npm:^5.4.2"
10171018
bin:

0 commit comments

Comments
 (0)