Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
delawski committed Aug 14, 2020
1 parent b8169a0 commit 138fe0d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 19 deletions.
20 changes: 13 additions & 7 deletions assets/src/js/amp-service-worker-offline-commenting.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* eslint-env browser */
/* global ERROR_MESSAGES, SITE_URL */
{
const queue = new wp.serviceWorker.backgroundSync.Queue( 'amp-wpPendingComments' );
const queue = new wp.serviceWorker.backgroundSync.Queue(
'amp-wpPendingComments'
);
const errorMessages = ERROR_MESSAGES;

const commentHandler = ( { event } ) => {
Expand All @@ -14,26 +17,29 @@
credentials: event.request.credentials,
referrer: event.request.referrer,
redirect: 'follow',
body: body
body,
} );

// Add request to queue.
queue.pushRequest( {
request: queuedRequest
request: queuedRequest,
} );

const jsonBody = JSON.stringify( { message: errorMessages.comment } );
const jsonBody = JSON.stringify( {
message: errorMessages.comment,
} );
return new Response( jsonBody, {
status: 202,
statusText: 'Accepted',
headers: {
'Access-Control-Allow-Origin': SITE_URL,
'Access-Control-Allow-Credentials': 'true',
'Content-Type': 'application/json; charset=UTF-8',
'Access-Control-Expose-Headers': 'AMP-Access-Control-Allow-Source-Origin',
'Access-Control-Expose-Headers':
'AMP-Access-Control-Allow-Source-Origin',
'AMP-Access-Control-Allow-Source-Origin': SITE_URL,
'Cache-Control': 'no-cache, must-revalidate, max-age=0'
}
'Cache-Control': 'no-cache, must-revalidate, max-age=0',
},
} );
} );
} );
Expand Down
1 change: 0 additions & 1 deletion assets/src/js/amp-wp-app-shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ function loadUrl( url, { scrollIntoView = false, pushState = true } = {} ) {
currentShadowDoc.ampdoc.whenReady().then( () => {
const currentUrl = new URL( url );


// Update the nav menu classes if the final URL has redirected somewhere else.
if ( currentUrl.toString() !== url.toString() ) {
updateNavMenuClasses( currentUrl );
Expand Down
2 changes: 1 addition & 1 deletion includes/amp-app-shell-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function amp_app_shell_register_default_scripts( $wp_scripts ) {

// App shell library.
$handle = 'amp-wp-app-shell';
$url = plugins_url( 'assets/js/' .$handle . '.js', AMP_APP_SHELL__FILE__ );
$url = plugins_url( 'assets/js/' . $handle . '.js', AMP_APP_SHELL__FILE__ );
$asset_file = AMP_APP_SHELL__DIR__ . '/assets/js/' . $handle . '.asset.php';
$asset = require $asset_file;
$dependencies = $asset['dependencies'];
Expand Down
4 changes: 2 additions & 2 deletions includes/class-amp-app-shell-service-worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function ( $blacklist_patterns ) {
function( $supportable_templates ) {
if ( ! isset( $supportable_templates['is_offline'] ) ) {
$supportable_templates['is_offline'] = [
'label' => __( 'Offline', 'amp' ),
'label' => __( 'Offline', 'amp-app-shell' ),
];
}
return $supportable_templates;
Expand Down Expand Up @@ -106,7 +106,7 @@ function( $supportable_templates ) {
*/
public static function add_live_list_offline_commenting( $service_workers ) {
if ( ! ( $service_workers instanceof WP_Service_Worker_Scripts ) ) {
_doing_it_wrong( __METHOD__, esc_html__( 'Expected argument to be WP_Service_Worker_Scripts.', 'amp' ), '1.0' );
_doing_it_wrong( __METHOD__, esc_html__( 'Expected argument to be WP_Service_Worker_Scripts.', 'amp-app-shell' ), '0.1' );
return;
}

Expand Down
18 changes: 11 additions & 7 deletions includes/class-amp-app-shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,11 @@ public static function get_requested_app_shell_component() {
* @see AMP_App_Shell::prepare_response()
*/
public static function start_output_buffering() {
ob_start( function( $response ) {
return self::prepare_response( $response );
} );
ob_start(
function( $response ) {
return self::prepare_response( $response );
}
);
}

/**
Expand All @@ -225,9 +227,11 @@ public static function start_output_buffering() {
* @see AMP_App_Shell::prepare_response()
*/
public static function start_late_output_buffering() {
ob_start( function( $response ) {
return self::prepare_response( $response, true );
} );
ob_start(
function( $response ) {
return self::prepare_response( $response, true );
}
);
}

/**
Expand Down Expand Up @@ -371,7 +375,7 @@ protected static function prepare_inner_app_shell_document( DOMElement $content_
*/
protected static function sanitize_styles_for_shadow_dom( Document $dom ) {
$lower_case = 'translate( %s, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz" )'; // In XPath 2.0 this is lower-case().
$query = sprintf( '//*[ ( self::style and not( @amp-boilerplate ) and ( not( @type ) or %s = "text/css" ) ) ]', sprintf( $lower_case, '@type' ) );
$query = sprintf( '//*[ ( self::style and not( @amp-boilerplate ) and ( not( @type ) or %s = "text/css" ) ) ]', sprintf( $lower_case, '@type' ) );

foreach ( $dom->xpath->query( $query ) as $element ) {
/*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint:js": "wp-scripts lint-js assets/src/js",
"lint:js:fix": "npm run lint:js -- --fix",
"lint:php": "vendor/bin/phpcs",
"lint:php:fix": "./bin/phpcbf.sh",
"lint:php:fix": "vendor/bin/phpcbf",
"start": "wp-scripts start assets/src/js/* --output-path=assets/js",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down
13 changes: 13 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
</properties>
</rule>

<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
<property name="customPropertiesWhitelist" type="array">
<element value="parentNode"/>
<element value="nextSibling"/>
<element value="previousSibling"/>
<element value="firstChild"/>
<element value="nodeValue"/>
<element value="ownerDocument"/>
</property>
</properties>
</rule>

<config name="testVersion" value="5.6-"/>
<rule ref="PHPCompatibilityWP"/>

Expand Down

0 comments on commit 138fe0d

Please sign in to comment.