Skip to content

Commit 792b8d4

Browse files
authored
Enable verbatimModuleSyntax and related eslint rule, fix imports (#125)
* Enable verbatimModuleSyntax and related eslint rule, fix imports * extract type imports from regular imports and add missing import type * fix sample imports
1 parent 61337d4 commit 792b8d4

File tree

15 files changed

+46
-48
lines changed

15 files changed

+46
-48
lines changed

modules/@shopify/checkout-sheet-kit/src/context.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
*/
2323

24-
import React, {PropsWithChildren, useCallback, useMemo, useRef} from 'react';
25-
import {EmitterSubscription} from 'react-native';
24+
import React, {useCallback, useMemo, useRef} from 'react';
25+
import type {PropsWithChildren} from 'react';
26+
import type {EmitterSubscription} from 'react-native';
2627
import {ShopifyCheckoutSheet} from './index';
2728
import type {
2829
AddEventListener,

modules/@shopify/checkout-sheet-kit/src/index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
*/
2323

24-
import {EmitterSubscription} from 'react-native';
25-
import {PixelEvent} from './pixels';
26-
import {CheckoutCompletedEvent} from './events';
27-
import {CheckoutException} from './errors';
24+
import type {EmitterSubscription} from 'react-native';
25+
import type {PixelEvent} from './pixels';
26+
import type {CheckoutCompletedEvent} from './events';
27+
import type {CheckoutException} from './errors';
2828

2929
export type Maybe<T> = T | undefined;
3030

modules/@shopify/checkout-sheet-kit/src/index.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
*/
2323

24-
import {
25-
NativeModules,
26-
NativeEventEmitter,
27-
EmitterSubscription,
28-
} from 'react-native';
24+
import {NativeModules, NativeEventEmitter} from 'react-native';
25+
import type {EmitterSubscription} from 'react-native';
2926
import {ShopifyCheckoutSheetProvider, useShopifyCheckoutSheet} from './context';
3027
import {ColorScheme} from './index.d';
3128
import type {
@@ -34,19 +31,18 @@ import type {
3431
Configuration,
3532
ShopifyCheckoutSheetKit,
3633
} from './index.d';
34+
import type {CheckoutException, CheckoutNativeError} from './errors.d';
3735
import {
38-
CheckoutException,
3936
CheckoutExpiredError,
4037
CheckoutClientError,
4138
CheckoutHTTPError,
4239
ConfigurationError,
4340
InternalError,
44-
CheckoutNativeError,
4541
CheckoutNativeErrorType,
4642
GenericError,
4743
} from './errors.d';
4844
import {CheckoutErrorCode} from './errors.d';
49-
import {CheckoutCompletedEvent} from './events.d';
45+
import type {CheckoutCompletedEvent} from './events.d';
5046
import type {CustomEvent, PixelEvent, StandardEvent} from './pixels.d';
5147

5248
const RNShopifyCheckoutSheetKit = NativeModules.ShopifyCheckoutSheetKit;

modules/@shopify/checkout-sheet-kit/tsconfig.build.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"resolveJsonModule": true,
2222
"skipLibCheck": true,
2323
"strict": true,
24-
"target": "esnext"
24+
"target": "esnext",
25+
"verbatimModuleSyntax": true,
2526
}
2627
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"extends": "@react-native",
7676
"rules": {
7777
"@typescript-eslint/no-shadow": "off",
78+
"@typescript-eslint/consistent-type-imports": "error",
7879
"no-console": "error"
7980
}
8081
},

sample/src/App.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
*/
2323

24-
import React, {PropsWithChildren, ReactNode, useEffect} from 'react';
24+
import type {PropsWithChildren, ReactNode} from 'react';
25+
import React, {useEffect} from 'react';
2526
import {Link, NavigationContainer} from '@react-navigation/native';
2627
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
2728
import {createNativeStackNavigator} from '@react-navigation/native-stack';
@@ -32,22 +33,24 @@ import Icon from 'react-native-vector-icons/Entypo';
3233
import CatalogScreen from './screens/CatalogScreen';
3334
import SettingsScreen from './screens/SettingsScreen';
3435

36+
import type {Configuration} from '@shopify/checkout-sheet-kit';
3537
import {
3638
ColorScheme,
37-
Configuration,
3839
ShopifyCheckoutSheetProvider,
3940
useShopifyCheckoutSheet,
40-
type CheckoutCompletedEvent,
41-
type CheckoutException,
42-
type PixelEvent,
41+
} from '@shopify/checkout-sheet-kit';
42+
import type {
43+
CheckoutCompletedEvent,
44+
CheckoutException,
45+
PixelEvent,
4346
} from '@shopify/checkout-sheet-kit';
4447
import {ConfigProvider} from './context/Config';
4548
import {ThemeProvider, getNavigationTheme, useTheme} from './context/Theme';
4649
import {Appearance, StatusBar} from 'react-native';
4750
import {CartProvider, useCart} from './context/Cart';
4851
import CartScreen from './screens/CartScreen';
4952
import ProductDetailsScreen from './screens/ProductDetailsScreen';
50-
import {ProductVariant, ShopifyProduct} from '../@types';
53+
import type {ProductVariant, ShopifyProduct} from '../@types';
5154
import ErrorBoundary from './ErrorBoundary';
5255

5356
const colorScheme = ColorScheme.web;

sample/src/context/Cart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type {PropsWithChildren} from 'react';
12
import React, {
2-
PropsWithChildren,
33
createContext,
44
useCallback,
55
useEffect,

sample/src/context/Config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import type {PropsWithChildren} from 'react';
12
import React, {
2-
PropsWithChildren,
33
createContext,
44
useCallback,
55
useEffect,
66
useMemo,
77
useState,
88
} from 'react';
9+
import type {Configuration} from '@shopify/checkout-sheet-kit';
910
import {
1011
ColorScheme,
11-
Configuration,
1212
useShopifyCheckoutSheet,
1313
} from '@shopify/checkout-sheet-kit';
1414
import {useTheme} from './Theme';

sample/src/context/Theme.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import React, {
2-
PropsWithChildren,
3-
createContext,
4-
useCallback,
5-
useMemo,
6-
useState,
7-
} from 'react';
8-
import {Appearance, ColorSchemeName, useColorScheme} from 'react-native';
1+
import type {PropsWithChildren} from 'react';
2+
import React, {createContext, useCallback, useMemo, useState} from 'react';
3+
import type {ColorSchemeName} from 'react-native';
4+
import {Appearance, useColorScheme} from 'react-native';
95
import {DarkTheme, DefaultTheme} from '@react-navigation/native';
106
import {ColorScheme} from '@shopify/checkout-sheet-kit';
117

sample/src/screens/CartScreen.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ import Icon from 'react-native-vector-icons/Entypo';
3838
import {useShopifyCheckoutSheet} from '@shopify/checkout-sheet-kit';
3939
import useShopify from '../hooks/useShopify';
4040

41-
import type {CartItem, CartLineItem} from '../../@types';
42-
import {Colors, useTheme} from '../context/Theme';
41+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
42+
import type {CartLineItem, CartItem} from '../../@types';
43+
import type {Colors} from '../context/Theme';
44+
import {useTheme} from '../context/Theme';
4345
import {useCart} from '../context/Cart';
4446
import {currency} from '../utils';
4547

0 commit comments

Comments
 (0)