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(Checkbox/Radio): replace isLabelBeforeButton with labelPosition="start" #587

Merged
merged 2 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,5 +1,6 @@
// 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",
"menuItemAction-warn-update-markup",
"menuToggle-warn-iconOnly-toggle",
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### checkbox-radio-replace-isLabelBeforeButton [(#10016)](https://github.com/patternfly/patternfly-react/pull/10016)

The `isLabelBeforeButton` prop in Checkbox and Radio has been replaced with `labelPosition="start"`

#### Examples

In:

```jsx
%inputExample%
```

Out:

```jsx
%outputExample%
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const ruleTester = require("../../ruletester");
import * as rule from "./checkbox-radio-replace-isLabelBeforeButton";

ruleTester.run("checkbox-radio-replace-isLabelBeforeButton", rule, {
valid: [
{
code: `<Checkbox isLabelBeforeButton />`,
},
{
code: `import { Checkbox } from '@patternfly/react-core'; <Checkbox someOtherProp />`,
},
{
code: `<Radio isLabelBeforeButton />`,
},
{
code: `import { Radio } from '@patternfly/react-core'; <Radio someOtherProp />`,
},
],
invalid: ["Checkbox", "Radio"].map((component) => ({
code: `import { ${component} } from '@patternfly/react-core'; <${component} isLabelBeforeButton />`,
output: `import { ${component} } from '@patternfly/react-core'; <${component} labelPosition="start" />`,
errors: [
{
message: `isLabelBeforeButton prop for ${component} has been replaced with labelPosition="start"`,
type: "JSXOpeningElement",
},
],
})),
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { renameProps } from "../../helpers";

const renames = {
isLabelBeforeButton: {
newName: 'labelPosition="start"',
replace: true,
},
};

// https://github.com/patternfly/patternfly-react/pull/10016
module.exports = {
meta: { fixable: "code" },
create: renameProps({
Checkbox: renames,
Radio: renames,
}),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Checkbox, Radio } from "@patternfly/react-core";

export const CheckboxReplaceIsLabelBeforeButtonInput = () => (
<Checkbox isLabelBeforeButton />
);
export const RadioReplaceIsLabelBeforeButtonInput = () => (
<Radio isLabelBeforeButton />
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Checkbox, Radio } from "@patternfly/react-core";

export const CheckboxReplaceIsLabelBeforeButtonInput = () => (
<Checkbox labelPosition="start" />
);
export const RadioReplaceIsLabelBeforeButtonInput = () => (
<Radio labelPosition="start" />
);
Loading