-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FormGroup): rename labelIcon to labelHelp (#581)
* feat(FormGroup): rename labelIcon to labelHelp * prettier fix * docs(FormGroup): use actual classname instead of token * feat(FormGroup): add rule to Beta rules before React PR is merged
- Loading branch information
1 parent
c0e4dd1
commit 61f97d0
Showing
6 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...pf-codemods/src/rules/v6/formGroupRenameLabelIcon/formGroup-rename-labelIcon.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### formGroup-rename-labelIcon [(#10016)](https://github.com/patternfly/patternfly-react/pull/10016) | ||
|
||
The `labelIcon` prop for FormGroup has been renamed to `labelHelp`. We recommend using FormGroupLabelHelp element for the labelHelp prop. The markup has also changed, we now wrap the labelHelp element in `<span className="pf-v6-c-form__group-label-help">`, so there is no need to add `className="pf-v6-c-form__group-label-help"` to the labelHelp element. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
25 changes: 25 additions & 0 deletions
25
...ugin-pf-codemods/src/rules/v6/formGroupRenameLabelIcon/formGroup-rename-labelIcon.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./formGroup-rename-labelIcon"; | ||
|
||
ruleTester.run("formGroup-rename-labelIcon", rule, { | ||
valid: [ | ||
{ | ||
code: `<FormGroup labelIcon />`, | ||
}, | ||
{ | ||
code: `import { FormGroup } from '@patternfly/react-core'; <FormGroup someOtherProp />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { FormGroup } from '@patternfly/react-core'; <FormGroup labelIcon={<>Help icon</>} />`, | ||
output: `import { FormGroup } from '@patternfly/react-core'; <FormGroup labelHelp={<>Help icon</>} />`, | ||
errors: [ | ||
{ | ||
message: `The \`labelIcon\` prop for FormGroup has been renamed to \`labelHelp\`. We recommend using FormGroupLabelHelp element for the labelHelp prop. The markup has also changed, we now wrap the labelHelp element in \`<span className="pf-v6-c-form__group-label-help">\`, so there is no need to add \`className="pf-v6-c-form__group-label-help"\` to the labelHelp element.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
14 changes: 14 additions & 0 deletions
14
...nt-plugin-pf-codemods/src/rules/v6/formGroupRenameLabelIcon/formGroup-rename-labelIcon.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { renameProps } from "../../helpers"; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10016 | ||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: renameProps({ | ||
FormGroup: { | ||
labelIcon: { | ||
newName: "labelHelp", | ||
message: `The \`labelIcon\` prop for FormGroup has been renamed to \`labelHelp\`. We recommend using FormGroupLabelHelp element for the labelHelp prop. The markup has also changed, we now wrap the labelHelp element in \`<span className="pf-v6-c-form__group-label-help">\`, so there is no need to add \`className="pf-v6-c-form__group-label-help"\` to the labelHelp element.`, | ||
}, | ||
}, | ||
}), | ||
}; |
5 changes: 5 additions & 0 deletions
5
...lugin-pf-codemods/src/rules/v6/formGroupRenameLabelIcon/formGroupRenameLabelIconInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FormGroup } from "@patternfly/react-core"; | ||
|
||
export const FormGroupRenameLabelIconInput = () => ( | ||
<FormGroup labelIcon={<>Help icon</>} /> | ||
); |
5 changes: 5 additions & 0 deletions
5
...ugin-pf-codemods/src/rules/v6/formGroupRenameLabelIcon/formGroupRenameLabelIconOutput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { FormGroup } from "@patternfly/react-core"; | ||
|
||
export const FormGroupRenameLabelIconInput = () => ( | ||
<FormGroup labelHelp={<>Help icon</>} /> | ||
); |