Skip to content

False positive Magento2.Legacy.PhtmlTemplate #351

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

Closed
DmitryFurs opened this issue Dec 28, 2021 · 3 comments · Fixed by #368
Closed

False positive Magento2.Legacy.PhtmlTemplate #351

DmitryFurs opened this issue Dec 28, 2021 · 3 comments · Fixed by #368
Assignees
Labels
bug Something isn't working P1 Priority 1 Progress: done

Comments

@DmitryFurs
Copy link

Preconditions

  1. .phtml file with <script type="text/x-magento-init">
  2. magento-coding-standard v16

Steps to reproduce

  1. Create .phtml file with <script type="text/x-magento-init">
  2. run phpcs

Expected result

  1. No Magento2.Legacy.PhtmlTemplate triggered

Actual result

-------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------
 49 | WARNING | Please do not initialize JS component in php. Do it in template
-------------------------------------------------------------------------------------------------------------------------------

Additional Notes

It's probably false positive triggering, or I'm missing something and now it's forbidden to use the <script type="text/x-magento-init"></script> script and data-mage-init="{}"attribute in phtml files.

@DmitryFurs DmitryFurs added the bug Something isn't working label Dec 28, 2021
@m2-assistant
Copy link

m2-assistant bot commented Dec 28, 2021

Hi @DmitryFurs. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


@ihor-sviziev
Copy link
Collaborator

ihor-sviziev commented Jan 6, 2022

I'm having the same issue and it's really annoying.
@sivaschenko could you set high priority for this issue?

@sivaschenko
Copy link
Member

@DmitryFurs agree, it looks like\Magento2\Sniffs\Legacy\PhtmlTemplateSniff has to be split into two sniffs: one for phtml and another for PHP files. Thanks for reporting!

@ihor-sviziev done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 Priority 1 Progress: done
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants