|
5 | 5 | * @param {import('jscodeshift').JSCodeshift} context.j
|
6 | 6 | * @param {ReturnType<import('jscodeshift').Core>} context.root
|
7 | 7 | */
|
8 |
| -module.exports = function rootOptionToUse(context, rootOptionName) { |
| 8 | +module.exports = function rootPropToUse(context, rootPropName) { |
9 | 9 | const { j, root } = context
|
10 | 10 |
|
11 | 11 | const appRoots = root.find(j.CallExpression, {
|
12 | 12 | callee: { name: 'createApp' },
|
13 | 13 | arguments: args =>
|
14 | 14 | args.length === 1 &&
|
15 | 15 | args[0].type === 'ObjectExpression' &&
|
16 |
| - args[0].properties.find(p => p.key.name === rootOptionName) |
| 16 | + args[0].properties.find(p => p.key.name === rootPropName) |
17 | 17 | })
|
18 | 18 |
|
19 | 19 | appRoots.replaceWith(({ node: createAppCall }) => {
|
20 |
| - const rootOptions = createAppCall.arguments[0] |
21 |
| - const propertyIndex = rootOptions.properties.findIndex( |
22 |
| - p => p.key.name === rootOptionName |
| 20 | + const rootProps = createAppCall.arguments[0] |
| 21 | + const propertyIndex = rootProps.properties.findIndex( |
| 22 | + p => p.key.name === rootPropName |
23 | 23 | )
|
24 |
| - const [{ value: pluginInstance }] = rootOptions.properties.splice( |
| 24 | + const [{ value: pluginInstance }] = rootProps.properties.splice( |
25 | 25 | propertyIndex,
|
26 | 26 | 1
|
27 | 27 | )
|
28 | 28 |
|
29 | 29 | return j.callExpression(
|
30 | 30 | j.memberExpression(
|
31 |
| - j.callExpression(j.identifier('createApp'), [rootOptions]), |
| 31 | + j.callExpression(j.identifier('createApp'), [rootProps]), |
32 | 32 | j.identifier('use')
|
33 | 33 | ),
|
34 | 34 | [pluginInstance]
|
|
0 commit comments