Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopify Code in JS Reported as Error #58

Open
Muxstang opened this issue Sep 23, 2020 · 5 comments
Open

Shopify Code in JS Reported as Error #58

Muxstang opened this issue Sep 23, 2020 · 5 comments
Labels
📖 Documentation Requires documentation

Comments

@Muxstang
Copy link

I am not 100% sure if this is an issue with this extension, if I have it configured wrong, or if I should have disabled something else. I just recently started with Shopify so please forgive me.

I am seeing that the following code, see below, gets a "Property Assignment expected error on the first { after "addToCart: "and then 4 errors for Decloration or statement expected.

<script> // Override default values of shop.strings for each template. // Alternate product templates can change values of // add to cart button, sold out, and unavailable states here. theme.productStrings = { addToCart: {{ 'products.product.add_to_cart' | t | json }}, soldOut: {{ 'products.product.sold_out' | t | json }}, unavailable: {{ 'products.product.unavailable' | t | json }} } </script>

Again, not sure is this is truley replated to the extension or note.
Thanks for any help.

@Max-Stevenson
Copy link

Possibly having the same issue I was having.

In the root of your project create a new directory called .vscode and inside that directory create a new file called settings.json.
In the settings.json file add the following rule:

{
  "html.validate.scripts": false,
  "html.validate.styles": false
}

@panoply
Copy link
Owner

panoply commented Dec 30, 2020

Hey guys,

For now this is the best solution to avoid such errors, it's difficult to find a fluent solution to overcome such an issue as JavaScript infused with Liquid is not something that JavaScript parsers are equipped to handle just yet. I may work on something like this in future but for now, best to just skip validating as per @Max-Stevenson comment.

I'll keep this open and think it might be worth adding to the readme/docs.

@panoply panoply added 📖 Documentation Requires documentation 💧Liquify Features shipping in Liquify labels Dec 30, 2020
@panoply panoply added v3.0.0 and removed 💧Liquify Features shipping in Liquify labels Sep 25, 2022
@panoply panoply removed the v3.1.0 label Oct 27, 2022
@joshistoast
Copy link

Any news on this in the year 2023? 👀

@panoply
Copy link
Owner

panoply commented Jul 25, 2023

Hey @joshistoast,

This one must of got lost, but essentially JS errors are going to be reported for Liquid contained in JavaScript because it is invalid. The workaround is to simply disable validations as per Max comment above #58 (comment).

@joshistoast
Copy link

This one must of got lost, but essentially JS errors are going to be reported for Liquid contained in JavaScript because it is invalid. The workaround is to simply disable validations as per Max comment above #58 (comment).

I saw that, was hoping for a more graceful solution then disabling validation. There's been a few years between then and now so I was curious if any headway was made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 Documentation Requires documentation
Projects
None yet
Development

No branches or pull requests

4 participants