zackad / prettier-plugin-twig

Code formatting plugin for Prettier to handle Twig templates
Apache License 2.0
57 stars 6 forks source link

Add support for spread operator #44

Closed zackad closed 1 week ago

zackad commented 3 months ago

Split up from #16

Input

<twig:Alert {{ ...attributes }} />

Error

root@6ec48a6a90a1:/var/www/html# node_modules/.bin/prettier -c templates/test.html.twig 
Checking formatting...
templates/test.html.twig
[error] templates/test.html.twig: Error: ERROR: Unexpected token "operator" of value ".."
[error] > 1 | <twig:Alert {{ ...attributes }} />
[error]     |                ^
[error]   2 | 
[error]     at TokenStream.error (/var/www/html/node_modules/melody-parser/lib/index.js:1362:22)
[error]     at Parser.error (/var/www/html/node_modules/melody-parser/lib/index.js:830:21)
[error]     at Parser.matchPrimaryExpression (/var/www/html/node_modules/melody-parser/lib/index.js:976:26)
[error]     at Parser.getPrimary (/var/www/html/node_modules/melody-parser/lib/index.js:935:21)
[error]     at Parser.matchExpression (/var/www/html/node_modules/melody-parser/lib/index.js:885:25)
[error]     at Parser.matchAttributes (/var/www/html/node_modules/melody-parser/lib/index.js:815:46)
[error]     at Parser.matchElement (/var/www/html/node_modules/melody-parser/lib/index.js:726:14)
[error]     at Parser.parse (/var/www/html/node_modules/melody-parser/lib/index.js:627:32)
[error]     at Object.parse (/var/www/html/node_modules/@zackad/prettier-plugin-twig-melody/src/parser.js:84:24)
[error]     at parse4 (file:///var/www/html/node_modules/prettier/index.mjs:22117:24)
All matched files use Prettier code style!