Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/eslint-plugin-pf-codemods/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const rules = {
"chart-remove-allowZoom": require('./lib/rules/v4/chartVoronoiContainer-remove-allowTooltip'),
"react-icons-remove-icon": require('./lib/rules/v4/react-icons-remove-icon'),
"toolbar-remove-visiblity": require('./lib/rules/v5/toolbar-remove-visiblity'),
"divider-remove-isVertical": require('./lib/rules/v5/divider-remove-isVertical'),
};

module.exports = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { renameProp } = require('../../helpers');

// https://github.com/patternfly/patternfly-react/pull/8199
module.exports = {
meta: { fixable: 'code' },
create: renameProp(
'Divider',
{'isVertical': `orientation={{ default: 'vertical' }}`},
node => `isVertical prop has been removed for ${node.name.name} and replaced with the orientation prop, which can specify verticality at various breakpoints.`
),
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const ruleTester = require('../../ruletester');
const rule = require('../../../lib/rules/v5/divider-remove-isVertical');

ruleTester.run("divider-remove-isVertical", rule, {
valid: [
{
code: `import { Divider } from '@patternfly/react-core'; <Divider orientation={{ default: 'vertical' }} />`,
},
{
// No @patternfly/react-core import
code: `<Divider isVertical />`,
}
],
invalid: [
{
code: `import { Divider } from '@patternfly/react-core'; <Divider isVertical />`,
output: `import { Divider } from '@patternfly/react-core'; <Divider orientation={{ default: 'vertical' }} />`,
errors: [{
message: `isVertical prop has been removed for Divider and replaced with the orientation prop, which can specify verticality at various breakpoints.`,
type: "JSXOpeningElement",
}]
}
]
});
16 changes: 16 additions & 0 deletions packages/pf-codemods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ Options:

These rules are based off the breaking change notes for React. Each rule links the breaking change patternfly-react PR in case you want to better understand the change. Also, each rule makes sure you're using a PatternFly component before running.

### divider-remove-isVertical [(#8199)](https://github.com/patternfly/patternfly-react/pull/8199)

We've replaced the `isVertical` flag with the `orientation` property that can define verticality on different breakpoints.

#### Examples

```jsx
<Divider isVertical />
```

Out:

```jsx
<Divider orientation={{ default: "vertical" }} />
```

### toolbar-remove-visiblity [(#8212)](https://github.com/patternfly/patternfly-react/pull/8212)

We've removed the deprecated `visiblity` prop. This rule wil replace it with the correct spelled `visibility` prop.
Expand Down