-
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.
fix(Card): updated markup for actionable cards
- Loading branch information
1 parent
c42de7e
commit 6153951
Showing
9 changed files
with
90 additions
and
44 deletions.
There are no files selected for viewing
27 changes: 0 additions & 27 deletions
27
packages/eslint-plugin-pf-codemods/src/rules/helpers/JSXElements.ts
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
packages/eslint-plugin-pf-codemods/src/rules/helpers/getChildJSXElementByName.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,41 @@ | ||
import { | ||
JSXElement, | ||
JSXText, | ||
JSXExpressionContainer, | ||
JSXSpreadChild, | ||
JSXFragment, | ||
} from "estree-jsx"; | ||
|
||
function getChildJSXElementCallback( | ||
childNode: | ||
| JSXElement | ||
| JSXText | ||
| JSXExpressionContainer | ||
| JSXSpreadChild | ||
| JSXFragment, | ||
name: string | ||
) { | ||
return ( | ||
childNode.type === "JSXElement" && | ||
childNode.openingElement.name.type === "JSXIdentifier" && | ||
childNode.openingElement.name.name === name | ||
); | ||
} | ||
|
||
/** Can be used to run logic if the specific child element exists, or to run logic on the | ||
* specified element. | ||
*/ | ||
export function getChildJSXElementByName(node: JSXElement, name: string) { | ||
return node.children?.find((child) => | ||
getChildJSXElementCallback(child, name) | ||
) as JSXElement | undefined; | ||
} | ||
|
||
/** Can be used to run logic if the specific child elements exist, or to run logic on the | ||
* specified elements. | ||
*/ | ||
export function getAllChildJSXElementsByName(node: JSXElement, name: string) { | ||
return node.children?.filter((child) => | ||
getChildJSXElementCallback(child, name) | ||
) as JSXElement[]; | ||
} |
14 changes: 7 additions & 7 deletions
14
packages/eslint-plugin-pf-codemods/src/rules/helpers/getLocalComponentName.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
16 changes: 16 additions & 0 deletions
16
packages/eslint-plugin-pf-codemods/src/rules/helpers/getSpecifierFromImports.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,16 @@ | ||
import { ImportSpecifier, ImportDefaultSpecifier } from "estree-jsx"; | ||
|
||
/** Can be used to extract a specific specifier from an array of imports, such as to only | ||
* run logic if X and Y imports are present or to use the specifier properties in other logic. */ | ||
export function getSpecifierFromImports( | ||
imports: (ImportSpecifier | ImportDefaultSpecifier)[], | ||
importedName: string | ||
) { | ||
const importSpecifier = imports.find((imp) => | ||
imp.type === "ImportDefaultSpecifier" | ||
? imp.local.name === importedName | ||
: imp.imported.name === importedName | ||
); | ||
|
||
return importSpecifier; | ||
} |
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
9 changes: 9 additions & 0 deletions
9
packages/eslint-plugin-pf-codemods/src/rules/helpers/nodeIsComponentNamed.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,9 @@ | ||
import { JSXElement } from "estree-jsx"; | ||
|
||
export function nodeIsComponentNamed(node: JSXElement, componentName: string) { | ||
if (node.openingElement.name.type === "JSXIdentifier") { | ||
return node.openingElement.name.name === componentName; | ||
} | ||
|
||
return false; | ||
} |
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
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