Skip to content

Commit

Permalink
feat(Masthead): Remove backgroundColor prop (#566)
Browse files Browse the repository at this point in the history
* feat(Masthead): Remove backgroundColor prop

* chore(Masthead): fix typos, update tests
  • Loading branch information
wise-king-sullyman authored Feb 15, 2024
1 parent 18edec9 commit d4f52bc
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 80 deletions.
3 changes: 3 additions & 0 deletions generators/src/write-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ ruleTester.run("${ruleName}", rule, {
valid: [
{
code: \`<${componentName} ${propName} />\`
},
{
code: \`import { ${componentName} } from '@patternfly/react-core'; <${componentName} someOtherProp />\`
}
],
invalid: [
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"test:v6": "yarn build && mocha packages/eslint-plugin-pf-codemods/dist/js/rules/v6/*/*.test.js",
"test:v4:single": "pf-codemods --v4 --no-cache test/v4test.tsx",
"test:v5:single": "pf-codemods --no-cache test/test.tsx",
"test:v6:single": "yarn build && pf-codemods --v6 --no-cache packages/eslint-plugin-pf-codemods/src/rules/v6/*/*.tsx",
"test:v6:single": "yarn build && pf-codemods --v6 --no-cache packages/eslint-plugin-pf-codemods/src/rules/v6/*/*Input.tsx",
"test:v6:single:output": "yarn build && pf-codemods --v6 --no-cache packages/eslint-plugin-pf-codemods/src/rules/v6/*/*Output.tsx",
"test:koku": "pf-codemods --no-cache test/koku-ui",
"test:console": "pf-codemods --no-cache test/console/frontend",
"test:integreatly": "pf-codemods --no-cache test/tutorial-web-app",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
### masthead-remove-background-color [(#9774)](https://github.com/patternfly/patternfly-react/pull/9774)

We've removed the `backgroundColor` prop from Masthead as theming is no longer handled React-side.

#### Examples

In:

```jsx
%inputExample%
```

Out:

```jsx
%outputExample%
```

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const ruleTester = require('../../ruletester');
import * as rule from './masthead-remove-background-color';

ruleTester.run("masthead-remove-background-color", rule, {
valid: [
{
code: `<Masthead backgroundColor="dark" />`
},
{
code: `import { Masthead } from '@patternfly/react-core'; <Masthead someOtherProp />`
}
],
invalid: [
{
code: `import { Masthead } from '@patternfly/react-core'; <Masthead backgroundColor="dark" />`,
output: `import { Masthead } from '@patternfly/react-core'; <Masthead />`,
errors: [{
message: `We've removed the \`backgroundColor\` prop from Masthead as theming is no longer handled React-side.`,
type: "JSXOpeningElement",
}]
},
]
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { renameProps } from '../../helpers';

// https://github.com/patternfly/patternfly-react/pull/9774
module.exports = {
meta: { fixable: 'code' },
create: renameProps({
Masthead: {
"backgroundColor": {
newName: "",
message: () =>
"We've removed the `backgroundColor` prop from Masthead as theming is no longer handled React-side.",
},
},
}),
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Masthead } from "@patternfly/react-core";

export const MastheadRemoveBackgroundColorInput = () => <Masthead backgroundColor />
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Masthead } from "@patternfly/react-core";

export const MastheadRemoveBackgroundColorInput = () => <Masthead />
12 changes: 6 additions & 6 deletions packages/pf-codemods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,25 @@ These rules are based off the breaking change notes for React. Each rule links t

Some rules will add either a comment (`/* data-codemods */`) or data attribute (`data-codemods="true"`) in order to prevent certain other rules from applying an unnecessary fix.

### example-rule[(#1234)](https://github.com/patternfly/patternfly-react/pull/1234)
### masthead-remove-background-color [(#9774)](https://github.com/patternfly/patternfly-react/pull/9774)

We've renamed the `ComponentName` component to `NewComponentName`.
We've removed the `backgroundColor` prop from Masthead as theming is no longer handled React-side.

#### Examples

In:

```jsx
import { ComponentName } from "@patternfly/react-core";
import { Masthead } from "@patternfly/react-core";

export const ExampleRule = () => <ComponentName propName="foo">Body</ComponentName>;
export const MastheadRemoveBackgroundColorInput = () => <Masthead backgroundColor />
```

Out:

```jsx
import { ComponentName } from "@patternfly/react-core";
import { Masthead } from "@patternfly/react-core";

export const ExampleRule = () => <ComponentName >Body</ComponentName>;
export const MastheadRemoveBackgroundColorInput = () => <Masthead />
```

0 comments on commit d4f52bc

Please sign in to comment.