Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/eslint-plugin-pf-codemods/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// if you want your rule to only run when explicitly called for using the --only flag, add the rule name to the below array
const betaRuleNames = ["fileUploadField-cb-param-updates"];
const betaRuleNames = ["expandableSection-onToggle-event-added", "fileUploadField-cb-param-updates"];

const createListOfRules = (version, includeBeta = false) => {
const rules = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { addCallbackParam } = require("../../helpers");

// https://github.com/patternfly/patternfly-react/pull/8880
module.exports = {
meta: { fixable: "code" },
create: addCallbackParam(["ExpandableSection"], { onToggle: "_event" }),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { addCallbackParamTester } = require("../../testHelpers");

addCallbackParamTester('expandableSection-onToggle-event-added', 'ExpandableSection', 'onToggle')


29 changes: 29 additions & 0 deletions packages/pf-codemods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,35 @@ Out:
<ExpandableSection displaySize="lg" />
```

### expandableSection-onToggle-event-added [(#8880)](https://github.com/patternfly/patternfly-react/pull/8880)

**Not yet included in pf-react**

We've updated the `onToggle` prop for ExpandableSection so that the `event` parameter is the first parameter. Handlers may require an update.

#### Examples

In:

```jsx
<ExpandableSection onToggle={(id) => handler(id)} />
const handler1 = (id) => {};
<ExpandableSection onToggle={handler1} />
function handler2(id) {};
<ExpandableSection onToggle={handler2} />
```

Out:

```jsx
<ExpandableSection onToggle={(_event, id) => handler(id)} />
const handler1 = (_event, id) => {};
<ExpandableSection onToggle={handler1} />
function handler2(_event, id) {};
<ExpandableSection onToggle={handler2} />
```


### fileUpload-remove-onChange [(#8155)](https://github.com/patternfly/patternfly-react/pull/8155)

We've removed the deprecated `onChange` prop. This rule will remove the prop from the FileUpload component and suggest replacing it with the `onFileInputChange`, `onTextChange`, `onDataChange`, and `onClearClick` props as needed.
Expand Down
2 changes: 2 additions & 0 deletions test/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
EmptyStatePrimary as ESP,
EmptyStateSecondaryActions,
EmptyStateVariant,
ExpandableSection,
FileUpload,
FileUploadField,
KebabToggle,
Expand Down Expand Up @@ -126,6 +127,7 @@ const myVariant = EmptyStateVariant.small;
</EmptyState>
<EmptyStateIcon />
<EmptyStateIcon component={Spinner} variant="container"/>
<ExpandableSection onToggle={foo => handler(foo)} />
<FileUploadField onTextChange={bar => textHandler(bar)} />
<KebabToggle onToggle={} />
<Label />
Expand Down