Skip to content

Commit 7795773

Browse files
committed
Fix linting issues
1 parent 609f322 commit 7795773

File tree

7 files changed

+32
-33
lines changed

7 files changed

+32
-33
lines changed

src/blocks/shared-block/edit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import SharedBlocksSelector from './sharedBlocksSelector';
2525
import './editor.scss';
2626

2727
export default function Edit( { attributes, setAttributes } ) {
28-
const { siteId, postId, blockId, blockTitle, display } = attributes;
28+
const { blockId, blockTitle, display } = attributes;
2929

3030
const [ isEditing, setIsEditing ] = useState( false );
3131

src/blocks/shared-block/sharedBlocksSelector.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ import { __, sprintf } from '@wordpress/i18n';
2222
const SEARCH_ENDPOINT = '/multisite-shared-blocks/v1/search';
2323

2424
/**
25+
* Do search request.
26+
*
27+
* Build and send request to the shared blocks search endpoint.
2528
*
2629
* @param {Object} params
2730
* @param {AbortController} controller
28-
* @returns {Promise<*[]>}
31+
* @return {Promise<*[]>} Search request promise.
2932
*/
3033
function makeRequest( params, controller ) {
3134
const path = addQueryArgs( SEARCH_ENDPOINT, {
@@ -102,7 +105,7 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
102105
/**
103106
* Update the site id param in the query.
104107
*
105-
* @param {int} site
108+
* @param {number} site
106109
*/
107110
const setSite = ( site ) => {
108111
setQuery( { ...query, site } );
@@ -136,15 +139,15 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
136139
/**
137140
* Fetch results for the query.
138141
*
139-
* @param {object} params
142+
* @param {Object} params
140143
* @param {?AbortController} controller
141144
*/
142145
const searchBlock = ( params, controller ) => {
143-
let query = {
146+
const searchQuery = {
144147
...params,
145148
page: currentPage,
146149
};
147-
makeRequest( query, controller )
150+
makeRequest( searchQuery, controller )
148151
.then( ( blocks ) => {
149152
// Handle case where we don't have results and the request returned no results.
150153
// In that case we want to display the "No Results" state.
@@ -205,7 +208,7 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
205208
...availableSitesOptions,
206209
] }
207210
onChange={ ( value ) => {
208-
let site = '0' !== value ? +value : 0;
211+
const site = '0' !== value ? +value : 0;
209212
setSite( site );
210213
} }
211214
/>
@@ -225,7 +228,7 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
225228
...availablePostTypesOptions,
226229
] }
227230
onChange={ ( value ) => {
228-
let postType = '0' !== value ? value : '';
231+
const postType = '0' !== value ? value : '';
229232
setPostType( postType );
230233
} }
231234
/>
@@ -252,10 +255,14 @@ export default function SharedBlocksSelector( { onItemSelect } ) {
252255
>
253256
{ results.map( ( result ) => {
254257
return (
255-
<div className={ 'results__item' }>
258+
<div
259+
key={ result.id }
260+
className={ 'results__item' }
261+
>
256262
<Button
257263
variant={ 'link' }
258264
label={ sprintf(
265+
//translators: %s shared block title
259266
__(
260267
'Select block "%s"',
261268
'multisite-shared-blocks'

src/hooks/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Check if current block is excluded from sharing.
55
*
66
* @param {string} blockName
7-
* @returns {boolean}
7+
* @return {boolean} True if the block type support sharing, false otherwise.
88
*/
99
export function blockSupportSharing( blockName ) {
1010
const excludedBlocks = multisiteSharedBlocksHooksData.excluded_blocks ?? [];
@@ -15,7 +15,7 @@ export function blockSupportSharing( blockName ) {
1515
/**
1616
* Get custom attributes for the sharing functionality.
1717
*
18-
* @returns {object}
18+
* @return {Object} Custom attributes for the sharing functionality.
1919
*/
2020
export function getBlockSharingAttributs() {
2121
return multisiteSharedBlocksHooksData.attributes || {};

src/hooks/registerSharedBlockAttributes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import { blockSupportSharing, getBlockSharingAttributs } from './helper';
1414
* Since we need to keep our custom attributes in sync between PHP and JS, we inject them in the page in a custom
1515
* variable `multisiteSharedBlocksGutenbergData`.
1616
*
17-
* @param settings
18-
* @param name
19-
* @returns {any}
17+
* @param {Object} settings
18+
* @param {string} name
19+
* @return {any} New settings with the custom attributes for sharing.
2020
*/
2121
const registerSharedBlockAttributes = ( settings, name ) => {
2222
const sharedBlockAttributes = getBlockSharingAttributs();

src/hooks/sharedBlockIdComponent.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@ import { blockSupportSharing } from './helper';
1919
*/
2020
const sharedBlockIdComponent = createHigherOrderComponent( ( BlockEdit ) => {
2121
return class extends Component {
22-
constructor() {
23-
super( ...arguments );
24-
}
25-
2622
componentDidMount() {
2723
const {
2824
name,
2925
setAttributes,
3026
attributes: { sharedBlockId } = false,
3127
} = this.props;
32-
if ( blockSupportSharing( name ) ) {
33-
sharedBlockId || setAttributes( { sharedBlockId: uuidv4() } );
28+
if ( blockSupportSharing( name ) && ! sharedBlockId ) {
29+
setAttributes( { sharedBlockId: uuidv4() } );
3430
}
3531
}
3632

tests/QueryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function test_site__in_param(): void {
8383

8484
$query = new Query(
8585
[
86-
'site__in' => [1, 2],
86+
'site__in' => [ 1, 2 ],
8787
]
8888
);
8989
$sql = $wpdb->remove_placeholder_escape( $query->get_request() );

webpack.config.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' )
2-
const {getWebpackEntryPoints} = require( '@wordpress/scripts/utils' )
1+
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
2+
const { getWebpackEntryPoints } = require( '@wordpress/scripts/utils' );
33
const { resolve } = require( 'path' );
44

55
module.exports = {
6-
...defaultConfig,
7-
entry: {
8-
...getWebpackEntryPoints(),
9-
'hooks/index': resolve(
10-
process.cwd(),
11-
'src/hooks',
12-
'index.js'
13-
)
14-
}
15-
}
6+
...defaultConfig,
7+
entry: {
8+
...getWebpackEntryPoints(),
9+
'hooks/index': resolve( process.cwd(), 'src/hooks', 'index.js' ),
10+
},
11+
};

0 commit comments

Comments
 (0)