Skip to content

Commit

Permalink
chore(lint): fix linting errors (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek authored Jan 21, 2020
1 parent 69367a0 commit b3cc58e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
6 changes: 3 additions & 3 deletions src/block-styles/core/columns/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
}

&.is-style-borders {
[data-type="core/column"] {
[data-type='core/column'] {
border-bottom: 1px solid $color__border;
position: relative;

&:last-child,
// exclude nested columns
[data-type="core/column"] {
[data-type='core/column'] {
border-bottom: 0;
}

Expand All @@ -50,7 +50,7 @@

&:last-child::after,
// exclude nested columns
[data-type="core/column"]:after {
[data-type='core/column']::after {
display: none;
}
}
Expand Down
40 changes: 20 additions & 20 deletions src/blocks/homepage-articles/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,28 +296,36 @@ class Edit extends Component {
{ postsToShow && (
<QueryControls
numberOfItems={ postsToShow }
onNumberOfItemsChange={ postsToShow => setAttributes( { postsToShow } ) }
onNumberOfItemsChange={ _postsToShow =>
setAttributes( { postsToShow: _postsToShow } )
}
specificMode={ specificMode }
onSpecificModeChange={ specificMode => setAttributes( { specificMode } ) }
onSpecificModeChange={ _specificMode =>
setAttributes( { specificMode: _specificMode } )
}
specificPosts={ specificPosts }
onSpecificPostsChange={ specificPosts => setAttributes( { specificPosts } ) }
onSpecificPostsChange={ _specificPosts =>
setAttributes( { specificPosts: _specificPosts } )
}
authors={ authors }
onAuthorsChange={ authors => setAttributes( { authors } ) }
onAuthorsChange={ _authors => setAttributes( { authors: _authors } ) }
categories={ categories }
onCategoriesChange={ categories => setAttributes( { categories } ) }
onCategoriesChange={ _categories => setAttributes( { categories: _categories } ) }
tags={ tags }
onTagsChange={ tags => {
setAttributes( { tags } );
onTagsChange={ _tags => {
setAttributes( { tags: _tags } );
} }
tagExclusions={ tagExclusions }
onTagExclusionsChange={ tagExclusions => setAttributes( { tagExclusions } ) }
onTagExclusionsChange={ _tagExclusions =>
setAttributes( { tagExclusions: _tagExclusions } )
}
/>
) }
{ postLayout === 'grid' && (
<RangeControl
label={ __( 'Columns', 'newspack-blocks' ) }
value={ columns }
onChange={ columns => setAttributes( { columns } ) }
onChange={ _columns => setAttributes( { columns: _columns } ) }
min={ 2 }
max={ 6 }
required
Expand Down Expand Up @@ -397,7 +405,7 @@ class Edit extends Component {
'newspack-blocks'
) }
value={ minHeight }
onChange={ minHeight => setAttributes( { minHeight } ) }
onChange={ _minHeight => setAttributes( { minHeight: _minHeight } ) }
min={ 0 }
max={ 100 }
required
Expand Down Expand Up @@ -425,7 +433,7 @@ class Edit extends Component {
className="type-scale-slider"
label={ __( 'Type Scale', 'newspack-blocks' ) }
value={ typeScale }
onChange={ typeScale => setAttributes( { typeScale } ) }
onChange={ _typeScale => setAttributes( { typeScale: _typeScale } ) }
min={ 1 }
max={ 10 }
beforeIcon="editor-textcolor"
Expand Down Expand Up @@ -658,15 +666,7 @@ const isSpecificPostModeActive = ( { specificMode, specificPosts } ) =>
specificMode && specificPosts && specificPosts.length;

const queryCriteriaFromAttributes = attributes => {
const {
postsToShow,
authors,
categories,
tags,
specificPosts,
specificMode,
tagExclusions,
} = attributes;
const { postsToShow, authors, categories, tags, specificPosts, tagExclusions } = attributes;
const criteria = pickBy(
isSpecificPostModeActive( attributes )
? {
Expand Down
29 changes: 18 additions & 11 deletions src/blocks/homepage-articles/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { registerStore, select, subscribe, dispatch } from '@wordpress/data';
import { uniq, compact } from 'lodash';
import { uniq } from 'lodash';

import metadata from './block.json';

Expand Down Expand Up @@ -40,27 +40,34 @@ const actions = {
},
};

/**
* @typedef Block A Gutenberg editor block
* @type {Object}
* @typedef uuid Unique id
* @type {string}
*/

/**
* Returns the Query blocks that appear before the current one on the page
*
* @param {Block[]} orderedBlocks
* @param {uuid} clientId
* @returns {Block[]}
* @param {Block[]} orderedBlocks Ordered Blocks
* @param {uuid} clientId client id
* @return {Block[]} blocks
*/
const blocksBefore = ( orderedBlocks, clientId ) => {
const ourBlockIdx = orderedBlocks.findIndex( b => b.clientId == clientId );
const ourBlockIdx = orderedBlocks.findIndex( b => b.clientId === clientId );
return orderedBlocks.slice( 0, ourBlockIdx );
};

const selectors = {
previousPostIds( state, clientId ) {
previousPostIds( state, _clientId ) {
const { queryBlocks, specificPostsByBlock, postsByBlock } = state;

const postIdsFromSpecificMode = queryBlocks
.filter( ( { clientId } ) => specificPostsByBlock[ clientId ] )
.flatMap( ( { clientId } ) => specificPostsByBlock[ clientId ].map( p => p.id ) );

const previousPostIds = blocksBefore( queryBlocks, clientId )
const previousPostIds = blocksBefore( queryBlocks, _clientId )
.filter( ( { clientId } ) => postsByBlock[ clientId ] )
.flatMap( ( { clientId } ) => postsByBlock[ clientId ].map( p => p.id ) );

Expand All @@ -73,13 +80,13 @@ const selectors = {
* the page. This is needed to be able to show the editor blocks in the order
* that PHP will render them.
*
* @param {Block[]} blocks
* @return {Block[]}
* @param {Block[]} blocks any blocks
* @return {Block[]} ordered newspack-blocks/query blocks
*/
const getQueryBlocksInOrder = blocks =>
blocks.flatMap( block => {
const queryBlocks = [];
if ( block.name == blockName ) {
if ( block.name === blockName ) {
queryBlocks.push( block );
}
return queryBlocks.concat( getQueryBlocksInOrder( block.innerBlocks ) );
Expand Down Expand Up @@ -128,7 +135,7 @@ export const registerQueryStore = () => {
subscribe( () => {
const newBlocksIds = getClientIdsWithDescendants();
// I don't know why != works but it does, I guess getClientIdsWithDescendants is memoized?
const blocksChanged = newBlocksIds != currentBlocksIds;
const blocksChanged = newBlocksIds !== currentBlocksIds;
currentBlocksIds = newBlocksIds;

if ( blocksChanged ) {
Expand Down
1 change: 1 addition & 0 deletions src/blocks/homepage-articles/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const fetchRetryCount = 3;
* Load More Button Handling
*
* Calls Array.prototype.forEach for IE11 compatibility.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/NodeList
*/
Array.prototype.forEach.call(
Expand Down
3 changes: 1 addition & 2 deletions src/components/query-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,8 @@ class QueryControls extends Component {
/>
),
! specificMode && onTagExclusionsChange && (
<p>
<p key="toggle-advanced-filters">
<Button
key="toggle-advanced-filters"
isLink
onClick={ () => this.setState( { showAdvancedFilters: ! showAdvancedFilters } ) }
>
Expand Down

0 comments on commit b3cc58e

Please sign in to comment.