Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/jest-helpers/src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import makeHelpers from '..'
import { RenderWithThemeFn } from '../helpers/renderWithTheme'
import { ShouldMatchEmotionSnapshotFn } from '../helpers/shouldMatchEmotionSnapshot'
import { ShouldMatchEmotionSnapshotWithPortalFn } from '../helpers/shouldMatchEmotionSnapshotWithPortal'
import type { RenderWithThemeFn } from '../helpers/renderWithTheme'
import type { ShouldMatchEmotionSnapshotFn } from '../helpers/shouldMatchEmotionSnapshot'
import type { ShouldMatchEmotionSnapshotWithPortalFn } from '../helpers/shouldMatchEmotionSnapshotWithPortal'

describe('@jest-helpers', () => {
let renderWithTheme: RenderWithThemeFn<unknown>
Expand Down
5 changes: 3 additions & 2 deletions packages/jest-helpers/src/helpers/renderWithTheme.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import createCache from '@emotion/cache'
import { CacheProvider } from '@emotion/react'
import { RenderOptions, render } from '@testing-library/react'
import { FC, ReactNode } from 'react'
import type { RenderOptions } from '@testing-library/react'
import { render } from '@testing-library/react'
import type { FC, ReactNode } from 'react'

const emotionCache = createCache({
key: 'cache',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RenderOptions, render } from '@testing-library/react'
import { ReactNode } from 'react'
import { RenderWithThemeFn } from './renderWithTheme'
import type { RenderOptions, render } from '@testing-library/react'
import type { ReactNode } from 'react'
import type { RenderWithThemeFn } from './renderWithTheme'

interface Options<Theme> {
type Options<Theme> = {
options?: RenderOptions
transform?: (node: ReturnType<typeof render>) => Promise<void> | void
theme?: Theme
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RenderOptions, render } from '@testing-library/react'
import { ReactNode } from 'react'
import { RenderWithThemeFn } from './renderWithTheme'
import type { RenderOptions, render } from '@testing-library/react'
import type { ReactNode } from 'react'
import type { RenderWithThemeFn } from './renderWithTheme'

interface Options<Theme> {
type Options<Theme> = {
options?: RenderOptions
transform?: (node: ReturnType<typeof render>) => Promise<void> | void
theme?: Theme
Expand Down
20 changes: 9 additions & 11 deletions packages/jest-helpers/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { CreateSerializerOptions, createSerializer } from '@emotion/jest'
import { FC, ReactNode } from 'react'
import makeRenderWithTheme, {
RenderWithThemeFn,
} from './helpers/renderWithTheme'
import makeShouldMatchEmotionSnapshot, {
ShouldMatchEmotionSnapshotFn,
} from './helpers/shouldMatchEmotionSnapshot'
import makeShouldMatchEmotionSnapshotWithPortal, {
ShouldMatchEmotionSnapshotWithPortalFn,
} from './helpers/shouldMatchEmotionSnapshotWithPortal'
import type { CreateSerializerOptions } from '@emotion/jest'
import { createSerializer } from '@emotion/jest'
import type { FC, ReactNode } from 'react'
import type { RenderWithThemeFn } from './helpers/renderWithTheme'
import makeRenderWithTheme from './helpers/renderWithTheme'
import type { ShouldMatchEmotionSnapshotFn } from './helpers/shouldMatchEmotionSnapshot'
import makeShouldMatchEmotionSnapshot from './helpers/shouldMatchEmotionSnapshot'
import type { ShouldMatchEmotionSnapshotWithPortalFn } from './helpers/shouldMatchEmotionSnapshotWithPortal'
import makeShouldMatchEmotionSnapshotWithPortal from './helpers/shouldMatchEmotionSnapshotWithPortal'

export { default as makeRenderWithTheme } from './helpers/renderWithTheme'

Expand Down
1 change: 1 addition & 0 deletions packages/outdated-browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const STORAGE_KEY = '__outdated'
const ignore = sessionStorage.getItem(STORAGE_KEY) || 'false'

declare global {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Window {
closeOutdated: () => void
}
Expand Down
13 changes: 3 additions & 10 deletions packages/use-dataloader/src/DataLoaderProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import PropTypes from 'prop-types'
import {
ReactElement,
ReactNode,
createContext,
useCallback,
useContext,
useMemo,
useRef,
} from 'react'
import type { ReactElement, ReactNode } from 'react'
import { createContext, useCallback, useContext, useMemo, useRef } from 'react'
import {
DEFAULT_MAX_CONCURRENT_REQUESTS,
KEY_IS_NOT_STRING_ERROR,
} from './constants'
import DataLoader from './dataloader'
import { OnErrorFn, PromiseType } from './types'
import type { OnErrorFn, PromiseType } from './types'

type CachedData = Record<string, unknown>
type Reloads = Record<string, () => Promise<void | unknown>>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { render, renderHook, screen, waitFor } from '@testing-library/react'
import { ReactNode } from 'react'
import type { ReactNode } from 'react'
import DataLoaderProvider, { useDataLoaderContext } from '../DataLoaderProvider'
import { KEY_IS_NOT_STRING_ERROR, StatusEnum } from '../constants'

Expand Down
4 changes: 2 additions & 2 deletions packages/use-dataloader/src/__tests__/useDataLoader.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
import { renderHook, waitFor } from '@testing-library/react'
import { ReactNode } from 'react'
import type { ReactNode } from 'react'
import DataLoaderProvider, { useDataLoaderContext } from '../DataLoaderProvider'
import { KeyType, UseDataLoaderConfig } from '../types'
import type { KeyType, UseDataLoaderConfig } from '../types'
import useDataLoader from '../useDataLoader'

type UseDataLoaderHookProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable no-console */
import { act, renderHook, waitFor } from '@testing-library/react'
import { ReactNode } from 'react'
import type { ReactNode } from 'react'
import DataLoaderProvider from '../DataLoaderProvider'
import { UsePaginatedDataLoaderMethodParams } from '../types'
import type { UsePaginatedDataLoaderMethodParams } from '../types'
import usePaginatedDataLoader from '../usePaginatedDataLoader'

const PROMISE_TIMEOUT = 5
Expand Down
2 changes: 1 addition & 1 deletion packages/use-dataloader/src/dataloader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DEFAULT_MAX_CONCURRENT_REQUESTS, StatusEnum } from './constants'
import { PromiseType } from './types'
import type { PromiseType } from './types'

export type DataLoaderConstructorArgs<ResultType> = {
key: string
Expand Down
4 changes: 2 additions & 2 deletions packages/use-dataloader/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type NeedPollingType<ResultType> =
* @property {number} [dataLifetime=undefined] Time before data from previous success is considered as outdated (in millisecond)
* @property {NeedPollingType} [needPolling=true] When pollingInterval is set you can set a set a custom callback to know if polling is enabled
*/
export interface UseDataLoaderConfig<ResultType, ErrorType> {
export type UseDataLoaderConfig<ResultType, ErrorType> = {
enabled?: boolean
initialData?: ResultType
keepPreviousData?: boolean
Expand All @@ -50,7 +50,7 @@ export interface UseDataLoaderConfig<ResultType, ErrorType> {
* @property {string} error the error occured during the request
* @property {Function} reload reload the data
*/
export interface UseDataLoaderResult<ResultType, ErrorType> {
export type UseDataLoaderResult<ResultType, ErrorType> = {
data?: ResultType
error?: ErrorType
isError: boolean
Expand Down
2 changes: 1 addition & 1 deletion packages/use-dataloader/src/useDataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useDataLoaderContext } from './DataLoaderProvider'
import { StatusEnum } from './constants'
import { marshalQueryKey } from './helpers'
import {
import type {
KeyType,
PromiseType,
UseDataLoaderConfig,
Expand Down
2 changes: 1 addition & 1 deletion packages/use-dataloader/src/usePaginatedDataLoader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
import {
import type {
KeyType,
PromiseType,
UsePaginatedDataLoaderConfig,
Expand Down
7 changes: 4 additions & 3 deletions packages/use-gtm/src/__tests__/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { fireEvent, renderHook } from '@testing-library/react'
import mockdate from 'mockdate'
import { ReactNode } from 'react'
import GTMProvider, { SendGTM, useGTM } from '..'
import { GTMProviderProps } from '../useGTM'
import type { ReactNode } from 'react'
import type { SendGTM } from '..'
import GTMProvider, { useGTM } from '..'
import type { GTMProviderProps } from '../useGTM'

const defaultEvents = {
sampleEvent: (sendGTM?: SendGTM) => (extraValue: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/use-gtm/src/scripts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GTMEnvironment } from './types'
import type { GTMEnvironment } from './types'

export const DATALAYER_NAME = 'dataLayer'
export const LOAD_ERROR_EVENT = 'gtm_loading_error'
Expand Down
8 changes: 5 additions & 3 deletions packages/use-gtm/src/useGTM.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { ReactNode, createContext, useContext, useEffect, useMemo } from 'react'
import type { ReactNode } from 'react'
import { createContext, useContext, useEffect, useMemo } from 'react'
import generateScripts, { DATALAYER_NAME, LOAD_ERROR_EVENT } from './scripts'
import { DataLayerEvent, Events, GTMEnvironment, SendGTM } from './types'
import type { DataLayerEvent, Events, GTMEnvironment, SendGTM } from './types'

interface GTMContextInterface<T extends Events = Events> {
type GTMContextInterface<T extends Events = Events> = {
sendGTM: SendGTM | undefined
events: { [K in keyof T]: ReturnType<T[K]> }
}

declare global {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface Window {
dataLayer: DataLayerEvent[] | undefined
}
Expand Down
3 changes: 2 additions & 1 deletion packages/use-i18n/src/__tests__/formatDate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import formatDate, { FormatDateOptions, supportedFormats } from '../formatDate'
import type { FormatDateOptions } from '../formatDate'
import formatDate, { supportedFormats } from '../formatDate'

const locales = ['en', 'fr', 'de', 'ro', 'es']

Expand Down
3 changes: 2 additions & 1 deletion packages/use-i18n/src/__tests__/formatUnit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import formatUnit, { FormatUnitOptions, supportedUnits } from '../formatUnit'
import type { FormatUnitOptions } from '../formatUnit'
import formatUnit, { supportedUnits } from '../formatUnit'

const locales = ['en', 'fr', 'ro']

Expand Down
2 changes: 1 addition & 1 deletion packages/use-i18n/src/__tests__/usei18n.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { act, renderHook, waitFor } from '@testing-library/react'
import mockdate from 'mockdate'
import { ReactNode } from 'react'
import type { ReactNode } from 'react'
import I18n, { useI18n, useTranslation } from '..'
import en from './locales/en.json'
import es from './locales/es.json'
Expand Down
2 changes: 1 addition & 1 deletion packages/use-i18n/src/formatUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export const supportedUnits: Partial<
),
}

export interface FormatUnitOptions {
export type FormatUnitOptions = {
unit: SupportedUnits
short?: boolean
}
Expand Down
7 changes: 4 additions & 3 deletions packages/use-i18n/src/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { NumberFormatOptions } from '@formatjs/ecma402-abstract'
import memoize, { Cache, strategies } from '@formatjs/fast-memoize'
import type { Cache } from '@formatjs/fast-memoize'
import memoize, { strategies } from '@formatjs/fast-memoize'
import IntlTranslationFormat from 'intl-messageformat'

// Deeply inspired by https://github.com/formatjs/formatjs/blob/7406e526a9c5666cee22cc2316dad1fa1d88697c/packages/intl-messageformat/src/core.ts
Expand All @@ -8,7 +9,7 @@ import IntlTranslationFormat from 'intl-messageformat'
// Intl.ListFormat in at TC39 stage 4 and is widely adopted in browsers
// So we expose homegrown types
// https://github.com/tc39/proposal-intl-list-format
export interface IntlListFormatOptions {
export type IntlListFormatOptions = {
localeMatcher?: 'best fit' | 'lookup'
type?: 'conjunction' | 'disjunction' | 'unit'
style?: 'long' | 'short' | 'narrow'
Expand All @@ -20,7 +21,7 @@ declare abstract class IntlListFormat {
format: (items: string[]) => string
}

interface BaseFormatters {
type BaseFormatters = {
getNumberFormat(
locales?: string | string[],
opts?: NumberFormatOptions,
Expand Down
21 changes: 10 additions & 11 deletions packages/use-i18n/src/usei18n.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import type { NumberFormatOptions } from '@formatjs/ecma402-abstract'
import {
Locale as DateFnsLocale,
formatDistanceToNow,
formatDistanceToNowStrict,
} from 'date-fns'
import type { Locale as DateFnsLocale } from 'date-fns'
import { formatDistanceToNow, formatDistanceToNowStrict } from 'date-fns'
import type { BaseLocale } from 'international-types'
import PropTypes from 'prop-types'
import type { ReactElement, ReactNode } from 'react'
import {
ReactElement,
ReactNode,
createContext,
useCallback,
useContext,
Expand All @@ -17,9 +13,12 @@ import {
useState,
} from 'react'
import ReactDOM from 'react-dom'
import dateFormat, { FormatDateOptions } from './formatDate'
import unitFormat, { FormatUnitOptions } from './formatUnit'
import formatters, { IntlListFormatOptions } from './formatters'
import type { FormatDateOptions } from './formatDate'
import dateFormat from './formatDate'
import type { FormatUnitOptions } from './formatUnit'
import unitFormat from './formatUnit'
import type { IntlListFormatOptions } from './formatters'
import formatters from './formatters'
import type { ReactParamsObject, ScopedTranslateFn, TranslateFn } from './types'

const LOCALE_ITEM_STORAGE = 'locale'
Expand Down Expand Up @@ -62,7 +61,7 @@ const getCurrentLocale = ({
)
}

interface Context<Locale extends BaseLocale> {
type Context<Locale extends BaseLocale> = {
currentLocale: string
dateFnsLocale?: DateFnsLocale
datetime: (
Expand Down
2 changes: 1 addition & 1 deletion packages/use-media/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { DependencyList, EffectCallback } from 'react'
import type { DependencyList, EffectCallback } from 'react'

export type Effect = (effect: EffectCallback, deps?: DependencyList) => void
2 changes: 1 addition & 1 deletion packages/use-media/src/useMedia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useLayoutEffect, useState } from 'react'
import { Effect } from './types'
import type { Effect } from './types'

function noop() {}

Expand Down
6 changes: 4 additions & 2 deletions packages/use-query-params/src/__tests__/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { act, renderHook } from '@testing-library/react'
import { History, createMemoryHistory } from 'history'
import { ReactNode, useLayoutEffect, useState } from 'react'
import type { History } from 'history'
import { createMemoryHistory } from 'history'
import type { ReactNode } from 'react'
import { useLayoutEffect, useState } from 'react'
import { MemoryRouter, Router } from 'react-router-dom'
import useQueryParams from '..'

Expand Down
2 changes: 1 addition & 1 deletion packages/use-query-params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { parse, stringify } from 'query-string'
import { useCallback, useMemo } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'

interface Options {
type Options = {
/** Set to true to push a new entry onto the history stack */
push: boolean
}
Expand Down
5 changes: 3 additions & 2 deletions packages/use-segment/src/__tests__/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AnalyticsBrowser, Context } from '@segment/analytics-next'
import type { Context } from '@segment/analytics-next'
import { AnalyticsBrowser } from '@segment/analytics-next'
import { renderHook, waitFor } from '@testing-library/react'
import { ReactNode } from 'react'
import type { ReactNode } from 'react'
import waitForExpect from 'wait-for-expect'
import SegmentProvider, { useSegment } from '..'
import type { Analytics, OnEventError, SegmentProviderProps } from '..'
Expand Down
12 changes: 3 additions & 9 deletions packages/use-segment/src/useSegment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ import type {
AnalyticsBrowserSettings,
InitOptions,
} from '@segment/analytics-next'
import {
ReactNode,
createContext,
useContext,
useEffect,
useMemo,
useState,
} from 'react'
import type { ReactNode } from 'react'
import { createContext, useContext, useEffect, useMemo, useState } from 'react'

export type OnEventError = (error: Error) => Promise<void> | void
type EventFunction = (...args: never[]) => Promise<void>
Expand All @@ -20,7 +14,7 @@ type Events = Record<
(analytics?: Analytics, onEventError?: OnEventError) => EventFunction
>

interface SegmentContextInterface<T extends Events = Events> {
type SegmentContextInterface<T extends Events = Events> = {
analytics: Analytics | undefined
events: { [K in keyof T]: ReturnType<T[K]> }
}
Expand Down
2 changes: 1 addition & 1 deletion packages/validate-icu-locales/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import { parse } from '@formatjs/icu-messageformat-parser'
import { ParserError } from '@formatjs/icu-messageformat-parser/error'
import type { ParserError } from '@formatjs/icu-messageformat-parser/error'
import { readFile } from 'fs/promises'
import { globby } from 'globby'
import { importFromString } from 'module-from-string'
Expand Down
Loading