From 2bd9ddbfb2635b17dc2f2dfbae1247220fb0b80f Mon Sep 17 00:00:00 2001 From: Joshua Pease Date: Mon, 11 Nov 2024 10:01:39 -0800 Subject: [PATCH 1/3] [#33] POC Twig/Tailwind Prettier TODO: Still needc to sort out how to get TW to work with .twig extension --- .prettierrc | 11 ++- package-lock.json | 203 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 + 3 files changed, 215 insertions(+), 1 deletion(-) diff --git a/.prettierrc b/.prettierrc index b04bde6..3cdc3a8 100644 --- a/.prettierrc +++ b/.prettierrc @@ -2,5 +2,14 @@ "semi": false, "singleQuote": true, "tabWidth": 2, - "trailingComma": "all" + "trailingComma": "all", + "plugins": ["@zackad/prettier-plugin-twig", "prettier-plugin-tailwindcss"], + "twigPrintWidth": 80, + "twigAlwaysBreakObjects": true, + "twigMultiTags": [ + "nav,endnav", + "switch,case,default,endswitch", + "ifchildren,endifchildren", + "cache,endcache" + ] } diff --git a/package-lock.json b/package-lock.json index 54119fd..8968897 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ }, "devDependencies": { "@eslint/js": "^9.3.0", + "@zackad/prettier-plugin-twig": "^0.9.1", "autoprefixer": "^10.4.19", "cssnano": "^7.0.1", "eslint-config-prettier": "^9.1.0", @@ -23,6 +24,7 @@ "postcss": "^8.4.38", "postcss-pxtorem": "^6.1.0", "prettier": "3.2.5", + "prettier-plugin-tailwindcss": "^0.6.8", "tailwindcss": "^3.4.3", "vite": "^5.2.0", "vite-plugin-static-copy": "^1.0.6" @@ -54,6 +56,86 @@ "tabbable": "^5.3.3" } }, + "node_modules/@babel/code-frame": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.26.2.tgz", + "integrity": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.25.9", + "js-tokens": "^4.0.0", + "picocolors": "^1.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.26.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.2.tgz", + "integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.26.0" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/template": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.25.9.tgz", + "integrity": "sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.25.9", + "@babel/parser": "^7.25.9", + "@babel/types": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.0.tgz", + "integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", @@ -998,6 +1080,24 @@ "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.1.5.tgz", "integrity": "sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA==" }, + "node_modules/@zackad/prettier-plugin-twig": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/@zackad/prettier-plugin-twig/-/prettier-plugin-twig-0.9.1.tgz", + "integrity": "sha512-v8yiHr1GKbht8kYlstDqMxPvBcnQqYG1YfkacdGNkZcEzyHzgJHYh/a5POCalEZI28rcBxojAhrPJAo6Ab8WaA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@babel/template": "^7.24.7", + "@babel/types": "^7.24.9", + "he": "^1.2.0", + "lodash": "^4.17.21", + "prettier": "^3.0.0", + "resolve": "^1.12.0" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/acorn": { "version": "8.12.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", @@ -2305,6 +2405,16 @@ "node": ">= 0.4" } }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "license": "MIT", + "bin": { + "he": "bin/he" + } + }, "node_modules/human-signals": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz", @@ -2487,6 +2597,13 @@ "jiti": "bin/jiti.js" } }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -2647,6 +2764,13 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.memoize": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", @@ -3725,6 +3849,85 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-plugin-tailwindcss": { + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.8.tgz", + "integrity": "sha512-dGu3kdm7SXPkiW4nzeWKCl3uoImdd5CTZEJGxyypEPL37Wj0HT2pLqjrvSei1nTeuQfO4PUfjeW5cTUNRLZ4sA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.21.3" + }, + "peerDependencies": { + "@ianvs/prettier-plugin-sort-imports": "*", + "@prettier/plugin-pug": "*", + "@shopify/prettier-plugin-liquid": "*", + "@trivago/prettier-plugin-sort-imports": "*", + "@zackad/prettier-plugin-twig-melody": "*", + "prettier": "^3.0", + "prettier-plugin-astro": "*", + "prettier-plugin-css-order": "*", + "prettier-plugin-import-sort": "*", + "prettier-plugin-jsdoc": "*", + "prettier-plugin-marko": "*", + "prettier-plugin-multiline-arrays": "*", + "prettier-plugin-organize-attributes": "*", + "prettier-plugin-organize-imports": "*", + "prettier-plugin-sort-imports": "*", + "prettier-plugin-style-order": "*", + "prettier-plugin-svelte": "*" + }, + "peerDependenciesMeta": { + "@ianvs/prettier-plugin-sort-imports": { + "optional": true + }, + "@prettier/plugin-pug": { + "optional": true + }, + "@shopify/prettier-plugin-liquid": { + "optional": true + }, + "@trivago/prettier-plugin-sort-imports": { + "optional": true + }, + "@zackad/prettier-plugin-twig-melody": { + "optional": true + }, + "prettier-plugin-astro": { + "optional": true + }, + "prettier-plugin-css-order": { + "optional": true + }, + "prettier-plugin-import-sort": { + "optional": true + }, + "prettier-plugin-jsdoc": { + "optional": true + }, + "prettier-plugin-marko": { + "optional": true + }, + "prettier-plugin-multiline-arrays": { + "optional": true + }, + "prettier-plugin-organize-attributes": { + "optional": true + }, + "prettier-plugin-organize-imports": { + "optional": true + }, + "prettier-plugin-sort-imports": { + "optional": true + }, + "prettier-plugin-style-order": { + "optional": true + }, + "prettier-plugin-svelte": { + "optional": true + } + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/package.json b/package.json index fa7f1ac..0340f66 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ }, "devDependencies": { "@eslint/js": "^9.3.0", + "@zackad/prettier-plugin-twig": "^0.9.1", "autoprefixer": "^10.4.19", "cssnano": "^7.0.1", "eslint-config-prettier": "^9.1.0", @@ -22,6 +23,7 @@ "postcss": "^8.4.38", "postcss-pxtorem": "^6.1.0", "prettier": "3.2.5", + "prettier-plugin-tailwindcss": "^0.6.8", "tailwindcss": "^3.4.3", "vite": "^5.2.0", "vite-plugin-static-copy": "^1.0.6" From 79c66d88c492841be11d9052b20eb70f3eb6824e Mon Sep 17 00:00:00 2001 From: Joshua Pease Date: Tue, 25 Feb 2025 09:02:23 -0800 Subject: [PATCH 2/3] TEMP - Test Markup --- templates/test.twig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 templates/test.twig diff --git a/templates/test.twig b/templates/test.twig new file mode 100644 index 0000000..7064568 --- /dev/null +++ b/templates/test.twig @@ -0,0 +1,15 @@ +
+ +
+ +
+
+ + +
From 9fd43eb015bb243eecf90ac5bd562de206a2b341 Mon Sep 17 00:00:00 2001 From: Joshua Pease Date: Tue, 25 Feb 2025 09:31:44 -0800 Subject: [PATCH 3/3] [#33] Update prettier plugins. Remove deprecated config option --- .prettierrc | 1 - package-lock.json | 26 ++++++++++++++------------ package.json | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.prettierrc b/.prettierrc index 3cdc3a8..1544d71 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,7 +4,6 @@ "tabWidth": 2, "trailingComma": "all", "plugins": ["@zackad/prettier-plugin-twig", "prettier-plugin-tailwindcss"], - "twigPrintWidth": 80, "twigAlwaysBreakObjects": true, "twigMultiTags": [ "nav,endnav", diff --git a/package-lock.json b/package-lock.json index 8968897..c38b64c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ }, "devDependencies": { "@eslint/js": "^9.3.0", - "@zackad/prettier-plugin-twig": "^0.9.1", + "@zackad/prettier-plugin-twig": "^0.15.3", "autoprefixer": "^10.4.19", "cssnano": "^7.0.1", "eslint-config-prettier": "^9.1.0", @@ -24,7 +24,7 @@ "postcss": "^8.4.38", "postcss-pxtorem": "^6.1.0", "prettier": "3.2.5", - "prettier-plugin-tailwindcss": "^0.6.8", + "prettier-plugin-tailwindcss": "^0.6.11", "tailwindcss": "^3.4.3", "vite": "^5.2.0", "vite-plugin-static-copy": "^1.0.6" @@ -1081,9 +1081,9 @@ "integrity": "sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA==" }, "node_modules/@zackad/prettier-plugin-twig": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/@zackad/prettier-plugin-twig/-/prettier-plugin-twig-0.9.1.tgz", - "integrity": "sha512-v8yiHr1GKbht8kYlstDqMxPvBcnQqYG1YfkacdGNkZcEzyHzgJHYh/a5POCalEZI28rcBxojAhrPJAo6Ab8WaA==", + "version": "0.15.3", + "resolved": "https://registry.npmjs.org/@zackad/prettier-plugin-twig/-/prettier-plugin-twig-0.15.3.tgz", + "integrity": "sha512-R8csxPqWAGjbGBRMXZz/wOLH40uLp6QDIdCFBSwIBTrysNb9eI1KCi66Vz4tcyd+i7vuz7o17pB7izzhg8T6jA==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -1091,11 +1091,13 @@ "@babel/types": "^7.24.9", "he": "^1.2.0", "lodash": "^4.17.21", - "prettier": "^3.0.0", - "resolve": "^1.12.0" + "prettier": "^3.0.0" }, "engines": { "node": ">=18" + }, + "funding": { + "url": "https://github.com/zackad/prettier-plugin-twig?sponsor=1" } }, "node_modules/acorn": { @@ -3850,9 +3852,9 @@ } }, "node_modules/prettier-plugin-tailwindcss": { - "version": "0.6.8", - "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.8.tgz", - "integrity": "sha512-dGu3kdm7SXPkiW4nzeWKCl3uoImdd5CTZEJGxyypEPL37Wj0HT2pLqjrvSei1nTeuQfO4PUfjeW5cTUNRLZ4sA==", + "version": "0.6.11", + "resolved": "https://registry.npmjs.org/prettier-plugin-tailwindcss/-/prettier-plugin-tailwindcss-0.6.11.tgz", + "integrity": "sha512-YxaYSIvZPAqhrrEpRtonnrXdghZg1irNg4qrjboCXrpybLWVs55cW2N3juhspVJiO0JBvYJT8SYsJpc8OQSnsA==", "dev": true, "license": "MIT", "engines": { @@ -3863,7 +3865,7 @@ "@prettier/plugin-pug": "*", "@shopify/prettier-plugin-liquid": "*", "@trivago/prettier-plugin-sort-imports": "*", - "@zackad/prettier-plugin-twig-melody": "*", + "@zackad/prettier-plugin-twig": "*", "prettier": "^3.0", "prettier-plugin-astro": "*", "prettier-plugin-css-order": "*", @@ -3890,7 +3892,7 @@ "@trivago/prettier-plugin-sort-imports": { "optional": true }, - "@zackad/prettier-plugin-twig-melody": { + "@zackad/prettier-plugin-twig": { "optional": true }, "prettier-plugin-astro": { diff --git a/package.json b/package.json index 0340f66..1907fca 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "devDependencies": { "@eslint/js": "^9.3.0", - "@zackad/prettier-plugin-twig": "^0.9.1", + "@zackad/prettier-plugin-twig": "^0.15.3", "autoprefixer": "^10.4.19", "cssnano": "^7.0.1", "eslint-config-prettier": "^9.1.0", @@ -23,7 +23,7 @@ "postcss": "^8.4.38", "postcss-pxtorem": "^6.1.0", "prettier": "3.2.5", - "prettier-plugin-tailwindcss": "^0.6.8", + "prettier-plugin-tailwindcss": "^0.6.11", "tailwindcss": "^3.4.3", "vite": "^5.2.0", "vite-plugin-static-copy": "^1.0.6"