Skip to content

Commit

Permalink
chore(dev-deps): bump prettier & eslint (alibaba#2248)
Browse files Browse the repository at this point in the history
* chore(deps): bump prettier from 2.2.0 to 3.0.0

* chore(deps): bump prettier from 2.2.0 to 3.0.0

* fix: fix

* fix: fix

* fix: fix

* fix: fix

* fix: fix type

* chore: add type

* fix: fix

* fix: fix
  • Loading branch information
li-jia-nan authored Feb 27, 2024
1 parent 8eb174a commit dfc55d8
Show file tree
Hide file tree
Showing 9 changed files with 1,054 additions and 576 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run pretty
npm run pretty
2 changes: 1 addition & 1 deletion example/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/react-dom": "^17.0.0",
"@umijs/test": "^3.4.20",
"lint-staged": "^10.0.7",
"prettier": "^2.2.0",
"prettier": "^3.2.2",
"react": "17.x",
"react-dom": "17.x",
"typescript": "^5.1.3",
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"test:strict": "cross-env REACT_MODE=strict jest"
},
"devDependencies": {
"@ant-design/icons": "^5.0.1",
"@ant-design/icons": "^5.3.0",
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/plugin-transform-runtime": "^7.19.6",
Expand All @@ -43,14 +43,14 @@
"@types/mockjs": "^1.0.7",
"@types/react-router": "^5.1.19",
"@umijs/fabric": "^2.1.0",
"antd": "^5.2.1",
"antd": "^5.14.2",
"babel-plugin-import": "^1.12.0",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"del": "^5.1.0",
"dumi": "^1.1.48",
"eslint": "^7.2.0",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"fast-glob": "^3.2.11",
"fs-extra": "^10.0.1",
"gray-matter": "^4.0.3",
Expand All @@ -62,8 +62,8 @@
"jest-environment-jsdom": "^29.4.1",
"jest-localstorage-mock": "^2.4.18",
"mockjs": "^1.1.0",
"prettier": "^2.0.5",
"pretty-quick": "^3.1.3",
"prettier": "^3.2.5",
"pretty-quick": "^4.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-drag-listview": "^0.1.6",
Expand All @@ -73,7 +73,7 @@
"surge": "^0.21.3",
"ts-jest": "^29.1.1",
"typescript": "^5.1.3",
"webpack": "^5.88.2",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4",
"webpack-merge": "^4.2.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('useDeepCompareEffect', () => {
const [x, setX] = useState(0);
const [y, setY] = useState({});
useDeepCompareEffect(() => {
setX((x) => x + 1);
setX((prevState) => prevState + 1);
}, [y]);
return { x, setY };
});
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useInterval/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isNumber } from '../utils';

const useInterval = (fn: () => void, delay?: number, options: { immediate?: boolean } = {}) => {
const timerCallback = useMemoizedFn(fn);
const timerRef = useRef<NodeJS.Timer | null>(null);
const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);

const clear = useCallback(() => {
if (timerRef.current) {
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useMemoizedFn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function useMemoizedFn<T extends noop>(fn: T) {

// why not write `fnRef.current = fn`?
// https://github.com/alibaba/hooks/issues/728
fnRef.current = useMemo(() => fn, [fn]);
fnRef.current = useMemo<T>(() => fn, [fn]);

const memoizedFn = useRef<PickFunction<T>>();
if (!memoizedFn.current) {
Expand Down
14 changes: 8 additions & 6 deletions packages/hooks/src/useRafInterval/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import useLatest from '../useLatest';
import { isNumber } from '../utils';

interface Handle {
id: number | NodeJS.Timer;
id: number | ReturnType<typeof setInterval>;
}

const setRafInterval = function (callback: () => void, delay: number = 0): Handle {
Expand All @@ -12,23 +12,23 @@ const setRafInterval = function (callback: () => void, delay: number = 0): Handl
id: setInterval(callback, delay),
};
}
let start = new Date().getTime();
let start = Date.now();
const handle: Handle = {
id: 0,
};
const loop = () => {
const current = new Date().getTime();
const current = Date.now();
if (current - start >= delay) {
callback();
start = new Date().getTime();
start = Date.now();
}
handle.id = requestAnimationFrame(loop);
};
handle.id = requestAnimationFrame(loop);
return handle;
};

function cancelAnimationFrameIsNotDefined(t: any): t is NodeJS.Timer {
function cancelAnimationFrameIsNotDefined(t: any): t is ReturnType<typeof setInterval> {
return typeof cancelAnimationFrame === typeof undefined;
}

Expand All @@ -52,7 +52,9 @@ function useRafInterval(
const timerRef = useRef<Handle>();

useEffect(() => {
if (!isNumber(delay) || delay < 0) return;
if (!isNumber(delay) || delay < 0) {
return;
}
if (immediate) {
fnRef.current();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/useTimeout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isNumber } from '../utils';

const useTimeout = (fn: () => void, delay?: number) => {
const timerCallback = useMemoizedFn(fn);
const timerRef = useRef<NodeJS.Timer | null>(null);
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);

const clear = useCallback(() => {
if (timerRef.current) {
Expand Down
Loading

0 comments on commit dfc55d8

Please sign in to comment.