From 6b1feee18d5638781e79505727654f0b511cd663 Mon Sep 17 00:00:00 2001 From: KevinLeScouarnec Date: Wed, 2 Oct 2024 11:32:29 -0400 Subject: [PATCH] chore: upgrade TypeScript and ESLint libraries for TypeScript support --- documentation/helpers/ToC/useActiveAnchor.ts | 8 +- package-lock.json | 371 ++++++++++++++++-- package.json | 6 +- packages/components/chip/src/Chip.stories.tsx | 4 +- .../components/chip/src/ChipClearButton.tsx | 4 +- .../components/chip/src/useChipElement.tsx | 14 +- .../combobox/src/tests/test-utils.ts | 2 +- .../icons/scripts/utils/matchFileRoutes.mjs | 4 +- packages/components/pagination/src/utils.ts | 11 +- .../components/select/src/SelectContext.tsx | 2 +- .../components/snackbar/src/SnackbarItem.tsx | 4 +- .../components/tabs/src/useResizeObserver.ts | 3 +- packages/components/tag/src/Tag.stories.tsx | 2 +- .../src/useCombinedState.tsx | 2 +- .../hooks/use-merge-refs/src/useMergeRefs.tsx | 2 +- .../internal-utils/src/variants/types.ts | 3 +- .../tailwind-plugins/animations/index.js | 5 +- packages/utils/tailwind-plugins/index.js | 20 +- .../utils/tailwind-plugins/sizings/index.js | 5 +- .../spark-theme/getCSSVariableDeclarations.js | 12 +- .../spark-theme/getCSSVariableReferences.js | 13 +- .../tailwind-plugins/spark-theme/index.js | 17 +- .../utils/tailwind-plugins/utilities/index.js | 5 +- .../utils/tailwind-plugins/variants/index.js | 5 +- tailwind.config.cjs | 8 +- tsconfig.json | 1 + 26 files changed, 424 insertions(+), 109 deletions(-) diff --git a/documentation/helpers/ToC/useActiveAnchor.ts b/documentation/helpers/ToC/useActiveAnchor.ts index 3582c63f7..596ef8d71 100644 --- a/documentation/helpers/ToC/useActiveAnchor.ts +++ b/documentation/helpers/ToC/useActiveAnchor.ts @@ -23,13 +23,17 @@ export const useActiveAnchor = (elements: HTMLHeadingElement[]): HTMLHeadingElem const handleScroll = useCallback(() => { if (elements) { const closestAnchor = findAnchorClosestToTop(elements) - closestAnchor && setActiveAnchor(closestAnchor) + if (closestAnchor) { + setActiveAnchor(closestAnchor) + } } }, [elements]) useEffect(() => { const closestAnchor = elements && findAnchorClosestToTop(elements) - closestAnchor && setActiveAnchor(closestAnchor) + if (closestAnchor) { + setActiveAnchor(closestAnchor) + } window.addEventListener('scroll', handleScroll) diff --git a/package-lock.json b/package-lock.json index e2301337d..4132d3cfb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,8 +54,8 @@ "@types/node": "^20.14.11", "@types/react": "18.3.5", "@types/react-dom": "18.3.0", - "@typescript-eslint/eslint-plugin": "5.62.0", - "@typescript-eslint/parser": "5.62.0", + "@typescript-eslint/eslint-plugin": "8.8.0", + "@typescript-eslint/parser": "8.8.0", "@vitejs/plugin-react": "3.1.0", "@vitest/coverage-istanbul": "^0.34.1", "@vitest/ui": "0.34.7", @@ -105,7 +105,7 @@ "tailwindcss-radix": "2.9.0", "ts-node": "10.9.2", "type-fest": "3.13.1", - "typescript": "5.5.4", + "typescript": "5.6.2", "vite": "^4.3.9", "vite-plugin-dts": "2.3.0", "vite-plugin-turbosnap": "1.0.3", @@ -2330,6 +2330,7 @@ }, "node_modules/@clack/prompts/node_modules/is-unicode-supported": { "version": "1.3.0", + "extraneous": true, "inBundle": true, "license": "MIT", "engines": { @@ -14607,32 +14608,113 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.62.0.tgz", - "integrity": "sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.0.tgz", + "integrity": "sha512-wORFWjU30B2WJ/aXBfOm1LX9v9nyt9D3jsSOxC3cCaTQGCW5k4jNpmjFv3U7p/7s4yvdjHzwtv2Sd2dOyhjS0A==", "dev": true, "dependencies": { - "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.62.0", - "@typescript-eslint/type-utils": "5.62.0", - "@typescript-eslint/utils": "5.62.0", - "debug": "^4.3.4", + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.8.0", + "@typescript-eslint/type-utils": "8.8.0", + "@typescript-eslint/utils": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0", "graphemer": "^1.4.0", - "ignore": "^5.2.0", - "natural-compare-lite": "^1.4.0", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.0.tgz", + "integrity": "sha512-EL8eaGC6gx3jDd8GwEFEV091210U97J0jeEHrAYvIYosmEGet4wJ+g0SYmLu+oRiAwbSA5AVrt6DxLHfdd+bUg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/type-utils": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.8.0.tgz", + "integrity": "sha512-IKwJSS7bCqyCeG4NVGxnOP6lLT9Okc3Zj8hLO96bpMkJab+10HIfJbMouLrlpyOr3yrQ1cA413YPFiGd1mW9/Q==", + "dev": true, + "dependencies": { + "@typescript-eslint/typescript-estree": "8.8.0", + "@typescript-eslint/utils": "8.8.0", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.0.tgz", + "integrity": "sha512-QJwc50hRCgBd/k12sTykOJbESe1RrzmX6COk8Y525C9l7oweZ+1lw9JiU56im7Amm8swlz00DRIlxMYLizr2Vw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.0.tgz", + "integrity": "sha512-ZaMJwc/0ckLz5DaAZ+pNLmHv8AMVGtfWxZe/x2JVEkD5LnmhWiQMMcYT7IY7gkdJuzJ9P14fRy28lUrlDSWYdw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" }, "peerDependenciesMeta": { "typescript": { @@ -14640,10 +14722,89 @@ } } }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.8.0.tgz", + "integrity": "sha512-QE2MgfOTem00qrlPgyByaCHay9yb1+9BjnMFnSFkUKQfu7adBXDTnCAivURnuPPAG/qiB+kzKkZKmKfaMT0zVg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.8.0", + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/typescript-estree": "8.8.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.0.tgz", + "integrity": "sha512-8mq51Lx6Hpmd7HnA2fcHQo3YgfX1qbccxQOgZcb4tvasu//zXRaA1j5ZRFeCw/VRAdFi4mRM9DnZw0Nu0Q2d1g==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/@typescript-eslint/eslint-plugin/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/semver": { - "version": "7.6.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", - "integrity": "sha512-FNAIBWCx9qcRhoHcgcJ0gvU7SN1lYU2ZXuSfl04bSC5OpvDHFyJCjdNHomPXxjQlCBU67YW64PzY7/VIEH7F2w==", + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, "bin": { "semver": "bin/semver.js" @@ -14653,25 +14814,26 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.62.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", - "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.8.0.tgz", + "integrity": "sha512-uEFUsgR+tl8GmzmLjRqz+VrDv4eoaMqMXW7ruXfgThaAShO9JTciKpEsB+TvnfFfbg5IpujgMXVV36gOJRLtZg==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "5.62.0", - "@typescript-eslint/types": "5.62.0", - "@typescript-eslint/typescript-estree": "5.62.0", + "@typescript-eslint/scope-manager": "8.8.0", + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/typescript-estree": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0", "debug": "^4.3.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^8.57.0 || ^9.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -14679,6 +14841,133 @@ } } }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.0.tgz", + "integrity": "sha512-EL8eaGC6gx3jDd8GwEFEV091210U97J0jeEHrAYvIYosmEGet4wJ+g0SYmLu+oRiAwbSA5AVrt6DxLHfdd+bUg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.0.tgz", + "integrity": "sha512-QJwc50hRCgBd/k12sTykOJbESe1RrzmX6COk8Y525C9l7oweZ+1lw9JiU56im7Amm8swlz00DRIlxMYLizr2Vw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.0.tgz", + "integrity": "sha512-ZaMJwc/0ckLz5DaAZ+pNLmHv8AMVGtfWxZe/x2JVEkD5LnmhWiQMMcYT7IY7gkdJuzJ9P14fRy28lUrlDSWYdw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "@typescript-eslint/visitor-keys": "8.8.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.0.tgz", + "integrity": "sha512-8mq51Lx6Hpmd7HnA2fcHQo3YgfX1qbccxQOgZcb4tvasu//zXRaA1j5ZRFeCw/VRAdFi4mRM9DnZw0Nu0Q2d1g==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "8.8.0", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/parser/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@typescript-eslint/scope-manager": { "version": "5.62.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz", @@ -27526,12 +27815,6 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==", - "dev": true - }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -34047,6 +34330,18 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/ts-api-utils": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", + "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", + "dev": true, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-dedent": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz", @@ -34622,9 +34917,9 @@ } }, "node_modules/typescript": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 3af175002..6fe8c897a 100644 --- a/package.json +++ b/package.json @@ -77,8 +77,8 @@ "@types/node": "^20.14.11", "@types/react": "18.3.5", "@types/react-dom": "18.3.0", - "@typescript-eslint/eslint-plugin": "5.62.0", - "@typescript-eslint/parser": "5.62.0", + "@typescript-eslint/eslint-plugin": "8.8.0", + "@typescript-eslint/parser": "8.8.0", "@vitejs/plugin-react": "3.1.0", "@vitest/coverage-istanbul": "^0.34.1", "@vitest/ui": "0.34.7", @@ -128,7 +128,7 @@ "tailwindcss-radix": "2.9.0", "ts-node": "10.9.2", "type-fest": "3.13.1", - "typescript": "5.5.4", + "typescript": "5.6.2", "vite": "^4.3.9", "vite-plugin-dts": "2.3.0", "vite-plugin-turbosnap": "1.0.3", diff --git a/packages/components/chip/src/Chip.stories.tsx b/packages/components/chip/src/Chip.stories.tsx index 6003b6bda..360e31641 100644 --- a/packages/components/chip/src/Chip.stories.tsx +++ b/packages/components/chip/src/Chip.stories.tsx @@ -286,7 +286,9 @@ export const Input: StoryFn = () => { onChange={event => setValue(event.target.value)} onKeyPress={event => { if (event.key === 'Enter') { - !tags.includes(value) && setTags([...tags, value]) + if (!tags.includes(value)) { + setTags([...tags, value]) + } setValue('') } }} diff --git a/packages/components/chip/src/ChipClearButton.tsx b/packages/components/chip/src/ChipClearButton.tsx index bab341240..da1f256bb 100644 --- a/packages/components/chip/src/ChipClearButton.tsx +++ b/packages/components/chip/src/ChipClearButton.tsx @@ -33,7 +33,9 @@ export const ChipClearButton = forwardRef const onClearHandler = useCallback( (event: React.MouseEvent) => { event.stopPropagation() - !disabled && onClear && onClear(event) + if (!disabled && onClear) { + onClear(event) + } }, [disabled, onClear] ) diff --git a/packages/components/chip/src/useChipElement.tsx b/packages/components/chip/src/useChipElement.tsx index d4a6e81ce..280dc796a 100644 --- a/packages/components/chip/src/useChipElement.tsx +++ b/packages/components/chip/src/useChipElement.tsx @@ -108,8 +108,12 @@ export const useChipElement = ({ if (!!clearButton && !disabled && ['Delete', 'Backspace'].includes(event.key)) { if (onClear) { onClear() - event.key === 'Delete' && emulateTab() - event.key === 'Backspace' && emulateTab.backwards() + if (event.key === 'Delete') { + emulateTab() + } + if (event.key === 'Backspace') { + emulateTab.backwards() + } } } } @@ -124,8 +128,10 @@ export const useChipElement = ({ 'data-state': isPressed ? 'on' : 'off', }), onClick: (event: React.MouseEvent): void => { - isPressed !== undefined && setIsPressed(!isPressed) - onClick && onClick(event, { pressed: isPressed as boolean, value: innerValue }) + if (isPressed !== undefined) { + setIsPressed(!isPressed) + } + onClick?.(event, { pressed: isPressed as boolean, value: innerValue }) }, onKeyDown, disabled, diff --git a/packages/components/combobox/src/tests/test-utils.ts b/packages/components/combobox/src/tests/test-utils.ts index c44eaa905..942ac78b0 100644 --- a/packages/components/combobox/src/tests/test-utils.ts +++ b/packages/components/combobox/src/tests/test-utils.ts @@ -27,7 +27,7 @@ export const getSelectedItem = (accessibleName: string) => { return within(item).queryByText(accessibleName) }) - return matchingItem || (null as any as HTMLElement) + return matchingItem || (null as unknown as HTMLElement) } export const getSelectedItemClearButton = (accessibleName: string) => { diff --git a/packages/components/icons/scripts/utils/matchFileRoutes.mjs b/packages/components/icons/scripts/utils/matchFileRoutes.mjs index 1fef95742..326c9b2fb 100755 --- a/packages/components/icons/scripts/utils/matchFileRoutes.mjs +++ b/packages/components/icons/scripts/utils/matchFileRoutes.mjs @@ -10,8 +10,8 @@ const matchFileRoutes = (base = process.cwd(), minimatchPattern, accomulator) => const newBase = path.join(base, file) if (fs.statSync(newBase).isDirectory()) { result = matchFileRoutes(newBase, minimatchPattern, result) - } else { - minimatch(newBase.replace(`${process.cwd()}/`, ''), minimatchPattern) && result.push(newBase) + } else if (minimatch(newBase.replace(`${process.cwd()}/`, ''), minimatchPattern)) { + result.push(newBase) } }) diff --git a/packages/components/pagination/src/utils.ts b/packages/components/pagination/src/utils.ts index 346ce874a..2930a1eb2 100644 --- a/packages/components/pagination/src/utils.ts +++ b/packages/components/pagination/src/utils.ts @@ -1,4 +1,13 @@ -export function sliceArrayWithIndex(arr: any[], index: number, length: number) { +type Page = + | { + type: 'ellipsis' + } + | { + type: 'page' + value: number + } + +export function sliceArrayWithIndex(arr: Page[], index: number, length: number) { const relativeElements = (length - 1) / 2 let start = Math.max(0, index - relativeElements) diff --git a/packages/components/select/src/SelectContext.tsx b/packages/components/select/src/SelectContext.tsx index 03072353a..ecff460a1 100644 --- a/packages/components/select/src/SelectContext.tsx +++ b/packages/components/select/src/SelectContext.tsx @@ -95,7 +95,7 @@ export const SelectProvider = ({ const [ariaLabel, setAriaLabel] = useState() // Computed state - const firstItem = itemsMap.entries().next().value[1] + const firstItem = itemsMap.entries().next().value?.[1] const selectedItem = typeof value === 'string' ? itemsMap.get(value) : firstItem const isControlled = valueProp != null diff --git a/packages/components/snackbar/src/SnackbarItem.tsx b/packages/components/snackbar/src/SnackbarItem.tsx index 5bf51c8c7..f473a6d8f 100644 --- a/packages/components/snackbar/src/SnackbarItem.tsx +++ b/packages/components/snackbar/src/SnackbarItem.tsx @@ -94,7 +94,9 @@ export const SnackbarItem = forwardRef { - ;['left', 'right'].includes(`${direction}`) && state.close(toast.key) + if (['left', 'right'].includes(`${direction}`)) { + state.close(toast.key) + } }, }) diff --git a/packages/components/tabs/src/useResizeObserver.ts b/packages/components/tabs/src/useResizeObserver.ts index d45407ccf..4acea8385 100644 --- a/packages/components/tabs/src/useResizeObserver.ts +++ b/packages/components/tabs/src/useResizeObserver.ts @@ -35,8 +35,7 @@ export const useResizeObserver = ( resizeObserverRef.current.observe(targetElm as unknown as HTMLElement) return () => { - resizeObserverRef.current && - resizeObserverRef.current.unobserve(targetElm as unknown as HTMLElement) + resizeObserverRef.current?.unobserve(targetElm as unknown as HTMLElement) } }, [target, resizeObserverRef, resizeCallbackRef]) diff --git a/packages/components/tag/src/Tag.stories.tsx b/packages/components/tag/src/Tag.stories.tsx index af3582dcd..212e200a9 100644 --- a/packages/components/tag/src/Tag.stories.tsx +++ b/packages/components/tag/src/Tag.stories.tsx @@ -50,7 +50,7 @@ export const Intent: StoryFn = _args => ( } return ( - + {intent} tag ) diff --git a/packages/hooks/use-combined-state/src/useCombinedState.tsx b/packages/hooks/use-combined-state/src/useCombinedState.tsx index d7780daf4..4eb955e05 100644 --- a/packages/hooks/use-combined-state/src/useCombinedState.tsx +++ b/packages/hooks/use-combined-state/src/useCombinedState.tsx @@ -31,7 +31,7 @@ export function useCombinedState( if (shouldUpdate && !isControlled) { setInnerValue(nextValue) } - onChange && onChange(nextValue) + onChange?.(nextValue) }, [isControlled, value, onChange] ) diff --git a/packages/hooks/use-merge-refs/src/useMergeRefs.tsx b/packages/hooks/use-merge-refs/src/useMergeRefs.tsx index a039c1941..e951cc8a3 100644 --- a/packages/hooks/use-merge-refs/src/useMergeRefs.tsx +++ b/packages/hooks/use-merge-refs/src/useMergeRefs.tsx @@ -15,7 +15,7 @@ export function assignRef(ref: ReactRef | null | undefined, value: T) { try { ;(ref as MutableRefObject).current = value - } catch (error) { + } catch { throw new Error(`Cannot assign value '${value}' to ref '${ref}'`) } } diff --git a/packages/utils/internal-utils/src/variants/types.ts b/packages/utils/internal-utils/src/variants/types.ts index 861a1d6d9..9b3fdb8ec 100644 --- a/packages/utils/internal-utils/src/variants/types.ts +++ b/packages/utils/internal-utils/src/variants/types.ts @@ -1,7 +1,6 @@ import { designs, intents, shapes, sizes } from './constants' -/* eslint-disable-next-line @typescript-eslint/ban-types */ -type Picks = PickedItems extends [ +type Picks = PickedItems extends [ infer Head, ...infer Rest, ] diff --git a/packages/utils/tailwind-plugins/animations/index.js b/packages/utils/tailwind-plugins/animations/index.js index 3f2db9c58..8e4ef0165 100644 --- a/packages/utils/tailwind-plugins/animations/index.js +++ b/packages/utils/tailwind-plugins/animations/index.js @@ -1,5 +1,4 @@ -/* eslint-disable-next-line @typescript-eslint/no-var-requires */ -const plugin = require('tailwindcss/plugin') +import { withOptions } from 'tailwindcss/plugin' function arrToObj(arr) { return arr.reduce((acc, cur) => { @@ -25,7 +24,7 @@ function removeKeyFromObj(obj, key) { return copyObj } -module.exports = plugin.withOptions( +export default withOptions( /** * @typedef {Object} Options * @property {string} variantPrefix The prefix to use for the animation variants. diff --git a/packages/utils/tailwind-plugins/index.js b/packages/utils/tailwind-plugins/index.js index a5779b710..49ea134be 100644 --- a/packages/utils/tailwind-plugins/index.js +++ b/packages/utils/tailwind-plugins/index.js @@ -1,12 +1,12 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const animations = require('./animations') -const sizings = require('./sizings') -const utilities = require('./utilities') -const variants = require('./variants') -const sparkTheme = require('./spark-theme') -const tailwindConfigViewerUtils = require('./tailwind-config-viewer') -const tailwindConfigViewerMisc = require('./tailwind-config-viewer/misc') -const tailwindcssRadix = require('tailwindcss-radix') +import tailwindcssRadix from 'tailwindcss-radix' + +import animations from './animations' +import sizings from './sizings' +import sparkTheme from './spark-theme' +import tailwindConfigViewerUtils from './tailwind-config-viewer' +import tailwindConfigViewerMisc from './tailwind-config-viewer/misc' +import utilities from './utilities' +import variants from './variants' /** * @typedef {Object} Options @@ -31,7 +31,7 @@ const sparkConfig = ({ htmlFontSize, themes }) => { ] } -module.exports = { +export default { animations, sizings, utilities, diff --git a/packages/utils/tailwind-plugins/sizings/index.js b/packages/utils/tailwind-plugins/sizings/index.js index 4326d327f..1707b7188 100644 --- a/packages/utils/tailwind-plugins/sizings/index.js +++ b/packages/utils/tailwind-plugins/sizings/index.js @@ -1,5 +1,4 @@ -/* eslint-disable-next-line @typescript-eslint/no-var-requires */ -const plugin = require('tailwindcss/plugin') +import { withOptions } from 'tailwindcss/plugin' const sizingRange = [ 0, 1, 2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 48, 56, 64, 80, 96, 112, 128, 144, @@ -33,7 +32,7 @@ function getCSSVariableReferences() { return CSSVariableReferences } -module.exports = plugin.withOptions( +export default withOptions( /** * @typedef {Object} Options * @property {number} htmlFontSize The base font size of your app. diff --git a/packages/utils/tailwind-plugins/spark-theme/getCSSVariableDeclarations.js b/packages/utils/tailwind-plugins/spark-theme/getCSSVariableDeclarations.js index 28e58c463..a1800826d 100644 --- a/packages/utils/tailwind-plugins/spark-theme/getCSSVariableDeclarations.js +++ b/packages/utils/tailwind-plugins/spark-theme/getCSSVariableDeclarations.js @@ -1,15 +1,13 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { DEFAULT_KEY } = require('./constants') -const { hexRgb } = require('./hexRgb') - -const { +import { DEFAULT_KEY } from './constants' +import { hexRgb } from './hexRgb' +import { doubleHyphensRegex, getRemEquivalentValue, isHex, isObject, isStringOrNumber, toKebabCase, -} = require('./utils') +} from './utils' function getCSSVariableDeclarations(_theme, htmlFontSize) { const CSSVariableObj = {} @@ -46,4 +44,4 @@ function getCSSVariableDeclarations(_theme, htmlFontSize) { return CSSVariableObj } -module.exports = { getCSSVariableDeclarations } +export default { getCSSVariableDeclarations } diff --git a/packages/utils/tailwind-plugins/spark-theme/getCSSVariableReferences.js b/packages/utils/tailwind-plugins/spark-theme/getCSSVariableReferences.js index e36aed5b3..1e40da512 100644 --- a/packages/utils/tailwind-plugins/spark-theme/getCSSVariableReferences.js +++ b/packages/utils/tailwind-plugins/spark-theme/getCSSVariableReferences.js @@ -1,13 +1,12 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { +import { DEFAULT_KEY, tailwindCategoryKeys, - transitionDurationLookup, transitionDelayDurationLookup, + transitionDurationLookup, transitionTimingFunctionLookup, unassignedColors, -} = require('./constants') -const { +} from './constants' +import { doubleHyphensRegex, hasNumber, isAlphanumericWithLeadingLetter, @@ -16,7 +15,7 @@ const { isObject, isStringOrNumber, toKebabCase, -} = require('./utils') +} from './utils' function getCSSVariableReferences(_theme) { const themeCpy = JSON.parse(JSON.stringify(_theme)) @@ -117,4 +116,4 @@ function getCSSVariableReferences(_theme) { } } -module.exports = { getCSSVariableReferences } +export default { getCSSVariableReferences } diff --git a/packages/utils/tailwind-plugins/spark-theme/index.js b/packages/utils/tailwind-plugins/spark-theme/index.js index 219cf28ff..f52e11883 100644 --- a/packages/utils/tailwind-plugins/spark-theme/index.js +++ b/packages/utils/tailwind-plugins/spark-theme/index.js @@ -1,10 +1,9 @@ -/* eslint-disable @typescript-eslint/no-var-requires */ -const { getCSSVariableDeclarations } = require('./getCSSVariableDeclarations') -const { getCSSVariableReferences } = require('./getCSSVariableReferences') -const { retrieveArrayDifferences, getAllObjectKeys, getObjectDifferences } = require('./utils') +import { defaultTheme } from '@spark-ui/theme-utils' +import { withOptions } from 'tailwindcss/plugin' -const themeUtils = require('@spark-ui/theme-utils') -const plugin = require('tailwindcss/plugin') +import { getCSSVariableDeclarations } from './getCSSVariableDeclarations' +import { getCSSVariableReferences } from './getCSSVariableReferences' +import { getAllObjectKeys, getObjectDifferences, retrieveArrayDifferences } from './utils' const missingDefaultThemeErrorMsg = 'A default theme is required. Please ensure that the "themes" object passed to this plugin includes a "default" key containing your default theme.' @@ -19,7 +18,7 @@ const missingItemsErrorMsg = (themeLabel, keys) => keys )} are missing from the ${themeLabel} theme, but required to comply with our Spark Theme interface` -module.exports = plugin.withOptions( +export default withOptions( /** * @typedef {Object} Options * @property {Object} options.themes - An object containing your themes where each key corresponds to a data-theme attribute value. @@ -43,7 +42,7 @@ module.exports = plugin.withOptions( if (!themes.default) throw new Error(missingDefaultThemeErrorMsg) const { missingItems, additionalItems } = retrieveArrayDifferences({ - ref: getAllObjectKeys(themeUtils.defaultTheme), + ref: getAllObjectKeys(defaultTheme), comp: getAllObjectKeys(themes.default), }) @@ -61,7 +60,7 @@ module.exports = plugin.withOptions( if (key === 'default') return const { missingItems, additionalItems } = retrieveArrayDifferences({ - ref: getAllObjectKeys(themeUtils.defaultTheme), + ref: getAllObjectKeys(defaultTheme), comp: getAllObjectKeys(value), }) diff --git a/packages/utils/tailwind-plugins/utilities/index.js b/packages/utils/tailwind-plugins/utilities/index.js index 1ecd13f93..616112725 100644 --- a/packages/utils/tailwind-plugins/utilities/index.js +++ b/packages/utils/tailwind-plugins/utilities/index.js @@ -1,7 +1,6 @@ -/* eslint-disable-next-line @typescript-eslint/no-var-requires */ -const plugin = require('tailwindcss/plugin') +import { withOptions } from 'tailwindcss/plugin' -module.exports = plugin.withOptions(() => ({ addUtilities, theme }) => { +export default withOptions(() => ({ addUtilities, theme }) => { addUtilities({ '.u-current-font-size': { width: '1em', diff --git a/packages/utils/tailwind-plugins/variants/index.js b/packages/utils/tailwind-plugins/variants/index.js index 497e5656a..774dae20a 100644 --- a/packages/utils/tailwind-plugins/variants/index.js +++ b/packages/utils/tailwind-plugins/variants/index.js @@ -1,6 +1,5 @@ -/* eslint-disable-next-line @typescript-eslint/no-var-requires */ -const plugin = require('tailwindcss/plugin') +import { withOptions } from 'tailwindcss/plugin' -module.exports = plugin.withOptions(() => ({ addVariant }) => { +export default withOptions(() => ({ addVariant }) => { addVariant('retina', '@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)') }) diff --git a/tailwind.config.cjs b/tailwind.config.cjs index d46680421..a4166c110 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -1,9 +1,13 @@ -const sparkPlugins = require('@spark-ui/tailwind-plugins') +const sparkPlugins = require('@spark-ui/tailwind-plugins').default const themeUtils = require('@spark-ui/theme-utils') /** @type {import('tailwindcss').Config} */ module.exports = { - content: ['./.storybook/**/*.{js,ts,jsx,tsx}', './packages/**/*.{js,ts,jsx,tsx}', './documentation/**/*.{js,ts,jsx,tsx,mdx}'], + content: [ + './.storybook/**/*.{js,ts,jsx,tsx}', + './packages/**/*.{js,ts,jsx,tsx}', + './documentation/**/*.{js,ts,jsx,tsx,mdx}', + ], plugins: [ ...sparkPlugins.sparkConfig({ themes: { diff --git a/tsconfig.json b/tsconfig.json index e3d3afeeb..c760b4175 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ "downlevelIteration": true, "emitDeclarationOnly": false, "noEmit": true, + "strict": true, "module": "ESNext", "paths": { "@docs/*": ["documentation/*"]