(
node: t.CallExpression,
arg_idx: number,
name: string,
)
| 27 | } |
| 28 | |
| 29 | function addNameToOptions( |
| 30 | node: t.CallExpression, |
| 31 | arg_idx: number, |
| 32 | name: string, |
| 33 | ): void { |
| 34 | |
| 35 | let name_property = t.objectProperty(NAME_ID, t.stringLiteral(name)) |
| 36 | |
| 37 | // fill in-between arguments with undefined |
| 38 | while (node.arguments.length < arg_idx) { |
| 39 | node.arguments.push(UNDEFINED_ID) |
| 40 | } |
| 41 | |
| 42 | // no options argument |
| 43 | if (node.arguments.length === arg_idx) { |
| 44 | node.arguments.push(t.objectExpression([name_property])) |
| 45 | } |
| 46 | else { |
| 47 | // existing options argument |
| 48 | const options = node.arguments[arg_idx]! |
| 49 | if (options.type !== 'ObjectExpression') { |
| 50 | return |
| 51 | } |
| 52 | |
| 53 | // Check there isn't already a "name" property |
| 54 | if (options.properties.some(prop => |
| 55 | prop.type === 'ObjectProperty' && |
| 56 | prop.key.type === 'Identifier' && |
| 57 | prop.key.name === NAME_ID.name, |
| 58 | )) { |
| 59 | return |
| 60 | } |
| 61 | |
| 62 | options.properties.unshift(name_property) |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | type Source = |
| 67 | | 'createSignal' |
no outgoing calls
no test coverage detected
searching dependent graphs…