-
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(codemod): rename InvalidObject to MissingPage
- Loading branch information
1 parent
64f0fbf
commit 6c111f1
Showing
6 changed files
with
100 additions
and
0 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
...UnauthorizedAccess copy/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% | ||
``` | ||
|
57 changes: 57 additions & 0 deletions
57
...ameToUnauthorizedAccess copy/component-groups-invalidObject-rename-to-missingPage.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-invalidObject-rename-to-missingPage"; | ||
|
||
const errors = [ | ||
{ | ||
message: `InvalidObject has been renamed to MissingPage.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
]; | ||
|
||
ruleTester.run("component-groups-invalidObject-rename-to-missingPage", rule, { | ||
valid: [ | ||
// missing import | ||
{ | ||
code: `<InvalidObject />`, | ||
}, | ||
// import from wrong package | ||
{ | ||
code: `import { InvalidObject } from '@patternfly/react-core'; <InvalidObject />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { InvalidObject } from '@patternfly/react-component-groups'; <InvalidObject />`, | ||
output: `import { MissingPage } from '@patternfly/react-component-groups'; <MissingPage data-codemods />`, | ||
errors, | ||
}, | ||
// named import with alias | ||
{ | ||
code: `import { InvalidObject as InvObj } from '@patternfly/react-component-groups'; <InvObj />`, | ||
output: `import { MissingPage as InvObj } from '@patternfly/react-component-groups'; <InvObj />`, | ||
errors, | ||
}, | ||
// default imports | ||
{ | ||
code: `import InvalidObject from '@patternfly/react-component-groups/dist/cjs/InvalidObject/index'; <InvalidObject />`, | ||
output: `import MissingPage from '@patternfly/react-component-groups/dist/cjs/MissingPage/index'; <MissingPage data-codemods />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import InvalidObject from '@patternfly/react-component-groups/dist/esm/InvalidObject/index'; <InvalidObject />`, | ||
output: `import MissingPage from '@patternfly/react-component-groups/dist/esm/MissingPage/index'; <MissingPage data-codemods />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import InvalidObject from '@patternfly/react-component-groups/dist/dynamic/InvalidObject'; <InvalidObject />`, | ||
output: `import MissingPage from '@patternfly/react-component-groups/dist/dynamic/MissingPage'; <MissingPage data-codemods />`, | ||
errors, | ||
}, | ||
// default import with name not matching the component name | ||
{ | ||
code: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/InvalidObject'; <InvObj />`, | ||
output: `import InvObj from '@patternfly/react-component-groups/dist/dynamic/MissingPage'; <InvObj />`, | ||
errors, | ||
}, | ||
], | ||
}); |
12 changes: 12 additions & 0 deletions
12
...edRenameToUnauthorizedAccess copy/component-groups-invalidObject-rename-to-missingPage.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( | ||
{ | ||
InvalidObject: "MissingPage", | ||
}, | ||
"@patternfly/react-component-groups" | ||
), | ||
}; |
4 changes: 4 additions & 0 deletions
4
...dRenameToUnauthorizedAccess copy/componentGroupsInvalidObjectRenameToMissingPageInput.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,4 @@ | ||
import { InvalidObject } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsInvalidObjectRenameToMissingPageInput = | ||
() => <InvalidObject />; |
4 changes: 4 additions & 0 deletions
4
...RenameToUnauthorizedAccess copy/componentGroupsInvalidObjectRenameToMissingPageOutput.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,4 @@ | ||
import { MissingPage } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsInvalidObjectRenameToMissingPageInput = | ||
() => <MissingPage data-codemods />; |