Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FormGroup): rename labelIcon to labelHelp #581

Merged
merged 5 commits into from
Feb 28, 2024
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// if you want your rule to only run when explicitly called for using the --only flag, add the rule name to the below array
export const betaRuleNames: string[] = [
"checkbox-radio-replace-isLabelBeforeButton",
"formGroup-rename-labelIcon",
"menuItemAction-warn-update-markup",
"menuToggle-warn-iconOnly-toggle",
];
Expand Down
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%
```
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",
},
],
},
],
});
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.`,
},
},
}),
};
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</>} />
);
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</>} />
);
Loading