-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(CG - NotAuthorized): rename props
- Loading branch information
1 parent
d8e33d8
commit f6cdf48
Showing
5 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...ntGroupsNotAuthorizedRenameProps/component-groups-notAuthorized-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,17 @@ | ||
### component-groups-notAuthorized-rename-props [(react-component-groups/#145)](https://github.com/patternfly/react-component-groups/pull/145) | ||
|
||
In react-component-groups, we've renamed NotAuthorized's props `description` to `bodyText` and `title` to `titleText`. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
93 changes: 93 additions & 0 deletions
93
...mponentGroupsNotAuthorizedRenameProps/component-groups-notAuthorized-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-notAuthorized-rename-props"; | ||
|
||
const renameMap = { | ||
description: "bodyText", | ||
title: "titleText", | ||
}; | ||
|
||
const errors = Object.entries(renameMap).map(([oldName, newName]) => ({ | ||
message: `The ${oldName} prop for NotAuthorized has been renamed to ${newName}.`, | ||
type: "JSXOpeningElement", | ||
})); | ||
|
||
ruleTester.run("component-groups-notAuthorized-rename-props", rule, { | ||
valid: [ | ||
{ | ||
code: `<NotAuthorized description="" />`, | ||
}, | ||
{ | ||
code: `<NotAuthorized title="" />`, | ||
}, | ||
{ | ||
code: `import { NotAuthorized } from '@patternfly/react-component-groups'; <NotAuthorized someOtherProp />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { NotAuthorized } from '@patternfly/react-component-groups'; | ||
<NotAuthorized | ||
description="Description text" | ||
title="Title text" | ||
/>`, | ||
output: `import { NotAuthorized } from '@patternfly/react-component-groups'; | ||
<NotAuthorized | ||
bodyText="Description text" | ||
titleText="Title text" | ||
/>`, | ||
errors, | ||
}, | ||
{ | ||
code: `import NotAuthorized from '@patternfly/react-component-groups/dist/cjs/NotAuthorized/index'; | ||
<NotAuthorized | ||
description="Description text" | ||
title="Title text" | ||
/>`, | ||
output: `import NotAuthorized from '@patternfly/react-component-groups/dist/cjs/NotAuthorized/index'; | ||
<NotAuthorized | ||
bodyText="Description text" | ||
titleText="Title text" | ||
/>`, | ||
errors, | ||
}, | ||
{ | ||
code: `import NotAuthorized from '@patternfly/react-component-groups/dist/esm/NotAuthorized/index'; | ||
<NotAuthorized | ||
description="Description text" | ||
title="Title text" | ||
/>`, | ||
output: `import NotAuthorized from '@patternfly/react-component-groups/dist/esm/NotAuthorized/index'; | ||
<NotAuthorized | ||
bodyText="Description text" | ||
titleText="Title text" | ||
/>`, | ||
errors, | ||
}, | ||
{ | ||
code: `import NotAuthorized from '@patternfly/react-component-groups/dist/dynamic/NotAuthorized'; | ||
<NotAuthorized | ||
description="Description text" | ||
title="Title text" | ||
/>`, | ||
output: `import NotAuthorized from '@patternfly/react-component-groups/dist/dynamic/NotAuthorized'; | ||
<NotAuthorized | ||
bodyText="Description text" | ||
titleText="Title text" | ||
/>`, | ||
errors, | ||
}, | ||
{ | ||
code: `import NotAuth from '@patternfly/react-component-groups/dist/dynamic/NotAuthorized'; | ||
<NotAuth | ||
description="Description text" | ||
title="Title text" | ||
/>`, | ||
output: `import NotAuth from '@patternfly/react-component-groups/dist/dynamic/NotAuthorized'; | ||
<NotAuth | ||
bodyText="Description text" | ||
titleText="Title text" | ||
/>`, | ||
errors, | ||
}, | ||
], | ||
}); |
25 changes: 25 additions & 0 deletions
25
...v6/componentGroupsNotAuthorizedRenameProps/component-groups-notAuthorized-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 NotAuthorized has been renamed to ${newPropName}.`; | ||
|
||
const renames: Renames = { | ||
NotAuthorized: { | ||
description: { | ||
newName: "bodyText", | ||
message: formatMessage("description", "bodyText"), | ||
}, | ||
title: { | ||
newName: "titleText", | ||
message: formatMessage("title", "titleText"), | ||
}, | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: renameProps(renames, "@patternfly/react-component-groups"), | ||
}; |
5 changes: 5 additions & 0 deletions
5
.../componentGroupsNotAuthorizedRenameProps/componentGroupsNotAuthorizedRenamePropsInput.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 { NotAuthorized } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsNotAuthorizedRenamePropsInput = () => ( | ||
<NotAuthorized description="Description text" title="Title text" /> | ||
); |
5 changes: 5 additions & 0 deletions
5
...componentGroupsNotAuthorizedRenameProps/componentGroupsNotAuthorizedRenamePropsOutput.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 { NotAuthorized } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsNotAuthorizedRenamePropsInput = () => ( | ||
<NotAuthorized bodyText="Description text" titleText="Title text" /> | ||
); |