-
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(Menu): updated markup for MenuItemAction (#590)
* feat(Menu): updated markup for MenuItemAction * Added rules to beta array
- Loading branch information
1 parent
3d0cbb1
commit 2fa045b
Showing
7 changed files
with
68 additions
and
2 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
2 changes: 1 addition & 1 deletion
2
...f-codemods/src/rules/v6/jumpLinksItemWarnMarkupChange/jumpLinksItem-warn-markup-change.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
3 changes: 3 additions & 0 deletions
3
...rc/rules/v6/menuItemActionWarnUpdateMarkup/menuItemAction-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 @@ | ||
### menuItemAction-warn-update-markup [(#10089)](https://github.com/patternfly/patternfly-react/pull/10089) | ||
|
||
The markup for MenuItemAction has been updated. It now uses our Button component internally, has a wrapper around the action button, and no longer renders an icon wrapper inside the action button. |
22 changes: 22 additions & 0 deletions
22
...ods/src/rules/v6/menuItemActionWarnUpdateMarkup/menuItemAction-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,22 @@ | ||
const ruleTester = require("../../ruletester"); | ||
import * as rule from "./menuItemAction-warn-update-markup"; | ||
|
||
ruleTester.run("menuItemAction-warn-update-markup", rule, { | ||
valid: [ | ||
{ | ||
code: `import { MenuItemAction } from '@someOtherPackage';`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
code: `import { MenuItemAction } from '@patternfly/react-core';`, | ||
output: `import { MenuItemAction } from '@patternfly/react-core';`, | ||
errors: [ | ||
{ | ||
message: `The markup for MenuItemAction has been updated. It now uses our Button component internally, has a wrapper around the action button, and no longer renders an icon wrapper inside the action button.`, | ||
type: "ImportDeclaration", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
35 changes: 35 additions & 0 deletions
35
...codemods/src/rules/v6/menuItemActionWarnUpdateMarkup/menuItemAction-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,35 @@ | ||
import { getFromPackage } from "../../helpers"; | ||
import { Rule } from "eslint"; | ||
import { ImportDeclaration } from "estree-jsx"; | ||
|
||
// https://github.com/patternfly/patternfly-react/pull/10089 | ||
module.exports = { | ||
meta: {}, | ||
create: function (context: Rule.RuleContext) { | ||
const { imports } = getFromPackage(context, "@patternfly/react-core"); | ||
|
||
const menuItemActionImport = imports.find( | ||
(specifier) => specifier.imported.name === "MenuItemAction" | ||
); | ||
|
||
return !menuItemActionImport | ||
? {} | ||
: { | ||
ImportDeclaration(node: ImportDeclaration) { | ||
if ( | ||
node.specifiers.find( | ||
(specifier) => | ||
specifier.type === "ImportSpecifier" && | ||
specifier.imported.name === menuItemActionImport.imported.name | ||
) | ||
) { | ||
context.report({ | ||
node, | ||
message: | ||
"The markup for MenuItemAction has been updated. It now uses our Button component internally, has a wrapper around the action button, and no longer renders an icon wrapper inside the action button.", | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}; |
1 change: 1 addition & 0 deletions
1
...emods/src/rules/v6/menuItemActionWarnUpdateMarkup/menuItemActionWarnUpdateMarkupInput.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 @@ | ||
import { MenuItemAction } from "@patternfly/react-core"; |
1 change: 1 addition & 0 deletions
1
...mods/src/rules/v6/menuItemActionWarnUpdateMarkup/menuItemActionWarnUpdateMarkupOutput.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 @@ | ||
import { MenuItemAction } from "@patternfly/react-core"; |