-
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(codemod): rename NotAuthorized to UnauthorizedAccess
- Loading branch information
1 parent
f182182
commit dbfc10b
Showing
7 changed files
with
196 additions
and
79 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
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
...authorizedAccess/component-groups-notAuthorized-rename-to-unauthorizedAccess.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-notAuthorized-rename-to-unauthorizedAccess [(react-component-groups/#313)](https://github.com/patternfly/react-component-groups/pull/313) | ||
|
||
In react-component-groups, we've renamed NotAuthorized component to UnauthorizedAccess | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` | ||
|
61 changes: 61 additions & 0 deletions
61
...eToUnauthorizedAccess/component-groups-notAuthorized-rename-to-unauthorizedAccess.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,61 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./component-groups-notAuthorized-rename-to-unauthorizedAccess"; | ||
|
||
const errors = [ | ||
{ | ||
message: `NotAuthorized has been renamed to UnauthorizedAccess.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
]; | ||
|
||
ruleTester.run( | ||
"component-groups-notAuthorized-rename-to-unauthorizedAccess", | ||
rule, | ||
{ | ||
valid: [ | ||
// missing import | ||
{ | ||
code: `<NotAuthorized />`, | ||
}, | ||
// import from wrong package | ||
{ | ||
code: `import { NotAuthorized } from '@patternfly/react-core'; <NotAuthorized />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { NotAuthorized } from '@patternfly/react-component-groups'; <NotAuthorized />`, | ||
output: `import { UnauthorizedAccess } from '@patternfly/react-component-groups'; <UnauthorizedAccess data-codemods />`, | ||
errors, | ||
}, | ||
// named import with alias | ||
{ | ||
code: `import { NotAuthorized as NotAuth } from '@patternfly/react-component-groups'; <NotAuth />`, | ||
output: `import { UnauthorizedAccess as NotAuth } from '@patternfly/react-component-groups'; <NotAuth />`, | ||
errors, | ||
}, | ||
// default imports | ||
{ | ||
code: `import NotAuthorized from '@patternfly/react-component-groups/dist/cjs/NotAuthorized/index'; <NotAuthorized />`, | ||
output: `import UnauthorizedAccess from '@patternfly/react-component-groups/dist/cjs/UnauthorizedAccess/index'; <UnauthorizedAccess data-codemods />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import NotAuthorized from '@patternfly/react-component-groups/dist/esm/NotAuthorized/index'; <NotAuthorized />`, | ||
output: `import UnauthorizedAccess from '@patternfly/react-component-groups/dist/esm/UnauthorizedAccess/index'; <UnauthorizedAccess data-codemods />`, | ||
errors, | ||
}, | ||
{ | ||
code: `import NotAuthorized from '@patternfly/react-component-groups/dist/dynamic/NotAuthorized'; <NotAuthorized />`, | ||
output: `import UnauthorizedAccess from '@patternfly/react-component-groups/dist/dynamic/UnauthorizedAccess'; <UnauthorizedAccess data-codemods />`, | ||
errors, | ||
}, | ||
// default import with name not matching the component name | ||
{ | ||
code: `import NotAuth from '@patternfly/react-component-groups/dist/dynamic/NotAuthorized'; <NotAuth />`, | ||
output: `import NotAuth from '@patternfly/react-component-groups/dist/dynamic/UnauthorizedAccess'; <NotAuth />`, | ||
errors, | ||
}, | ||
], | ||
} | ||
); |
12 changes: 12 additions & 0 deletions
12
...RenameToUnauthorizedAccess/component-groups-notAuthorized-rename-to-unauthorizedAccess.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( | ||
{ | ||
NotAuthorized: "UnauthorizedAccess", | ||
}, | ||
"@patternfly/react-component-groups" | ||
), | ||
}; |
4 changes: 4 additions & 0 deletions
4
...enameToUnauthorizedAccess/componentGroupsNotAuthorizedRenameToUnauthorizedAccessInput.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 { NotAuthorized } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsNotAuthorizedRenameToUnauthorizedAccessInput = | ||
() => <NotAuthorized />; |
4 changes: 4 additions & 0 deletions
4
...nameToUnauthorizedAccess/componentGroupsNotAuthorizedRenameToUnauthorizedAccessOutput.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 { UnauthorizedAccess } from "@patternfly/react-component-groups"; | ||
|
||
export const ComponentGroupsNotAuthorizedRenameToUnauthorizedAccessInput = | ||
() => <UnauthorizedAccess data-codemods />; |