Shopify / packwerk

Good things come in small packages.
MIT License
1.59k stars 110 forks source link

Fix error when parsing ERB files with yield on the top level #404

Closed rafaelfranca closed 5 months ago

rafaelfranca commented 5 months ago

Top level yields are invalid Ruby on files, but are valid on eval.

They exist on ERB files, and since those files are evaluated no written to disk they are fine.

We can tell Prism to parse the code using the eval context by passing scopes: [[]] to parse, but since are are using the Prism::Translation::Parser class we have no way to do that.

A PR was proposed to Prism to always consider the code as being evaluated in the Parser translation.

For now, we can safely ignore that class of error by overriding the valid_error? method on our own parser.

Fixes #400.

gmcgibbon commented 5 months ago

rbi-0.1.12 requires ruby version >= 3.0.0, which is incompatible with the current version, 2.7.8 🤔

We might need multiple gemfiles.

rafaelfranca commented 5 months ago

I'm dropping support to EOL rubies.

rafaelfranca commented 5 months ago

https://github.com/Shopify/packwerk/pull/405