-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Page): rename header to masthead (#652)
* feat(Page): rename header to masthead * test(Page): add test for aliased import * chore(Page): better error message
- Loading branch information
1 parent
46b9ff7
commit b3e8f40
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
...s/eslint-plugin-pf-codemods/src/rules/v6/pageRenameHeader/page-rename-header.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 @@ | ||
### page-rename-header [(#10454)](https://github.com/patternfly/patternfly-react/pull/10454) | ||
|
||
We've renamed the `header` prop for Page to `masthead`. | ||
|
||
#### Examples | ||
|
||
In: | ||
|
||
```jsx | ||
%inputExample% | ||
``` | ||
|
||
Out: | ||
|
||
```jsx | ||
%outputExample% | ||
``` |
45 changes: 45 additions & 0 deletions
45
packages/eslint-plugin-pf-codemods/src/rules/v6/pageRenameHeader/page-rename-header.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,45 @@ | ||
const ruleTester = require('../../ruletester'); | ||
import * as rule from './page-rename-header'; | ||
|
||
const error = { | ||
message: `We've renamed the \`header\` prop for Page to \`masthead\`.`, | ||
type: 'JSXOpeningElement', | ||
}; | ||
|
||
ruleTester.run('page-rename-header', rule, { | ||
valid: [ | ||
{ | ||
code: `<Page header />`, | ||
}, | ||
{ | ||
code: `import { Page } from '@patternfly/react-core'; <Page someOtherProp />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { Page } from '@patternfly/react-core'; <Page header={<Masthead />} />`, | ||
output: `import { Page } from '@patternfly/react-core'; <Page masthead={<Masthead />} />`, | ||
errors: [error], | ||
}, | ||
{ | ||
code: `import { Page as CustomPage } from '@patternfly/react-core'; <CustomPage header={<Masthead />} />`, | ||
output: `import { Page as CustomPage } from '@patternfly/react-core'; <CustomPage masthead={<Masthead />} />`, | ||
errors: [error], | ||
}, | ||
{ | ||
code: `import { Page } from '@patternfly/react-core/dist/esm/components/Page/index.js'; <Page header={<Masthead />} />`, | ||
output: `import { Page } from '@patternfly/react-core/dist/esm/components/Page/index.js'; <Page masthead={<Masthead />} />`, | ||
errors: [error], | ||
}, | ||
{ | ||
code: `import { Page } from '@patternfly/react-core/dist/js/components/Page/index.js'; <Page header={<Masthead />} />`, | ||
output: `import { Page } from '@patternfly/react-core/dist/js/components/Page/index.js'; <Page masthead={<Masthead />} />`, | ||
errors: [error], | ||
}, | ||
{ | ||
code: `import { Page } from '@patternfly/react-core/dist/dynamic/components/Page/index.js'; <Page header={<Masthead />} />`, | ||
output: `import { Page } from '@patternfly/react-core/dist/dynamic/components/Page/index.js'; <Page masthead={<Masthead />} />`, | ||
errors: [error], | ||
}, | ||
], | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/eslint-plugin-pf-codemods/src/rules/v6/pageRenameHeader/page-rename-header.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,14 @@ | ||
import { renameProps } from '../../helpers'; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10454 | ||
module.exports = { | ||
meta: { fixable: 'code' }, | ||
create: renameProps({ | ||
Page: { | ||
header: { | ||
newName: 'masthead', | ||
message: `We've renamed the \`header\` prop for Page to \`masthead\`.`, | ||
}, | ||
}, | ||
}), | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/eslint-plugin-pf-codemods/src/rules/v6/pageRenameHeader/pageRenameHeaderInput.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,3 @@ | ||
import { Page } from '@patternfly/react-core'; | ||
|
||
export const PageRenameHeaderInput = () => <Page header={<Masthead />} />; |
3 changes: 3 additions & 0 deletions
3
packages/eslint-plugin-pf-codemods/src/rules/v6/pageRenameHeader/pageRenameHeaderOutput.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,3 @@ | ||
import { Page } from '@patternfly/react-core'; | ||
|
||
export const PageRenameHeaderInput = () => <Page masthead={<Masthead />} />; |