Skip to content

Commit

Permalink
chore: lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
iamyoki committed Feb 18, 2022
1 parent f204db4 commit 02beb0e
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"clean": "rimraf dist",
"build": "yarn clean && run-p build:*",
"watch": "yarn clean && run-p 'build:* -- --watch'",
"lint": "eslint src --fix",
"lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
"semantic-release": "semantic-release"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/ListTransition/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';

import {Stage, useListTransition} from '..';

type ListTransitionProps<Item> = {
Expand Down
2 changes: 1 addition & 1 deletion src/SwitchTransition/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Stage, useSwitchTransition} from '..';
import {Mode} from '../useSwitchTransition/types';

type SwitchTransitionProps<S = any> = {
type SwitchTransitionProps<S> = {
state: S;
timeout: number;
mode: Mode;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/setAnimationFrameTimeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export type Canceller = {
};

export function setAnimationFrameTimeout(
callback: Function,
callback: () => void,
timeout: number = 0
) {
const startTime = performance.now();
Expand Down
3 changes: 2 additions & 1 deletion src/useListTransition/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Fragment, useEffect, useRef, useState} from 'react';

import {Stage} from '..';
import {insertArray} from '../helpers/insertArray';
import {setAnimationFrameTimeout} from '../helpers/setAnimationFrameTimeout';
Expand Down Expand Up @@ -29,7 +30,7 @@ export function useListTransition<Item>(list: Array<Item>, timeout: number) {

useEffect(
function handleListChange() {
let newItemsWithIndex: Array<ItemWithKey<Item>> = [];
const newItemsWithIndex: Array<ItemWithKey<Item>> = [];

list.forEach((item, index) => {
if (listState.every((itemState) => itemState.item !== item)) {
Expand Down
1 change: 1 addition & 0 deletions src/useSwitchTransition/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Fragment, useRef, useState} from 'react';

import {Stage} from '../useTransition';
import {ListItem, Mode} from './types';
import {useDefaultMode} from './useDefaultMode';
Expand Down
2 changes: 1 addition & 1 deletion src/useSwitchTransition/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ListItem<S> = {
stage: Stage;
};

export type ModeHookParam<S = any> = {
export type ModeHookParam<S> = {
state: S;
timeout: number;
mode?: Mode;
Expand Down
1 change: 1 addition & 0 deletions src/useSwitchTransition/useDefaultMode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useEffect} from 'react';

import {ListItem, ModeHookParam} from './types';

export function useDefaultMode<S>({
Expand Down
6 changes: 3 additions & 3 deletions src/useSwitchTransition/useInOutMode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useEffect, useRef} from 'react';

import {
Canceller,
clearAnimationFrameTimeout,
Expand Down Expand Up @@ -48,8 +49,7 @@ export function useInOutMode<S>({
if (
lastItem.state === state &&
lastItem.stage === 'enter' &&
secondLastItem &&
secondLastItem?.stage === 'enter'
secondLastItem.stage === 'enter'
) {
// 3 leave second last item after new item enter animation ends
clearAnimationFrameTimeout(timerRef.current);
Expand All @@ -61,7 +61,7 @@ export function useInOutMode<S>({
// if second last item exist
// && second last item is enter
// (unmount second last item)
if (secondLastItem && secondLastItem.stage === 'leave') {
if (secondLastItem.stage === 'leave') {
// 4 unmount second last item after it's leave animation ends
clearAnimationFrameTimeout(timerRef2.current);
timerRef2.current = setAnimationFrameTimeout(() => {
Expand Down
5 changes: 4 additions & 1 deletion src/useSwitchTransition/useOutInMode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useEffect, useRef} from 'react';

import {
Canceller,
clearAnimationFrameTimeout,
Expand Down Expand Up @@ -46,6 +47,8 @@ export function useOutInMode<S>({
});
}

return () => clearAnimationFrameTimeout(timerRef.current);
return () => {
clearAnimationFrameTimeout(timerRef.current);
};
}, [keyRef, list, mode, setList, state, timeout]);
}
7 changes: 5 additions & 2 deletions src/useTransition/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useEffect, useRef, useState} from 'react';

import {
Canceller,
clearAnimationFrameTimeout,
Expand All @@ -21,7 +22,7 @@ export function useTransition(state: boolean, timeout: number) {

// when true - trans from to enter
// when false - trans enter to leave, unmount after timeout
if (state === true) {
if (state) {
setStage('from');
setShouldMount(true);
setAnimationFrameTimeout(() => {
Expand All @@ -34,7 +35,9 @@ export function useTransition(state: boolean, timeout: number) {
}, timeout);
}

return () => clearAnimationFrameTimeout(timer.current);
return () => {
clearAnimationFrameTimeout(timer.current);
};
},
[state, timeout]
);
Expand Down

0 comments on commit 02beb0e

Please sign in to comment.