From 01deaf8927c06cdf694ab6a344a5ab77bd4efe04 Mon Sep 17 00:00:00 2001 From: ukorvl Date: Sat, 21 Oct 2023 15:32:56 +0400 Subject: [PATCH] apply formatter #14 --- lib/__tests__/OnScreen.test.tsx | 16 ++++++++-------- lib/__tests__/testUtils.ts | 14 +++++++------- lib/__tests__/useOnScreen.test.tsx | 18 +++++++++--------- lib/__tests__/withOnScreen.test.tsx | 18 +++++++++--------- lib/index.ts | 12 ++++++------ lib/internal/index.ts | 2 +- lib/useOnScreen.tsx | 2 +- lib/withOnScreen.tsx | 12 ++++++------ package.json | 4 ++-- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/lib/__tests__/OnScreen.test.tsx b/lib/__tests__/OnScreen.test.tsx index fda70b3..1ea0992 100644 --- a/lib/__tests__/OnScreen.test.tsx +++ b/lib/__tests__/OnScreen.test.tsx @@ -1,24 +1,24 @@ -import React from 'react'; -import { OnScreen } from '../OnScreen'; +import React from "react"; +import { OnScreen } from "../OnScreen"; import { ComponentRenderer, createIsOnScreenValueTest, createOnceParameterTest, createRenderTest, -} from './testUtils'; +} from "./testUtils"; const renderComponent: ComponentRenderer = (settings) => ( {...settings}> {({ ref, isOnScreen }) => ( -
+
)} ); -describe('OnScreen', () => { - it('OnScreen component renders', createRenderTest(renderComponent)); +describe("OnScreen", () => { + it("OnScreen component renders", createRenderTest(renderComponent)); - it('isOnScreen value changes', createIsOnScreenValueTest(renderComponent)); + it("isOnScreen value changes", createIsOnScreenValueTest(renderComponent)); - it('Once prop is working as expected', createOnceParameterTest(renderComponent)); + it("Once prop is working as expected", createOnceParameterTest(renderComponent)); }); diff --git a/lib/__tests__/testUtils.ts b/lib/__tests__/testUtils.ts index eab6595..15264bf 100644 --- a/lib/__tests__/testUtils.ts +++ b/lib/__tests__/testUtils.ts @@ -1,16 +1,16 @@ /*global expect*/ -import { act, render } from '@testing-library/react'; -import { mockIntersectionObserver } from 'jsdom-testing-mocks'; -import { ReactElement } from 'react'; -import { UseOnScreenParameters } from '../useOnScreen'; +import { act, render } from "@testing-library/react"; +import { mockIntersectionObserver } from "jsdom-testing-mocks"; +import { ReactElement } from "react"; +import { UseOnScreenParameters } from "../useOnScreen"; /** * Renders component. */ -export type ComponentRenderer = (settings?: Pick) => ReactElement; +export type ComponentRenderer = (settings?: Pick) => ReactElement; -const targetTestId = 'target'; -const targetIsOnScreenTestId = 'target-isOnScreen'; +const targetTestId = "target"; +const targetIsOnScreenTestId = "target-isOnScreen"; const io = mockIntersectionObserver(); diff --git a/lib/__tests__/useOnScreen.test.tsx b/lib/__tests__/useOnScreen.test.tsx index 675d6b7..9c592c9 100644 --- a/lib/__tests__/useOnScreen.test.tsx +++ b/lib/__tests__/useOnScreen.test.tsx @@ -1,25 +1,25 @@ -import React, { useRef } from 'react'; -import { useOnScreen, UseOnScreenParameters } from '../useOnScreen'; +import React, { useRef } from "react"; +import { useOnScreen, UseOnScreenParameters } from "../useOnScreen"; import { ComponentRenderer, createIsOnScreenValueTest, createOnceParameterTest, createRenderTest, -} from './testUtils'; +} from "./testUtils"; -const ComponentTemplate = (props: Pick) => { +const ComponentTemplate = (props: Pick) => { const ref = useRef(null); const { isOnScreen } = useOnScreen({ ref, ...props }); - return
; + return
; }; const renderComponent: ComponentRenderer = (settings) => ; -describe('useOnScreen', () => { - it('useOnScreen component renders', createRenderTest(renderComponent)); +describe("useOnScreen", () => { + it("useOnScreen component renders", createRenderTest(renderComponent)); - it('isOnScreen value changes', createIsOnScreenValueTest(renderComponent)); + it("isOnScreen value changes", createIsOnScreenValueTest(renderComponent)); - it('Once prop is working as expected', createOnceParameterTest(renderComponent)); + it("Once prop is working as expected", createOnceParameterTest(renderComponent)); }); diff --git a/lib/__tests__/withOnScreen.test.tsx b/lib/__tests__/withOnScreen.test.tsx index cc6daa4..8022a76 100644 --- a/lib/__tests__/withOnScreen.test.tsx +++ b/lib/__tests__/withOnScreen.test.tsx @@ -1,16 +1,16 @@ -import React, { forwardRef } from 'react'; -import { useOnScreen } from '../useOnScreen'; -import { withOnScreen } from '../withOnScreen'; +import React, { forwardRef } from "react"; +import { useOnScreen } from "../useOnScreen"; +import { withOnScreen } from "../withOnScreen"; import { ComponentRenderer, createIsOnScreenValueTest, createOnceParameterTest, createRenderTest, -} from './testUtils'; +} from "./testUtils"; const ComponentTemplate = forwardRef>( function ComponentTemplate({ isOnScreen }, ref) { - return
; + return
; }, ); @@ -19,10 +19,10 @@ const renderComponent: ComponentRenderer = (settings) => { return ; }; -describe('withOnScreen', () => { - it('withOnScreen component renders', createRenderTest(renderComponent)); +describe("withOnScreen", () => { + it("withOnScreen component renders", createRenderTest(renderComponent)); - it('isOnScreen value changes', createIsOnScreenValueTest(renderComponent)); + it("isOnScreen value changes", createIsOnScreenValueTest(renderComponent)); - it('Once prop is working as expected', createOnceParameterTest(renderComponent)); + it("Once prop is working as expected", createOnceParameterTest(renderComponent)); }); diff --git a/lib/index.ts b/lib/index.ts index 1041931..3eaa616 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,6 +1,6 @@ -export { useOnScreen } from './useOnScreen'; -export type { UseOnScreenParameters } from './useOnScreen'; -export { OnScreen } from './OnScreen'; -export type { OnScreenProps } from './OnScreen'; -export { withOnScreen } from './withOnScreen'; -export type { WithOnScreenWrappedComponent } from './withOnScreen'; +export { useOnScreen } from "./useOnScreen"; +export type { UseOnScreenParameters } from "./useOnScreen"; +export { OnScreen } from "./OnScreen"; +export type { OnScreenProps } from "./OnScreen"; +export { withOnScreen } from "./withOnScreen"; +export type { WithOnScreenWrappedComponent } from "./withOnScreen"; diff --git a/lib/internal/index.ts b/lib/internal/index.ts index 92702d5..13b376c 100644 --- a/lib/internal/index.ts +++ b/lib/internal/index.ts @@ -1 +1 @@ -export * from './assignRefs'; +export * from "./assignRefs"; diff --git a/lib/useOnScreen.tsx b/lib/useOnScreen.tsx index dadc1ef..b127a6d 100644 --- a/lib/useOnScreen.tsx +++ b/lib/useOnScreen.tsx @@ -1,4 +1,4 @@ -import { RefObject, useEffect, useState } from 'react'; +import { RefObject, useEffect, useState } from "react"; /** * UseOnScreen hook settings. diff --git a/lib/withOnScreen.tsx b/lib/withOnScreen.tsx index 0e25926..1e0c3d6 100644 --- a/lib/withOnScreen.tsx +++ b/lib/withOnScreen.tsx @@ -1,7 +1,7 @@ -import React, { useRef, ComponentType, forwardRef, ForwardedRef } from 'react'; -import hoistNonReactStatics from 'hoist-non-react-statics'; -import { UseOnScreenParameters, useOnScreen } from './useOnScreen'; -import { assignRefs } from './internal'; +import React, { useRef, ComponentType, forwardRef, ForwardedRef } from "react"; +import hoistNonReactStatics from "hoist-non-react-statics"; +import { UseOnScreenParameters, useOnScreen } from "./useOnScreen"; +import { assignRefs } from "./internal"; /** * WithOnScreen wrapped component with injected props. @@ -30,7 +30,7 @@ export type WithOnScreenWrappedComponent,> */ export const withOnScreen =

, T extends HTMLElement>( WrappedComponent: WithOnScreenWrappedComponent

, - settings?: Omit, 'ref'>, + settings?: Omit, "ref">, ) => { const WithOnScreen = (props: P, forwardedRef: ForwardedRef) => { const ref = useRef(null); @@ -42,7 +42,7 @@ export const withOnScreen =

, T extends HTMLEl hoistNonReactStatics(WithOnScreen, WrappedComponent); WithOnScreen.displayName = `WithOnScreen(${ - WrappedComponent.displayName || WrappedComponent.name || 'Component' + WrappedComponent.displayName || WrappedComponent.name || "Component" })`; return forwardRef(WithOnScreen); diff --git a/package.json b/package.json index 64ea426..4b9c77c 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "build": "rollup -c", "test": "jest", "lint": "biome lint ./lib", - "format": "biome format --write", + "format": "biome format --write ./lib", "prepare": "husky install" }, "keywords": [ @@ -65,7 +65,7 @@ "access": "public" }, "lint-staged": { - "*.{js,ts,tsx}": "npm run format" + "*.{js,ts,tsx}": "biome format --write" }, "jest": { "roots": [