Skip to content

Commit

Permalink
feat(Page): rename header to masthead (#652)
Browse files Browse the repository at this point in the history
* feat(Page): rename header to masthead

* test(Page): add test for aliased import

* chore(Page): better error message
  • Loading branch information
adamviktora authored Jun 6, 2024
1 parent 46b9ff7 commit b3e8f40
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
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%
```
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],
},
],
});
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\`.`,
},
},
}),
};
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 />} />;
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 />} />;

0 comments on commit b3e8f40

Please sign in to comment.