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

WP/EnqueuedResourceParameters: change MissingVersion to a warning #2146

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
$type = 'style';
}

$this->phpcsFile->addError(
'Resource version not set in call to %s(). This means new versions of the %s will not always be loaded due to browser caching.',
$this->phpcsFile->addWarning(
'Resource version not set in call to %s(). This means new versions of the %s may not always be loaded due to browser caching.',
$stackPtr,
'MissingVersion',
array( $matched_content, $type )
Expand Down
8 changes: 4 additions & 4 deletions WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ) ); // Error - missing $ver, Warning - In Footer is set to a falsy (default) value.
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ) ); // Warning - missing $ver, Warning - In Footer is set to a falsy (default) value.

wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), /* comment */ '1.1.1', true ); // OK.
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), /* comment */ '0' /* another comment */, true ); // Error - 0, false or NULL are not allowed.
Expand Down Expand Up @@ -36,13 +36,13 @@ wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), '1.1.0', $in_footer ); // OK.

wp_enqueue_script( 'script-name', 'https://example.com/someScript.js', false, '1.0.0', true ); // OK.
wp_enqueue_script( 'script-name', 'https://example.com/someScript.js' ); // Error - missing $ver, Warning - missing $in_footer.
wp_enqueue_script( 'script-name', 'https://example.com/someScript.js' ); // Warning - missing $ver, Warning - missing $in_footer.

wp_register_style( 'script-name', 'https://example.com/someScript.js', false, '1.0.0' ); // OK.
wp_register_style( 'script-name', 'https://example.com/someScript.js' ); // Error - missing $ver.
wp_register_style( 'script-name', 'https://example.com/someScript.js' ); // Warning - missing $ver.

wp_enqueue_style( 'script-name', 'https://example.com/someScript.js', false, '1.0.0'); // OK.
wp_enqueue_style( 'script-name', 'https://example.com/someScript.js' ); // Error - missing $ver.
wp_enqueue_style( 'script-name', 'https://example.com/someScript.js' ); // Warning - missing $ver.

wp_register_script( 'someScript-js' ); // OK.
wp_enqueue_script( 'someScript-js' ); // OK.
Expand Down
12 changes: 5 additions & 7 deletions WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,13 @@ class EnqueuedResourceParametersUnitTest extends AbstractSniffUnitTest {
*/
public function getErrorList() {
return array(
3 => 1,
6 => 1,
9 => 1,
10 => 1,
11 => 1,
12 => 1,
13 => 1,
14 => 1,
22 => 1,
39 => 1,
42 => 1,
45 => 1,
54 => 1,
57 => 1,
);
Expand All @@ -51,9 +46,12 @@ public function getErrorList() {
*/
public function getWarningList() {
return array(
3 => 1,
3 => 2,
11 => 1,
32 => 1,
39 => 1,
39 => 2,
42 => 1,
45 => 1,
);
}

Expand Down