prettier-plugin-erb icon indicating copy to clipboard operation
prettier-plugin-erb copied to clipboard

TypeError: formattedExpression.trim is not a function

Open vizcay opened this issue 3 years ago • 9 comments

Hi :wave:

I'm getting this error on all my erb files! Any suggestion?

$ node -v
v12.21.0

$ yarn prettier --check app/**/*.rb
yarn run v1.22.11
Checking formatting...
All matched files use Prettier code style!
✨  Done in 3.01s.

$ yarn prettier --check 'app/**/*.erb'
Checking formatting...
app/views/administrador/_tabla_estudios_contables.html.erb[error] app/views/administrador/_tabla_estudios_contables.html.erb: TypeError: formattedExpression.trim is not a function
[error]     at /Users/pablo/Projects/xxx/node_modules/prettier-plugin-erb/lib/formatter.js:28:46
[error]     at Array.map (<anonymous>)
[error]     at formatMultilineExpressions (/Users/pablo/Projects/xxx/node_modules/prettier-plugin-erb/lib/formatter.js:7:6)
[error]     at Object.print (/Users/pablo/Projects/xxx/node_modules/prettier-plugin-erb/lib/printers.js:22:27)
[error]     at callPluginPrintFunction (/Users/pablo/Projects/xxx/node_modules/prettier/index.js:13787:21)
[error]     at mainPrintInternal (/Users/pablo/Projects/xxx/node_modules/prettier/index.js:13725:17)
[error]     at mainPrint (/Users/pablo/Projects/xxx/node_modules/prettier/index.js:13707:14)
[error]     at printAstToDoc (/Users/pablo/Projects/xxx/node_modules/prettier/index.js:13694:13)
[error]     at coreFormat (/Users/pablo/Projects/xxx/node_modules/prettier/index.js:14055:15)
[error]     at formatWithCursor$1 (/Users/pablo/Projects/xxx/node_modules/prettier/index.js:14284:14)

vizcay avatar Oct 30 '21 15:10 vizcay

I'm seeing this too.

abuzzell avatar Nov 01 '21 11:11 abuzzell

Same for me as well

3atharvkurdukar avatar Nov 04 '21 05:11 3atharvkurdukar

Same here.

sonnypgs avatar Nov 04 '21 09:11 sonnypgs

Same!

akimthedream avatar Nov 04 '21 14:11 akimthedream

It seems like the issue occurs in combination with the new release of version 2.0.0 of @prettier/plugin-ruby. I downgraded to "@prettier/plugin-ruby": "1.6.1" and formatting is working now again as expected 🚀

akimthedream avatar Nov 04 '21 15:11 akimthedream

It seems like the issue occurs in combination with the new release of version 2.0.0 of @prettier/plugin-ruby. I downgraded to "@prettier/plugin-ruby": "1.6.1" and formatting is working now again as expected 🚀

This didn't work for me. I restarted VS Code and still got the "..trim" error

alanjudson avatar Nov 19 '21 15:11 alanjudson

@akimthedream Hello, can we please see your package.json, tried to downgrade but it wipes out much of the code on save and changes the html tags to I'm trying to guess which combination we need.

It would be big help! thank you, if you have time.

"devDependencies": {
   "@prettier/plugin-ruby": "1.6.1",
   "prettier": "1.9.0",
   "prettier-plugin-erb": "^0.4.0",
   "webpack-dev-server": "^3"
 }

ghost avatar Dec 05 '21 08:12 ghost

This combination worked for me -

"@prettier/plugin-ruby": "1.6.1",
"prettier": "2.2.0",
"prettier-plugin-erb": "^0.4.0"

joshunger avatar Feb 11 '22 11:02 joshunger

This is all related to #49

tmaier avatar Mar 31 '22 20:03 tmaier