How to use the isJSXIdentifier function from @babel/types
Find comprehensive JavaScript @babel/types.isJSXIdentifier code examples handpicked from public code repositorys.
GitHub: raxjs/miniapp
204 205 206 207 208 209 210 211 212 213
); } } else if (t.isJSXMemberExpression(node.name)) { // <RecyclerView.Cell /> or <Context.Provider> const { object, property } = node.name; if (t.isJSXIdentifier(object) && t.isJSXIdentifier(property)) { if (property.name === 'Provider') { // <Context.Provider> const valueAttribute = node.attributes.find(a => t.isJSXIdentifier(a.name, { name: 'value' }),
32
66
12
+ 45 other calls in file
GitHub: alijk-fe/motor-rax
192 193 194 195 196 197 198 199 200 201
const { object, property } = node.name; if (t.isJSXIdentifier(object) && t.isJSXIdentifier(property)) { if (property.name === 'Provider') { // <Context.Provider> const valueAttribute = node.attributes.find(a => t.isJSXIdentifier(a.name, { name: 'value' }), ); const contextInitValue = valueAttribute && valueAttribute.value.expression; const contextItem = { contextInitValue,
664
11
1
+ 35 other calls in file
GitHub: alijk-fe/motor-rax
186 187 188 189 190 191 192 193 194 195
[adapter.forIndex]: t.stringLiteral(renamedIndex.name), }; if (adapter.needTransformKey && t.isJSXElement(returnElPath.node)) { const attributes = returnElPath.node.openingElement.attributes; const keyIndex = findIndex(attributes, attr => t.isJSXIdentifier(attr.name, { name: 'key' })); if (keyIndex > -1) { listAttr.key = attributes[keyIndex].value; attributes.splice(keyIndex, 1); } else {
663
11
1
+ 13 other calls in file
13 14 15 16 17 18 19 20 21 22
let rootName = name && name.name; try { // 针对 Card.Content 这种子组件 if (t.isJSXMemberExpression(name)) { if (t.isJSXIdentifier(name.object) && t.isJSXIdentifier(name.property)) { componentName = `${name.object.name}.${name.property.name}`; rootName = name.object.name; } // 针对 React 组件
59
0
0
+ 3 other calls in file
63 64 65 66 67 68 69 70 71 72
// Only inspect elements that are `<I18N.Ref>`. if (types.isJSXMemberExpression(name)) { const { object, property } = name; if ( types.isJSXIdentifier(object, { name: 'I18N' }) && types.isJSXIdentifier(property, { name: 'Ref' }) ) { const i18nId = getPropStringFromI18NJSX(attributes, 'id'); if (i18nId) {
5
24
13
+ 19 other calls in file
88 89 90 91 92 93 94 95 96 97
JSXElement(nodePath) { const { node } = nodePath; // update Shell attribute if ( t.isJSXOpeningElement(node.openingElement) && t.isJSXIdentifier(node.openingElement.name, { name: 'Shell' }) ) { SHELL_ATTRIBUTE.forEach((attribute) => { const value = layoutConfig[attribute.property] || attribute.value; const nodeValue = attribute.type === 'stringLiteral' ? t.stringLiteral(value) : t.jsxExpressionContainer(t[attribute.type](value));
3
3
11
+ 11 other calls in file
64 65 66 67 68 69 70 71 72 73
name = node.name.name; state.isLegacyRef.value = false; } } else if (state.isLegacyRef.value === false || state.syntacticPlaceholders) { return; } else if (t.isIdentifier(node) || t.isJSXIdentifier(node)) { name = node.name; state.isLegacyRef.value = true; } else if (t.isStringLiteral(node)) { name = node.value;
0
1
1
+ 4 other calls in file
260 261 262 263 264 265 266 267 268 269
const canvasExports = {}; for (let i = 0; i < ast.children.length; i += 1) { const child = ast.children[i]; if (t.isJSXElement(child) && t.isJSXIdentifier(child.openingElement.name) && child.openingElement.name.name === 'Story') { const storyExport = genStoryExport(child, context); const { code } = generate(child, {}); // @ts-ignore
1
2
1
GitHub: john024x/TiendaAvocado
434 435 436 437 438 439 440 441 442
let attribs = []; const extracted = Object.create(null); for (const attr of openingPath.get("attributes")) { if (attr.isJSXAttribute() && t.isJSXIdentifier(attr.node.name)) { const { name } = attr.node.name;
0
0
1
+ 17 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)