Browse Source

fix lint errors

Yuki Takei 3 years ago
parent
commit
4ff7494b12
2 changed files with 13 additions and 20 deletions
  1. 1 12
      packages/app/src/pages/_app.page.tsx
  2. 12 8
      packages/app/src/utils/swr-utils.ts

+ 1 - 12
packages/app/src/pages/_app.page.tsx

@@ -1,6 +1,5 @@
 import React, { ReactElement, ReactNode, useEffect } from 'react';
 
-import { isServer } from '@growi/core';
 import { NextPage } from 'next';
 import { appWithTranslation } from 'next-i18next';
 import { AppProps } from 'next/app';
@@ -25,16 +24,6 @@ import '~/styles/theme/_apply-colors.scss';
 
 const isDev = process.env.NODE_ENV === 'development';
 
-const swrConfig = Object.assign(
-  {},
-  swrGlobalConfiguration,
-  // set the request scoped cache provider in server
-  isServer()
-    ? {
-      provider: (cache: any) => new Map<string, any>(cache),
-    }
-    : {},
-);
 
 // eslint-disable-next-line @typescript-eslint/ban-types
 export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
@@ -73,7 +62,7 @@ function GrowiApp({ Component, pageProps }: GrowiAppProps): JSX.Element {
   const getLayout = Component.getLayout ?? (page => page);
 
   return (
-    <SWRConfig value={swrConfig}>
+    <SWRConfig value={swrGlobalConfiguration}>
       {getLayout(<Component {...pageProps} />)}
     </SWRConfig>
   );

+ 12 - 8
packages/app/src/utils/swr-utils.ts

@@ -1,9 +1,13 @@
-import { ProviderConfiguration, PublicConfiguration } from 'swr/dist/types';
+import { isServer } from '@growi/core';
 
-export type SWRConfigValue = Partial<PublicConfiguration> & Partial<ProviderConfiguration> & {
-  provider?: (cache) => any | undefined,
-};
-
-export const swrGlobalConfiguration: SWRConfigValue = {
-  errorRetryCount: 1,
-};
+export const swrGlobalConfiguration = Object.assign(
+  {
+    errorRetryCount: 1,
+  },
+  // set the request scoped cache provider in server
+  isServer()
+    ? {
+      provider: (cache: any) => new Map<string, any>(cache),
+    }
+    : {},
+);