From 2c9138ab09112962e93c800f1307d84ed9e4d9a0 Mon Sep 17 00:00:00 2001 From: Fadi Khadra Date: Mon, 25 Nov 2024 14:41:21 -0500 Subject: [PATCH] chore: switch to lefthook --- .gitignore | 3 +- lefthook.yml | 6 + package.json | 45 ++-- pnpm-lock.yaml | 192 +++++++++++++----- .../NotificationCenter.cy.tsx | 49 +---- src/utils/collapseToast.ts | 6 +- vite.config.ts => vite.config.mts | 0 7 files changed, 180 insertions(+), 121 deletions(-) create mode 100644 lefthook.yml rename vite.config.ts => vite.config.mts (100%) diff --git a/.gitignore b/.gitignore index c39013a3..c44f5120 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ dist/ /addons .nyc_output cypress/videos/* -cypress/screenshots/* \ No newline at end of file +cypress/screenshots/* +.husky \ No newline at end of file diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 00000000..526a9878 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,6 @@ + pre-commit: + parallel: true + commands: + lint-staged: + glob: "*.{js,ts,jsx,tsx,css}" + run: pnpm lint-staged \ No newline at end of file diff --git a/package.json b/package.json index 29202a0a..6f80e34f 100644 --- a/package.json +++ b/package.json @@ -9,21 +9,22 @@ "react-component", "react-toastify", "push", - "alert" + "alert", + "snackbar", + "message" ], "files": [ "dist", "addons" ], "scripts": { + "prepare": "lefthook install", "setup": "pnpm link .", "start": "cd playground && pnpm dev", "test": "cypress open --component", "test:run": "cypress run --component -b chrome", - "lint": "eslint \"src/**/*.{ts,tsx}\"", "prettier": "prettier --write src", - "build": "tsup && cp src/style.css dist/ReactToastify.css", - "prepare": "husky install" + "build": "tsup && cp src/style.css dist/ReactToastify.css" }, "peerDependencies": { "react": ">=18.0.0", @@ -47,29 +48,29 @@ }, "homepage": "https://github.com/fkhadra/react-toastify#readme", "devDependencies": { - "@4tw/cypress-drag-drop": "^2.2.4", - "@cypress/code-coverage": "^3.12.18", + "@4tw/cypress-drag-drop": "^2.2.5", + "@cypress/code-coverage": "^3.13.7", "@istanbuljs/nyc-config-typescript": "^1.0.2", - "@testing-library/cypress": "^10.0.1", + "@testing-library/cypress": "^10.0.2", "@types/node": "^22.9.3", - "@types/react": "^18.2.47", - "@types/react-dom": "^18.2.18", - "@vitejs/plugin-react": "^4.2.1", - "coveralls": "^3.0.9", - "cypress": "^13.6.2", - "husky": "^9.1.7", + "@types/react": "^18.3.12", + "@types/react-dom": "^18.3.1", + "@vitejs/plugin-react": "^4.3.3", + "coveralls": "^3.1.1", + "cypress": "^13.16.0", + "lefthook": "^1.8.4", "lint-staged": "^15.2.10", - "postcss": "^8.4.33", - "prettier": "3.2.2", - "react": "^18.0.0", - "react-dom": "^18.0.0", + "postcss": "^8.4.49", + "prettier": "3.3.3", + "react": "^18.3.1", + "react-dom": "^18.3.1", "tsup": "^8.3.5", - "typescript": "^5.3.3", - "vite": "^5.0.11", - "vite-plugin-istanbul": "^5.0.0" + "typescript": "^5.7.2", + "vite": "^5.4.11", + "vite-plugin-istanbul": "^6.0.2" }, "dependencies": { - "clsx": "^2.1.0" + "clsx": "^2.1.1" }, "main": "dist/index.js", "typings": "dist/index.d.ts", @@ -98,4 +99,4 @@ "lint-staged": { "*.{js,jsx,ts,tsx,md,html,css}": "prettier --write" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d9316cf4..0e464716 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,70 +6,70 @@ settings: dependencies: clsx: - specifier: ^2.1.0 + specifier: ^2.1.1 version: 2.1.1 devDependencies: '@4tw/cypress-drag-drop': - specifier: ^2.2.4 + specifier: ^2.2.5 version: 2.2.5(cypress@13.16.0) '@cypress/code-coverage': - specifier: ^3.12.18 + specifier: ^3.13.7 version: 3.13.7(@babel/core@7.26.0)(@babel/preset-env@7.26.0)(babel-loader@9.2.1)(cypress@13.16.0)(webpack@5.96.1) '@istanbuljs/nyc-config-typescript': specifier: ^1.0.2 version: 1.0.2(nyc@17.1.0) '@testing-library/cypress': - specifier: ^10.0.1 + specifier: ^10.0.2 version: 10.0.2(cypress@13.16.0) '@types/node': specifier: ^22.9.3 version: 22.9.3 '@types/react': - specifier: ^18.2.47 + specifier: ^18.3.12 version: 18.3.12 '@types/react-dom': - specifier: ^18.2.18 + specifier: ^18.3.1 version: 18.3.1 '@vitejs/plugin-react': - specifier: ^4.2.1 + specifier: ^4.3.3 version: 4.3.3(vite@5.4.11) coveralls: - specifier: ^3.0.9 + specifier: ^3.1.1 version: 3.1.1 cypress: - specifier: ^13.6.2 + specifier: ^13.16.0 version: 13.16.0 - husky: - specifier: ^9.1.7 - version: 9.1.7 + lefthook: + specifier: ^1.8.4 + version: 1.8.4 lint-staged: specifier: ^15.2.10 version: 15.2.10 postcss: - specifier: ^8.4.33 + specifier: ^8.4.49 version: 8.4.49 prettier: - specifier: 3.2.2 - version: 3.2.2 + specifier: 3.3.3 + version: 3.3.3 react: - specifier: ^18.0.0 + specifier: ^18.3.1 version: 18.3.1 react-dom: - specifier: ^18.0.0 + specifier: ^18.3.1 version: 18.3.1(react@18.3.1) tsup: specifier: ^8.3.5 version: 8.3.5(postcss@8.4.49)(typescript@5.7.2) typescript: - specifier: ^5.3.3 + specifier: ^5.7.2 version: 5.7.2 vite: - specifier: ^5.0.11 + specifier: ^5.4.11 version: 5.4.11(@types/node@22.9.3) vite-plugin-istanbul: - specifier: ^5.0.0 - version: 5.0.0(vite@5.4.11) + specifier: ^6.0.2 + version: 6.0.2(vite@5.4.11) packages: @@ -3022,18 +3022,18 @@ packages: estraverse: 4.3.0 dev: true - /eslint-visitor-keys@3.4.3: - resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /eslint-visitor-keys@4.2.0: + resolution: {integrity: sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} dev: true - /espree@9.6.1: - resolution: {integrity: sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + /espree@10.3.0: + resolution: {integrity: sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} dependencies: acorn: 8.14.0 acorn-jsx: 5.3.2(acorn@8.14.0) - eslint-visitor-keys: 3.4.3 + eslint-visitor-keys: 4.2.0 dev: true /esprima@4.0.1: @@ -3504,12 +3504,6 @@ packages: engines: {node: '>=16.17.0'} dev: true - /husky@9.1.7: - resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} - engines: {node: '>=18'} - hasBin: true - dev: true - /ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} dev: true @@ -3656,19 +3650,6 @@ packages: - supports-color dev: true - /istanbul-lib-instrument@5.2.1: - resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==} - engines: {node: '>=8'} - dependencies: - '@babel/core': 7.26.0 - '@babel/parser': 7.26.2 - '@istanbuljs/schema': 0.1.3 - istanbul-lib-coverage: 3.2.2 - semver: 6.3.1 - transitivePeerDependencies: - - supports-color - dev: true - /istanbul-lib-instrument@6.0.3: resolution: {integrity: sha512-Vtgk7L/R2JHyyGW07spoFlB8/lpjiOLTjMdms6AFMraYt3BaJauod/NGrfnVG/y4Ix1JEuMRPDPEj2ua+zz1/Q==} engines: {node: '>=10'} @@ -3837,6 +3818,103 @@ packages: hasBin: true dev: true + /lefthook-darwin-arm64@1.8.4: + resolution: {integrity: sha512-OS5MsU0gvd8LYSpuQCHtmDUqwNrJ/LjCO0LGC1wNepY4OkuVl9DfX+rQ506CVUQYZiGVcwy2/qPOOBjNzA5+wQ==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /lefthook-darwin-x64@1.8.4: + resolution: {integrity: sha512-QLRsqK9aTMRcVW8qz4pzI2OWnGCEcaEPJlIiFjwstYsS+wfkooxOS0UkfVMjy+QoGgEcki+cxF/FoY7lE7DDtw==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /lefthook-freebsd-arm64@1.8.4: + resolution: {integrity: sha512-chnQ1m/Cmn9c0sLdk5HL2SToE5LBJv5uQMdH1IGRRcw+nEqWqrMnDXvM75caiJAyjmUGvPH3czKTJDzTFV1E+A==} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /lefthook-freebsd-x64@1.8.4: + resolution: {integrity: sha512-KQi+WBUdnGLnK0rHOR58kbMH5TDVN1ZjZLu66Pv9FCG7Y7shR1qtaTXu+wmxdRhMvaLeQIXRsUEPjNRC66yMmA==} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + + /lefthook-linux-arm64@1.8.4: + resolution: {integrity: sha512-CXNcqIskLwTwQARidGdFqmNxpvOU3jsWPK4KA7pq2+QmlWJ64w98ebMvNBoUmRUCXqzmUm7Udf/jpfz2fobewQ==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /lefthook-linux-x64@1.8.4: + resolution: {integrity: sha512-pVNITkFBxUCEtamWSM/res2Gd48+m9YKbNyIBndAuZVC5pKV5aGKZy2DNq6PWUPYiUDPx+7hoAtCJg/tlAiqhw==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /lefthook-openbsd-arm64@1.8.4: + resolution: {integrity: sha512-l+i/Dg5X36kYzhpMGSPE3rMbWy1KSytbLB9lY1PmxYb6LRH6iQTYIoxvLabVUwSBPSq8HtIFa50+bvC5+scfVA==} + cpu: [arm64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /lefthook-openbsd-x64@1.8.4: + resolution: {integrity: sha512-CqhDDPPX8oHzMLgNi/Reba823DRzj+eMNWQ8axvSiIG+zmG1w20xZH5QSs/mD3tjrND90yfDd90mWMt181qPyA==} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + + /lefthook-windows-arm64@1.8.4: + resolution: {integrity: sha512-dvpvorICmVjmw29Aiczg7DcaSzkd86bEBomiGq4UsAEk3+7ExLrlWJDLFsI6xLjMKmTxy+F7eXb2uDtuFC1N4g==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /lefthook-windows-x64@1.8.4: + resolution: {integrity: sha512-e+y8Jt4/7PnoplhOuK48twjGVJEsU4T3J5kxD4mWfl6Cbit0YSn4bme9nW41eqCqTUqOm+ky29XlfnPHFX5ZNA==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + + /lefthook@1.8.4: + resolution: {integrity: sha512-XNyMaTWNRuADOaocYiHidgNkNDz8SCekpdNJ7lqceFcBT2zjumnb28/o7IMaNROpLBZdQkLkJXSeaQWGqn3kog==} + hasBin: true + requiresBuild: true + optionalDependencies: + lefthook-darwin-arm64: 1.8.4 + lefthook-darwin-x64: 1.8.4 + lefthook-freebsd-arm64: 1.8.4 + lefthook-freebsd-x64: 1.8.4 + lefthook-linux-arm64: 1.8.4 + lefthook-linux-x64: 1.8.4 + lefthook-openbsd-arm64: 1.8.4 + lefthook-openbsd-x64: 1.8.4 + lefthook-windows-arm64: 1.8.4 + lefthook-windows-x64: 1.8.4 + dev: true + /lilconfig@3.1.2: resolution: {integrity: sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==} engines: {node: '>=14'} @@ -4427,8 +4505,8 @@ packages: source-map-js: 1.2.1 dev: true - /prettier@3.2.2: - resolution: {integrity: sha512-HTByuKZzw7utPiDO523Tt2pLtEyK7OibUD9suEJQrPUCYQqrHr74GGX6VidMrovbf/I50mPqr8j/II6oBAuc5A==} + /prettier@3.3.3: + resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==} engines: {node: '>=14'} hasBin: true dev: true @@ -4872,6 +4950,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /source-map@0.7.4: + resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} + engines: {node: '>= 8'} + dev: true + /source-map@0.8.0-beta.0: resolution: {integrity: sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==} engines: {node: '>= 8'} @@ -5295,15 +5378,16 @@ packages: extsprintf: 1.3.0 dev: true - /vite-plugin-istanbul@5.0.0(vite@5.4.11): - resolution: {integrity: sha512-Tg9zDmm/u4SdEDFbEWHBz7mmFe7jhLRmArA2XCmw5yydEFCARU9r4TxqFFnBFWCL63D9A7XA7VELulOO5T5o/g==} + /vite-plugin-istanbul@6.0.2(vite@5.4.11): + resolution: {integrity: sha512-0/sKwjEEIwbEyl43xX7onX3dIbMJAsigNsKyyVPalG1oRFo5jn3qkJbS2PUfp9wrr3piy1eT6qRoeeum2p4B2A==} peerDependencies: - vite: '>=2.9.1 <= 5' + vite: '>=4 <=6' dependencies: '@istanbuljs/load-nyc-config': 1.1.0 - espree: 9.6.1 - istanbul-lib-instrument: 5.2.1 + espree: 10.3.0 + istanbul-lib-instrument: 6.0.3 picocolors: 1.1.1 + source-map: 0.7.4 test-exclude: 6.0.0 vite: 5.4.11(@types/node@22.9.3) transitivePeerDependencies: diff --git a/src/addons/use-notification-center/NotificationCenter.cy.tsx b/src/addons/use-notification-center/NotificationCenter.cy.tsx index 0550af87..1fd59dff 100644 --- a/src/addons/use-notification-center/NotificationCenter.cy.tsx +++ b/src/addons/use-notification-center/NotificationCenter.cy.tsx @@ -1,25 +1,14 @@ import React from 'react'; -import { ToastContainer, toast } from 'react-toastify'; -import { - NotificationCenterItem, - UseNotificationCenterParams, - useNotificationCenter -} from './useNotificationCenter'; +import { toast, ToastContainer } from 'react-toastify'; +import { NotificationCenterItem, useNotificationCenter, UseNotificationCenterParams } from './useNotificationCenter'; function TestComponent(props: UseNotificationCenterParams) { const [content, setContent] = React.useState(''); const [updateId, setUpdateId] = React.useState(''); - const { - unreadCount, - markAllAsRead, - markAsRead, - notifications, - remove, - add, - clear, - update - } = useNotificationCenter(props || {}); + const { unreadCount, markAllAsRead, markAsRead, notifications, remove, add, clear, update } = useNotificationCenter( + props || {} + ); const flex = { display: 'flex', @@ -33,9 +22,7 @@ function TestComponent(props: UseNotificationCenterParams) { - + - setContent(e.target.value)} - value={content} - /> - setUpdateId(e.target.value)} - value={updateId} - /> + setContent(e.target.value)} value={content} /> + setUpdateId(e.target.value)} value={updateId} />