-
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(InvalidObject): rename props (#714)
* docs: fix multi-content-card rule description PR link * feat(CG - InvalidObject): rename props
- Loading branch information
1 parent
0b39206
commit 7ca12d9
Showing
5 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...ntGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.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,18 @@ | ||
### component-groups-invalidObject-rename-props [(react-component-groups/#145)](https://github.com/patternfly/react-component-groups/pull/145) | ||
|
||
In react-component-groups, we've renamed InvalidObject's props `invalidObjectTitleText` to `titleText` and `invalidObjectBodyText` to `bodyText`. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` | ||
|
93 changes: 93 additions & 0 deletions
93
...mponentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.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,93 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./component-groups-invalidObject-rename-props"; | ||
|
||
const renameMap = { | ||
invalidObjectTitleText: "titleText", | ||
invalidObjectBodyText: "bodyText", | ||
}; | ||
|
||
const errors = Object.entries(renameMap).map(([oldName, newName]) => ({ | ||
message: `The ${oldName} prop for InvalidObject has been renamed to ${newName}.`, | ||
type: "JSXOpeningElement", | ||
})); | ||
|
||
ruleTester.run("component-groups-invalidObject-rename-props", rule, { | ||
valid: [ | ||
{ | ||
code: `<InvalidObject invalidObjectTitleText="" />`, | ||
}, | ||
{ | ||
code: `<InvalidObject invalidObjectBodyText="" />`, | ||
}, | ||
{ | ||
code: `import { InvalidObject } from '@patternfly/react-component-groups'; <InvalidObject someOtherProp />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { InvalidObject } from '@patternfly/react-component-groups'; | ||
<InvalidObject | ||
invalidObjectTitleText="Sample title text" | ||
invalidObjectBodyText="Sample body text" | ||
/>`, | ||
output: `import { InvalidObject } from '@patternfly/react-component-groups'; | ||
<InvalidObject | ||
titleText="Sample title text" | ||
bodyText="Sample body text" | ||
/>`, | ||
errors, | ||
}, | ||
{ | ||
code: `import InvalidObject from '@patternfly/react-component-groups/dist/cjs/InvalidObject/index'; | ||
<InvalidObject | ||
invalidObjectTitleText="Sample title text" | ||
invalidObjectBodyText="Sample body text" | ||
/>`, | ||
output: `import InvalidObject from '@patternfly/react-component-groups/dist/cjs/InvalidObject/index'; | ||
<InvalidObject | ||
titleText="Sample title text" | ||
bodyText="Sample body text" | ||
/>`, | ||
errors, | ||
}, | ||
{ | ||
code: `import InvalidObject from '@patternfly/react-component-groups/dist/esm/InvalidObject/index'; | ||
<InvalidObject | ||
invalidObjectTitleText="Sample title text" | ||
invalidObjectBodyText="Sample body text" | ||
/>`, | ||
output: `import InvalidObject from '@patternfly/react-component-groups/dist/esm/InvalidObject/index'; | ||
<InvalidObject | ||
titleText="Sample title text" | ||
bodyText="Sample body text" | ||
/>`, | ||
errors, | ||
}, | ||
{ | ||
code: `import InvalidObject from '@patternfly/react-component-groups/dist/dynamic/InvalidObject'; | ||
<InvalidObject | ||
invalidObjectTitleText="Sample title text" | ||
invalidObjectBodyText="Sample body text" | ||
/>`, | ||
output: `import InvalidObject from '@patternfly/react-component-groups/dist/dynamic/InvalidObject'; | ||
<InvalidObject | ||
titleText="Sample title text" | ||
bodyText="Sample body text" | ||
/>`, | ||
errors, | ||
}, | ||
{ | ||
code: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/InvalidObject'; | ||
<InvObj | ||
invalidObjectTitleText="Sample title text" | ||
invalidObjectBodyText="Sample body text" | ||
/>`, | ||
output: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/InvalidObject'; | ||
<InvObj | ||
titleText="Sample title text" | ||
bodyText="Sample body text" | ||
/>`, | ||
errors, | ||
}, | ||
], | ||
}); |
25 changes: 25 additions & 0 deletions
25
...v6/componentGroupsInvalidObjectRenameProps/component-groups-invalidObject-rename-props.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 @@ | ||
import { renameProps } from "../../helpers"; | ||
import { Renames } from "../../helpers/renameSinglePropOnNode"; | ||
|
||
// https://github.com/patternfly/react-component-groups/pull/145 | ||
|
||
const formatMessage = (oldPropName: string, newPropName: string) => | ||
`The ${oldPropName} prop for InvalidObject has been renamed to ${newPropName}.`; | ||
|
||
const renames: Renames = { | ||
InvalidObject: { | ||
invalidObjectTitleText: { | ||
newName: "titleText", | ||
message: formatMessage("invalidObjectTitleText", "titleText"), | ||
}, | ||
invalidObjectBodyText: { | ||
newName: "bodyText", | ||
message: formatMessage("invalidObjectBodyText", "bodyText"), | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: renameProps(renames, "@patternfly/react-component-groups"), | ||
}; |
8 changes: 8 additions & 0 deletions
8
.../componentGroupsInvalidObjectRenameProps/componentGroupsInvalidObjectRenamePropsInput.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,8 @@ | ||
import { InvalidObject } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsInvalidObjectRenamePropsInput = () => ( | ||
<InvalidObject | ||
invalidObjectTitleText="Sample title" | ||
invalidObjectBodyText="Sample description" | ||
/> | ||
); |
8 changes: 8 additions & 0 deletions
8
...componentGroupsInvalidObjectRenameProps/componentGroupsInvalidObjectRenamePropsOutput.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,8 @@ | ||
import { InvalidObject } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsInvalidObjectRenamePropsInput = () => ( | ||
<InvalidObject | ||
titleText="Sample title" | ||
bodyText="Sample description" | ||
/> | ||
); |