How to use the isObjectExpression function from @babel/types
Find comprehensive JavaScript @babel/types.isObjectExpression code examples handpicked from public code repositorys.
89 90 91 92 93 94 95 96 97 98
} if (!returnPath) { returnPath = t.isArrowFunctionExpression(node) && node.body && t.isObjectExpression(node.body) && matchProp("controller", (path.get && path.get("body.properties") || node.body.properties)); } return limit("directive", returnPath);
156
244
6
+ 5 other calls in file
121 122 123 124 125 126 127 128 129 130
result.push(value); } } function isStringObject(obj) { return t.isObjectExpression(obj) && obj.properties[0] && obj.properties[0].key.name === '__html' && t.isStringLiteral(obj.properties[0].value); }
69
4
1
19 20 21 22 23 24 25 26 27 28
if ( t.isMemberExpression(path.node.left) && t.isThisExpression(path.node.left.object) && t.isIdentifier(path.node.left.property) && path.node.left.property.name === 'hooks' && t.isObjectExpression(path.node.right) ) { const properties = path.node.right.properties .filter(p => t.isProperty(p)) .filter(p => t.isIdentifier(p.key))
22
151
8
+ 7 other calls in file
43 44 45 46 47 48 49 50 51 52
let targetPropertiesRef = null; const optionsArgSet = new Set(); this.traverseVueOptions(targetSource.ast, (node) => { const [optionsArg] = node.arguments; if (optionsArg && t.isObjectExpression(optionsArg)) { targetPropertiesRef = optionsArg.properties; optionsArg.properties.forEach((node) => { optionsArgSet.add(SourceSnippet.astToCode(node)); });
5
11
17
+ 3 other calls in file
GitHub: suchipi/tofu
102 103 104 105 106 107 108 109 110 111
node.left.end + code.slice(node.left.end).indexOf(node.operator); return [start, start + node.operator.length]; } if ( (t.isArrayExpression(node) || t.isObjectExpression(node)) && recursionDepth > 0 ) { if ((node.elements || node.properties).length == 0) { return start;
4
0
1
+ 13 other calls in file
GitHub: suchipi/tofu
92 93 94 95 96 97 98 99 100 101
return [node.left.end + 1, node.right.start - 1]; }; }) as Action; const isInCollectionExpression = ([start, end]: Cursor) => node => ((t.isArrayExpression(node) || t.isObjectExpression(node)) && start > node.start && end < node.end) || (t.isCallExpression(node) && start >
4
0
1
+ 5 other calls in file
84 85 86 87 88 89 90 91 92 93
} throw e; } case types.isObjectExpression(node): return { type: 'object', props: await getObjectDescriptor({ node, ast, cwd }), };
2
11
222
+ 3 other calls in file
94 95 96 97 98 99 100 101 102 103
// No handling for ^^ right now } else if ( t.isConditionalExpression(path.node.init) ){ // No handling for ^^ right now } else if ( t.isLogicalExpression(path.node.init) ){ // No handling for ^^ right now } else if ( t.isObjectExpression(path.node.init) ) { // No handling for ^^ right now - i think this is fine generally actually - if objects // are being built up, leaving this will be clearer } else if ( t.isCallExpression(path.node.init) ) { // No handling for ^^ right now
1
6
7
86 87 88 89 90 91 92 93 94 95
const { node } = astPath; // Handle only the locale object we want to update if (types.isIdentifier(node.key, { name: locale })) { invariant( types.isObjectExpression(node.value), `Internal error merging translations in ${filename}: '${locale}' must hold an object expression. Encountered ${node.value.type} instead.`, ); const { properties } = node.value;
1
1
7
324 325 326 327 328 329 330 331 332 333
removeUnusedValue () { // global.log('清理无用变量与函数') return { VariableDeclarator (path) { const { id, init } = path.node if (!(t.isLiteral(init) || t.isObjectExpression(init) || t.isFunctionExpression(init))) return const binding = path.scope.getBinding((id).name) if (!binding || binding.constantViolations.length > 0) return if (binding.referencePaths.length > 0) return
220
0
26
414 415 416 417 418 419 420 421 422 423
*/ removeUnusedValue() { traverse(this.ast, { VariableDeclarator(path) { const { id, init } = path.node if (!(t.isLiteral(init) || t.isObjectExpression(init))) return //只处理字面量 const binding = path.scope.getBinding(id.name) if (!binding || binding.constantViolations.length > 0) return if (binding.referencePaths.length > 0) return
43
73
5
+ 2 other calls in file
210 211 212 213 214 215 216 217 218 219
(t.isCallExpression(argumentPath.node) || t.isNewExpression(argumentPath.node) || t.isIdentifier(argumentPath.node))) || t.isMemberExpression(argumentPath.node) || t.isLiteral(argumentPath.node) || t.isObjectExpression(argumentPath.node) || t.isFunction(argumentPath.node) || t.isClass(argumentPath.node) ) { return;
0
3
3
+ 28 other calls in file
44 45 46 47 48 49 50 51 52 53
// Returns the ObjectExpression associated with the defineConfig call, // so we can add in the "toAdd" object property function getDefineConfigExpression(node) { for (const possibleIdentifier of defineConfigIdentifiers) { if (typeof possibleIdentifier === 'string') { if (t.isIdentifier(node.callee) && node.callee.name === possibleIdentifier && t.isObjectExpression(node.arguments[0])) { return node.arguments[0]; } } else if (Array.isArray(possibleIdentifier)) {
0
0
1
+ 9 other calls in file
28 29 30 31 32 33 34 35 36 37
async getContentNode() { if(this.nlsFilePath) { const fileStr = Util.readFileSync(this.nlsFilePath) const ast = parser.parse(fileStr) const content = await Util.findFirstNode(ast, node => { return t.isObjectExpression(node) //&& node.parent.callee.name === 'define' }) if(content) { const contentNode = t.variableDeclaration('const', [ t.variableDeclarator(t.identifier('nls'), content)
0
0
0
23 24 25 26 27 28 29 30 31
ObjectProperty(path) { const { key, value } = path.node; if ( types.isIdentifier(key) && availableLocales.has(key.name) && types.isObjectExpression(value) ) { const localeName = key.name; const { properties } = value;
0
0
0
138 139 140 141 142 143 144 145 146 147
const { key, value } = astPath.node; if ( types.isIdentifier(key) && availableLocales.has(key.name) && types.isObjectExpression(value) && key.name !== locale ) { const { properties } = value; const newProperties = [];
0
0
0
+ 3 other calls in file
GitHub: redexp/adv-parser
16 17 18 19 20 21 22 23 24 25
return ( t.isUnaryExpression(root) && root.operator === '!' && t.isUnaryExpression(root.argument) && root.argument.operator === '!' && t.isObjectExpression(root.argument.argument) ); } function asPure(root) {
0
0
2
+ 5 other calls in file
45 46 47 48 49 50 51 52 53
return t.isObjectProperty(prop) && t.isIdentifier(prop.key) && prop.key.name === 'components' })[0] if (componentsProperty && t.isObjectExpression(componentsProperty.value)) { handleComponentsObjectExpression(componentsProperty.value, path, state) } }
0
0
506
+ 19 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)