Skip to content

Commit b4ee10c

Browse files
committedDec 16, 2024
chore: switch to lefthook
1 parent ca8727a commit b4ee10c

File tree

7 files changed

+180
-121
lines changed

7 files changed

+180
-121
lines changed
 

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ dist/
1313
/addons
1414
.nyc_output
1515
cypress/videos/*
16-
cypress/screenshots/*
16+
cypress/screenshots/*
17+
.husky

‎lefthook.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pre-commit:
2+
parallel: true
3+
commands:
4+
lint-staged:
5+
glob: "*.{js,ts,jsx,tsx,css}"
6+
run: pnpm lint-staged

‎package.json

+23-22
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,22 @@
99
"react-component",
1010
"react-toastify",
1111
"push",
12-
"alert"
12+
"alert",
13+
"snackbar",
14+
"message"
1315
],
1416
"files": [
1517
"dist",
1618
"addons"
1719
],
1820
"scripts": {
21+
"prepare": "lefthook install",
1922
"setup": "pnpm link .",
2023
"start": "cd playground && pnpm dev",
2124
"test": "cypress open --component",
2225
"test:run": "cypress run --component -b chrome",
23-
"lint": "eslint \"src/**/*.{ts,tsx}\"",
2426
"prettier": "prettier --write src",
25-
"build": "tsup && cp src/style.css dist/ReactToastify.css",
26-
"prepare": "husky install"
27+
"build": "tsup && cp src/style.css dist/ReactToastify.css"
2728
},
2829
"peerDependencies": {
2930
"react": ">=18.0.0",
@@ -47,29 +48,29 @@
4748
},
4849
"homepage": "https://github.com/fkhadra/react-toastify#readme",
4950
"devDependencies": {
50-
"@4tw/cypress-drag-drop": "^2.2.4",
51-
"@cypress/code-coverage": "^3.12.18",
51+
"@4tw/cypress-drag-drop": "^2.2.5",
52+
"@cypress/code-coverage": "^3.13.7",
5253
"@istanbuljs/nyc-config-typescript": "^1.0.2",
53-
"@testing-library/cypress": "^10.0.1",
54+
"@testing-library/cypress": "^10.0.2",
5455
"@types/node": "^22.9.3",
55-
"@types/react": "^18.2.47",
56-
"@types/react-dom": "^18.2.18",
57-
"@vitejs/plugin-react": "^4.2.1",
58-
"coveralls": "^3.0.9",
59-
"cypress": "^13.6.2",
60-
"husky": "^9.1.7",
56+
"@types/react": "^18.3.12",
57+
"@types/react-dom": "^18.3.1",
58+
"@vitejs/plugin-react": "^4.3.3",
59+
"coveralls": "^3.1.1",
60+
"cypress": "^13.16.0",
61+
"lefthook": "^1.8.4",
6162
"lint-staged": "^15.2.10",
62-
"postcss": "^8.4.33",
63-
"prettier": "3.2.2",
64-
"react": "^18.0.0",
65-
"react-dom": "^18.0.0",
63+
"postcss": "^8.4.49",
64+
"prettier": "3.3.3",
65+
"react": "^18.3.1",
66+
"react-dom": "^18.3.1",
6667
"tsup": "^8.3.5",
67-
"typescript": "^5.3.3",
68-
"vite": "^5.0.11",
69-
"vite-plugin-istanbul": "^5.0.0"
68+
"typescript": "^5.7.2",
69+
"vite": "^5.4.11",
70+
"vite-plugin-istanbul": "^6.0.2"
7071
},
7172
"dependencies": {
72-
"clsx": "^2.1.0"
73+
"clsx": "^2.1.1"
7374
},
7475
"main": "dist/index.js",
7576
"typings": "dist/index.d.ts",
@@ -98,4 +99,4 @@
9899
"lint-staged": {
99100
"*.{js,jsx,ts,tsx,md,html,css}": "prettier --write"
100101
}
101-
}
102+
}

‎pnpm-lock.yaml

+138-54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/addons/use-notification-center/NotificationCenter.cy.tsx

+10-39
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,14 @@
11
import React from 'react';
22

3-
import { ToastContainer, toast } from 'react-toastify';
4-
import {
5-
NotificationCenterItem,
6-
UseNotificationCenterParams,
7-
useNotificationCenter
8-
} from './useNotificationCenter';
3+
import { toast, ToastContainer } from 'react-toastify';
4+
import { NotificationCenterItem, useNotificationCenter, UseNotificationCenterParams } from './useNotificationCenter';
95

106
function TestComponent(props: UseNotificationCenterParams) {
117
const [content, setContent] = React.useState('');
128
const [updateId, setUpdateId] = React.useState('');
13-
const {
14-
unreadCount,
15-
markAllAsRead,
16-
markAsRead,
17-
notifications,
18-
remove,
19-
add,
20-
clear,
21-
update
22-
} = useNotificationCenter(props || {});
9+
const { unreadCount, markAllAsRead, markAsRead, notifications, remove, add, clear, update } = useNotificationCenter(
10+
props || {}
11+
);
2312

2413
const flex = {
2514
display: 'flex',
@@ -33,9 +22,7 @@ function TestComponent(props: UseNotificationCenterParams) {
3322
<button onClick={markAllAsRead}>markAllAsRead</button>
3423
<button onClick={clear}>clear</button>
3524
<button onClick={() => add({ content })}>addNotification</button>
36-
<button onClick={() => update(updateId, { content })}>
37-
updateNotification
38-
</button>
25+
<button onClick={() => update(updateId, { content })}>updateNotification</button>
3926
</div>
4027
<ul>
4128
<li>
@@ -48,35 +35,19 @@ function TestComponent(props: UseNotificationCenterParams) {
4835
</li>
4936
</ul>
5037

51-
<input
52-
data-testid="content"
53-
type="text"
54-
onChange={e => setContent(e.target.value)}
55-
value={content}
56-
/>
57-
<input
58-
data-testid="updateId"
59-
type="text"
60-
onChange={e => setUpdateId(e.target.value)}
61-
value={updateId}
62-
/>
38+
<input data-testid="content" type="text" onChange={e => setContent(e.target.value)} value={content} />
39+
<input data-testid="updateId" type="text" onChange={e => setUpdateId(e.target.value)} value={updateId} />
6340

6441
<ul data-testid="notifications">
6542
{notifications.map(el => (
6643
<li key={el.id} style={flex}>
6744
{/* @ts-ignore */}
6845
<span data-testid={`content-${el.id}`}>{el.content}</span>
6946
<span data-testid={`read-${el.id}`}>{el.read.toString()}</span>
70-
<button
71-
data-testid={`markAsRead-${el.id}`}
72-
onClick={() => markAsRead(el.id)}
73-
>
47+
<button data-testid={`markAsRead-${el.id}`} onClick={() => markAsRead(el.id)}>
7448
markAsRead
7549
</button>
76-
<button
77-
data-testid={`remove-${el.id}`}
78-
onClick={() => remove(el.id)}
79-
>
50+
<button data-testid={`remove-${el.id}`} onClick={() => remove(el.id)}>
8051
remove
8152
</button>
8253
</li>

‎src/utils/collapseToast.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { Default } from './constant';
33
/**
44
* Used to collapse toast after exit animation
55
*/
6-
export function collapseToast(
7-
node: HTMLElement,
8-
done: () => void,
9-
duration = Default.COLLAPSE_DURATION
10-
) {
6+
export function collapseToast(node: HTMLElement, done: () => void, duration = Default.COLLAPSE_DURATION) {
117
const { scrollHeight, style } = node;
128

139
requestAnimationFrame(() => {

‎vite.config.ts ‎vite.config.mts

File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.