question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interpret `<script type="x-magento-init">` as JSON syntax

See original GitHub issue

Is your feature request related to a problem? Please describe.

I would like to get the validation of the <script type="x-magento-init"> as JSON in PHPStorm

Describe the solution you’d like (*)

When I create node <script type="x-magento-init"> I would like to get this validated as a JSON syntax, as well as have hints provided.

Describe alternatives you’ve considered

Manual configuration of PHPStorm.

Additional context

We can also cover data-mage-init too

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
bohdan-harniukcommented, Feb 1, 2022

Hello, @DmitryFurs, @ihor-sviziev, @dkorpar, @VitaliyBoyko, @andrewbess, @coderimus, @Iamwade!

We have added missed check if the Magento 2 integration is enabled (it will be included in the next release, 4.3.0. For now with plugin installed highlighting will work even if Magento 2 integration is disabled for a project).

Please, help us to decide, if we need to add separate ability to enable/disable uiComponent script highlighting if magento integration is enabled.

Please, use 👍 to approve this idea and 👎 to leave highlighting enabled just if integration is enabled.

Regards,

3reactions
DmitryFurscommented, Dec 18, 2020

@coderimus any updates?

By default now it looks like this

image

But if we configure the inspection that @dkorpar described, then if there is php code inside, we get the following situation

image

In case where the php expression is wrapped in double quotes these errors disappear

image

Also, ctrl+click to jump to the reference only works in the case of wrapped quotes. But quotation marks are not always necessary, for example, if we want to pass a strictly numeric value, or a boolean value true or false.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling and initializing JavaScript - Magento DevDocs
To call a JS component on an HTML element without direct access to the element or with no relation to a certain element,...
Read more >
unexpected SyntaxError from Template/Ajax - Magento 2
I am a newby in Magento, so sorry if my question seem stupid. I have an error. SyntaxError: JSON.parse: expected double-quoted property name ......
Read more >
How to fixed Uncaught SyntaxError: Unexpected token } in ...
Magento page console error Uncaught SyntaxError: Unexpected token } in JSON at position 530 while you have made mistake to your code.
Read more >
Magento 2: how to debug json error - Valuable Tech Notes
The only JSON.parse command in main.js is in the getData function; specifically, ... script into a template file, but that the attribute's JSON...
Read more >
Magento 2 Certified Professional JavaScript Developer Guide
Magento makes use of this behavior peculiarity and, after the page is loaded, uses JSON-content of such tags for initialization and launch of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found