-
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(ErrorState componentGroup): rename props (#711)
- Loading branch information
1 parent
d8e33d8
commit 4f7a867
Showing
5 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
...componentGroupsErrorStateRenameProps/componentGroups-errorState-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 @@ | ||
### componentGroups-errorState-rename-props [(react-component-groups/#145)](https://github.com/patternfly/react-component-groups/pull/145) | ||
|
||
In react-component-groups, we've renamed some ErrorState props to comply with its base component - EmptyState. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` | ||
|
81 changes: 81 additions & 0 deletions
81
...s/v6/componentGroupsErrorStateRenameProps/componentGroups-errorState-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,81 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./componentGroups-errorState-rename-props"; | ||
|
||
const renameMap = { | ||
errorTitle: "titleText", | ||
errorDescription: "bodyText", | ||
defaultErrorDescription: "defaultBodyText", | ||
}; | ||
|
||
ruleTester.run("componentGroups-errorState-rename-props", rule, { | ||
valid: [ | ||
{ | ||
code: `<ErrorState errorTitle="" />`, | ||
}, | ||
{ | ||
code: `<ErrorState errorDescription="" />`, | ||
}, | ||
{ | ||
code: `<ErrorState defaultErrorDescription="" />`, | ||
}, | ||
{ | ||
code: `import { ErrorState } from '@patternfly/react-component-groups'; <ErrorState someOtherProp />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { ErrorState } from '@patternfly/react-component-groups'; | ||
<ErrorState | ||
errorTitle="Sample error title" | ||
errorDescription="Sample error description" | ||
defaultErrorDescription="Sample default error description" | ||
/>`, | ||
output: `import { ErrorState } from '@patternfly/react-component-groups'; | ||
<ErrorState | ||
titleText="Sample error title" | ||
bodyText="Sample error description" | ||
defaultBodyText="Sample default error description" | ||
/>`, | ||
errors: Object.entries(renameMap).map(([oldName, newName]) => ({ | ||
message: `The ${oldName} prop for ErrorState has been renamed to ${newName}.`, | ||
type: "JSXOpeningElement", | ||
})), | ||
}, | ||
{ | ||
code: `import ErrorState from '@patternfly/react-component-groups/dist/cjs/ErrorState/index'; | ||
<ErrorState errorTitle="Sample error title" />`, | ||
output: `import ErrorState from '@patternfly/react-component-groups/dist/cjs/ErrorState/index'; | ||
<ErrorState titleText="Sample error title" />`, | ||
errors: [ | ||
{ | ||
message: `The errorTitle prop for ErrorState has been renamed to titleText.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import ErrorState from '@patternfly/react-component-groups/dist/esm/ErrorState/index'; | ||
<ErrorState errorTitle="Sample error title" />`, | ||
output: `import ErrorState from '@patternfly/react-component-groups/dist/esm/ErrorState/index'; | ||
<ErrorState titleText="Sample error title" />`, | ||
errors: [ | ||
{ | ||
message: `The errorTitle prop for ErrorState has been renamed to titleText.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import ErrorState from '@patternfly/react-component-groups/dist/dynamic/ErrorState'; | ||
<ErrorState errorTitle="Sample error title" />`, | ||
output: `import ErrorState from '@patternfly/react-component-groups/dist/dynamic/ErrorState'; | ||
<ErrorState titleText="Sample error title" />`, | ||
errors: [ | ||
{ | ||
message: `The errorTitle prop for ErrorState has been renamed to titleText.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
29 changes: 29 additions & 0 deletions
29
.../rules/v6/componentGroupsErrorStateRenameProps/componentGroups-errorState-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,29 @@ | ||
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 ErrorState has been renamed to ${newPropName}.`; | ||
|
||
const renames: Renames = { | ||
ErrorState: { | ||
errorTitle: { | ||
newName: "titleText", | ||
message: formatMessage("errorTitle", "titleText"), | ||
}, | ||
errorDescription: { | ||
newName: "bodyText", | ||
message: formatMessage("errorDescription", "bodyText"), | ||
}, | ||
defaultErrorDescription: { | ||
newName: "defaultBodyText", | ||
message: formatMessage("defaultErrorDescription", "defaultBodyText"), | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: renameProps(renames, "@patternfly/react-component-groups"), | ||
}; |
9 changes: 9 additions & 0 deletions
9
...les/v6/componentGroupsErrorStateRenameProps/componentGroupsErrorStateRenamePropsInput.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,9 @@ | ||
import { ErrorState } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsErrorStateRenamePropsInput = () => ( | ||
<ErrorState | ||
errorTitle="Sample error title" | ||
errorDescription="Sample error description" | ||
defaultErrorDescription="Sample default error description" | ||
/> | ||
); |
9 changes: 9 additions & 0 deletions
9
...es/v6/componentGroupsErrorStateRenameProps/componentGroupsErrorStateRenamePropsOutput.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,9 @@ | ||
import { ErrorState } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsErrorStateRenamePropsInput = () => ( | ||
<ErrorState | ||
titleText="Sample error title" | ||
bodyText="Sample error description" | ||
defaultBodyText="Sample default error description" | ||
/> | ||
); |