From 78bb7281c2b22986170d732f870fbec8dbd4b395 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Fri, 25 Aug 2023 11:46:29 +0800 Subject: [PATCH 1/4] chore: add husky --- .eslintrc.js | 1 - .husky/pre-commit | 4 ++++ package.json | 11 ++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100755 .husky/pre-commit diff --git a/.eslintrc.js b/.eslintrc.js index afd0dc9..25c9491 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,3 @@ -/* eslint-disable import/no-extraneous-dependencies */ module.exports = { extends: [require.resolve('@umijs/fabric/dist/eslint')], rules: { diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..d24fdfc --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx lint-staged diff --git a/package.json b/package.json index 8e539b5..1557b5d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", "postpublish": "npm run docs:deploy", "start": "dumi dev", - "test": "rc-test" + "test": "rc-test", + "prepare": "husky install" }, "dependencies": { "@babel/runtime": "^7.11.1", @@ -57,6 +58,8 @@ "dumi": "^2.0.18", "eslint": "^7.0.0", "father": "^4.1.2", + "husky": "^8.0.3", + "lint-staged": "^14.0.1", "np": "^6.2.4", "prettier": "^2.1.1", "rc-test": "^7.0.14", @@ -73,5 +76,11 @@ }, "tnpm": { "mode": "npm" + }, + "lint-staged": { + "**/*.{js,jsx,tsx,ts,md,json}": [ + "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "git add" + ] } } From 53aa7508c267592a1224a6c911c561f150d7205e Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Fri, 25 Aug 2023 11:48:05 +0800 Subject: [PATCH 2/4] chore: update deps --- package.json | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 1557b5d..0fffbfc 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,18 @@ "docs:deploy": "gh-pages -d .doc", "lint": "eslint src/ --ext .tsx,.ts", "now-build": "npm run docs:build", + "prepare": "husky install", "prepublishOnly": "npm run compile && np --yolo --no-publish", "prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", "postpublish": "npm run docs:deploy", "start": "dumi dev", - "test": "rc-test", - "prepare": "husky install" + "test": "rc-test" + }, + "lint-staged": { + "**/*.{js,jsx,tsx,ts,md,json}": [ + "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "git add" + ] }, "dependencies": { "@babel/runtime": "^7.11.1", @@ -49,7 +55,6 @@ "@testing-library/jest-dom": "^5.16.4", "@testing-library/react": "^13.0.0", "@types/classnames": "^2.2.9", - "@types/enzyme": "^3.10.5", "@types/jest": "^26.0.8", "@types/react": "^16.9.2", "@types/react-dom": "^16.9.0", @@ -76,11 +81,5 @@ }, "tnpm": { "mode": "npm" - }, - "lint-staged": { - "**/*.{js,jsx,tsx,ts,md,json}": [ - "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", - "git add" - ] } } From 4939adbd1f8453c9b5ef7728a85b50ad8e33c9f9 Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Fri, 25 Aug 2023 11:48:18 +0800 Subject: [PATCH 3/4] chore: update deps --- docs/examples/basic.tsx | 2 +- docs/examples/deadline.tsx | 2 +- docs/examples/list.tsx | 2 +- docs/examples/ssr.tsx | 6 +++--- docs/examples/transition-inside-debug.tsx | 2 +- src/CSSMotionList.tsx | 10 +++++----- src/hooks/useDomMotionEvents.ts | 2 +- src/hooks/useIsomorphicLayoutEffect.ts | 2 +- src/hooks/useNextFrame.ts | 2 +- src/index.tsx | 8 +++----- tests/CSSMotionList.spec.tsx | 8 ++++---- tests/StrictMode.spec.tsx | 4 ++-- tests/util.spec.tsx | 2 +- 13 files changed, 25 insertions(+), 27 deletions(-) diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index 47b321d..8127183 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -1,6 +1,6 @@ -import React from 'react'; import classNames from 'classnames'; import CSSMotion from 'rc-motion'; +import React from 'react'; import './basic.less'; interface DemoState { diff --git a/docs/examples/deadline.tsx b/docs/examples/deadline.tsx index 64db917..00680b5 100644 --- a/docs/examples/deadline.tsx +++ b/docs/examples/deadline.tsx @@ -1,6 +1,6 @@ -import React from 'react'; import classNames from 'classnames'; import CSSMotion from 'rc-motion'; +import React from 'react'; import './basic.less'; interface DemoState { diff --git a/docs/examples/list.tsx b/docs/examples/list.tsx index b61aa5c..78564af 100644 --- a/docs/examples/list.tsx +++ b/docs/examples/list.tsx @@ -1,6 +1,6 @@ -import React from 'react'; import classNames from 'classnames'; import { CSSMotionList } from 'rc-motion'; +import React from 'react'; import './list.less'; interface DemoState { diff --git a/docs/examples/ssr.tsx b/docs/examples/ssr.tsx index e9855cc..a5243bc 100644 --- a/docs/examples/ssr.tsx +++ b/docs/examples/ssr.tsx @@ -1,9 +1,9 @@ +import classNames from 'classnames'; +import CSSMotion from 'rc-motion'; +import { genCSSMotion } from 'rc-motion/es/CSSMotion'; import React from 'react'; import { hydrate } from 'react-dom'; import ReactDOMServer from 'react-dom/server'; -import classNames from 'classnames'; -import { genCSSMotion } from 'rc-motion/es/CSSMotion'; -import CSSMotion from 'rc-motion'; import './basic.less'; const ServerCSSMotion = genCSSMotion(false); diff --git a/docs/examples/transition-inside-debug.tsx b/docs/examples/transition-inside-debug.tsx index 85954e8..69cc4bc 100644 --- a/docs/examples/transition-inside-debug.tsx +++ b/docs/examples/transition-inside-debug.tsx @@ -1,5 +1,5 @@ -import React from 'react'; import CSSMotion from 'rc-motion'; +import React from 'react'; import './transition-inside-debug.less'; export default function TransitionInsideDebug() { diff --git a/src/CSSMotionList.tsx b/src/CSSMotionList.tsx index 1ebaffb..5978000 100644 --- a/src/CSSMotionList.tsx +++ b/src/CSSMotionList.tsx @@ -1,17 +1,17 @@ /* eslint react/prop-types: 0 */ import * as React from 'react'; -import OriginCSSMotion from './CSSMotion'; import type { CSSMotionProps } from './CSSMotion'; -import { supportTransition } from './util/motion'; +import OriginCSSMotion from './CSSMotion'; +import type { KeyObject } from './util/diff'; import { + diffKeys, + parseKeys, STATUS_ADD, STATUS_KEEP, STATUS_REMOVE, STATUS_REMOVED, - diffKeys, - parseKeys, } from './util/diff'; -import type { KeyObject } from './util/diff'; +import { supportTransition } from './util/motion'; const MOTION_PROP_NAMES = [ 'eventProps', diff --git a/src/hooks/useDomMotionEvents.ts b/src/hooks/useDomMotionEvents.ts index 617547e..20d7bb3 100644 --- a/src/hooks/useDomMotionEvents.ts +++ b/src/hooks/useDomMotionEvents.ts @@ -1,8 +1,8 @@ import * as React from 'react'; import { useRef } from 'react'; -import { animationEndName, transitionEndName } from '../util/motion'; import type { MotionEvent } from '../interface'; +import { animationEndName, transitionEndName } from '../util/motion'; export default ( callback: (event: MotionEvent) => void, diff --git a/src/hooks/useIsomorphicLayoutEffect.ts b/src/hooks/useIsomorphicLayoutEffect.ts index f3a06f0..7dd0ab0 100644 --- a/src/hooks/useIsomorphicLayoutEffect.ts +++ b/src/hooks/useIsomorphicLayoutEffect.ts @@ -1,5 +1,5 @@ -import { useEffect, useLayoutEffect } from 'react'; import canUseDom from 'rc-util/lib/Dom/canUseDom'; +import { useEffect, useLayoutEffect } from 'react'; // It's safe to use `useLayoutEffect` but the warning is annoying const useIsomorphicLayoutEffect = canUseDom() ? useLayoutEffect : useEffect; diff --git a/src/hooks/useNextFrame.ts b/src/hooks/useNextFrame.ts index d27bb3f..9f06173 100644 --- a/src/hooks/useNextFrame.ts +++ b/src/hooks/useNextFrame.ts @@ -1,5 +1,5 @@ -import * as React from 'react'; import raf from 'rc-util/lib/raf'; +import * as React from 'react'; export default (): [ (callback: (info: { isCanceled: () => boolean }) => void) => void, diff --git a/src/index.tsx b/src/index.tsx index 31854d8..2fa1f88 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,12 +1,10 @@ -import CSSMotion from './CSSMotion'; -import CSSMotionList from './CSSMotionList'; import type { CSSMotionProps } from './CSSMotion'; +import CSSMotion from './CSSMotion'; import type { CSSMotionListProps } from './CSSMotionList'; -import type { MotionEventHandler, MotionEndEventHandler } from './interface'; +import CSSMotionList from './CSSMotionList'; +import type { MotionEndEventHandler, MotionEventHandler } from './interface'; export { default as Provider } from './context'; - export { CSSMotionList }; - export type { CSSMotionProps, CSSMotionListProps, diff --git a/tests/CSSMotionList.spec.tsx b/tests/CSSMotionList.spec.tsx index b8cbe0c..85dfce0 100644 --- a/tests/CSSMotionList.spec.tsx +++ b/tests/CSSMotionList.spec.tsx @@ -1,12 +1,12 @@ /* eslint-disable react/no-render-return-value, react/prefer-stateless-function, react/no-multi-comp, @typescript-eslint/no-implied-eval */ -import React from 'react'; +import { fireEvent, render } from '@testing-library/react'; import classNames from 'classnames'; +import React from 'react'; import { act } from 'react-dom/test-utils'; -import { render, fireEvent } from '@testing-library/react'; -import { genCSSMotionList } from '../src/CSSMotionList'; -import type { CSSMotionListProps } from '../src/CSSMotionList'; import { genCSSMotion } from '../src/CSSMotion'; +import type { CSSMotionListProps } from '../src/CSSMotionList'; +import { genCSSMotionList } from '../src/CSSMotionList'; describe('CSSMotionList', () => { beforeEach(() => { diff --git a/tests/StrictMode.spec.tsx b/tests/StrictMode.spec.tsx index 1583945..e7b6699 100644 --- a/tests/StrictMode.spec.tsx +++ b/tests/StrictMode.spec.tsx @@ -2,10 +2,10 @@ react/no-render-return-value, max-classes-per-file, react/prefer-stateless-function, react/no-multi-comp */ +import { fireEvent, render } from '@testing-library/react'; +import classNames from 'classnames'; import React from 'react'; import { act } from 'react-dom/test-utils'; -import classNames from 'classnames'; -import { render, fireEvent } from '@testing-library/react'; // import type { CSSMotionProps } from '../src/CSSMotion'; import { genCSSMotion } from '../src/CSSMotion'; // import RefCSSMotion, { genCSSMotion } from '../src/CSSMotion'; diff --git a/tests/util.spec.tsx b/tests/util.spec.tsx index e4b47a5..3c2a425 100644 --- a/tests/util.spec.tsx +++ b/tests/util.spec.tsx @@ -1,5 +1,5 @@ -import { getTransitionName } from '../src/util/motion'; import { diffKeys } from '../src/util/diff'; +import { getTransitionName } from '../src/util/motion'; describe('Util', () => { it('getTransitionName', () => { From 5cb182b9fdbe9e5a936a19de84e5296f8a9b3b3e Mon Sep 17 00:00:00 2001 From: MadCcc <1075746765@qq.com> Date: Fri, 25 Aug 2023 11:49:43 +0800 Subject: [PATCH 4/4] chore: update prettier --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0fffbfc..04526f2 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "lint-staged": { "**/*.{js,jsx,tsx,ts,md,json}": [ - "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"", + "prettier --write", "git add" ] },