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 @@ -16,6 +16,7 @@ const v4rules = createListOfRules("4");
const warningRules = [
"applicationLauncher-warn-input",
"card-warn-component",
"datePicker-warn-appendTo-default-value-changed",
"horizontalSubnav-ariaLabel",
"popover-appendTo-default",
"react-dropzone-warn-upgrade",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { getPackageImports } = require("../../helpers");

// https://github.com/patternfly/patternfly-react/pull/8636
module.exports = {
meta: {},
create: function (context) {
const imports = getPackageImports(
context,
"@patternfly/react-core"
).filter((specifier) => specifier.imported.name === "DatePicker");

return imports.length === 0
? {}
: {
JSXOpeningElement(node) {
if (
imports
.map((imp) => imp.local.name)
.includes(node.name.name)
) {
context.report({
node,
message: 'The default value of the DatePicker prop "appendTo" has been updated to a value of "inline" and may cause markup changes that require updating selectors used in tests.',
});
}
},
};
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const ruleTester = require('../../ruletester');
const rule = require('../../../lib/rules/v5/datePicker-warn-appendTo-default-value-changed');

ruleTester.run("datePicker-warn-appendTo-default-value-changed", rule, {
valid: [
{
// No @patternfly/react-core import
code: `<DatePicker />`,
}
],
invalid: [
{
code: `import { DatePicker } from '@patternfly/react-core'; <DatePicker />`,
output: `import { DatePicker } from '@patternfly/react-core'; <DatePicker />`,
errors: [{
message: 'The default value of the DatePicker prop "appendTo" has been updated to a value of "inline" and may cause markup changes that require updating selectors used in tests.',
type: "JSXOpeningElement",
}]
}
]
});
4 changes: 4 additions & 0 deletions packages/pf-codemods/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ Out:
<DataList />
```

### datePicker-warn-appendTo-default-value-changed [(#8636)](https://github.com/patternfly/patternfly-react/pull/8636)

The default value of the `appendTo` prop on DatePicker has been updated, which may cause markup changes that require updating selectors in tests. This rule will raise a warning, but will not make any changes.

### 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.
Expand Down
2 changes: 2 additions & 0 deletions test/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ApplicationLauncher,
Button,
Card,
DatePicker,
DropdownItem,
DropdownToggle,
FileUpload,
Expand All @@ -28,6 +29,7 @@ const isRead = true;
<Alert aria-label='tester' />
<Button isLarge />
<Button isSmall />
<DatePicker />
<DropdownItem isHovered={true} />
<DropdownToggle isPrimary />
<MenuItem hasCheck />
Expand Down