-
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(component groups): rename various components (#776)
* feat(renameComponents helper): rename node when default import matches component name * feat(dataCodemodsCleanup): include component-groups package * feat(codemod): rename ContentHeader to PageHeader * feat(codemod): rename InvalidObject to MissingPage * feat(codemod): rename NotAuthorized to UnauthorizedAccess
- Loading branch information
1 parent
57f41a2
commit aa1d152
Showing
21 changed files
with
511 additions
and
160 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
...HeaderRenameToPageHeader/component-groups-contentHeader-rename-to-pageHeader.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-contentHeader-rename-to-pageHeader [(react-component-groups/#313)](https://github.com/patternfly/react-component-groups/pull/313) | ||
|
||
In react-component-groups, we've renamed ContentHeader component to PageHeader | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` | ||
|
57 changes: 57 additions & 0 deletions
57
...ntentHeaderRenameToPageHeader/component-groups-contentHeader-rename-to-pageHeader.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,57 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./component-groups-contentHeader-rename-to-pageHeader"; | ||
|
||
const errors = [ | ||
{ | ||
message: `ContentHeader has been renamed to PageHeader.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
]; | ||
|
||
ruleTester.run("component-groups-contentHeader-rename-to-pageHeader", rule, { | ||
valid: [ | ||
// missing import | ||
{ | ||
code: `<ContentHeader />`, | ||
}, | ||
// import from wrong package | ||
{ | ||
code: `import { ContentHeader } from '@patternfly/react-core'; <ContentHeader />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { ContentHeader } from '@patternfly/react-component-groups'; <ContentHeader />`, | ||
output: `import { PageHeader } from '@patternfly/react-component-groups'; <PageHeader data-codemods />`, | ||
errors, | ||
}, | ||
// named import with alias | ||
{ | ||
code: `import { ContentHeader as Header } from '@patternfly/react-component-groups'; <Header />`, | ||
output: `import { PageHeader as Header } from '@patternfly/react-component-groups'; <Header />`, | ||
errors, | ||
}, | ||
// default imports | ||
{ | ||
code: `import ContentHeader from '@patternfly/react-component-groups/dist/cjs/ContentHeader/index'; <ContentHeader />`, | ||
output: `import PageHeader from '@patternfly/react-component-groups/dist/cjs/PageHeader/index'; <PageHeader data-codemods />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import ContentHeader from '@patternfly/react-component-groups/dist/esm/ContentHeader/index'; <ContentHeader />`, | ||
output: `import PageHeader from '@patternfly/react-component-groups/dist/esm/PageHeader/index'; <PageHeader data-codemods />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import ContentHeader from '@patternfly/react-component-groups/dist/dynamic/ContentHeader'; <ContentHeader />`, | ||
output: `import PageHeader from '@patternfly/react-component-groups/dist/dynamic/PageHeader'; <PageHeader data-codemods />`, | ||
errors, | ||
}, | ||
// default import with name not matching the component name | ||
{ | ||
code: `import Header from '@patternfly/react-component-groups/dist/dynamic/ContentHeader'; <Header />`, | ||
output: `import Header from '@patternfly/react-component-groups/dist/dynamic/PageHeader'; <Header />`, | ||
errors, | ||
}, | ||
], | ||
}); |
12 changes: 12 additions & 0 deletions
12
...upsContentHeaderRenameToPageHeader/component-groups-contentHeader-rename-to-pageHeader.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,12 @@ | ||
import { renameComponent } from "../../helpers/renameComponent"; | ||
|
||
// https://github.com/patternfly/react-component-groups/pull/313 | ||
module.exports = { | ||
meta: { fixable: "code" }, | ||
create: renameComponent( | ||
{ | ||
ContentHeader: "PageHeader", | ||
}, | ||
"@patternfly/react-component-groups" | ||
), | ||
}; |
5 changes: 5 additions & 0 deletions
5
...psContentHeaderRenameToPageHeader/componentGroupsContentHeaderRenameToPageHeaderInput.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 { ContentHeader } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsContentHeaderRenameToPageHeaderInput = () => ( | ||
<ContentHeader /> | ||
); |
5 changes: 5 additions & 0 deletions
5
...sContentHeaderRenameToPageHeader/componentGroupsContentHeaderRenameToPageHeaderOutput.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 { PageHeader } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsContentHeaderRenameToPageHeaderInput = () => ( | ||
<PageHeader data-codemods /> | ||
); |
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
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
18 changes: 18 additions & 0 deletions
18
...jectRenameToMissingPage/component-groups-invalidObject-rename-to-missingPage.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-to-missingPage [(react-component-groups/#313)](https://github.com/patternfly/react-component-groups/pull/313) | ||
|
||
In react-component-groups, we've renamed InvalidObject component to MissingPage | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` | ||
|
Oops, something went wrong.