-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(various): updated markup for several components (#644)
* feat(various): updated markup for several components * Added rules for table and wizard updates * Added rule for toolbaritem * Added toolbar rule to warnings * Updated per PR feedback
- Loading branch information
1 parent
8925085
commit 90052e1
Showing
32 changed files
with
786 additions
and
0 deletions.
There are no files selected for viewing
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
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
3 changes: 3 additions & 0 deletions
3
...tionDrawerHeaderWarnUpdateMarkup/notificationDrawerHeader-warn-update-markup.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,3 @@ | ||
### notificationDrawerHeader-warn-update-markup [(#10378)](https://github.com/patternfly/patternfly-react/pull/10378) | ||
|
||
NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native `h1` element. |
62 changes: 62 additions & 0 deletions
62
...ificationDrawerHeaderWarnUpdateMarkup/notificationDrawerHeader-warn-update-markup.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,62 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./notificationDrawerHeader-warn-update-markup"; | ||
|
||
ruleTester.run("notificationDrawerHeader-warn-update-markup", rule, { | ||
valid: [ | ||
{ | ||
code: `<NotificationDrawerHeader />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { NotificationDrawerHeader } from '@patternfly/react-core'; <NotificationDrawerHeader />`, | ||
output: `import { NotificationDrawerHeader } from '@patternfly/react-core'; <NotificationDrawerHeader />`, | ||
errors: [ | ||
{ | ||
message: `NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native \`h1\` element.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { NotificationDrawerHeader as CustomDrawerHeader } from '@patternfly/react-core'; <CustomDrawerHeader />`, | ||
output: `import { NotificationDrawerHeader as CustomDrawerHeader } from '@patternfly/react-core'; <CustomDrawerHeader />`, | ||
errors: [ | ||
{ | ||
message: `NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native \`h1\` element.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { NotificationDrawerHeader } from '@patternfly/react-core/dist/esm/components/EmptyState/index.js'; <NotificationDrawerHeader />`, | ||
output: `import { NotificationDrawerHeader } from '@patternfly/react-core/dist/esm/components/EmptyState/index.js'; <NotificationDrawerHeader />`, | ||
errors: [ | ||
{ | ||
message: `NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native \`h1\` element.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { NotificationDrawerHeader } from '@patternfly/react-core/dist/js/components/EmptyState/index.js'; <NotificationDrawerHeader />`, | ||
output: `import { NotificationDrawerHeader } from '@patternfly/react-core/dist/js/components/EmptyState/index.js'; <NotificationDrawerHeader />`, | ||
errors: [ | ||
{ | ||
message: `NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native \`h1\` element.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { NotificationDrawerHeader } from '@patternfly/react-core/dist/dynamic/components/EmptyState/index.js'; <NotificationDrawerHeader />`, | ||
output: `import { NotificationDrawerHeader } from '@patternfly/react-core/dist/dynamic/components/EmptyState/index.js'; <NotificationDrawerHeader />`, | ||
errors: [ | ||
{ | ||
message: `NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native \`h1\` element.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
32 changes: 32 additions & 0 deletions
32
...6/notificationDrawerHeaderWarnUpdateMarkup/notificationDrawerHeader-warn-update-markup.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,32 @@ | ||
import { Rule } from "eslint"; | ||
import { JSXOpeningElement } from "estree-jsx"; | ||
import { getFromPackage } from "../../helpers"; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10378 | ||
module.exports = { | ||
meta: {}, | ||
create: function (context: Rule.RuleContext) { | ||
const { imports } = getFromPackage(context, "@patternfly/react-core"); | ||
|
||
const componentImport = imports.find( | ||
(specifier) => specifier.imported.name === "NotificationDrawerHeader" | ||
); | ||
|
||
return !componentImport | ||
? {} | ||
: { | ||
JSXOpeningElement(node: JSXOpeningElement) { | ||
if ( | ||
node.name.type === "JSXIdentifier" && | ||
componentImport.local.name === node.name.name | ||
) { | ||
context.report({ | ||
node, | ||
message: | ||
"NotificationDrawerHeader no longer uses our Text component internally, and instead renders a native `h1` element.", | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
5 changes: 5 additions & 0 deletions
5
...otificationDrawerHeaderWarnUpdateMarkup/notificationDrawerHeaderWarnUpdateMarkupInput.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,5 @@ | ||
import { NotificationDrawerHeader } from "@patternfly/react-core"; | ||
|
||
export const NotificationDrawerHeaderWarnUpdateMarkupInput = () => ( | ||
<NotificationDrawerHeader /> | ||
); |
5 changes: 5 additions & 0 deletions
5
...tificationDrawerHeaderWarnUpdateMarkup/notificationDrawerHeaderWarnUpdateMarkupOutput.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,5 @@ | ||
import { NotificationDrawerHeader } from "@patternfly/react-core"; | ||
|
||
export const NotificationDrawerHeaderWarnUpdateMarkupInput = () => ( | ||
<NotificationDrawerHeader /> | ||
); |
3 changes: 3 additions & 0 deletions
3
...demods/src/rules/v6/sliderStepWarnUpdateMarkup/sliderStep-warn-update-markup.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,3 @@ | ||
### sliderStep-warn-update-markup [(#10378)](https://github.com/patternfly/patternfly-react/pull/10378) | ||
|
||
The `--pf-v6-c-slider__step--Left` CSS variable applied as an inline style has been updated to the `--pf-v6-c-slider__step--InsetInlineStart` CSS variable. |
62 changes: 62 additions & 0 deletions
62
...pf-codemods/src/rules/v6/sliderStepWarnUpdateMarkup/sliderStep-warn-update-markup.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,62 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./sliderStep-warn-update-markup"; | ||
|
||
ruleTester.run("sliderStep-warn-update-markup", rule, { | ||
valid: [ | ||
{ | ||
code: `<Slider/>`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { Slider } from '@patternfly/react-core'; <Slider />`, | ||
output: `import { Slider } from '@patternfly/react-core'; <Slider />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-slider__step--Left\` CSS variable applied as an inline style to SliderStep has been updated to the \`--pf-v6-c-slider__step--InsetInlineStart\` CSS variable.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Slider as CustomSlider } from '@patternfly/react-core'; <CustomSlider />`, | ||
output: `import { Slider as CustomSlider } from '@patternfly/react-core'; <CustomSlider />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-slider__step--Left\` CSS variable applied as an inline style to SliderStep has been updated to the \`--pf-v6-c-slider__step--InsetInlineStart\` CSS variable.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Slider } from '@patternfly/react-core/dist/esm/components/Slider/index.js'; <Slider />`, | ||
output: `import { Slider } from '@patternfly/react-core/dist/esm/components/Slider/index.js'; <Slider />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-slider__step--Left\` CSS variable applied as an inline style to SliderStep has been updated to the \`--pf-v6-c-slider__step--InsetInlineStart\` CSS variable.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Slider } from '@patternfly/react-core/dist/js/components/Slider/index.js'; <Slider />`, | ||
output: `import { Slider } from '@patternfly/react-core/dist/js/components/Slider/index.js'; <Slider />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-slider__step--Left\` CSS variable applied as an inline style to SliderStep has been updated to the \`--pf-v6-c-slider__step--InsetInlineStart\` CSS variable.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Slider } from '@patternfly/react-core/dist/dynamic/components/Slider/index.js'; <Slider />`, | ||
output: `import { Slider } from '@patternfly/react-core/dist/dynamic/components/Slider/index.js'; <Slider />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-slider__step--Left\` CSS variable applied as an inline style to SliderStep has been updated to the \`--pf-v6-c-slider__step--InsetInlineStart\` CSS variable.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
32 changes: 32 additions & 0 deletions
32
...ugin-pf-codemods/src/rules/v6/sliderStepWarnUpdateMarkup/sliderStep-warn-update-markup.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,32 @@ | ||
import { Rule } from "eslint"; | ||
import { JSXOpeningElement } from "estree-jsx"; | ||
import { getFromPackage } from "../../helpers"; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10378 | ||
module.exports = { | ||
meta: {}, | ||
create: function (context: Rule.RuleContext) { | ||
const { imports } = getFromPackage(context, "@patternfly/react-core"); | ||
|
||
const componentImport = imports.find( | ||
(specifier) => specifier.imported.name === "Slider" | ||
); | ||
|
||
return !componentImport | ||
? {} | ||
: { | ||
JSXOpeningElement(node: JSXOpeningElement) { | ||
if ( | ||
node.name.type === "JSXIdentifier" && | ||
componentImport.local.name === node.name.name | ||
) { | ||
context.report({ | ||
node, | ||
message: | ||
"The `--pf-v6-c-slider__step--Left` CSS variable applied as an inline style to SliderStep has been updated to the `--pf-v6-c-slider__step--InsetInlineStart` CSS variable.", | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
3 changes: 3 additions & 0 deletions
3
...n-pf-codemods/src/rules/v6/sliderStepWarnUpdateMarkup/sliderStepWarnUpdateMarkupInput.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 { Slider } from "@patternfly/react-core"; | ||
|
||
export const SliderStepWarnUpdateMarkupInput = () => <Slider />; |
3 changes: 3 additions & 0 deletions
3
...-pf-codemods/src/rules/v6/sliderStepWarnUpdateMarkup/sliderStepWarnUpdateMarkupOutput.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 { Slider } from "@patternfly/react-core"; | ||
|
||
export const SliderStepWarnUpdateMarkupInput = () => <Slider />; |
3 changes: 3 additions & 0 deletions
3
...lugin-pf-codemods/src/rules/v6/thTdWarnUpdateMarkup/Th-Td-warn-update-markup.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,3 @@ | ||
### Th-Td-warn-update-markup [(#10378)](https://github.com/patternfly/patternfly-react/pull/10378) | ||
|
||
The `--pf-v6-c-table__sticky-cell--Left` and `--pf-v6-c-table__sticky-cell--Right` CSS variables applied as inline styles when `isStickyColumn` is true have been updated to `--pf-v6-c-table__sticky-cell--InsetInlineStart` and `--pf-v6-c-table__sticky-cell--InsetInlineEnd`, respectively. |
81 changes: 81 additions & 0 deletions
81
...int-plugin-pf-codemods/src/rules/v6/thTdWarnUpdateMarkup/Th-Td-warn-update-markup.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,81 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./Th-Td-warn-update-markup"; | ||
|
||
ruleTester.run("Th-Td-warn-update-markup", rule, { | ||
valid: [ | ||
{ | ||
code: `<Th />`, | ||
}, | ||
{ | ||
code: `<Td />`, | ||
}, | ||
{ | ||
code: `import { Th } from '@patternfly/react-table'; <Th />`, | ||
}, | ||
{ | ||
code: `import { Td } from '@patternfly/react-table'; <Td />`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { Th } from '@patternfly/react-table'; <Th isStickyColumn />`, | ||
output: `import { Th } from '@patternfly/react-table'; <Th isStickyColumn />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-table__sticky-cell--Left\` and \`--pf-v6-c-table__sticky-cell--Right\` CSS variables applied as inline styles have been updated to \`--pf-v6-c-table__sticky-cell--InsetInlineStart\` and \`--pf-v6-c-table__sticky-cell--InsetInlineEnd\`, respectively.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Th as CustomTh } from '@patternfly/react-table'; <CustomTh isStickyColumn />`, | ||
output: `import { Th as CustomTh } from '@patternfly/react-table'; <CustomTh isStickyColumn />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-table__sticky-cell--Left\` and \`--pf-v6-c-table__sticky-cell--Right\` CSS variables applied as inline styles have been updated to \`--pf-v6-c-table__sticky-cell--InsetInlineStart\` and \`--pf-v6-c-table__sticky-cell--InsetInlineEnd\`, respectively.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Td } from '@patternfly/react-table'; <Td isStickyColumn />`, | ||
output: `import { Td } from '@patternfly/react-table'; <Td isStickyColumn />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-table__sticky-cell--Left\` and \`--pf-v6-c-table__sticky-cell--Right\` CSS variables applied as inline styles have been updated to \`--pf-v6-c-table__sticky-cell--InsetInlineStart\` and \`--pf-v6-c-table__sticky-cell--InsetInlineEnd\`, respectively.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Th } from '@patternfly/react-table/dist/esm/components/Table/index.js'; <Th isStickyColumn />`, | ||
output: `import { Th } from '@patternfly/react-table/dist/esm/components/Table/index.js'; <Th isStickyColumn />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-table__sticky-cell--Left\` and \`--pf-v6-c-table__sticky-cell--Right\` CSS variables applied as inline styles have been updated to \`--pf-v6-c-table__sticky-cell--InsetInlineStart\` and \`--pf-v6-c-table__sticky-cell--InsetInlineEnd\`, respectively.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Th } from '@patternfly/react-table/dist/js/components/Table/index.js'; <Th isStickyColumn />`, | ||
output: `import { Th } from '@patternfly/react-table/dist/js/components/Table/index.js'; <Th isStickyColumn />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-table__sticky-cell--Left\` and \`--pf-v6-c-table__sticky-cell--Right\` CSS variables applied as inline styles have been updated to \`--pf-v6-c-table__sticky-cell--InsetInlineStart\` and \`--pf-v6-c-table__sticky-cell--InsetInlineEnd\`, respectively.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
{ | ||
code: `import { Th } from '@patternfly/react-table/dist/dynamic/components/Table/index.js'; <Th isStickyColumn />`, | ||
output: `import { Th } from '@patternfly/react-table/dist/dynamic/components/Table/index.js'; <Th isStickyColumn />`, | ||
errors: [ | ||
{ | ||
message: `The \`--pf-v6-c-table__sticky-cell--Left\` and \`--pf-v6-c-table__sticky-cell--Right\` CSS variables applied as inline styles have been updated to \`--pf-v6-c-table__sticky-cell--InsetInlineStart\` and \`--pf-v6-c-table__sticky-cell--InsetInlineEnd\`, respectively.`, | ||
type: "JSXOpeningElement", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
37 changes: 37 additions & 0 deletions
37
...s/eslint-plugin-pf-codemods/src/rules/v6/thTdWarnUpdateMarkup/Th-Td-warn-update-markup.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,37 @@ | ||
import { Rule } from "eslint"; | ||
import { JSXOpeningElement } from "estree-jsx"; | ||
import { getFromPackage, getAttribute } from "../../helpers"; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10378 | ||
module.exports = { | ||
meta: {}, | ||
create: function (context: Rule.RuleContext) { | ||
const { imports } = getFromPackage(context, "@patternfly/react-table"); | ||
|
||
const componentImports = imports.filter((specifier) => | ||
["Th", "Td"].includes(specifier.imported.name) | ||
); | ||
|
||
return !componentImports.length | ||
? {} | ||
: { | ||
JSXOpeningElement(node: JSXOpeningElement) { | ||
if ( | ||
node.name.type === "JSXIdentifier" && | ||
componentImports | ||
.map((imp) => imp.local.name) | ||
.includes(node.name.name) | ||
) { | ||
const attribute = getAttribute(node, "isStickyColumn"); | ||
if (attribute) { | ||
context.report({ | ||
node, | ||
message: | ||
"The `--pf-v6-c-table__sticky-cell--Left` and `--pf-v6-c-table__sticky-cell--Right` CSS variables applied as inline styles have been updated to `--pf-v6-c-table__sticky-cell--InsetInlineStart` and `--pf-v6-c-table__sticky-cell--InsetInlineEnd`, respectively.", | ||
}); | ||
} | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
8 changes: 8 additions & 0 deletions
8
...eslint-plugin-pf-codemods/src/rules/v6/thTdWarnUpdateMarkup/thTdWarnUpdateMarkupInput.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,8 @@ | ||
import { Th, Td } from "@patternfly/react-core"; | ||
|
||
export const ThTdWarnUpdateMarkupInput = () => ( | ||
<> | ||
<Th /> | ||
<Td /> | ||
</> | ||
); |
Oops, something went wrong.