From 53ac883c1877de4c675d9811ff7eb4ee608e4919 Mon Sep 17 00:00:00 2001 From: Alex <8125011+alex-kinokon@users.noreply.github.com> Date: Sat, 6 Jul 2024 19:17:37 -0400 Subject: [PATCH] Update --- package.json | 13 +- pnpm-lock.yaml | 196 ++++++++++-------- src/__tests__/__snapshots__/attr.test.ts.snap | 24 +-- .../__snapshots__/options.test.ts.snap | 12 +- .../__snapshots__/spread.test.ts.snap | 45 ++-- .../__snapshots__/styleObject.test.ts.snap | 4 +- src/__tests__/__snapshots__/tw.test.ts.snap | 41 ++++ src/__tests__/attr.test.ts | 8 +- src/__tests__/options.test.ts | 6 +- src/__tests__/spread.test.ts | 28 ++- src/__tests__/styleObject.test.ts | 8 +- src/__tests__/tw.test.ts | 37 +--- src/__tests__/utils.ts | 18 +- src/babel-tailwind.ts | 19 +- 14 files changed, 259 insertions(+), 200 deletions(-) create mode 100644 src/__tests__/__snapshots__/tw.test.ts.snap diff --git a/package.json b/package.json index 1645a67..d881f14 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "@aet/tailwind", - "version": "0.0.1-beta.34", + "version": "0.0.1-beta.36", "license": "MIT", "scripts": { "build": "./scripts/index.ts", - "test": "vitest" + "test": "vitest", + "do": "vitest run && yarn build && ver bump && npm publish && ver unpub" }, "files": [ "dist" @@ -18,12 +19,12 @@ } }, "devDependencies": { - "@aet/eslint-rules": "^0.0.34", + "@aet/eslint-rules": "^0.0.36", "@types/babel__core": "^7.20.5", "@types/bun": "^1.1.6", "@types/dedent": "^0.7.2", "@types/lodash": "^4.17.6", - "@types/node": "^20.14.9", + "@types/node": "^20.14.10", "@types/postcss-safe-parser": "^5.0.4", "@types/react": "^18.3.3", "@types/stylis": "^4.2.6", @@ -40,7 +41,7 @@ "tslib": "^2.6.3", "tsup": "^8.1.0", "typescript": "^5.5.3", - "vite": "^5.3.2", + "vite": "^5.3.3", "vitest": "^1.6.0" }, "peerDependencies": { @@ -66,4 +67,4 @@ "singleQuote": false, "trailingComma": "es5" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c40c06c..9e74826 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,8 +40,8 @@ importers: version: 4.21.0 devDependencies: '@aet/eslint-rules': - specifier: ^0.0.34 - version: 0.0.34(eslint@8.57.0)(typescript@5.5.3) + specifier: ^0.0.36 + version: 0.0.36(eslint@8.57.0)(typescript@5.5.3) '@types/babel__core': specifier: ^7.20.5 version: 7.20.5 @@ -55,8 +55,8 @@ importers: specifier: ^4.17.6 version: 4.17.6 '@types/node': - specifier: ^20.14.9 - version: 20.14.9 + specifier: ^20.14.10 + version: 20.14.10 '@types/postcss-safe-parser': specifier: ^5.0.4 version: 5.0.4 @@ -106,11 +106,11 @@ importers: specifier: ^5.5.3 version: 5.5.3 vite: - specifier: ^5.3.2 - version: 5.3.2(@types/node@20.14.9) + specifier: ^5.3.3 + version: 5.3.3(@types/node@20.14.10) vitest: specifier: ^1.6.0 - version: 1.6.0(@types/node@20.14.9) + version: 1.6.0(@types/node@20.14.10) packages: @@ -118,12 +118,12 @@ packages: resolution: {integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==} engines: {node: '>=0.10.0'} - '@aet/eslint-define-config@0.1.0-beta.1': - resolution: {integrity: sha512-CpHRfl17loRfmX2yimeFiu72vTG/m+h8Trq2z90yAZr6rGP7kcV/ypsm56cZ/BrK8iK94MWNdsRa3QIgw1Xcrw==} + '@aet/eslint-define-config@0.1.0-beta.3': + resolution: {integrity: sha512-vJ8YsXCu8Dt3+xN7B4n8FOJTZO1S0/ztb4EIwE5F4Sh6jB9UrvticcMRapqmANNCyska3joNMOFhqZI8hH1kVQ==} engines: {node: '>=18.0.0', npm: '>=9.0.0'} - '@aet/eslint-rules@0.0.34': - resolution: {integrity: sha512-3NYOYf1HJg9IRQgvl0kGR6CZlfPzRk/rf8519xOD1bXdmChhpPP+MAHm5G1WKQqAVeAa4J6aV7hKy2iyJcHZTA==} + '@aet/eslint-rules@0.0.36': + resolution: {integrity: sha512-uZLVGOm578acCot5e/PvSUdg2QxkUYx6+a58kQJLU1gHKOvOe/KDVtqRYG2EiZBX2g1PHby4dLCdORSslhDEVw==} peerDependencies: eslint: ^8.57.0 typescript: ^5.4.4 @@ -544,6 +544,10 @@ packages: resolution: {integrity: sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + '@eslint-community/regexpp@4.11.0': + resolution: {integrity: sha512-G/M/tIiMrTAxEWRfLfQJMmGNX28IxBg4PBz8XqQhqUHLFI6TL2htpIB1iQCj144V5ee/JaKyT9/WZ0MGZWfA7A==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + '@eslint/eslintrc@2.1.4': resolution: {integrity: sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -724,8 +728,8 @@ packages: '@types/node@20.12.14': resolution: {integrity: sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==} - '@types/node@20.14.9': - resolution: {integrity: sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==} + '@types/node@20.14.10': + resolution: {integrity: sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==} '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -745,8 +749,8 @@ packages: '@types/ws@8.5.10': resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} - '@typescript-eslint/eslint-plugin@7.14.1': - resolution: {integrity: sha512-aAJd6bIf2vvQRjUG3ZkNXkmBpN+J7Wd0mfQiiVCJMu9Z5GcZZdcc0j8XwN/BM97Fl7e3SkTXODSk4VehUv7CGw==} + '@typescript-eslint/eslint-plugin@7.15.0': + resolution: {integrity: sha512-uiNHpyjZtFrLwLDpHnzaDlP3Tt6sGMqTCiqmxaN4n4RP0EfYZDODJyddiFDF44Hjwxr5xAcaYxVKm9QKQFJFLA==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: '@typescript-eslint/parser': ^7.0.0 @@ -756,8 +760,8 @@ packages: typescript: optional: true - '@typescript-eslint/parser@7.14.1': - resolution: {integrity: sha512-8lKUOebNLcR0D7RvlcloOacTOWzOqemWEWkKSVpMZVF/XVcwjPR+3MD08QzbW9TCGJ+DwIc6zUSGZ9vd8cO1IA==} + '@typescript-eslint/parser@7.15.0': + resolution: {integrity: sha512-k9fYuQNnypLFcqORNClRykkGOMOj+pV6V91R4GO/l1FDGwpqmSwoOQrOHo3cGaH63e+D3ZiCAOsuS/D2c99j/A==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 @@ -766,12 +770,12 @@ packages: typescript: optional: true - '@typescript-eslint/scope-manager@7.14.1': - resolution: {integrity: sha512-gPrFSsoYcsffYXTOZ+hT7fyJr95rdVe4kGVX1ps/dJ+DfmlnjFN/GcMxXcVkeHDKqsq6uAcVaQaIi3cFffmAbA==} + '@typescript-eslint/scope-manager@7.15.0': + resolution: {integrity: sha512-Q/1yrF/XbxOTvttNVPihxh1b9fxamjEoz2Os/Pe38OHwxC24CyCqXxGTOdpb4lt6HYtqw9HetA/Rf6gDGaMPlw==} engines: {node: ^18.18.0 || >=20.0.0} - '@typescript-eslint/type-utils@7.14.1': - resolution: {integrity: sha512-/MzmgNd3nnbDbOi3LfasXWWe292+iuo+umJ0bCCMCPc1jLO/z2BQmWUUUXvXLbrQey/JgzdF/OV+I5bzEGwJkQ==} + '@typescript-eslint/type-utils@7.15.0': + resolution: {integrity: sha512-SkgriaeV6PDvpA6253PDVep0qCqgbO1IOBiycjnXsszNTVQe5flN5wR5jiczoEoDEnAqYFSFFc9al9BSGVltkg==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 @@ -784,8 +788,12 @@ packages: resolution: {integrity: sha512-mL7zNEOQybo5R3AavY+Am7KLv8BorIv7HCYS5rKoNZKQD9tsfGUpO4KdAn3sSUvTiS4PQkr2+K0KJbxj8H9NDg==} engines: {node: ^18.18.0 || >=20.0.0} - '@typescript-eslint/typescript-estree@7.14.1': - resolution: {integrity: sha512-k5d0VuxViE2ulIO6FbxxSZaxqDVUyMbXcidC8rHvii0I56XZPv8cq+EhMns+d/EVIL41sMXqRbK3D10Oza1bbA==} + '@typescript-eslint/types@7.15.0': + resolution: {integrity: sha512-aV1+B1+ySXbQH0pLK0rx66I3IkiZNidYobyfn0WFsdGhSXw+P3YOqeTq5GED458SfB24tg+ux3S+9g118hjlTw==} + engines: {node: ^18.18.0 || >=20.0.0} + + '@typescript-eslint/typescript-estree@7.15.0': + resolution: {integrity: sha512-gjyB/rHAopL/XxfmYThQbXbzRMGhZzGw6KpcMbfe8Q3nNQKStpxnUKeXb0KiN/fFDR42Z43szs6rY7eHk0zdGQ==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: typescript: '*' @@ -793,14 +801,14 @@ packages: typescript: optional: true - '@typescript-eslint/utils@7.14.1': - resolution: {integrity: sha512-CMmVVELns3nak3cpJhZosDkm63n+DwBlDX8g0k4QUa9BMnF+lH2lr3d130M1Zt1xxmB3LLk3NV7KQCq86ZBBhQ==} + '@typescript-eslint/utils@7.15.0': + resolution: {integrity: sha512-hfDMDqaqOqsUVGiEPSMLR/AjTSCsmJwjpKkYQRo1FNbmW4tBwBspYDwO9eh7sKSTwMQgBw9/T4DHudPaqshRWA==} engines: {node: ^18.18.0 || >=20.0.0} peerDependencies: eslint: ^8.56.0 - '@typescript-eslint/visitor-keys@7.14.1': - resolution: {integrity: sha512-Crb+F75U1JAEtBeQGxSKwI60hZmmzaqA3z9sYsVm8X7W5cwLEm5bRe0/uXS6+MR/y8CVpKSR/ontIAIEPFcEkA==} + '@typescript-eslint/visitor-keys@7.15.0': + resolution: {integrity: sha512-Hqgy/ETgpt2L5xueA/zHHIl4fJI2O4XUE9l4+OIfbJIRSnTJb/QscncdqqZzofQegIJugRIF57OJea1khw2SDw==} engines: {node: ^18.18.0 || >=20.0.0} '@ungap/structured-clone@1.2.0': @@ -1197,20 +1205,20 @@ packages: eslint-import-resolver-webpack: optional: true - eslint-plugin-es-x@7.7.0: - resolution: {integrity: sha512-aP3qj8BwiEDPttxQkZdI221DLKq9sI/qHolE2YSQL1/9+xk7dTV+tB1Fz8/IaCA+lnLA1bDEnvaS2LKs0k2Uig==} + eslint-plugin-es-x@8.0.0: + resolution: {integrity: sha512-kPIagK5FxZBDwVxZXCsxmZUjU2aYGeTs4/wfAauI2FAThsbeLgred5b+6S0x7Hhx04GPzrB4j0h60bnsyLpzEA==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: eslint: '>=8' - eslint-plugin-import-x@0.5.2: - resolution: {integrity: sha512-6f1YMmg3PdLwfiJDYnCRPfh67zJKbwbOKL99l6xGZDmIFkMht/4xyudafGEcDOmDlgp36e41W4RXDfOn7+pGRg==} + eslint-plugin-import-x@0.5.3: + resolution: {integrity: sha512-hJ/wkMcsLQXAZL3+txXIDpbW5cqwdm1rLTqV4VRY03aIbzE3zWE7rPZKW6Gzf7xyl1u3V1iYC6tOG77d9NF4GQ==} engines: {node: '>=16'} peerDependencies: eslint: ^8.56.0 || ^9.0.0-0 - eslint-plugin-jsdoc@48.5.0: - resolution: {integrity: sha512-ukXPNpGby3KjCveCizIS8t1EbuJEHYEu/tBg8GCbn/YbHcXwphyvYCdvRZ/oMRfTscGSSzfsWoZ+ZkAP0/6YMQ==} + eslint-plugin-jsdoc@48.5.2: + resolution: {integrity: sha512-VXBJFviQz30rynlOEQ+dNWLmeopjoAgutUVrWOZwm6Ki4EVDm4XkyIqAV/Zhf7FcDr0AG0aGmRn5FxxCtAF0tA==} engines: {node: '>=18'} peerDependencies: eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 @@ -2003,6 +2011,9 @@ packages: spdx-license-ids@3.0.17: resolution: {integrity: sha512-sh8PWc/ftMqAAdFiBu6Fy6JUOYjqDJBJvIhpfDMyHrr0Rbp5liZqd4TjtQ/RgfLjKFZb+LMx5hpml5qOWy0qvg==} + stable-hash@0.0.4: + resolution: {integrity: sha512-LjdcbuBeLcdETCrPn9i8AYAZ1eCtu4ECAWtP7UleOiZ9LzVxRzzUZEoZ8zB24nhkQnDWyET0I+3sWokSDS3E7g==} + stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} @@ -2210,8 +2221,8 @@ packages: engines: {node: ^18.0.0 || >=20.0.0} hasBin: true - vite@5.3.2: - resolution: {integrity: sha512-6lA7OBHBlXUxiJxbO5aAY2fsHHzDr1q7DvXYnyZycRs2Dz+dXBWuhpWHvmljTRTpQC2uvGmUFFkSHF2vGo90MA==} + vite@5.3.3: + resolution: {integrity: sha512-NPQdeCU0Dv2z5fu+ULotpuq5yfCS1BzKUIPhNbP3YBfAMGJXbt2nS+sbTFu+qchaqWTD+H3JK++nRwr6XIcp6A==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -2322,17 +2333,17 @@ snapshots: '@aashutoshrathi/word-wrap@1.2.6': {} - '@aet/eslint-define-config@0.1.0-beta.1': {} + '@aet/eslint-define-config@0.1.0-beta.3': {} - '@aet/eslint-rules@0.0.34(eslint@8.57.0)(typescript@5.5.3)': + '@aet/eslint-rules@0.0.36(eslint@8.57.0)(typescript@5.5.3)': dependencies: - '@aet/eslint-define-config': 0.1.0-beta.1 + '@aet/eslint-define-config': 0.1.0-beta.3 '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) '@types/eslint': 8.56.10 - '@typescript-eslint/eslint-plugin': 7.14.1(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3) - '@typescript-eslint/parser': 7.14.1(eslint@8.57.0)(typescript@5.5.3) - '@typescript-eslint/type-utils': 7.14.1(eslint@8.57.0)(typescript@5.5.3) - '@typescript-eslint/utils': 7.14.1(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/eslint-plugin': 7.15.0(@typescript-eslint/parser@7.15.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/parser': 7.15.0(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/type-utils': 7.15.0(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/utils': 7.15.0(eslint@8.57.0)(typescript@5.5.3) aria-query: 5.3.0 axe-core: 4.9.1 axobject-query: 4.0.0 @@ -2344,10 +2355,10 @@ snapshots: eslint: 8.57.0 eslint-config-prettier: 9.1.0(eslint@8.57.0) eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.0) - eslint-plugin-es-x: 7.7.0(eslint@8.57.0) - eslint-plugin-import-x: 0.5.2(eslint@8.57.0)(typescript@5.5.3) - eslint-plugin-jsdoc: 48.5.0(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.15.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.0) + eslint-plugin-es-x: 8.0.0(eslint@8.57.0) + eslint-plugin-import-x: 0.5.3(eslint@8.57.0)(typescript@5.5.3) + eslint-plugin-jsdoc: 48.5.2(eslint@8.57.0) eslint-plugin-unicorn: 54.0.0(eslint@8.57.0) esprima: 4.0.1 esquery: 1.5.0 @@ -2686,6 +2697,8 @@ snapshots: '@eslint-community/regexpp@4.10.0': {} + '@eslint-community/regexpp@4.11.0': {} + '@eslint/eslintrc@2.1.4': dependencies: ajv: 6.12.6 @@ -2864,7 +2877,7 @@ snapshots: dependencies: undici-types: 5.26.5 - '@types/node@20.14.9': + '@types/node@20.14.10': dependencies: undici-types: 5.26.5 @@ -2885,16 +2898,16 @@ snapshots: '@types/ws@8.5.10': dependencies: - '@types/node': 20.14.9 + '@types/node': 20.14.10 - '@typescript-eslint/eslint-plugin@7.14.1(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3)': + '@typescript-eslint/eslint-plugin@7.15.0(@typescript-eslint/parser@7.15.0(eslint@8.57.0)(typescript@5.5.3))(eslint@8.57.0)(typescript@5.5.3)': dependencies: '@eslint-community/regexpp': 4.10.0 - '@typescript-eslint/parser': 7.14.1(eslint@8.57.0)(typescript@5.5.3) - '@typescript-eslint/scope-manager': 7.14.1 - '@typescript-eslint/type-utils': 7.14.1(eslint@8.57.0)(typescript@5.5.3) - '@typescript-eslint/utils': 7.14.1(eslint@8.57.0)(typescript@5.5.3) - '@typescript-eslint/visitor-keys': 7.14.1 + '@typescript-eslint/parser': 7.15.0(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/scope-manager': 7.15.0 + '@typescript-eslint/type-utils': 7.15.0(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/utils': 7.15.0(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/visitor-keys': 7.15.0 eslint: 8.57.0 graphemer: 1.4.0 ignore: 5.3.1 @@ -2905,12 +2918,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.5.3)': + '@typescript-eslint/parser@7.15.0(eslint@8.57.0)(typescript@5.5.3)': dependencies: - '@typescript-eslint/scope-manager': 7.14.1 - '@typescript-eslint/types': 7.14.1 - '@typescript-eslint/typescript-estree': 7.14.1(typescript@5.5.3) - '@typescript-eslint/visitor-keys': 7.14.1 + '@typescript-eslint/scope-manager': 7.15.0 + '@typescript-eslint/types': 7.15.0 + '@typescript-eslint/typescript-estree': 7.15.0(typescript@5.5.3) + '@typescript-eslint/visitor-keys': 7.15.0 debug: 4.3.5 eslint: 8.57.0 optionalDependencies: @@ -2918,15 +2931,15 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/scope-manager@7.14.1': + '@typescript-eslint/scope-manager@7.15.0': dependencies: - '@typescript-eslint/types': 7.14.1 - '@typescript-eslint/visitor-keys': 7.14.1 + '@typescript-eslint/types': 7.15.0 + '@typescript-eslint/visitor-keys': 7.15.0 - '@typescript-eslint/type-utils@7.14.1(eslint@8.57.0)(typescript@5.5.3)': + '@typescript-eslint/type-utils@7.15.0(eslint@8.57.0)(typescript@5.5.3)': dependencies: - '@typescript-eslint/typescript-estree': 7.14.1(typescript@5.5.3) - '@typescript-eslint/utils': 7.14.1(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/typescript-estree': 7.15.0(typescript@5.5.3) + '@typescript-eslint/utils': 7.15.0(eslint@8.57.0)(typescript@5.5.3) debug: 4.3.5 eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.5.3) @@ -2937,10 +2950,12 @@ snapshots: '@typescript-eslint/types@7.14.1': {} - '@typescript-eslint/typescript-estree@7.14.1(typescript@5.5.3)': + '@typescript-eslint/types@7.15.0': {} + + '@typescript-eslint/typescript-estree@7.15.0(typescript@5.5.3)': dependencies: - '@typescript-eslint/types': 7.14.1 - '@typescript-eslint/visitor-keys': 7.14.1 + '@typescript-eslint/types': 7.15.0 + '@typescript-eslint/visitor-keys': 7.15.0 debug: 4.3.5 globby: 11.1.0 is-glob: 4.0.3 @@ -2952,20 +2967,20 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@7.14.1(eslint@8.57.0)(typescript@5.5.3)': + '@typescript-eslint/utils@7.15.0(eslint@8.57.0)(typescript@5.5.3)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) - '@typescript-eslint/scope-manager': 7.14.1 - '@typescript-eslint/types': 7.14.1 - '@typescript-eslint/typescript-estree': 7.14.1(typescript@5.5.3) + '@typescript-eslint/scope-manager': 7.15.0 + '@typescript-eslint/types': 7.15.0 + '@typescript-eslint/typescript-estree': 7.15.0(typescript@5.5.3) eslint: 8.57.0 transitivePeerDependencies: - supports-color - typescript - '@typescript-eslint/visitor-keys@7.14.1': + '@typescript-eslint/visitor-keys@7.15.0': dependencies: - '@typescript-eslint/types': 7.14.1 + '@typescript-eslint/types': 7.15.0 eslint-visitor-keys: 3.4.3 '@ungap/structured-clone@1.2.0': {} @@ -3349,26 +3364,26 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.8.1(@typescript-eslint/parser@7.14.1(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.0): + eslint-module-utils@2.8.1(@typescript-eslint/parser@7.15.0(eslint@8.57.0)(typescript@5.5.3))(eslint-import-resolver-node@0.3.9)(eslint@8.57.0): dependencies: debug: 3.2.7 optionalDependencies: - '@typescript-eslint/parser': 7.14.1(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/parser': 7.15.0(eslint@8.57.0)(typescript@5.5.3) eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 transitivePeerDependencies: - supports-color - eslint-plugin-es-x@7.7.0(eslint@8.57.0): + eslint-plugin-es-x@8.0.0(eslint@8.57.0): dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0) - '@eslint-community/regexpp': 4.10.0 + '@eslint-community/regexpp': 4.11.0 eslint: 8.57.0 eslint-compat-utils: 0.5.1(eslint@8.57.0) - eslint-plugin-import-x@0.5.2(eslint@8.57.0)(typescript@5.5.3): + eslint-plugin-import-x@0.5.3(eslint@8.57.0)(typescript@5.5.3): dependencies: - '@typescript-eslint/utils': 7.14.1(eslint@8.57.0)(typescript@5.5.3) + '@typescript-eslint/utils': 7.15.0(eslint@8.57.0)(typescript@5.5.3) debug: 4.3.5 doctrine: 3.0.0 eslint: 8.57.0 @@ -3377,12 +3392,13 @@ snapshots: is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.2 + stable-hash: 0.0.4 tslib: 2.6.3 transitivePeerDependencies: - supports-color - typescript - eslint-plugin-jsdoc@48.5.0(eslint@8.57.0): + eslint-plugin-jsdoc@48.5.2(eslint@8.57.0): dependencies: '@es-joy/jsdoccomment': 0.43.1 are-docs-informative: 0.0.2 @@ -4163,6 +4179,8 @@ snapshots: spdx-license-ids@3.0.17: {} + stable-hash@0.0.4: {} + stackback@0.0.2: {} std-env@3.7.0: {} @@ -4363,13 +4381,13 @@ snapshots: spdx-correct: 3.2.0 spdx-expression-parse: 3.0.1 - vite-node@1.6.0(@types/node@20.14.9): + vite-node@1.6.0(@types/node@20.14.10): dependencies: cac: 6.7.14 debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.3.2(@types/node@20.14.9) + vite: 5.3.3(@types/node@20.14.10) transitivePeerDependencies: - '@types/node' - less @@ -4380,16 +4398,16 @@ snapshots: - supports-color - terser - vite@5.3.2(@types/node@20.14.9): + vite@5.3.3(@types/node@20.14.10): dependencies: esbuild: 0.21.5 postcss: 8.4.39 rollup: 4.13.2 optionalDependencies: - '@types/node': 20.14.9 + '@types/node': 20.14.10 fsevents: 2.3.3 - vitest@1.6.0(@types/node@20.14.9): + vitest@1.6.0(@types/node@20.14.10): dependencies: '@vitest/expect': 1.6.0 '@vitest/runner': 1.6.0 @@ -4408,11 +4426,11 @@ snapshots: strip-literal: 2.1.0 tinybench: 2.6.0 tinypool: 0.8.3 - vite: 5.3.2(@types/node@20.14.9) - vite-node: 1.6.0(@types/node@20.14.9) + vite: 5.3.3(@types/node@20.14.10) + vite-node: 1.6.0(@types/node@20.14.10) why-is-node-running: 2.2.2 optionalDependencies: - '@types/node': 20.14.9 + '@types/node': 20.14.10 transitivePeerDependencies: - less - lightningcss diff --git a/src/__tests__/__snapshots__/attr.test.ts.snap b/src/__tests__/__snapshots__/attr.test.ts.snap index 73ca4e2..dcaa1cd 100644 --- a/src/__tests__/__snapshots__/attr.test.ts.snap +++ b/src/__tests__/__snapshots__/attr.test.ts.snap @@ -1,8 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`attr > supports conditional expression in "css" attribute 1`] = ` -"// src/.temp-attr/index.tsx -import { jsx } from "react/jsx-runtime"; +"import { jsx } from "react/jsx-runtime"; function Hello({ isCenter }) { @@ -10,37 +9,30 @@ function Hello({ } export { Hello -}; -" +};" `; exports[`attr > supports conditional expression in "css" attribute 2`] = ` -"/* babel-tailwind:/Users/aet/Documents/Git/babel-tailwind/src/.temp-attr/index.css */ -.tw-gqn2k6 { +".tw-gqn2k6 { text-align: center; -} -" +}" `; exports[`attr > supports grouped array css attribute 1`] = ` -"// src/.temp-attr/index.tsx -import { jsx } from "react/jsx-runtime"; +"import { jsx } from "react/jsx-runtime"; function Hello() { return /* @__PURE__ */ jsx("div", { className: "tw-gqn2k6 tw-1qtvvjy", children: "Hello, world!" }); } export { Hello -}; -" +};" `; exports[`attr > supports grouped array css attribute 2`] = ` -"/* babel-tailwind:/Users/aet/Documents/Git/babel-tailwind/src/.temp-attr/index.css */ -.tw-gqn2k6 { +".tw-gqn2k6 { text-align: center; } .tw-1qtvvjy:hover { font-weight: 600; -} -" +}" `; diff --git a/src/__tests__/__snapshots__/options.test.ts.snap b/src/__tests__/__snapshots__/options.test.ts.snap index f21ba7d..a334f93 100644 --- a/src/__tests__/__snapshots__/options.test.ts.snap +++ b/src/__tests__/__snapshots__/options.test.ts.snap @@ -1,21 +1,17 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`options > supports custom jsxAttributeName 1`] = ` -"// src/.temp-options/index.tsx -import { jsx } from "react/jsx-runtime"; +"import { jsx } from "react/jsx-runtime"; function Hello() { return /* @__PURE__ */ jsx("div", { className: "tw-gqn2k6", children: "Hello, world!" }); } export { Hello -}; -" +};" `; exports[`options > supports custom jsxAttributeName 2`] = ` -"/* babel-tailwind:/Users/aet/Documents/Git/babel-tailwind/src/.temp-options/index.css */ -.tw-gqn2k6 { +".tw-gqn2k6 { text-align: center; -} -" +}" `; diff --git a/src/__tests__/__snapshots__/spread.test.ts.snap b/src/__tests__/__snapshots__/spread.test.ts.snap index 447fbf3..9e787bf 100644 --- a/src/__tests__/__snapshots__/spread.test.ts.snap +++ b/src/__tests__/__snapshots__/spread.test.ts.snap @@ -1,8 +1,7 @@ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html exports[`spread > supports spread attribute in "css" attribute (2) 1`] = ` -"// src/.temp-spread/index.tsx -import { cx as _cx } from "@emotion/css"; +"import { cx as _cx } from "@emotion/css"; import * as _tslib from "tslib"; import { jsx } from "react/jsx-runtime"; function Hello(props) { @@ -14,21 +13,17 @@ function Hello(props) { } export { Hello -}; -" +};" `; exports[`spread > supports spread attribute in "css" attribute (2) 2`] = ` -"/* babel-tailwind:/Users/aet/Documents/Git/babel-tailwind/src/.temp-spread/index.css */ -.tw-gqn2k6 { +".tw-gqn2k6 { text-align: center; -} -" +}" `; exports[`spread > supports spread attribute in "css" attribute 1`] = ` -"// src/.temp-spread/index.tsx -import { cx as _cx } from "@emotion/css"; +"import { cx as _cx } from "@emotion/css"; import { jsx } from "react/jsx-runtime"; function Hello({ className: _className, @@ -38,14 +33,32 @@ function Hello({ } export { Hello -}; -" +};" `; exports[`spread > supports spread attribute in "css" attribute 2`] = ` -"/* babel-tailwind:/Users/aet/Documents/Git/babel-tailwind/src/.temp-spread/index.css */ -.tw-gqn2k6 { +".tw-gqn2k6 { text-align: center; -} -" +}" +`; + +exports[`spread > supports spread attribute in "css" attribute with an object pattern 1`] = ` +"import { cx as _cx } from "@emotion/css"; +import { jsx } from "react/jsx-runtime"; +function Hello({ + className: _className, + style, + ...props +}) { + return /* @__PURE__ */ jsx("div", { ...props, className: _cx("tw-gqn2k6", _className), children: "Hello, world!" }); +} +export { + Hello +};" +`; + +exports[`spread > supports spread attribute in "css" attribute with an object pattern 2`] = ` +".tw-gqn2k6 { + text-align: center; +}" `; diff --git a/src/__tests__/__snapshots__/styleObject.test.ts.snap b/src/__tests__/__snapshots__/styleObject.test.ts.snap index 8e08235..6a826c2 100644 --- a/src/__tests__/__snapshots__/styleObject.test.ts.snap +++ b/src/__tests__/__snapshots__/styleObject.test.ts.snap @@ -44,13 +44,11 @@ var tw_kt12th = { } }; -// src/.temp-styleObject/index.tsx import { jsx } from "react/jsx-runtime"; function Hello() { return /* @__PURE__ */ jsx("div", { style: tw_kt12th, children: "Hello, world!" }); } export { Hello -}; -" +};" `; diff --git a/src/__tests__/__snapshots__/tw.test.ts.snap b/src/__tests__/__snapshots__/tw.test.ts.snap new file mode 100644 index 0000000..a5ff30e --- /dev/null +++ b/src/__tests__/__snapshots__/tw.test.ts.snap @@ -0,0 +1,41 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`babel-tailwind > passes through \`group\` className 1`] = ` +"var index_default = "tw-qcda3o group"; +export { + index_default as default +};" +`; + +exports[`babel-tailwind > passes through \`group\` className 2`] = ` +".tw-qcda3o:hover { + text-align: center; +}" +`; + +exports[`babel-tailwind > supports grouped tw 1`] = ` +"var index_default = "tw-4cbsua"; +export { + index_default as default +};" +`; + +exports[`babel-tailwind > supports grouped tw 2`] = ` +".tw-4cbsua { + display: flex; + font-size: 0.875rem; + line-height: 1.25rem; +} +.group:hover .tw-4cbsua { + text-align: center; +} +.tw-4cbsua[data-nested=true] { + border-width: 1px; +} +.tw-4cbsua[data-name=hello] { + text-align: right; +} +.tw-4cbsua > div { + font-weight: 600; +}" +`; diff --git a/src/__tests__/attr.test.ts b/src/__tests__/attr.test.ts index ed8e4cf..5eb9d51 100644 --- a/src/__tests__/attr.test.ts +++ b/src/__tests__/attr.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { getBuild } from "./utils"; +import { getBuild, matchSnapshot } from "./utils"; describe("attr", () => { const compileESBuild = getBuild("attr"); @@ -19,8 +19,7 @@ describe("attr", () => { `, }); - expect(files.js.text).toMatchSnapshot(); - expect(files.css.text).toMatchSnapshot(); + matchSnapshot(files); }); it('supports conditional expression in "css" attribute', async () => { @@ -38,7 +37,6 @@ describe("attr", () => { `, }); - expect(files.js.text).toMatchSnapshot(); - expect(files.css.text).toMatchSnapshot(); + matchSnapshot(files); }); }); diff --git a/src/__tests__/options.test.ts b/src/__tests__/options.test.ts index cbfef58..3958c6e 100644 --- a/src/__tests__/options.test.ts +++ b/src/__tests__/options.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { getBuild } from "./utils"; +import { getBuild, matchSnapshot } from "./utils"; describe("options", () => { const compileESBuild = getBuild("options"); @@ -18,9 +18,7 @@ describe("options", () => { } `, }); - - expect(files.js.text).toMatchSnapshot(); - expect(files.css.text).toMatchSnapshot(); + matchSnapshot(files); }); it("does not remove the attribute if `preserveAttribute` is true", async () => { diff --git a/src/__tests__/spread.test.ts b/src/__tests__/spread.test.ts index 9fe10bf..078b4e3 100644 --- a/src/__tests__/spread.test.ts +++ b/src/__tests__/spread.test.ts @@ -1,6 +1,6 @@ /* eslint-disable unicorn/string-content */ -import { describe, expect, it } from "vitest"; -import { getBuild } from "./utils"; +import { describe, it } from "vitest"; +import { getBuild, matchSnapshot } from "./utils"; describe("spread", () => { const compileESBuild = getBuild("spread"); @@ -20,8 +20,25 @@ describe("spread", () => { `, }); - expect(files.js.text).toMatchSnapshot(); - expect(files.css.text).toMatchSnapshot(); + matchSnapshot(files); + }); + + it('supports spread attribute in "css" attribute with an object pattern', async () => { + const { files } = await compileESBuild({ + clsx: "emotion", + expectFiles: 2, + javascript: /* tsx */ ` + export function Hello({ style, ...props }) { + return ( +
+ Hello, world! +
+ ); + } + `, + }); + + matchSnapshot(files); }); it('supports spread attribute in "css" attribute (2)', async () => { @@ -40,7 +57,6 @@ describe("spread", () => { `, }); - expect(files.js.text).toMatchSnapshot(); - expect(files.css.text).toMatchSnapshot(); + matchSnapshot(files); }); }); diff --git a/src/__tests__/styleObject.test.ts b/src/__tests__/styleObject.test.ts index 45fe573..1f2d602 100644 --- a/src/__tests__/styleObject.test.ts +++ b/src/__tests__/styleObject.test.ts @@ -1,5 +1,5 @@ -import { describe, expect, it } from "vitest"; -import { getBuild } from "./utils"; +import { describe, it } from "vitest"; +import { getBuild, matchSnapshot } from "./utils"; describe("babel-tailwind", () => { const compileESBuild = getBuild("styleObject"); @@ -21,7 +21,7 @@ describe("babel-tailwind", () => { `, }); - expect(files.js.text).toMatchSnapshot(); + matchSnapshot(files, true); }); it("supports .hover, .focus, .active, .group-hover, .group-focus, .group-active", async () => { @@ -40,6 +40,6 @@ describe("babel-tailwind", () => { `, }); - expect(files.js.text).toMatchSnapshot(); + matchSnapshot(files, true); }); }); diff --git a/src/__tests__/tw.test.ts b/src/__tests__/tw.test.ts index 6b50466..426e89b 100644 --- a/src/__tests__/tw.test.ts +++ b/src/__tests__/tw.test.ts @@ -1,6 +1,5 @@ -import { describe, expect, it } from "vitest"; -import { getClassName } from "../index"; -import { getBuild } from "./utils"; +import { describe, it } from "vitest"; +import { getBuild, matchSnapshot } from "./utils"; describe("babel-tailwind", () => { const compileESBuild = getBuild("tw"); @@ -25,31 +24,7 @@ describe("babel-tailwind", () => { `, }); - const clsName = getClassName( - "text-sm flex group-hover:text-center [&>div]:font-semibold data-[name='hello']:text-right data-[nested=true]:border" - ); - expect(files.js.text).toContain(`= "${clsName}"`); - expect(files.css.text).toMatch( - [ - `.${clsName} {`, - " display: flex;", - " font-size: 0.875rem;", - " line-height: 1.25rem;", - "}", - `.group:hover .${clsName} {`, - " text-align: center;", - "}", - `.${clsName}[data-nested=true] {`, - " border-width: 1px;", - "}", - `.${clsName}[data-name=hello] {`, - " text-align: right;", - "}", - `.${clsName} > div {`, - " font-weight: 600;", - "}", - ].join("\n") - ); + matchSnapshot(files); }); it("passes through `group` className", async () => { @@ -63,10 +38,6 @@ describe("babel-tailwind", () => { `, }); - const clsName = getClassName("group hover:text-center"); - expect(files.js.text).toContain(`"${clsName} group"`); - expect(files.css.text).toMatch( - [`.${clsName}:hover {`, " text-align: center;", "}"].join("\n") - ); + matchSnapshot(files); }); }); diff --git a/src/__tests__/utils.ts b/src/__tests__/utils.ts index e58d98f..d615b02 100644 --- a/src/__tests__/utils.ts +++ b/src/__tests__/utils.ts @@ -1,5 +1,5 @@ import { promises as fs } from "node:fs"; -import { resolve } from "node:path"; +import { join, resolve } from "node:path"; import { afterEach, beforeEach, expect } from "vitest"; import * as esbuild from "esbuild"; import dedent from "dedent"; @@ -17,9 +17,9 @@ export function getBuild(name: string) { const folder = resolve(import.meta.dirname, "..", ".temp-" + name); async function write(path: string, content: string) { - const resolved = resolve(folder, path); + const resolved = join(folder, path); await fs.writeFile(resolved, content); - return resolved; + return `./src/.temp-${name}/${path}`; } beforeEach(async () => { @@ -65,9 +65,19 @@ export function getBuild(name: string) { return { outputFiles: outputFiles!, - files: new Proxy({} as Record, { + files: new Proxy({} as Files, { get: (_, ext: string) => findByExt(outputFiles!, ext), }), }; }; } +type Files = Record; + +export function matchSnapshot(files: Files, noCSS = false) { + expect(files.js.text.replace(/\/\/ src.+\n/g, "").trim()).toMatchSnapshot(); + if (!noCSS) { + expect( + files.css.text.replace(/\/\* babel-tailwind:[^*]+\*\/\n/g, "").trim() + ).toMatchSnapshot(); + } +} diff --git a/src/babel-tailwind.ts b/src/babel-tailwind.ts index af9f4fe..960e72b 100644 --- a/src/babel-tailwind.ts +++ b/src/babel-tailwind.ts @@ -302,18 +302,25 @@ export function babelTailwind( // props from argument and not modified anywhere const scope = path.scope.getBinding(arg.name); let index: number; + const node = scope?.path.node; if ( scope && !scope.constantViolations.length && t.isFunctionDeclaration(scope.path.parent) && - (index = (scope.path.parent.params as t.Node[]).indexOf(scope.path.node)) !== - -1 + (index = (scope.path.parent.params as t.Node[]).indexOf(node!)) !== -1 && + (t.isIdentifier(node) || t.isObjectPattern(node)) ) { const clsVar = path.scope.generateUidIdentifier("className"); - scope.path.parent.params[index] = t.objectPattern([ - t.objectProperty(t.identifier("className"), clsVar), - t.restElement(scope.path.node as t.Identifier), - ]); + if (t.isIdentifier(node)) { + scope.path.parent.params[index] = t.objectPattern([ + t.objectProperty(t.identifier("className"), clsVar), + t.restElement(node), + ]); + } else { + node.properties.unshift( + t.objectProperty(t.identifier("className"), clsVar) + ); + } parent.attributes.push( t.jsxAttribute(