You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the WordPress Standards, this line fails the WordPress.WP.EnqueuedResources.NonEnqueuedScript sniff. In order to ignore that sniff for this line, I expected to be able to do this:
... however, that doesn't work. From what I gather, it's not possible to use the phpcs:ignore feature on a line of HTML. In fact, because the WordPress standards includes the Squiz.PHP.EmbeddedPhp.SpacingBeforeClose sniff, it adds that additional error (I'm not sure if that's deliberate or a false positive).
This is because a phpcs:ignore command ignores the current line when there is other content on that line, and only ignores the following line if there is no content. Currently, PHPCS is seeing the opening tag as a piece of content, which is why the following code works:
Summary
As best I can tell, it's not possible to use
phpcs:ignore
where the next line is HTML and not PHP.Details
Given the following line in a block of HTML in a PHP file:
When using the WordPress Standards, this line fails the
WordPress.WP.EnqueuedResources.NonEnqueuedScript
sniff. In order to ignore that sniff for this line, I expected to be able to do this:... however, that doesn't work. From what I gather, it's not possible to use the
phpcs:ignore
feature on a line of HTML. In fact, because the WordPress standards includes theSquiz.PHP.EmbeddedPhp.SpacingBeforeClose
sniff, it adds that additional error (I'm not sure if that's deliberate or a false positive).In my case, what I had to do was:
It would be nice to be able to use
phpcs:ignore
on an HTML line using a single line of PHP with a comment as demonstrated above.The text was updated successfully, but these errors were encountered: