Shopify / prettier-plugin-liquid

Prettier Liquid/HTML plugin
https://npm.im/@shopify/prettier-plugin-liquid
MIT License
93 stars 15 forks source link

TypeError: Cannot read properties of undefined (reading 'startsWith') #134

Closed albchu closed 1 year ago

albchu commented 1 year ago

Describe the bug Discovered a bit of a funky edge case when reviewing bug reports. The current playground is still on 0.4.0 and shows a different error than 1.0.0RC1. I bumped the version of the playground here if you wish to compare the error messages https://github.com/Shopify/prettier-plugin-liquid/pull/133

Unformatted source

 <div class="bundle-product"
                  data-variantId="{{ variant_id }}"
                  {% for i in (1..3) %}
                      {% assign plan_id = i | minus: 1 %}
                      data-sellingId-{{i}}="{{ product.selling_plan_groups[0].selling_plans[plan_id].id }}"
                  {% endfor %}
              ></div>

Expected output This current error isnt a prettier syntax error so the theme code editor can't show loc details with it. A standard syntax error would give more meaningful details to the user. The 0.4.0 playground was showing a different error which seems more detailed to my untrained eye. Not sure which one is more correct though.

Actual output

TypeError: Cannot read properties of undefined (reading 'startsWith')
    at isBlockLikeCssDisplay (https://www.unpkg.com/@shopify/prettier-plugin-liquid@v1.0.0-rc.1/standalone.js:2755:20)
    at isOuterRightWhitespaceSensitiveCssDisplay (https://www.unpkg.com/@shopify/prettier-plugin-liquid@v1.0.0-rc.1/standalone.js:2767:13)
    at isLeadingWhitespaceSensitiveNode (https://www.unpkg.com/@shopify/prettier-plugin-liquid@v1.0.0-rc.1/standalone.js:2578:10)
    at augmentWithWhitespaceHelpers (https://www.unpkg.com/@shopify/prettier-plugin-liquid@v1.0.0-rc.1/standalone.js:2523:39)
    at walk (https://www.unpkg.com/@shopify/prettier-plugin-liquid@v1.0.0-rc.1/standalone.js:2183:5)
    at https://www.unpkg.com/@shopify/prettier-plugin-liquid@v1.0.0-rc.1/standalone.js:2177:36
    at Array.forEach (<anonymous>)
    at walk (https://www.unpkg.com/@shopify/prettier-plugin-liquid@v1.0.0-rc.1/standalone.js:2177:18)
    at https://www.unpkg.com/@shopify/prettier-plugin-liquid@v1.0.0-rc.1/standalone.js:2177:36
    at Array.forEach (<anonymous>)
zub0r commented 3 months ago

Still an issue. The file that errors out