From 0d10bc143622e0ea4318f19b2ecad84073b0c9b8 Mon Sep 17 00:00:00 2001 From: d0422 Date: Thu, 20 Jun 2024 13:49:15 +0900 Subject: [PATCH 1/7] =?UTF-8?q?test:=20jest=20coverage=20threshold=20?= =?UTF-8?q?=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jest.config.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jest.config.ts b/jest.config.ts index b29931e..08d2a43 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -15,4 +15,11 @@ module.exports = { moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '', }), + coverageThreshold: { + global: { + branches: 80, + functions: 80, + lines: 80, + }, + }, }; From 3041c323c8739be585796bc21252da4b917a27ce Mon Sep 17 00:00:00 2001 From: d0422 Date: Thu, 20 Jun 2024 13:54:19 +0900 Subject: [PATCH 2/7] =?UTF-8?q?config:=20husky=20pre-push=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .husky/pre-push | 1 + 1 file changed, 1 insertion(+) create mode 100644 .husky/pre-push diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100644 index 0000000..42706ac --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1 @@ +npm run test:coverage \ No newline at end of file From a8a4fd6dc78e648f608ebf07c4dd2d651dcc7a4e Mon Sep 17 00:00:00 2001 From: d0422 Date: Thu, 20 Jun 2024 16:46:11 +0900 Subject: [PATCH 3/7] =?UTF-8?q?config:=20jest=20coverage=20=EC=88=98?= =?UTF-8?q?=EC=A7=91=20=EB=8C=80=EC=83=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jest.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.ts b/jest.config.ts index 08d2a43..6bb7b5a 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -16,7 +16,7 @@ module.exports = { prefix: '', }), coverageThreshold: { - global: { + 'src/**/*.test.{ts,tsx}': { branches: 80, functions: 80, lines: 80, From 9208af985b46b4e400141509be7c55f7979ce509 Mon Sep 17 00:00:00 2001 From: d0422 Date: Thu, 20 Jun 2024 16:51:21 +0900 Subject: [PATCH 4/7] =?UTF-8?q?config:=20coverage=20threshold=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jest.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.ts b/jest.config.ts index 6bb7b5a..4de6a67 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -19,7 +19,7 @@ module.exports = { 'src/**/*.test.{ts,tsx}': { branches: 80, functions: 80, - lines: 80, + lines: 100, }, }, }; From 00ff110bbfc5a23081d2ad9b3ea79b26616cf519 Mon Sep 17 00:00:00 2001 From: d0422 Date: Thu, 20 Jun 2024 16:51:48 +0900 Subject: [PATCH 5/7] =?UTF-8?q?chore:=20useScrollRatio=20=EC=9E=84?= =?UTF-8?q?=EC=8B=9C=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.ts | 2 -- src/useScrollRatio.ts | 28 ---------------------------- 2 files changed, 30 deletions(-) delete mode 100644 src/useScrollRatio.ts diff --git a/src/index.ts b/src/index.ts index 7410274..b0e0793 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,6 @@ import useAnimation from './useAnimation/useAnimation'; import useFocusAnimation from './useFocusAnimation/useFocusAnimation'; import useDragIndexCarousel from './useDragIndexCarousel/useDragIndexCarousel'; import useCarousel from './useCarousel/useCarousel'; -import useScrollRatio from './useScrollRatio'; import useInterval from './useInterval/useInterval'; import useAfterMountEffect from './useAfterMountEffect/useAfterMountEffect'; import useRadio from './useRadio/useRadio'; @@ -19,7 +18,6 @@ export { useFocusAnimation, useDragIndexCarousel, useCarousel, - useScrollRatio, useInterval, useAfterMountEffect, useRadio, diff --git a/src/useScrollRatio.ts b/src/useScrollRatio.ts deleted file mode 100644 index c581801..0000000 --- a/src/useScrollRatio.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { useRef, useState } from 'react'; - -let timer: NodeJS.Timeout | null; - -export default function useScrollRatio() { - const [scrollRatio, setScrollRatio] = useState(100); - const ref = useRef(null); - - const handleScroll = () => { - if (!timer) { - timer = setTimeout(() => { - timer = null; - - if (!ref.current) return; - - const { scrollTop, clientHeight, scrollHeight } = ref.current; - setScrollRatio(((scrollTop + clientHeight) / scrollHeight) * 100); - }, 200); - } - }; - - const moveToBottom = () => { - if (ref.current) ref.current.scrollTop = ref.current.scrollHeight; - setScrollRatio(100); - }; - - return { ref, scrollRatio, handleScroll, moveToBottom }; -} From c6e5d736311a470c957ab593efa130a51ef697e5 Mon Sep 17 00:00:00 2001 From: d0422 Date: Thu, 20 Jun 2024 16:53:27 +0900 Subject: [PATCH 6/7] =?UTF-8?q?fix:=20jest=20threshold=20=EC=88=98?= =?UTF-8?q?=EC=A7=91=20=EB=B2=94=EC=9C=84=20=EC=88=98=EC=A0=95=ED=95=98?= =?UTF-8?q?=EC=97=AC=20=ED=8C=8C=EC=9D=BC=20=EB=A7=A4=EC=B9=98=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jest.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.ts b/jest.config.ts index 4de6a67..2e43c2f 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -16,7 +16,7 @@ module.exports = { prefix: '', }), coverageThreshold: { - 'src/**/*.test.{ts,tsx}': { + 'src/**/*.{ts,tsx}': { branches: 80, functions: 80, lines: 100, From c137d6a56e22f2f51cd60e62a4c24d2454411de1 Mon Sep 17 00:00:00 2001 From: d0422 Date: Thu, 20 Jun 2024 16:58:55 +0900 Subject: [PATCH 7/7] =?UTF-8?q?docs:=20contributing=20=EB=AC=B8=EC=84=9C?= =?UTF-8?q?=EC=97=90=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A0=95=EC=B1=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/CONTRIBUTING.ko.md | 16 ++++++++++++++-- .github/CONTRIBUTING.md | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/CONTRIBUTING.ko.md b/.github/CONTRIBUTING.ko.md index c8f167e..7a92eea 100644 --- a/.github/CONTRIBUTING.ko.md +++ b/.github/CONTRIBUTING.ko.md @@ -3,11 +3,23 @@ 커뮤니티의 모든 분들의 Contribution을 환영합니다. [영어](https://github.com/Rapiders/react-hooks/tree/main/.github/CONTRIBUTING.md)와 한국어 중 편한 언어를 사용하면 됩니다. +## 테스트 코드 정책 + +라이브러리의 품질을 보증하기위해 다음의 정책이 적용됩니다. +하나의 기능에 대해 + +1. branches의 coverage는 80%를 넘어야합니다. (추후 개선 100%로 변경예정) +2. functions의 coverage는 80%를 넘어야합니다. (추후 개선 100%로 변경예정) +3. lines는 반드시 100%여야합니다. + +해당 정책을 만족하지 못하는 경우 `git push`가 이뤄지지 않습니다. + ## Fork 1. 기여하고 싶은 경우 우선 이 레포지토리를 fork 합니다. -2. 작업이 완료되었다면 main 브랜치로 PR을 오픈합니다. -3. merge 되기 위해서는 반드시 maintainer 중 한 명이 이상의 approve를 받아야 합니다. +2. npm install을 진행합니다. +3. 작업이 완료되었다면 main 브랜치로 PR을 오픈합니다. +4. merge 되기 위해서는 반드시 maintainer 중 한 명이 이상의 approve를 받아야 합니다. ## Issue diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 22018e4..aff67a2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -3,11 +3,22 @@ We welcome contribution from everyone in the community. you can use English and [Korean](https://github.com/Rapiders/react-hooks/tree/main/.github/CONTRIBUTING.ko.md) +## Test Code Policy + +To ensure the quality of the library, the following policy is applied for each feature: + +1. Branch coverage must exceed 80%. +2. Function coverage must exceed 80%. +3. Line coverage must be 100%. + +If these requirements are not met, `git push` will not be allowed. + ## Fork 1. If you wish to contribute, first fork this repository. -2. Once your work is complete, open a PR to the main branch. -3. To be merged, it must receive at least one approval from a maintainer. +2. npm install +3. Once your work is complete, open a PR to the main branch. +4. To be merged, it must receive at least one approval from a maintainer. ## Issue