diff --git a/src/__tests__/rehype-static-to-dynamic.test.ts b/src/__tests__/rehype-static-to-dynamic.test.ts index f5d99f0d31..a4650e2e09 100644 --- a/src/__tests__/rehype-static-to-dynamic.test.ts +++ b/src/__tests__/rehype-static-to-dynamic.test.ts @@ -1068,9 +1068,7 @@ describe('rehype-static-to-dynamic', () => { assert.strictEqual(output, expected); }); - test( - 'navigator with `.with(...)` merges screenOptions and screenListeners from plain objects', - async () => { + test('navigator with `.with(...)` merges screenOptions and screenListeners from plain objects', async () => { const input = dedent /* javascript */ ` import { useWindowDimensions } from 'react-native'; import { createDrawerNavigator } from '@react-navigation/drawer'; @@ -1155,14 +1153,11 @@ describe('rehype-static-to-dynamic', () => { } `; - assert.strictEqual(output, expected); - } - ); + assert.strictEqual(output, expected); + }); - test( - 'navigator with `.with(...)` merges static objects with wrapper functions', - async () => { - const input = dedent /* javascript */ ` + test('navigator with `.with(...)` merges static objects with wrapper functions', async () => { + const input = dedent /* javascript */ ` import { createDrawerNavigator } from '@react-navigation/drawer'; import { createStaticNavigation } from '@react-navigation/native'; @@ -1196,13 +1191,13 @@ describe('rehype-static-to-dynamic', () => { } `; - const tree = createTestTree(input); - const plugin = rehypeStaticToDynamic(); - await plugin(tree); + const tree = createTestTree(input); + const plugin = rehypeStaticToDynamic(); + await plugin(tree); - const output = extractTransformedCode(tree); + const output = extractTransformedCode(tree); - const expected = dedent /* javascript */ ` + const expected = dedent /* javascript */ ` import { createDrawerNavigator } from '@react-navigation/drawer'; import { NavigationContainer } from '@react-navigation/native'; @@ -1234,14 +1229,11 @@ describe('rehype-static-to-dynamic', () => { } `; - assert.strictEqual(output, expected); - } - ); + assert.strictEqual(output, expected); + }); - test( - 'navigator with `.with(...)` merges static functions with wrapper objects', - async () => { - const input = dedent /* javascript */ ` + test('navigator with `.with(...)` merges static functions with wrapper objects', async () => { + const input = dedent /* javascript */ ` import { createDrawerNavigator } from '@react-navigation/drawer'; import { createStaticNavigation } from '@react-navigation/native'; @@ -1275,13 +1267,13 @@ describe('rehype-static-to-dynamic', () => { } `; - const tree = createTestTree(input); - const plugin = rehypeStaticToDynamic(); - await plugin(tree); + const tree = createTestTree(input); + const plugin = rehypeStaticToDynamic(); + await plugin(tree); - const output = extractTransformedCode(tree); + const output = extractTransformedCode(tree); - const expected = dedent /* javascript */ ` + const expected = dedent /* javascript */ ` import { createDrawerNavigator } from '@react-navigation/drawer'; import { NavigationContainer } from '@react-navigation/native'; @@ -1313,14 +1305,11 @@ describe('rehype-static-to-dynamic', () => { } `; - assert.strictEqual(output, expected); - } - ); + assert.strictEqual(output, expected); + }); - test( - 'navigator with `.with(...)` merges screenOptions and screenListeners when both are functions', - async () => { - const input = dedent /* javascript */ ` + test('navigator with `.with(...)` merges screenOptions and screenListeners when both are functions', async () => { + const input = dedent /* javascript */ ` import { createDrawerNavigator } from '@react-navigation/drawer'; import { createStaticNavigation } from '@react-navigation/native'; @@ -1354,13 +1343,13 @@ describe('rehype-static-to-dynamic', () => { } `; - const tree = createTestTree(input); - const plugin = rehypeStaticToDynamic(); - await plugin(tree); + const tree = createTestTree(input); + const plugin = rehypeStaticToDynamic(); + await plugin(tree); - const output = extractTransformedCode(tree); + const output = extractTransformedCode(tree); - const expected = dedent /* javascript */ ` + const expected = dedent /* javascript */ ` import { createDrawerNavigator } from '@react-navigation/drawer'; import { NavigationContainer } from '@react-navigation/native'; @@ -1392,9 +1381,8 @@ describe('rehype-static-to-dynamic', () => { } `; - assert.strictEqual(output, expected); - } - ); + assert.strictEqual(output, expected); + }); test('drawer navigator', async () => { const input = dedent /* javascript */ ` diff --git a/src/plugins/rehype-static-to-dynamic.ts b/src/plugins/rehype-static-to-dynamic.ts index 324734fe93..7c08cea055 100644 --- a/src/plugins/rehype-static-to-dynamic.ts +++ b/src/plugins/rehype-static-to-dynamic.ts @@ -432,8 +432,11 @@ export async function convertStaticToDynamic(code: string): Promise { } const navigatorVariable = declarator.id.name; // e.g., "MyStack" - const { type: navigatorType, config, withCallback } = - navigatorCallInfo; + const { + type: navigatorType, + config, + withCallback, + } = navigatorCallInfo; navigatorInfos.push({ originalName: navigatorVariable, @@ -1388,10 +1391,7 @@ function createJsxAttributeFromPropValue(key: string, value: t.Expression) { return t.jsxAttribute(t.jsxIdentifier(key), t.stringLiteral(value.value)); } - return t.jsxAttribute( - t.jsxIdentifier(key), - t.jsxExpressionContainer(value) - ); + return t.jsxAttribute(t.jsxIdentifier(key), t.jsxExpressionContainer(value)); } function getJsxAttributeName( @@ -1692,7 +1692,9 @@ function createFallbackMergedFunctionExpression( [argIdentifier], t.objectExpression([ t.spreadElement(createSpreadSourceExpression(staticValue, argIdentifier)), - t.spreadElement(createSpreadSourceExpression(dynamicValue, argIdentifier)), + t.spreadElement( + createSpreadSourceExpression(dynamicValue, argIdentifier) + ), ]) ); } @@ -1733,7 +1735,11 @@ function createMergedNavigatorPropExpression( const params = getMergedFunctionParams(staticValue, dynamicValue); if (staticObject && dynamicObject && params) { - return createMergedFunctionExpression(params, staticObject, dynamicObject); + return createMergedFunctionExpression( + params, + staticObject, + dynamicObject + ); } return createFallbackMergedFunctionExpression(staticValue, dynamicValue); diff --git a/yarn.lock b/yarn.lock index ae01e66a05..195bdcf383 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11056,9 +11056,9 @@ __metadata: linkType: hard "picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.3, picomatch@npm:^2.3.1": - version: 2.3.1 - resolution: "picomatch@npm:2.3.1" - checksum: 26c02b8d06f03206fc2ab8d16f19960f2ff9e81a658f831ecb656d8f17d9edc799e8364b1f4a7873e89d9702dff96204be0fa26fe4181f6843f040f819dac4be + version: 2.3.2 + resolution: "picomatch@npm:2.3.2" + checksum: a554d1709e59be97d1acb9eaedbbc700a5c03dbd4579807baed95100b00420bc729335440ef15004ae2378984e2487a7c1cebd743cfdb72b6fa9ab69223c0d61 languageName: node linkType: hard