From d2a6b3189fb3d40c54b263cebecadfa59ee889ba Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Fri, 7 Aug 2020 13:50:25 -0500 Subject: [PATCH 01/15] Apply @nickcernis 's fix to Block Lab Nick fixed this attribute, and this also applies to Block Lab. --- js/blocks/components/image.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/blocks/components/image.js b/js/blocks/components/image.js index ef0312718..3e17c0cd0 100644 --- a/js/blocks/components/image.js +++ b/js/blocks/components/image.js @@ -101,7 +101,6 @@ const Image = withSelect( ( select, ownProps ) => { { ! isUploading && ( <> { const files = event.target.files; @@ -122,7 +121,6 @@ const Image = withSelect( ( select, ownProps ) => { render={ ( { open } ) => (
+ return ( + !! buttonValue && ( + + ) ); } ) }
- } + ) } ); /* eslint-enable jsx-a11y/no-autofocus */ diff --git a/js/blocks/components/fields.js b/js/blocks/components/fields.js index 49e179af5..1bb058e87 100644 --- a/js/blocks/components/fields.js +++ b/js/blocks/components/fields.js @@ -67,7 +67,9 @@ const Fields = ( { fields, parentBlockProps, parentBlock, rowIndex } ) => { */ const onChange = ( newValue ) => { const { clientId, setAttributes } = parentBlockProps; - const parentAttributes = select( 'core/block-editor' ).getBlockAttributes( clientId ); + const parentAttributes = select( + 'core/block-editor' + ).getBlockAttributes( clientId ); const attr = { ...parentAttributes }; if ( undefined === rowIndex ) { @@ -78,7 +80,8 @@ const Fields = ( { fields, parentBlockProps, parentBlock, rowIndex } ) => { // This is in a repeater row. const attribute = attr[ field.parent ]; const defaultRows = [ {} ]; - const rows = ( attribute && attribute.rows ) ? attribute.rows : defaultRows; + const rows = + attribute && attribute.rows ? attribute.rows : defaultRows; if ( ! rows[ rowIndex ] ) { rows[ rowIndex ] = {}; @@ -106,9 +109,15 @@ const Fields = ( { fields, parentBlockProps, parentBlock, rowIndex } ) => { } ) => { const attr = { ...ownParentBlockProps.attributes }; - if ( ownField.parent && attr[ ownField.parent ] && attr[ ownField.parent ].rows ) { + if ( + ownField.parent && + attr[ ownField.parent ] && + attr[ ownField.parent ].rows + ) { // The ownField is probably in a repeater row, as it has a parent. - return attr[ ownField.parent ].rows[ ownRowIndex ][ ownField.name ]; + return attr[ ownField.parent ].rows[ ownRowIndex ][ + ownField.name + ]; } // The ownField is not in a repeater row. return attr[ ownField.name ]; @@ -116,17 +125,22 @@ const Fields = ( { fields, parentBlockProps, parentBlock, rowIndex } ) => { const Control = getControl( field ); - return !! Control && ( -
- -
+ return ( + !! Control && ( +
+ +
+ ) ); } ); }; diff --git a/js/blocks/components/image.js b/js/blocks/components/image.js index 3e17c0cd0..21567aeb7 100644 --- a/js/blocks/components/image.js +++ b/js/blocks/components/image.js @@ -1,7 +1,14 @@ /** * WordPress dependencies */ -import { BaseControl, Button, Placeholder, DropZone, FormFileUpload, Spinner } from '@wordpress/components'; +import { + BaseControl, + Button, + Placeholder, + DropZone, + FormFileUpload, + Spinner, +} from '@wordpress/components'; import { withState } from '@wordpress/compose'; import { withSelect } from '@wordpress/data'; import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor'; @@ -14,12 +21,13 @@ const DEFAULT_IMG_ID = 0; const Image = withSelect( ( select, ownProps ) => { const { getValue } = ownProps; const fieldValue = getValue( ownProps ); - let media, imageAlt, + let media, + imageAlt, imageSrc = ''; if ( parseInt( fieldValue ) ) { media = select( 'core' ).getMedia( fieldValue ); - imageSrc = ( media && media.source_url ) ? media.source_url : ''; + imageSrc = media && media.source_url ? media.source_url : ''; } else if ( 'string' === typeof fieldValue ) { // Backwards-compatibility: this used to save the URL as the fieldValue, not the ID as it does now. imageSrc = fieldValue; @@ -29,7 +37,14 @@ const Image = withSelect( ( select, ownProps ) => { if ( media && media.alt ) { imageAlt = media.alt; } else if ( media && media.source_url ) { - imageAlt = sprintf( __( 'This image has no alt attribute, but its src is %s', 'block-lab' ), media.source_url ); + imageAlt = sprintf( + /* translators: %s: the src of the image */ + __( + 'This image has no alt attribute, but its src is %s', + 'block-lab' + ), + media.source_url + ); } else { imageAlt = __( 'This image has no alt attribute', 'block-lab' ); } @@ -38,114 +53,149 @@ const Image = withSelect( ( select, ownProps ) => { imageAlt, imageSrc, }; -} )( withState()( ( ownProps ) => { - const { field, getValue, imageAlt, imageSrc, instanceId, isUploading, onChange, setState } = ownProps; - const uploadStart = () => { - setState( { isUploading: true } ); - }; +} )( + withState()( ( ownProps ) => { + const { + field, + getValue, + imageAlt, + imageSrc, + instanceId, + isUploading, + onChange, + setState, + } = ownProps; + const uploadStart = () => { + setState( { isUploading: true } ); + }; - const uploadComplete = ( image ) => { - if ( image.hasOwnProperty( 'id' ) ) { - onChange( parseInt( image.id ) ); - } - setState( { isUploading: false } ); - }; + const uploadComplete = ( image ) => { + if ( image.hasOwnProperty( 'id' ) ) { + onChange( parseInt( image.id ) ); + } + setState( { isUploading: false } ); + }; - const onSelect = ( image ) => { - if ( ! image.hasOwnProperty( 'url' ) || ! image.hasOwnProperty( 'id' ) ) { - return; - } - if ( 'blob' === image.url.substr( 0, 4 ) ) { - // Still uploading… - return; - } + const onSelect = ( image ) => { + if ( + ! image.hasOwnProperty( 'url' ) || + ! image.hasOwnProperty( 'id' ) + ) { + return; + } + if ( 'blob' === image.url.substr( 0, 4 ) ) { + // Still uploading… + return; + } - uploadComplete( image ); - }; + uploadComplete( image ); + }; - const removeImage = () => { - // The attribute should be an int, so set it to 0 on removing an image. - onChange( DEFAULT_IMG_ID ); - }; + const removeImage = () => { + // The attribute should be an int, so set it to 0 on removing an image. + onChange( DEFAULT_IMG_ID ); + }; - const uploadFiles = ( files ) => { - mediaUpload( { - allowedTypes: ALLOWED_TYPES, - filesList: files, - onFileChange: ( image ) => { - onSelect( image[ 0 ] ); - }, - } ); - }; + const uploadFiles = ( files ) => { + mediaUpload( { + allowedTypes: ALLOWED_TYPES, + filesList: files, + onFileChange: ( image ) => { + onSelect( image[ 0 ] ); + }, + } ); + }; - return ( - - { !! field.help &&

{ field.help }

} - { ! isUploading && imageSrc && ( - { - ) } - { ! imageSrc && ( - - - { - if ( files.length ) { - uploadStart(); - uploadFiles( files ); - } - } } - > - { isUploading && ( - + return ( + + { !! field.help && ( +

+ { field.help } +

+ ) } + { ! isUploading && imageSrc && ( + { + ) } + { ! imageSrc && ( + - { - const files = event.target.files; - uploadStart( files[ 0 ].name ); + > + + { + if ( files.length ) { + uploadStart(); uploadFiles( files ); - } } - accept="image/*" - multiple={ false } - > - { __( 'Upload', 'block-lab' ) } - - ( -
- -
- ) } - /> - - ) } -
-
- ) } - { imageSrc && ( - - ) } -
- ); -} ) ); + } + } } + > + { isUploading && } + { ! isUploading && ( + <> + { + const files = event.target.files; + uploadStart( files[ 0 ].name ); + uploadFiles( files ); + } } + accept="image/*" + multiple={ false } + > + { __( 'Upload', 'block-lab' ) } + + ( +
+ +
+ ) } + /> + + ) } + + + ) } + { imageSrc && ( + + ) } + + ); + } ) +); export default Image; diff --git a/js/blocks/components/repeater-rows.js b/js/blocks/components/repeater-rows.js index e9f060dab..d9129c5f0 100644 --- a/js/blocks/components/repeater-rows.js +++ b/js/blocks/components/repeater-rows.js @@ -109,17 +109,24 @@ class RepeaterRows extends Component { move( from, to ) { const scrollView = () => { // Scroll the view. - const scrollContainer = getScrollContainer( this.repeaterRows.current ); - const rowRefs = this.repeaterRows.current.querySelectorAll( '.block-lab-repeater--row' ); + const scrollContainer = getScrollContainer( + this.repeaterRows.current + ); + const rowRefs = this.repeaterRows.current.querySelectorAll( + '.block-lab-repeater--row' + ); const rowRefFrom = rowRefs[ from ]; const rowRefTo = rowRefs[ to ]; - const scrollTop = scrollContainer.scrollTop + ( rowRefTo.offsetTop - rowRefFrom.offsetTop ); + const scrollTop = + scrollContainer.scrollTop + + ( rowRefTo.offsetTop - rowRefFrom.offsetTop ); rowRefTo.classList.add( 'row-to' ); rowRefFrom.classList.add( 'row-from' ); this.timeouts.push( - setTimeout( () => { /* eslint-disable-line @wordpress/react-no-unsafe-timeout */ + /* eslint-disable-next-line @wordpress/react-no-unsafe-timeout */ + setTimeout( () => { rowRefTo.classList.remove( 'row-to' ); rowRefFrom.classList.remove( 'row-from' ); }, 1000 ) @@ -156,63 +163,85 @@ class RepeaterRows extends Component { * @return {Object} The rows. */ getRows( attribute ) { - return ( attribute && attribute.rows ) ? attribute.rows : [ {} ]; + return attribute && attribute.rows ? attribute.rows : [ {} ]; } /** * Renders the repeater rows. */ render() { - const { rows, field, subFields, parentBlockProps, parentBlock } = this.props; + const { + rows, + field, + subFields, + parentBlockProps, + parentBlock, + } = this.props; return ( <> -
- { - rows.map( ( row, rowIndex ) => { - const activeClass = this.state.activeRow === parseInt( rowIndex ) ? 'active' : ''; // @todo: Make this dynamic. - - return ( - -
- -
- + { rows.map( ( row, rowIndex ) => { + const activeClass = + this.state.activeRow === parseInt( rowIndex ) + ? 'active' + : ''; // @todo: Make this dynamic. + + return ( + +
+ +
+ +
+ + -
- - -
- - ); - } ) - } +
+
+ ); + } ) }
); diff --git a/js/blocks/components/test/fetch-input.js b/js/blocks/components/test/fetch-input.js index ba0157386..032e0b6d5 100644 --- a/js/blocks/components/test/fetch-input.js +++ b/js/blocks/components/test/fetch-input.js @@ -66,16 +66,21 @@ describe( 'FetchInput', () => { const { input } = setup( baseProps ); fireEvent.focus( input ); - await waitFor( () => expect( screen.getByText( exampleResult ) ).toBeInTheDocument() ); + await waitFor( () => + expect( screen.getByText( exampleResult ) ).toBeInTheDocument() + ); } ); it.each( [ [ [], true ], [ [ 'a-result' ], false ], [ [ 'first-result', 'another-result' ], false ], - ] )( 'should only have the error class if there are no results after focusing', + ] )( + 'should only have the error class if there are no results after focusing', async ( apiResults, expected ) => { - apiFetch.mockImplementationOnce( () => new Promise( ( resolve ) => resolve( apiResults ) ) ); + apiFetch.mockImplementationOnce( + () => new Promise( ( resolve ) => resolve( apiResults ) ) + ); const { input } = setup( baseProps ); fireEvent.focus( input ); diff --git a/js/blocks/components/test/fields.js b/js/blocks/components/test/fields.js index bae855ab9..98f890d73 100644 --- a/js/blocks/components/test/fields.js +++ b/js/blocks/components/test/fields.js @@ -14,12 +14,14 @@ describe( 'Fields', () => { it( 'does not display a control that is supposed to be in the Inspector Controls', () => { render( ); @@ -30,12 +32,14 @@ describe( 'Fields', () => { it( 'displays a control that is supposed to be in the editor', () => { render( ); @@ -46,18 +50,22 @@ describe( 'Fields', () => { it( 'has a class name based on the width', () => { render( ); const classWithWidth = 'width-50'; - expect( document.body.getElementsByClassName( classWithWidth )[ 0 ] ).not.toBeNull(); + expect( + document.body.getElementsByClassName( classWithWidth )[ 0 ] + ).not.toBeNull(); } ); } ); diff --git a/js/blocks/components/tiny-mce.js b/js/blocks/components/tiny-mce.js index d5151f5dd..7bb55b5fc 100644 --- a/js/blocks/components/tiny-mce.js +++ b/js/blocks/components/tiny-mce.js @@ -75,7 +75,8 @@ class TinyMCE extends Component { content_css: false, fixed_toolbar_container: `#toolbar-${ editorId }`, setup: this.onSetup, - toolbar1: 'formatselect,bold,italic,bullist,numlist,outdent,indent,alignleft,aligncenter,alignright,link,unlink,wp_add_media,strikethrough', + toolbar1: + 'formatselect,bold,italic,bullist,numlist,outdent,indent,alignleft,aligncenter,alignright,link,unlink,wp_add_media,strikethrough', toolbar2: '', }, } ); diff --git a/js/blocks/controls/classic-text.js b/js/blocks/controls/classic-text.js index 2fc239114..3e4a6caac 100644 --- a/js/blocks/controls/classic-text.js +++ b/js/blocks/controls/classic-text.js @@ -9,10 +9,20 @@ import { BaseControl } from '@wordpress/components'; import { TinyMCE } from '../components'; const BlockLabClassicTextControl = ( props ) => { - const { field, getValue, onChange, rowIndex, parentBlockProps: { clientId } } = props; - const editorId = 'number' === typeof rowIndex ? `bl-${ clientId }-${ field.name }-rowIndex-${ rowIndex }` : `bl-${ clientId }-${ field.name }`; + const { + field, + getValue, + onChange, + rowIndex, + parentBlockProps: { clientId }, + } = props; + const editorId = + 'number' === typeof rowIndex + ? `bl-${ clientId }-${ field.name }-rowIndex-${ rowIndex }` + : `bl-${ clientId }-${ field.name }`; const initialValue = getValue( props ); - const value = 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = + 'undefined' !== typeof initialValue ? initialValue : field.default; return ( { - const toggleVisible = () => { - setState( ( state ) => ( { isVisible: ! state.isVisible } ) ); - }; - const colorChange = ( value ) => { - let newColor = value.hex; - if ( value.rgb.a < 1 ) { - newColor = 'rgba(' + value.rgb.r + ', ' + value.rgb.g + ', ' + value.rgb.b + ', ' + value.rgb.a + ')'; - } - setState( () => ( { color: newColor } ) ); - onUpdate( newColor ); - }; +const BlockLabColorPopover = withState( {} )( + ( { isVisible, color, onUpdate, setState } ) => { + const toggleVisible = () => { + setState( ( state ) => ( { isVisible: ! state.isVisible } ) ); + }; + const colorChange = ( value ) => { + let newColor = value.hex; + if ( value.rgb.a < 1 ) { + newColor = + 'rgba(' + + value.rgb.r + + ', ' + + value.rgb.g + + ', ' + + value.rgb.b + + ', ' + + value.rgb.a + + ')'; + } + setState( () => ( { color: newColor } ) ); + onUpdate( newColor ); + }; - return ( - - { - event.preventDefault(); // Prevent the popover blur. - } } - onClick={ toggleVisible } - > - { isVisible && ( - { - event.stopPropagation(); - } } - onBlur={ ( event ) => { - if ( null === event.relatedTarget ) { - return; - } - if ( event.relatedTarget.classList.contains( 'wp-block' ) ) { - toggleVisible(); - } - } } - > - { - colorChange( value ); + return ( + + { + event.preventDefault(); // Prevent the popover blur. + } } + onClick={ toggleVisible } + > + { isVisible && ( + { + event.stopPropagation(); } } - /> - - ) } - - - ); -} ); + onBlur={ ( event ) => { + if ( null === event.relatedTarget ) { + return; + } + if ( + event.relatedTarget.classList.contains( + 'wp-block' + ) + ) { + toggleVisible(); + } + } } + > + { + colorChange( value ); + } } + /> + + ) } + + + ); + } +); const BlockLabColorControl = ( props ) => { const { field, getValue, instanceId, onChange } = props; const initialValue = getValue( props ); - const value = 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = + 'undefined' !== typeof initialValue ? initialValue : field.default; return ( - - + + { const { field, getValue, onChange } = props; const initialValue = getValue( props ); - const value = 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = + 'undefined' !== typeof initialValue ? initialValue : field.default; /** * Sets the Error Class for the Text Control. diff --git a/js/blocks/controls/image.js b/js/blocks/controls/image.js index 0e93de218..e785830fa 100644 --- a/js/blocks/controls/image.js +++ b/js/blocks/controls/image.js @@ -4,9 +4,7 @@ import { Image } from '../components'; const BlockLabImageControl = ( props ) => { - return ( - - ); + return ; }; export default BlockLabImageControl; diff --git a/js/blocks/controls/number.js b/js/blocks/controls/number.js index fde99923a..186a24872 100644 --- a/js/blocks/controls/number.js +++ b/js/blocks/controls/number.js @@ -11,7 +11,8 @@ import { TextControl } from '@wordpress/components'; const BlockLabNumberControl = ( props ) => { const { field, getValue, onChange } = props; const initialValue = getValue( props ); - const value = 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = + 'undefined' !== typeof initialValue ? initialValue : field.default; /** * Sets the Error Class for the Text Control. diff --git a/js/blocks/controls/post.js b/js/blocks/controls/post.js index fafd76255..18a031e65 100644 --- a/js/blocks/controls/post.js +++ b/js/blocks/controls/post.js @@ -10,7 +10,10 @@ const BlockLabPostControl = ( props ) => { * @param {Object} apiResponse The API response in which to look for the post title. * @return {string} The post title from the response, or the default. */ - const getNameFromAPI = ( apiResponse ) => ( apiResponse && apiResponse.title && apiResponse.title.rendered ) ? apiResponse.title.rendered : ''; + const getNameFromAPI = ( apiResponse ) => + apiResponse && apiResponse.title && apiResponse.title.rendered + ? apiResponse.title.rendered + : ''; const contentProps = { ...props, getNameFromAPI }; return ; }; diff --git a/js/blocks/controls/repeater.js b/js/blocks/controls/repeater.js index 0e0b9a7b8..157700429 100644 --- a/js/blocks/controls/repeater.js +++ b/js/blocks/controls/repeater.js @@ -9,11 +9,19 @@ import { BaseControl, IconButton } from '@wordpress/components'; import { RepeaterRows } from '../components'; const BlockLabRepeaterControl = ( props ) => { - const { field, instanceId, onChange, parentBlock, parentBlockProps } = props; + const { + field, + instanceId, + onChange, + parentBlock, + parentBlockProps, + } = props; const { attributes, setAttributes } = parentBlockProps; const attr = { ...attributes }; const value = attr[ field.name ]; - const defaultRows = new Array( field.min ? field.min : 1 ).fill( { '': '' } ); + const defaultRows = new Array( field.min ? field.min : 1 ).fill( { + '': '', + } ); const hasRows = value && value.hasOwnProperty( 'rows' ); const rows = hasRows ? value.rows : defaultRows; @@ -36,7 +44,12 @@ const BlockLabRepeaterControl = ( props ) => { } return ( - + { className="block-lab-rich-text-control" help={ field.help } > - { - /* - * @todo: Resolve known issue with toolbar not disappearing on blur - * @see: https://github.com/WordPress/gutenberg/issues/7463 - */ - } + { /* + * @todo: Resolve known issue with toolbar not disappearing on blur + * @see: https://github.com/WordPress/gutenberg/issues/7463 + */ } { if ( '' === field.default ) { field.options = [ - { label: __( '– Select –', 'block-lab' ), value: '', disabled: true }, + { + label: __( '– Select –', 'block-lab' ), + value: '', + disabled: true, + }, ...field.options, ]; } diff --git a/js/blocks/controls/taxonomy.js b/js/blocks/controls/taxonomy.js index d77b17b97..26d90d732 100644 --- a/js/blocks/controls/taxonomy.js +++ b/js/blocks/controls/taxonomy.js @@ -10,7 +10,8 @@ const BlockLabTaxonomyControl = ( props ) => { * @param {Object} apiResponse The API response in which to look for the post title. * @return {string} The post title from the response, or the default. */ - const getNameFromAPI = ( apiResponse ) => ( apiResponse && apiResponse.name ) ? apiResponse.name : ''; + const getNameFromAPI = ( apiResponse ) => + apiResponse && apiResponse.name ? apiResponse.name : ''; const contentProps = { ...props, getNameFromAPI }; return ; diff --git a/js/blocks/controls/test/classic-text.js b/js/blocks/controls/test/classic-text.js index ad574e7a4..0e88bc849 100644 --- a/js/blocks/controls/test/classic-text.js +++ b/js/blocks/controls/test/classic-text.js @@ -41,7 +41,9 @@ test( 'classic text control', async () => { }, }; - const { findByText } = render( ); + const { findByText } = render( + + ); const control = await findByText( props.field.help ); expect( control ).toBeInTheDocument(); diff --git a/js/blocks/controls/test/color.js b/js/blocks/controls/test/color.js index a6136bd0e..6a7f16977 100644 --- a/js/blocks/controls/test/color.js +++ b/js/blocks/controls/test/color.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import user from '@testing-library/user-event'; /** @@ -33,6 +33,6 @@ test( 'color control', async () => { // On entering a new color, it should be sent to the onChange handler. const enteredColor = '#fff'; user.clear( input ); - user.type( input, enteredColor ); + fireEvent.change( input, { target: { value: enteredColor } } ); expect( mockOnChange ).toHaveBeenCalledWith( enteredColor ); } ); diff --git a/js/blocks/controls/test/email.js b/js/blocks/controls/test/email.js index cb1743d10..9a6a4df4f 100644 --- a/js/blocks/controls/test/email.js +++ b/js/blocks/controls/test/email.js @@ -31,11 +31,8 @@ describe( 'email control', () => { expect( control ).toHaveAttribute( 'value', props.field.default ); } ); - it.each( [ - 'you@example.com', - 'not-a-valid-email', - ')$@$%*)#$*@)#$', - ] )( 'should send any entered text to the onChange handler, even if it is not a valid email', + it.each( [ 'you@example.com', 'not-a-valid-email', ')$@$%*)#$*@)#$' ] )( + 'should send any entered text to the onChange handler, even if it is not a valid email', ( enteredText ) => { const props = getProps(); const { control } = setupControl( BlockLabEmailControl, props ); @@ -44,18 +41,20 @@ describe( 'email control', () => { } ); - it.each( [ - true, - false, - ] )( 'should have an invalid class if the event object finds it is invalid', + it.each( [ true, false ] )( + 'should have an invalid class if the event object finds it is invalid', ( isInputValid ) => { const props = getProps(); const { control } = setupControl( BlockLabEmailControl, props ); const mockCheckValidity = jest.fn(); mockCheckValidity.mockReturnValueOnce( isInputValid ); - fireEvent.blur( control, { target: { checkValidity: mockCheckValidity } } ); - expect( control.classList.contains( 'text-control__error' ) ).toStrictEqual( ! isInputValid ); + fireEvent.blur( control, { + target: { checkValidity: mockCheckValidity }, + } ); + expect( + control.classList.contains( 'text-control__error' ) + ).toStrictEqual( ! isInputValid ); } ); } ); diff --git a/js/blocks/controls/test/helpers/index.js b/js/blocks/controls/test/helpers/index.js index b0fa5d5cd..eef377760 100644 --- a/js/blocks/controls/test/helpers/index.js +++ b/js/blocks/controls/test/helpers/index.js @@ -12,12 +12,7 @@ import { render } from '@testing-library/react'; */ export const setupControl = ( Control, props ) => { const { field } = props; - const utils = render( - - ); + const utils = render( ); const control = utils.getByLabelText( field.label ); return { control, diff --git a/js/blocks/controls/test/multiselect.js b/js/blocks/controls/test/multiselect.js index bf43c3aff..80fe65589 100644 --- a/js/blocks/controls/test/multiselect.js +++ b/js/blocks/controls/test/multiselect.js @@ -31,7 +31,10 @@ test( 'multiselect control', () => { field, onChange: jest.fn(), }; - const { control, getByText } = setupControl( BlockLabMultiselectControl, props ); + const { control, getByText } = setupControl( + BlockLabMultiselectControl, + props + ); getByText( field.help ); fireEvent.change( control, { target: { value: [ secondValue ] } } ); diff --git a/js/blocks/controls/test/number.js b/js/blocks/controls/test/number.js index 8ca1dd8ff..e8a07aeda 100644 --- a/js/blocks/controls/test/number.js +++ b/js/blocks/controls/test/number.js @@ -32,15 +32,17 @@ describe( 'number control', () => { it( 'has the placeholder', async () => { const props = getProps(); - const { findByPlaceholderText } = setupControl( BlockLabNumberControl, props ); - expect( await findByPlaceholderText( props.field.placeholder ) ).toBeInTheDocument(); + const { findByPlaceholderText } = setupControl( + BlockLabNumberControl, + props + ); + expect( + await findByPlaceholderText( props.field.placeholder ) + ).toBeInTheDocument(); } ); - it.each( [ - 0, - 352343, - 9523342951313513414, - ] )( 'sends a number to the onChange handler when it is entered', + it.each( [ 0, 352343, 9523342951313513414 ] )( + 'sends a number to the onChange handler when it is entered', ( enteredText ) => { const props = getProps(); const { control } = setupControl( BlockLabNumberControl, props ); diff --git a/js/blocks/controls/test/post.js b/js/blocks/controls/test/post.js index 78f964834..49ecca143 100644 --- a/js/blocks/controls/test/post.js +++ b/js/blocks/controls/test/post.js @@ -34,7 +34,9 @@ const getProps = () => ( { test( 'post control', async () => { const props = getProps(); - const { findByRole, findByText, findByLabelText } = render( ); + const { findByRole, findByText, findByLabelText } = render( + + ); await findByLabelText( props.field.label ); await findByText( props.field.help ); @@ -60,5 +62,8 @@ test( 'post control', async () => { ); // The onChange handler should be called with the selected post. - expect( props.onChange ).toHaveBeenCalledWith( { id: post.id, name: post.title.rendered } ); + expect( props.onChange ).toHaveBeenCalledWith( { + id: post.id, + name: post.title.rendered, + } ); } ); diff --git a/js/blocks/controls/test/radio.js b/js/blocks/controls/test/radio.js index 879292898..90c70ad81 100644 --- a/js/blocks/controls/test/radio.js +++ b/js/blocks/controls/test/radio.js @@ -12,10 +12,7 @@ import BlockLabRadioControl from '../radio'; test( 'radio control', async () => { const firstOption = 'first'; const secondOption = 'second'; - const options = [ - { value: firstOption }, - { value: secondOption }, - ]; + const options = [ { value: firstOption }, { value: secondOption } ]; const field = { options, label: 'This is a label for the radio field', diff --git a/js/blocks/controls/test/select.js b/js/blocks/controls/test/select.js index 98e5622c2..5752a8ee2 100644 --- a/js/blocks/controls/test/select.js +++ b/js/blocks/controls/test/select.js @@ -34,12 +34,17 @@ test( 'select control', async () => { onChange: jest.fn(), }; - const { findByRole, findByText } = setupControl( BlockLabSelectControl, props ); + const { findByRole, findByText } = setupControl( + BlockLabSelectControl, + props + ); await findByText( field.help ); const control = await findByRole( 'combobox' ); // This should send the new value to the onChange handler. user.selectOptions( control, secondValue ); //fireEvent.change( control, { target: { value: secondValue } } ); - await waitFor( () => expect( props.onChange ).toHaveBeenCalledWith( secondValue ) ); + await waitFor( () => + expect( props.onChange ).toHaveBeenCalledWith( secondValue ) + ); } ); diff --git a/js/blocks/controls/test/taxonomy.js b/js/blocks/controls/test/taxonomy.js index 730df10a3..c6e4a950d 100644 --- a/js/blocks/controls/test/taxonomy.js +++ b/js/blocks/controls/test/taxonomy.js @@ -25,7 +25,9 @@ test( 'taxonomy control', async () => { getValue: jest.fn(), onChange: jest.fn(), }; - const { getByLabelText, getByRole, getByText } = render( ); + const { getByLabelText, getByRole, getByText } = render( + + ); getByLabelText( props.field.label ); getByText( props.field.help ); @@ -45,10 +47,11 @@ test( 'taxonomy control', async () => { fireEvent.focus( input ); // Click to select a taxonomy. - await waitFor( () => - fireEvent.click( getByText( taxonomy.name ) ) - ); + await waitFor( () => fireEvent.click( getByText( taxonomy.name ) ) ); // The onChange handler should be called with the selected taxonomy. - expect( props.onChange ).toHaveBeenCalledWith( { id: taxonomy.id, name: taxonomy.name } ); + expect( props.onChange ).toHaveBeenCalledWith( { + id: taxonomy.id, + name: taxonomy.name, + } ); } ); diff --git a/js/blocks/controls/test/text.js b/js/blocks/controls/test/text.js index 9e187e04d..d89903118 100644 --- a/js/blocks/controls/test/text.js +++ b/js/blocks/controls/test/text.js @@ -35,7 +35,8 @@ describe( 'text control', () => { '942', '#$ Special %()@$ characters @${}[]', 'Very long text that keeps going on and on and on and it continues longer than you would normally expect', - ] )( 'Any text entered is sent to the onChange handler', + ] )( + 'Any text entered is sent to the onChange handler', ( enteredText ) => { const props = getProps(); const { control } = setupControl( BlockLabTextControl, props ); diff --git a/js/blocks/controls/test/textarea.js b/js/blocks/controls/test/textarea.js index 4360a0e7f..0c6794de0 100644 --- a/js/blocks/controls/test/textarea.js +++ b/js/blocks/controls/test/textarea.js @@ -33,9 +33,14 @@ describe( 'textarea control', () => { it( 'has the placeholder', () => { const props = getProps(); - const { getByPlaceholderText } = setupControl( BlockLabTextareaControl, props ); - - expect( getByPlaceholderText( props.field.placeholder ) ).toBeInTheDocument(); + const { getByPlaceholderText } = setupControl( + BlockLabTextareaControl, + props + ); + + expect( + getByPlaceholderText( props.field.placeholder ) + ).toBeInTheDocument(); } ); it.each( [ @@ -43,7 +48,8 @@ describe( 'textarea control', () => { 'っていった', '987654321', 'This is long text that is entered into a textarea, it keeps going longer than one might normally type', - ] )( 'Any text entered is sent to the onChange handler', + ] )( + 'Any text entered is sent to the onChange handler', ( enteredText ) => { const props = getProps(); const { control } = setupControl( BlockLabTextareaControl, props ); diff --git a/js/blocks/controls/test/url.js b/js/blocks/controls/test/url.js index 0c6e5d7d6..e69950f68 100644 --- a/js/blocks/controls/test/url.js +++ b/js/blocks/controls/test/url.js @@ -39,10 +39,8 @@ describe( 'url control', () => { expect( props.onChange ).toHaveBeenCalledWith( enteredUrl ); } ); - it.each( [ - true, - false, - ] )( 'should have an invalid class if the event object finds it is invalid', + it.each( [ true, false ] )( + 'should have an invalid class if the event object finds it is invalid', ( isInputValid ) => { const props = getProps(); const { control } = setupControl( BlockLabURLControl, props ); @@ -50,7 +48,9 @@ describe( 'url control', () => { mockEvent.target.checkValidity.mockReturnValueOnce( isInputValid ); fireEvent.blur( control, mockEvent ); - expect( control.classList.contains( 'text-control__error' ) ).toStrictEqual( ! isInputValid ); + expect( + control.classList.contains( 'text-control__error' ) + ).toStrictEqual( ! isInputValid ); } ); } ); diff --git a/js/blocks/controls/test/user.js b/js/blocks/controls/test/user.js index 461931728..e50676a18 100644 --- a/js/blocks/controls/test/user.js +++ b/js/blocks/controls/test/user.js @@ -25,7 +25,9 @@ test( 'user control', async () => { onChange: jest.fn(), }; - const { getByLabelText, getByRole } = render( ); + const { getByLabelText, getByRole } = render( + + ); getByLabelText( props.field.label ); getByText( document, props.field.help ); @@ -44,10 +46,11 @@ test( 'user control', async () => { fireEvent.focus( input ); // Click to select a user. - await waitFor( () => - fireEvent.click( getByText( document, user.name ) ) - ); + await waitFor( () => fireEvent.click( getByText( document, user.name ) ) ); // The onChange handler should be called with the selected user. - expect( props.onChange ).toHaveBeenCalledWith( { id: user.id, userName: user.name } ); + expect( props.onChange ).toHaveBeenCalledWith( { + id: user.id, + userName: user.name, + } ); } ); diff --git a/js/blocks/controls/text.js b/js/blocks/controls/text.js index 846113972..82c3aab0a 100644 --- a/js/blocks/controls/text.js +++ b/js/blocks/controls/text.js @@ -6,7 +6,8 @@ import { TextControl } from '@wordpress/components'; const BlockLabTextControl = ( props ) => { const { field, getValue, onChange } = props; const initialValue = getValue( props ); - const value = 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = + 'undefined' !== typeof initialValue ? initialValue : field.default; return ( { const { getValue, field, onChange } = props; const initialValue = getValue( props ); - const value = 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = + 'undefined' !== typeof initialValue ? initialValue : field.default; return ( { const { field, onChange, getValue } = props; const initialValue = getValue( props ); - const value = 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = + 'undefined' !== typeof initialValue ? initialValue : field.default; return ( { const { field, getValue, onChange } = props; const initialValue = getValue( props ); - const value = 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = + 'undefined' !== typeof initialValue ? initialValue : field.default; /** * Sets the Error Class for the Text Control. diff --git a/js/blocks/controls/user.js b/js/blocks/controls/user.js index 87aa0883d..38eed54f6 100644 --- a/js/blocks/controls/user.js +++ b/js/blocks/controls/user.js @@ -6,10 +6,13 @@ import { FetchInput } from '../components'; const BlockLabUserControl = ( props ) => { const { field, getValue, onChange } = props; const DEFAULT_ID = 0; - const getIdFromAPI = ( apiResponse ) => ( apiResponse && apiResponse.id ) ? apiResponse.id : DEFAULT_ID; - const getNameFromAPI = ( apiResponse ) => ( apiResponse && apiResponse.name ) ? apiResponse.name : ''; + const getIdFromAPI = ( apiResponse ) => + apiResponse && apiResponse.id ? apiResponse.id : DEFAULT_ID; + const getNameFromAPI = ( apiResponse ) => + apiResponse && apiResponse.name ? apiResponse.name : ''; - const initialValue = ( 'object' === typeof getValue( props ) ) ? getValue( props ) : {}; + const initialValue = + 'object' === typeof getValue( props ) ? getValue( props ) : {}; const userAttribute = { id: DEFAULT_ID, userName: '', ...initialValue }; return ( diff --git a/js/blocks/helpers/getSimplifiedFields.js b/js/blocks/helpers/getSimplifiedFields.js index 3d214ede7..3a26b311c 100644 --- a/js/blocks/helpers/getSimplifiedFields.js +++ b/js/blocks/helpers/getSimplifiedFields.js @@ -34,12 +34,10 @@ const getSimplifiedFields = ( fields ) => { } const field = fields[ fieldName ]; - fieldList.push( - { - ...field, - name: fieldName, - } - ); + fieldList.push( { + ...field, + name: fieldName, + } ); } fieldList.sort( compare ); // @todo: is this needed? Even then, it should only affect the Block Lab editor UI. diff --git a/js/blocks/helpers/registerBlocks.js b/js/blocks/helpers/registerBlocks.js index a13ce2ad0..768ef9b07 100644 --- a/js/blocks/helpers/registerBlocks.js +++ b/js/blocks/helpers/registerBlocks.js @@ -28,7 +28,10 @@ const registerBlocks = ( blockLab, blockLabBlocks, EditComponent ) => { block.block_slug = blockName; // Don't register the block if it's excluded for this post type. - if ( blockLab.hasOwnProperty( 'postType' ) && block.hasOwnProperty( 'excluded' ) ) { + if ( + blockLab.hasOwnProperty( 'postType' ) && + block.hasOwnProperty( 'excluded' ) + ) { if ( -1 !== block.excluded.indexOf( blockLab.postType ) ) { continue; } @@ -37,14 +40,19 @@ const registerBlocks = ( blockLab, blockLabBlocks, EditComponent ) => { let icon = ''; if ( 'undefined' !== typeof icons[ block.icon ] ) { icon = ( - + ); } // Register the block. registerBlockType( blockName, { title: block.title, - category: 'object' === typeof block.category ? block.category.slug : block.category, + category: + 'object' === typeof block.category + ? block.category.slug + : block.category, icon, keywords: block.keywords, attributes: getBlockLabAttributes( block.fields ), diff --git a/js/blocks/helpers/test/getBlockLabAttributes.js b/js/blocks/helpers/test/getBlockLabAttributes.js index d978425f4..53b91ad78 100644 --- a/js/blocks/helpers/test/getBlockLabAttributes.js +++ b/js/blocks/helpers/test/getBlockLabAttributes.js @@ -18,24 +18,28 @@ describe( 'getBlockFromContent', () => { } ); it( 'should not throw an error if certain attributes are not present', () => { - expect( getBlockLabAttributes( fieldsWithOnlyType ) ).toStrictEqual( fieldsWithOnlyType ); + expect( getBlockLabAttributes( fieldsWithOnlyType ) ).toStrictEqual( + fieldsWithOnlyType + ); } ); it( 'should return only the attributes of the fields', () => { - expect( getBlockLabAttributes( { - example_text: { - type: 'text', - default: 'Here is some text', - help: 'This is the help text', - location: 'editor', - }, - example_url: { - type: 'url', - default: 'https://example.com/go-here', - help: 'Here is the help text', - location: 'inspector', - }, - } ) ).toStrictEqual( { + expect( + getBlockLabAttributes( { + example_text: { + type: 'text', + default: 'Here is some text', + help: 'This is the help text', + location: 'editor', + }, + example_url: { + type: 'url', + default: 'https://example.com/go-here', + help: 'Here is the help text', + location: 'inspector', + }, + } ) + ).toStrictEqual( { example_text: { type: 'text', default: 'Here is some text', diff --git a/js/blocks/helpers/test/getSimplifiedFields.js b/js/blocks/helpers/test/getSimplifiedFields.js index 2960d217d..01379b4ea 100644 --- a/js/blocks/helpers/test/getSimplifiedFields.js +++ b/js/blocks/helpers/test/getSimplifiedFields.js @@ -9,27 +9,29 @@ describe( 'getBlockFromContent', () => { } ); it( 'should return simplified fields for an object of 3 fields', () => { - expect( getSimplifiedFields( { - example_post: { - type: 'post', - help: 'This is some example help text', - location: 'editor', - post_type: 'posts', - width: '100', - }, - example_classic_text: { - type: 'classic_text', - default: 'https://example.com/go-here', - help: 'Here is the help text', - location: 'editor', - }, - example_user: { - type: 'user', - default: 'https://example.com/go-here', - help: 'Here is the help text', - location: 'inspector', - }, - } ) ).toStrictEqual( [ + expect( + getSimplifiedFields( { + example_post: { + type: 'post', + help: 'This is some example help text', + location: 'editor', + post_type: 'posts', + width: '100', + }, + example_classic_text: { + type: 'classic_text', + default: 'https://example.com/go-here', + help: 'Here is the help text', + location: 'editor', + }, + example_user: { + type: 'user', + default: 'https://example.com/go-here', + help: 'Here is the help text', + location: 'inspector', + }, + } ) + ).toStrictEqual( [ { name: 'example_post', type: 'post', @@ -56,11 +58,13 @@ describe( 'getBlockFromContent', () => { } ); it( 'should still include falsy values in the simplified fields', () => { - expect( getSimplifiedFields( { - test_taxonomy: { - default: '', - }, - } ) ).toStrictEqual( [ + expect( + getSimplifiedFields( { + test_taxonomy: { + default: '', + }, + } ) + ).toStrictEqual( [ { name: 'test_taxonomy', default: '', diff --git a/package-lock.json b/package-lock.json index 4500fa948..5a9e90eac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5357,6 +5357,12 @@ "requires": { "type-fest": "^0.8.1" } + }, + "prettier": { + "version": "npm:wp-prettier@2.0.5", + "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz", + "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==", + "dev": true } } }, @@ -6451,6 +6457,12 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "npm:wp-prettier@2.0.5", + "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz", + "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==", + "dev": true + }, "regexpp": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", @@ -9119,12 +9131,6 @@ "integrity": "sha512-sJAofoarcm76ZGpuooaO0eDy8saEy+YoZBLjC4h8srt4jeBnkYeOgqxgsJQTpyt2LjI5PTfLJHSL+41Yu4fEJA==", "dev": true }, - "cli-width": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", - "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", - "dev": true - }, "clipboard": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.6.tgz", @@ -10944,22 +10950,23 @@ } }, "eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.6.0.tgz", + "integrity": "sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", + "enquirer": "^2.3.5", + "eslint-scope": "^5.1.0", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^1.3.0", + "espree": "^7.2.0", + "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", @@ -10968,45 +10975,74 @@ "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", + "levn": "^0.4.1", + "lodash": "^4.17.19", "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.3", + "optionator": "^0.9.1", "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", "table": "^5.2.3", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" } }, "doctrine": { @@ -11028,6 +11064,12 @@ "estraverse": "^4.1.1" } }, + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + }, "glob-parent": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", @@ -11046,11 +11088,104 @@ "type-fest": "^0.8.1" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } } } }, @@ -11547,9 +11682,9 @@ } }, "eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" @@ -11562,14 +11697,14 @@ "dev": true }, "espree": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", - "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.2.0.tgz", + "integrity": "sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==", "dev": true, "requires": { - "acorn": "^7.1.1", + "acorn": "^7.3.1", "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "eslint-visitor-keys": "^1.3.0" }, "dependencies": { "acorn": { @@ -11577,6 +11712,12 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true + }, + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true } } }, @@ -14620,117 +14761,6 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, - "inquirer": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", - "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", - "dev": true, - "requires": { - "ansi-escapes": "^4.2.1", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-width": "^3.0.0", - "external-editor": "^3.0.3", - "figures": "^3.0.0", - "lodash": "^4.17.19", - "mute-stream": "0.0.8", - "run-async": "^2.4.0", - "rxjs": "^6.6.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", - "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "internal-slot": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.2.tgz", @@ -21501,12 +21531,6 @@ "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", "dev": true }, - "prettier": { - "version": "npm:wp-prettier@2.0.5", - "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz", - "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==", - "dev": true - }, "prettier-linter-helpers": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", @@ -22464,9 +22488,9 @@ } }, "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", + "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", "dev": true }, "regexpu-core": { @@ -23040,12 +23064,6 @@ "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", "dev": true }, - "run-async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", - "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", - "dev": true - }, "run-parallel": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", @@ -23073,15 +23091,6 @@ "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=", "dev": true }, - "rxjs": { - "version": "6.6.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz", - "integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", diff --git a/tests/e2e/jest.config.js b/tests/e2e/jest.config.js index f2c6e163a..9d726b1ea 100644 --- a/tests/e2e/jest.config.js +++ b/tests/e2e/jest.config.js @@ -5,7 +5,5 @@ module.exports = { '@wordpress/jest-console', 'expect-puppeteer', ], - testPathIgnorePatterns: [ - '/node_modules/', - ], + testPathIgnorePatterns: [ '/node_modules/' ], }; diff --git a/tests/e2e/specs/create-block.js b/tests/e2e/specs/create-block.js index 80c707a0d..de3b68af6 100644 --- a/tests/e2e/specs/create-block.js +++ b/tests/e2e/specs/create-block.js @@ -22,7 +22,7 @@ const insertBlockFromInserter = async ( blockName ) => { await page.keyboard.type( blockName ); const insertButton = ( await page.$x( `//button//span[contains(text(), '${ blockName }')]` ) - )[ 0 ]; + )[ 0 ]; await insertButton.click(); }; @@ -58,7 +58,13 @@ describe( 'TextBlock', () => { const fieldSelector = '.components-base-control__field'; // The block should have the Text field. - expect( await page.evaluate( () => document.querySelector( '.components-base-control__label' ).textContent ) ).toContain( fieldName ); + expect( + await page.evaluate( + () => + document.querySelector( '.components-base-control__label' ) + .textContent + ) + ).toContain( fieldName ); // Type into the text field. await page.click( `${ fieldSelector } input` ); @@ -69,8 +75,14 @@ describe( 'TextBlock', () => { await page.waitForSelector( '.block-lab-editor__ssr p' ); // The should display the content from the block template in the plugin, and should show the text field value. - const ssrText = await page.evaluate( () => document.querySelector( '.block-lab-editor__ssr p' ).innerText ); - expect( ssrText ).toContain( `Here is the result of calling block_value with the field name: ${ fieldValue }` ); - expect( ssrText ).toContain( `Here is the result of calling block_field with the field name: ${ fieldValue }` ); + const ssrText = await page.evaluate( + () => document.querySelector( '.block-lab-editor__ssr p' ).innerText + ); + expect( ssrText ).toContain( + `Here is the result of calling block_value with the field name: ${ fieldValue }` + ); + expect( ssrText ).toContain( + `Here is the result of calling block_field with the field name: ${ fieldValue }` + ); } ); } ); diff --git a/webpack.config.js b/webpack.config.js index b3d0d286e..07ae83712 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,7 @@ const path = require( 'path' ); const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' ); -const { defaultRequestToExternal, defaultRequestToHandle } = require( '@wordpress/dependency-extraction-webpack-plugin/util' ); +const { defaultRequestToExternal, defaultRequestToHandle } = require( '@wordpress/dependency-extraction-webpack-plugin/lib/util' ); const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); const isProduction = process.env.NODE_ENV === 'production'; From 8dcbbab0c6e6327460564641415bcb8df6f4d1b5 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Fri, 7 Aug 2020 15:42:58 -0500 Subject: [PATCH 10/15] Add a fix from Gutenberg for an extra file emitted --- package.json | 1 + webpack.config.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/package.json b/package.json index 4a0e45422..8a70d83ca 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "gulp-run": "1.7.1", "gulp-string-replace": "1.1.2", "husky": "4.2.5", + "ignore-emit-webpack-plugin": "2.0.2", "jest-axe": "3.5.0", "jest-environment-jsdom-sixteen": "1.0.3", "jest-silent-reporter": "0.2.1", diff --git a/webpack.config.js b/webpack.config.js index 07ae83712..300e02981 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,5 +1,7 @@ const path = require( 'path' ); const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); +const IgnoreEmitPlugin = require( 'ignore-emit-webpack-plugin' ); + const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' ); const { defaultRequestToExternal, defaultRequestToHandle } = require( '@wordpress/dependency-extraction-webpack-plugin/lib/util' ); const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); @@ -56,6 +58,11 @@ module.exports = { new MiniCssExtractPlugin( { filename: './css/blocks.editor.css', } ), + // Copied from Gutenberg. + // MiniCSSExtractPlugin creates JavaScript assets for CSS that are + // obsolete and should be removed. Related webpack issue: + // https://github.com/webpack-contrib/mini-css-extract-plugin/issues/85 + new IgnoreEmitPlugin( [ 'blocks.editor.js' ] ), new DependencyExtractionWebpackPlugin( { useDefaults: false, requestToHandle: ( request ) => { From ae02060f7ad7a641cb87100722ebc5cd6c432075 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Fri, 7 Aug 2020 15:48:01 -0500 Subject: [PATCH 11/15] Revert "Do npm run lint:js:fix" This reverts commit 5186c4242599b98b927e16a6689d382d6aac96c7. --- js/admin.block-post.js | 405 +++++++----------- js/blocks/components/content-control.js | 9 +- js/blocks/components/edit.js | 16 +- js/blocks/components/fetch-input.js | 232 +++------- js/blocks/components/fields.js | 44 +- js/blocks/components/image.js | 260 +++++------ js/blocks/components/repeater-rows.js | 131 +++--- js/blocks/components/test/fetch-input.js | 11 +- js/blocks/components/test/fields.js | 48 +-- js/blocks/components/tiny-mce.js | 3 +- js/blocks/controls/classic-text.js | 16 +- js/blocks/controls/color.js | 131 +++--- js/blocks/controls/email.js | 3 +- js/blocks/controls/image.js | 4 +- js/blocks/controls/number.js | 3 +- js/blocks/controls/post.js | 5 +- js/blocks/controls/repeater.js | 19 +- js/blocks/controls/rich-text.js | 10 +- js/blocks/controls/select.js | 6 +- js/blocks/controls/taxonomy.js | 3 +- js/blocks/controls/test/classic-text.js | 4 +- js/blocks/controls/test/color.js | 4 +- js/blocks/controls/test/email.js | 21 +- js/blocks/controls/test/helpers/index.js | 7 +- js/blocks/controls/test/multiselect.js | 5 +- js/blocks/controls/test/number.js | 16 +- js/blocks/controls/test/post.js | 9 +- js/blocks/controls/test/radio.js | 5 +- js/blocks/controls/test/select.js | 9 +- js/blocks/controls/test/taxonomy.js | 13 +- js/blocks/controls/test/text.js | 3 +- js/blocks/controls/test/textarea.js | 14 +- js/blocks/controls/test/url.js | 10 +- js/blocks/controls/test/user.js | 13 +- js/blocks/controls/text.js | 3 +- js/blocks/controls/textarea.js | 3 +- js/blocks/controls/toggle.js | 3 +- js/blocks/controls/url.js | 3 +- js/blocks/controls/user.js | 9 +- js/blocks/helpers/getSimplifiedFields.js | 10 +- js/blocks/helpers/registerBlocks.js | 14 +- .../helpers/test/getBlockLabAttributes.js | 34 +- js/blocks/helpers/test/getSimplifiedFields.js | 56 ++- package-lock.json | 383 ++++++++--------- tests/e2e/jest.config.js | 4 +- tests/e2e/specs/create-block.js | 22 +- webpack.config.js | 2 +- 47 files changed, 797 insertions(+), 1241 deletions(-) diff --git a/js/admin.block-post.js b/js/admin.block-post.js index 06faae1ce..3cb8f0a0d 100644 --- a/js/admin.block-post.js +++ b/js/admin.block-post.js @@ -7,14 +7,14 @@ /* global blockLab, jQuery */ -( function ( $ ) { - $( function () { +( function( $ ) { + $( function() { blockTitleInit(); blockIconInit(); blockFieldInit(); blockPostTypesInit(); - $( '#block-add-field' ).on( 'click', function () { + $( '#block-add-field' ).on( 'click', function() { const template = wp.template( 'field-repeater' ), data = { uid: new Date().getTime() }, row = $( template( data ) ), @@ -33,7 +33,7 @@ label.select(); } ); - $( '#block_fields' ).on( 'click', '#block-add-sub-field', function () { + $( '#block_fields' ).on( 'click', '#block-add-sub-field', function() { const template = wp.template( 'field-repeater' ), data = { uid: new Date().getTime() }, row = $( template( data ) ), @@ -44,9 +44,7 @@ incrementRow( row ); // Prevents adding a repeater, in a repeater, in a repeater… - row.find( - '.block-fields-edit-control option[value="repeater"]' - ).remove(); + row.find( '.block-fields-edit-control option[value="repeater"]' ).remove(); // Don't render the location or width settings for sub-fields. row.find( '.block-fields-edit-location-settings' ).remove(); @@ -70,154 +68,102 @@ label.select(); } ); - $( '.block-lab-pub-section .edit-post-types' ).on( - 'click', - function () { - const excludedPostTypes = $( '#block-excluded-post-types' ) - .val() - .split( ',' ) - .filter( Boolean ); - - $( '.post-types-select-items input' ).prop( 'checked', true ); - - for ( const postType of excludedPostTypes ) { - $( - '.post-types-select-items input[value="' + - postType + - '"]' - ).prop( 'checked', false ); - } + $( '.block-lab-pub-section .edit-post-types' ).on( 'click', function() { + const excludedPostTypes = $( '#block-excluded-post-types' ).val().split( ',' ).filter( Boolean ); - $( '.block-lab-pub-section .post-types-select' ).slideDown( - 200 - ); - $( this ).hide(); - } - ); - - $( '.block-lab-pub-section .save-post-types' ).on( - 'click', - function () { - const checked = $( - '.post-types-select-items input:not(:checked)' - ), - postTypes = []; - for ( const input of checked ) { - postTypes.push( $( input ).val() ); - } + $( '.post-types-select-items input' ).prop( 'checked', true ); - $( '#block-excluded-post-types' ).val( postTypes.join( ',' ) ); + for ( const postType of excludedPostTypes ) { + $( '.post-types-select-items input[value="' + postType + '"]' ).prop( 'checked', false ); + } - blockPostTypesInit(); + $( '.block-lab-pub-section .post-types-select' ).slideDown( 200 ); + $( this ).hide(); + } ); - $( '.block-lab-pub-section .post-types-select' ).slideUp( 200 ); - $( '.block-lab-pub-section .edit-post-types' ).show(); + $( '.block-lab-pub-section .save-post-types' ).on( 'click', function() { + const checked = $( '.post-types-select-items input:not(:checked)' ), + postTypes = []; + for ( const input of checked ) { + postTypes.push( $( input ).val() ); } - ); - $( '.block-lab-pub-section .button-cancel' ).on( 'click', function () { + $( '#block-excluded-post-types' ).val( postTypes.join( ',' ) ); + + blockPostTypesInit(); + $( '.block-lab-pub-section .post-types-select' ).slideUp( 200 ); $( '.block-lab-pub-section .edit-post-types' ).show(); } ); - $( '#block_properties .block-properties-icon-select span' ).on( - 'click', - function () { - const svg = $( 'svg', this ).clone(); - $( - '#block_properties .block-properties-icon-select span.selected' - ).removeClass( 'selected' ); - $( this ).addClass( 'selected' ); - $( '#block-properties-icon' ).val( $( this ).data( 'value' ) ); - $( '#block-properties-icon-current' ).html( svg ); - } - ); - - $( '#block_properties .block-properties-category' ).on( - 'change', - function () { - if ( '__custom' === $( this ).val() ) { - $( this ) - .next( '.block-properties-category-custom' ) - .css( 'display', 'block' ); - } else { - $( this ) - .next( '.block-properties-category-custom' ) - .hide(); - } - } - ); + $( '.block-lab-pub-section .button-cancel' ).on( 'click', function() { + $( '.block-lab-pub-section .post-types-select' ).slideUp( 200 ); + $( '.block-lab-pub-section .edit-post-types' ).show(); + } ); - $( '#block_template .template-location a.filename' ).on( - 'click', - function ( event ) { - event.preventDefault(); + $( '#block_properties .block-properties-icon-select span' ).on( 'click', function() { + const svg = $( 'svg', this ).clone(); + $( '#block_properties .block-properties-icon-select span.selected' ).removeClass( 'selected' ); + $( this ).addClass( 'selected' ); + $( '#block-properties-icon' ).val( $( this ).data( 'value' ) ); + $( '#block-properties-icon-current' ).html( svg ); + } ); - const copy = $( - '#block_template .template-location .click-to-copy' - ), - input = $( 'input', copy ), - width = - $( this ).width() + - input.outerWidth( false ) - - input.width(); + $( '#block_properties .block-properties-category' ).on( 'change', function() { + if ( '__custom' === $( this ).val() ) { + $( this ).next( '.block-properties-category-custom' ).css( 'display', 'block' ); + } else { + $( this ).next( '.block-properties-category-custom' ).hide(); + } + } ); - copy.show(); - input.outerWidth( width ).focus().select(); + $( '#block_template .template-location a.filename' ).on( 'click', function( event ) { + event.preventDefault(); - const copied = document.execCommand( 'copy' ); + const copy = $( '#block_template .template-location .click-to-copy' ), + input = $( 'input', copy ), + width = $( this ).width() + input.outerWidth( false ) - input.width(); - if ( copied ) { - copy.attr( 'data-tooltip', blockLab.copySuccessMessage ); - } else { - copy.attr( 'data-tooltip', blockLab.copyFailMessage ); - } + copy.show(); + input.outerWidth( width ).focus().select(); - $( this ).hide(); - } - ); + const copied = document.execCommand( 'copy' ); - $( '#block_template .template-location .click-to-copy input' ).on( - 'blur', - function () { - $( '#block_template .template-location a.filename' ).show(); - $( this ).parent().hide(); + if ( copied ) { + copy.attr( 'data-tooltip', blockLab.copySuccessMessage ); + } else { + copy.attr( 'data-tooltip', blockLab.copyFailMessage ); } - ); + + $( this ).hide(); + } ); + + $( '#block_template .template-location .click-to-copy input' ).on( 'blur', function() { + $( '#block_template .template-location a.filename' ).show(); + $( this ).parent().hide(); + } ); $( '.block-fields-rows' ) - .on( 'click', '.block-fields-actions-delete', function () { + .on( 'click', '.block-fields-actions-delete', function() { const subRows = $( this ).closest( '.block-fields-sub-rows' ); $( this ).closest( '.block-fields-row' ).remove(); - if ( - 0 === - $( '.block-fields-rows' ).children( '.block-fields-row' ) - .length - ) { + if ( 0 === $( '.block-fields-rows' ).children( '.block-fields-row' ).length ) { $( '.block-no-fields' ).show(); } - if ( - 0 !== subRows.length && - 0 === $( '.block-fields-row', subRows ).length - ) { + if ( 0 !== subRows.length && 0 === $( '.block-fields-row', subRows ).length ) { subRows.parent().find( '.repeater-no-fields' ).show(); subRows.parent().find( '.repeater-has-fields' ).hide(); } } ) - .on( 'click', '.block-fields-actions-duplicate', function () { + .on( 'click', '.block-fields-actions-duplicate', function() { const row = $( this ).closest( '.block-fields-row' ), newRow = cloneRow( row ); // Expand the duplicated row. if ( newRow.hasClass( 'block-fields-row-active' ) ) { - row.find( '.block-fields-actions-edit' ) - .eq( 0 ) - .trigger( 'click' ); + row.find( '.block-fields-actions-edit' ).eq( 0 ).trigger( 'click' ); } else { - newRow - .find( '.block-fields-actions-edit' ) - .eq( 0 ) - .trigger( 'click' ); + newRow.find( '.block-fields-actions-edit' ).eq( 0 ).trigger( 'click' ); } // Select the label field of the new row. @@ -225,108 +171,72 @@ label.trigger( 'change' ); label.select(); } ) - .on( - 'click', - '.block-fields-actions-edit, a.row-title', - function () { - const currentRow = $( this ).closest( '.block-fields-row' ); - - // If we're expanding this row, first collapse all other rows and scroll this row into view. - if ( ! currentRow.hasClass( 'block-fields-row-active' ) ) { - const editRow = $( - '.block-fields-rows .block-fields-edit' - ); - - scrollRowIntoView( currentRow ); - editRow.slideUp(); - - $( - '.block-fields-rows .block-fields-row-active' - ).removeClass( 'block-fields-row-active' ); - } + .on( 'click', '.block-fields-actions-edit, a.row-title', function() { + const currentRow = $( this ).closest( '.block-fields-row' ); - currentRow.toggleClass( 'block-fields-row-active' ); - currentRow - .find( '.block-fields-edit' ) - .first() - .slideToggle(); - - // Fetch field settings if field is active and there are no settings. - if ( - $( this ) - .closest( '.block-fields-row' ) - .hasClass( 'block-fields-row-active' ) - ) { - const fieldRow = $( this ).closest( - '.block-fields-row' - ); - if ( - 0 === - fieldRow.find( '.block-fields-edit-settings' ) - .length - ) { - const fieldControl = fieldRow - .find( '.block-fields-edit-control select' ) - .val(); - fetchFieldSettings( fieldRow, fieldControl ); - } - } + // If we're expanding this row, first collapse all other rows and scroll this row into view. + if ( ! currentRow.hasClass( 'block-fields-row-active' ) ) { + const editRow = $( '.block-fields-rows .block-fields-edit' ); + + scrollRowIntoView( currentRow ); + editRow.slideUp(); + + $( '.block-fields-rows .block-fields-row-active' ).removeClass( 'block-fields-row-active' ); } - ) - .on( - 'click', - '.block-fields-edit-actions-close a.button', - function () { + + currentRow.toggleClass( 'block-fields-row-active' ); + currentRow.find( '.block-fields-edit' ).first().slideToggle(); + + // Fetch field settings if field is active and there are no settings. + if ( $( this ).closest( '.block-fields-row' ).hasClass( 'block-fields-row-active' ) ) { const fieldRow = $( this ).closest( '.block-fields-row' ); - fieldRow.removeClass( 'block-fields-row-active' ); - $( '.block-fields-edit', fieldRow ).slideUp(); + if ( 0 === fieldRow.find( '.block-fields-edit-settings' ).length ) { + const fieldControl = fieldRow.find( '.block-fields-edit-control select' ).val(); + fetchFieldSettings( fieldRow, fieldControl ); + } } - ) - .on( 'change keyup', '.block-fields-edit input', function () { + } ) + .on( 'click', '.block-fields-edit-actions-close a.button', function() { + const fieldRow = $( this ).closest( '.block-fields-row' ); + fieldRow.removeClass( 'block-fields-row-active' ); + $( '.block-fields-edit', fieldRow ).slideUp(); + } ) + .on( 'change keyup', '.block-fields-edit input', function() { const sync = $( this ).data( 'sync' ); $( '#' + sync ).text( $( this ).val() ); } ) - .on( 'change keyup', '.block-fields-edit select', function () { + .on( 'change keyup', '.block-fields-edit select', function() { const sync = $( this ).data( 'sync' ), option = $( 'option:selected', $( this ) ).text(); $( '#' + sync ).text( option ); } ) - .on( 'change', '.block-fields-edit-control select', function () { + .on( 'change', '.block-fields-edit-control select', function() { const fieldRow = $( this ).closest( '.block-fields-row' ); fetchFieldSettings( fieldRow, $( this ).val() ); if ( 'repeater' === $( this ).val() ) { const subRows = wp.template( 'sub-field-rows' ); fieldRow.append( subRows ); - blockFieldSubRowsInit( - $( '.block-fields-sub-rows', fieldRow ) - ); + blockFieldSubRowsInit( $( '.block-fields-sub-rows', fieldRow ) ); } else { - $( - '.block-fields-sub-rows,.block-fields-sub-rows-actions', - fieldRow - ).remove(); + $( '.block-fields-sub-rows,.block-fields-sub-rows-actions', fieldRow ).remove(); } } ) - .on( - 'change', - '.block-fields-edit-location-settings select', - function () { - blockFieldWidthInit( - $( this ).closest( '.block-fields-row' ) - ); - } - ) - .on( 'change keyup', '.block-fields-edit-label input', function () { + .on( 'change', '.block-fields-edit-location-settings select', function() { + blockFieldWidthInit( $( this ).closest( '.block-fields-row' ) ); + } ) + .on( 'change keyup', '.block-fields-edit-label input', function() { const slug = $( this ) .closest( '.block-fields-edit' ) .find( '.block-fields-edit-name input' ); if ( 'false' !== slug.data( 'autoslug' ) ) { - slug.val( slugify( $( this ).val() ) ).trigger( 'change' ); + slug + .val( slugify( $( this ).val() ) ) + .trigger( 'change' ); } } ) - .on( 'blur', '.block-fields-edit-label input', function () { + .on( 'blur', '.block-fields-edit-label input', function() { // If the value hasn't changed from default, don't turn off autoslug. if ( $( this ).data( 'defaultValue' ) === $( this ).val() ) { return; @@ -336,14 +246,10 @@ .find( '.block-fields-edit-name input' ) .data( 'autoslug', 'false' ); } ) - .on( - 'mouseenter', - '.block-fields-row div:not(.block-fields-edit,.block-fields-sub-rows,.block-fields-sub-rows-actions)', - function () { - $( this ).parent().addClass( 'hover' ); - } - ) - .on( 'mouseleave', '.block-fields-row div', function () { + .on( 'mouseenter', '.block-fields-row div:not(.block-fields-edit,.block-fields-sub-rows,.block-fields-sub-rows-actions)', function() { + $( this ).parent().addClass( 'hover' ); + } ) + .on( 'mouseleave', '.block-fields-row div', function() { $( this ).parent().removeClass( 'hover' ); } ) .sortable( { @@ -355,21 +261,21 @@ } ); } ); - const blockTitleInit = function () { + const blockTitleInit = function() { const title = $( '#title' ), slug = $( '#block-properties-slug' ); // If this is a new block, then enable auto-generated slugs. if ( '' === title.val() && '' === slug.val() ) { // If auto-generated slugs are enabled, set the slug based on the title. - title.on( 'change keyup', function () { + title.on( 'change keyup', function() { if ( 'false' !== slug.data( 'autoslug' ) ) { slug.val( slugify( title.val() ) ); } } ); // Turn auto-generated slugs off once a title has been set. - title.on( 'blur', function () { + title.on( 'blur', function() { if ( '' !== title.val() ) { slug.data( 'autoslug', 'false' ); } @@ -377,7 +283,7 @@ } }; - const blockIconInit = function () { + const blockIconInit = function() { const iconsContainer = $( '.block-properties-icon-select' ), selectedIcon = $( '.selected', iconsContainer ); if ( 0 !== iconsContainer.length && 0 !== selectedIcon.length ) { @@ -385,20 +291,17 @@ } }; - const blockFieldInit = function () { - if ( - 0 === - $( '.block-fields-rows' ).children( '.block-fields-row' ).length - ) { + const blockFieldInit = function() { + if ( 0 === $( '.block-fields-rows' ).children( '.block-fields-row' ).length ) { $( '.block-no-fields' ).show(); } $( '.block-fields-edit-name input' ).data( 'autoslug', 'false' ); - $( '.block-fields-sub-rows' ).each( function () { + $( '.block-fields-sub-rows' ).each( function() { blockFieldSubRowsInit( $( this ) ); } ); }; - const blockFieldSubRowsInit = function ( subRows ) { + const blockFieldSubRowsInit = function( subRows ) { subRows.sortable( { axis: 'y', cursor: 'grabbing', @@ -408,13 +311,9 @@ } ); }; - const blockFieldWidthInit = function ( fieldRow ) { - const widthSettings = fieldRow.find( - '.block-fields-edit-width-settings' - ), - locationSettings = fieldRow.find( - '.block-fields-edit-location-settings' - ); + const blockFieldWidthInit = function( fieldRow ) { + const widthSettings = fieldRow.find( '.block-fields-edit-width-settings' ), + locationSettings = fieldRow.find( '.block-fields-edit-location-settings' ); if ( 'editor' !== $( 'select', locationSettings ).val() ) { widthSettings.hide(); @@ -423,7 +322,7 @@ } }; - const blockPostTypesInit = function () { + const blockPostTypesInit = function() { if ( 0 === $( '.block-lab-pub-section' ).length ) { return; } @@ -451,20 +350,21 @@ for ( const input of inputs ) { const postType = $( input ).val(); if ( -1 === excludedPostTypes.indexOf( postType ) ) { - displayList.push( $( input ).next( 'label' ).text() ); + displayList.push( + $( input ).next( 'label' ).text() + ); } } display.text( displayList.join( ', ' ) ); }; - const fetchFieldSettings = function ( fieldRow, fieldControl ) { + const fetchFieldSettings = function( fieldRow, fieldControl ) { if ( ! blockLab.hasOwnProperty( 'fieldSettingsNonce' ) ) { return; } - const loadingRow = - '' + + const loadingRow = '' + '' + ' ' + ' ' + @@ -493,9 +393,7 @@ return; } const settingsRows = $( result.html ); - $( '.block-fields-edit-control', fieldRow ).after( - settingsRows - ); + $( '.block-fields-edit-control', fieldRow ).after( settingsRows ); blockFieldWidthInit( fieldRow ); scrollRowIntoView( fieldRow ); }, @@ -506,10 +404,10 @@ } ); }; - const scrollRowIntoView = function ( row ) { + const scrollRowIntoView = function( row ) { let scrollTop = 0; - $( '.block-fields-rows .block-fields-row' ).each( function () { + $( '.block-fields-rows .block-fields-row' ).each( function() { // Add the height of all previous rows to the target scrollTop position. if ( $( this ).is( row ) ) { return false; @@ -529,7 +427,7 @@ * @param {boolean} append Whether to append the cloned row, or just return it. * @return {jQuery} The cloned row. */ - const cloneRow = function ( row, append = true ) { + const cloneRow = function( row, append = true ) { const uid = row.data( 'uid' ), newUid = Math.floor( Math.random() * 1000000000000 ), newRow = row.clone(), @@ -542,21 +440,18 @@ // Replace all the UIDs. newRow.attr( 'data-uid', newUid ); - newRow.html( function ( index, html ) { + newRow.html( function( index, html ) { return html.replace( new RegExp( uid, 'g' ), newUid ); } ); // Set the values manually. jQuery's clone method doesn't work for dynamic data. - row.find( '[name*="[' + uid + ']"]' ).each( function () { + row.find( '[name*="[' + uid + ']"]' ).each( function() { const newRowName = $( this ).attr( 'name' ).replace( uid, newUid ), newRowInput = newRow.find( '[name="' + newRowName + '"]' ); // Radio and Checkbox inputs are unique in that multiple can exist with the same name. if ( $( this ).is( '[type="radio"],[type="checkbox"]' ) ) { - newRowInput - .parent() - .find( '[value="' + $( this ).val() + '"]' ) - .prop( 'checked', $( this ).prop( 'checked' ) ); + newRowInput.parent().find( '[value="' + $( this ).val() + '"]' ).prop( 'checked', $( this ).prop( 'checked' ) ); } else { newRowInput.val( $( this ).val() ); } @@ -569,45 +464,39 @@ newRow.insertAfter( row ); } - subRows.each( function () { - $( this ) - .find( 'input[name^="block-fields-parent"]' ) - .val( newUid ); - newRow - .find( '.block-fields-sub-rows' ) - .append( cloneRow( $( this ), false ) ); + subRows.each( function() { + $( this ).find( 'input[name^="block-fields-parent"]' ).val( newUid ); + newRow.find( '.block-fields-sub-rows' ).append( cloneRow( $( this ), false ) ); } ); return newRow; }; - const incrementRow = function ( row ) { + const incrementRow = function( row ) { const label = row.find( '.block-fields-edit-label input' ).eq( 0 ), name = row.find( '.block-fields-edit-name input' ).eq( 0 ), baseName = name.val().replace( /-\d+$/, '' ), baseLabel = label.val().replace( / \d+$/, '' ), nameMatchRegex = new RegExp( '^' + baseName + '(-\\d+)?$' ), - matchedNames = $( 'input[name^="block-fields-name"]' ).filter( - function () { - // Get all other rows that have the same base name. - return $( this ).val().match( nameMatchRegex ); - } - ); + matchedNames = $( 'input[name^="block-fields-name"]' ).filter( function() { + // Get all other rows that have the same base name. + return $( this ).val().match( nameMatchRegex ); + } ); let numbers = []; // Get the number of each row, then sort them. - matchedNames.each( function () { + matchedNames.each( function() { numbers.push( $( this ).val().match( /\d*$/ )[ 0 ] ); } ); // Filter out duplicate numbers. - numbers = numbers.filter( function ( value, index, self ) { + numbers = numbers.filter( function( value, index, self ) { return self.indexOf( value ) === index; } ); // Put the numbers in ascending order. - numbers = numbers.sort( function ( a, b ) { + numbers = numbers.sort( function( a, b ) { return b - a; } ); @@ -627,11 +516,11 @@ label.data( 'defaultValue', label.val() ); }; - const slugify = function ( text ) { + const slugify = function( text ) { return text .toLowerCase() .replace( /[^\w ]+/g, '' ) .replace( / +/g, '-' ) .replace( /_+/g, '-' ); }; -} )( jQuery ); +}( jQuery ) ); diff --git a/js/blocks/components/content-control.js b/js/blocks/components/content-control.js index bb1f8763c..9daccc2f4 100644 --- a/js/blocks/components/content-control.js +++ b/js/blocks/components/content-control.js @@ -20,15 +20,10 @@ const ContentControl = ( props ) => { * @param {Object} apiResponse The API response in which to look for the ID. * @return {number} The ID from the value, or 0. */ - const getIdfromAPI = ( apiResponse ) => - apiResponse && apiResponse.id ? parseInt( apiResponse.id ) : DEFAULT_ID; + const getIdfromAPI = ( apiResponse ) => ( apiResponse && apiResponse.id ) ? parseInt( apiResponse.id ) : DEFAULT_ID; const initialValue = getValue( props ); - const valueAttribute = { - id: DEFAULT_ID, - name: DEFAULT_NAME, - ...initialValue, - }; + const valueAttribute = { id: DEFAULT_ID, name: DEFAULT_NAME, ...initialValue }; return ( { return ( <> -
+
{ isSelected ? (
-

- +

+

) : ( event.stopPropagation(); class FetchInput extends Component { /** * Constructs the component class. - * - * @param {Object} props - * @param {Object} props.autocompleteRef The ref for auto-complete. */ constructor( { autocompleteRef } ) { super( ...arguments ); @@ -73,10 +65,7 @@ class FetchInput extends Component { const { prevResults, prevShowSuggestions } = prevState; // Exit if the relevant state values didn't update. - if ( - results === prevResults && - showSuggestions === prevShowSuggestions - ) { + if ( results === prevResults && showSuggestions === prevShowSuggestions ) { return; } @@ -125,58 +114,43 @@ class FetchInput extends Component { } ), } ); - request - .then( ( results ) => { - // A fetch Promise doesn't have an abort option. It's mimicked by - // comparing the request reference in on the instance, which is - // reset or deleted on subsequent requests or unmounting. - if ( this.suggestionsRequest !== request ) { - return; - } + request.then( ( results ) => { + // A fetch Promise doesn't have an abort option. It's mimicked by + // comparing the request reference in on the instance, which is + // reset or deleted on subsequent requests or unmounting. + if ( this.suggestionsRequest !== request ) { + return; + } - this.setState( { - results, - showSuggestions: true, - loading: false, - } ); + this.setState( { + results, + showSuggestions: true, + loading: false, + } ); - if ( !! results.length ) { - this.props.debouncedSpeak( - sprintf( - /* translators: %d: the number of results found */ - _n( - '%d result found, use up and down arrow keys to navigate.', - '%d results found, use up and down arrow keys to navigate.', - results.length, - 'block-lab' - ), - results.length - ), - 'assertive' - ); - - if ( - null === this.state.selectedSuggestion && - '' !== this.getInputValue() - ) { - this.setState( { - selectedSuggestion: 0, - } ); - } - } else { - this.props.debouncedSpeak( - __( 'No results.', 'block-lab' ), - 'assertive' - ); - } - } ) - .catch( () => { - if ( this.suggestionsRequest === request ) { + if ( !! results.length ) { + this.props.debouncedSpeak( sprintf( _n( + '%d result found, use up and down arrow keys to navigate.', + '%d results found, use up and down arrow keys to navigate.', + results.length, + 'block-lab' + ), results.length ), 'assertive' ); + + if ( null === this.state.selectedSuggestion && '' !== this.getInputValue() ) { this.setState( { - loading: false, + selectedSuggestion: 0, } ); } - } ); + } else { + this.props.debouncedSpeak( __( 'No results.', 'block-lab' ), 'assertive' ); + } + } ).catch( () => { + if ( this.suggestionsRequest === request ) { + this.setState( { + loading: false, + } ); + } + } ); this.suggestionsRequest = request; } @@ -190,21 +164,12 @@ class FetchInput extends Component { * @param {boolean} isValid Whether the value in the is valid. */ setInputValidity( isValid ) { - if ( - ! this.inputRef.current || - ! this.inputRef.current.setCustomValidity - ) { + if ( ! this.inputRef.current || ! this.inputRef.current.setCustomValidity ) { return; } if ( ! isValid ) { - this.inputRef.current.setCustomValidity( - sprintf( - /* translators: %s: the control type */ - __( 'Invalid %s', 'block-lab' ), - this.props.field.control - ) - ); + this.inputRef.current.setCustomValidity( sprintf( __( 'Invalid %s', 'block-lab' ), this.props.field.control ) ); this.inputRef.current.reportValidity(); } else { this.inputRef.current.setCustomValidity( '' ); @@ -227,12 +192,8 @@ class FetchInput extends Component { onBlur( event ) { if ( event.relatedTarget && - ! event.relatedTarget.classList.contains( - 'components-popover__content' - ) && - ! event.relatedTarget.classList.contains( - 'bl-fetch-input__suggestion' - ) + ! event.relatedTarget.classList.contains( 'components-popover__content' ) && + ! event.relatedTarget.classList.contains( 'bl-fetch-input__suggestion' ) ) { this.setState( { showSuggestions: false, @@ -245,9 +206,7 @@ class FetchInput extends Component { if ( false === this.inputRef.current.checkValidity() ) { this.handlePopoverButton( '' ); } else { - this.handlePopoverButton( - this.state.results[ this.state.selectedSuggestion ] - ); + this.handlePopoverButton( this.state.results[ this.state.selectedSuggestion ] ); } } } @@ -276,12 +235,7 @@ class FetchInput extends Component { * @param {Object} event The DOM keydown event. */ onKeyDown( event ) { - const { - showSuggestions, - selectedSuggestion, - results, - loading, - } = this.state; + const { showSuggestions, selectedSuggestion, results, loading } = this.state; const inputValue = this.getInputValue(); // If the suggestions are not shown or loading, we shouldn't handle the arrow keys // We shouldn't preventDefault to allow block arrow keys navigation. @@ -312,10 +266,7 @@ class FetchInput extends Component { event.preventDefault(); // Set the input caret to the last position. - event.target.setSelectionRange( - inputValue.length, - inputValue.length - ); + event.target.setSelectionRange( inputValue.length, inputValue.length ); } break; } @@ -330,9 +281,7 @@ class FetchInput extends Component { case UP: { event.stopPropagation(); event.preventDefault(); - const previousIndex = ! selectedSuggestion - ? results.length - 1 - : selectedSuggestion - 1; + const previousIndex = ! selectedSuggestion ? results.length - 1 : selectedSuggestion - 1; this.setState( { selectedSuggestion: previousIndex, } ); @@ -341,11 +290,7 @@ class FetchInput extends Component { case DOWN: { event.stopPropagation(); event.preventDefault(); - const nextIndex = - selectedSuggestion === null || - selectedSuggestion === results.length - 1 - ? 0 - : selectedSuggestion + 1; + const nextIndex = selectedSuggestion === null || ( selectedSuggestion === results.length - 1 ) ? 0 : selectedSuggestion + 1; this.setState( { selectedSuggestion: nextIndex, } ); @@ -387,40 +332,19 @@ class FetchInput extends Component { * @return {string} The value of the */ getInputValue() { - return this.props.hasOwnProperty( 'displayValue' ) - ? this.props.displayValue - : this.props.value; + return this.props.hasOwnProperty( 'displayValue' ) ? this.props.displayValue : this.props.value; } render() { - const { - autoFocus = false, - className, - getDisplayValueFromAPI, - getValueFromAPI, - field, - instanceId, - } = this.props; - const { - showSuggestions, - results, - selectedSuggestion, - loading, - } = this.state; + const { autoFocus = false, className, getDisplayValueFromAPI, getValueFromAPI, field, instanceId } = this.props; + const { showSuggestions, results, selectedSuggestion, loading } = this.state; const shouldDisplayPopover = showSuggestions && !! results.length; const inputValue = this.getInputValue(); - const getButtonValue = getDisplayValueFromAPI - ? getDisplayValueFromAPI - : getValueFromAPI; + const getButtonValue = getDisplayValueFromAPI ? getDisplayValueFromAPI : getValueFromAPI; /* eslint-disable jsx-a11y/no-autofocus */ return ( - + } - { shouldDisplayPopover && ( + { shouldDisplayPopover &&
{ const buttonValue = getButtonValue( result ); - return ( - !! buttonValue && ( - - ) + return !! buttonValue && ( + ); } ) }
- ) } + }
); /* eslint-enable jsx-a11y/no-autofocus */ diff --git a/js/blocks/components/fields.js b/js/blocks/components/fields.js index 1bb058e87..49e179af5 100644 --- a/js/blocks/components/fields.js +++ b/js/blocks/components/fields.js @@ -67,9 +67,7 @@ const Fields = ( { fields, parentBlockProps, parentBlock, rowIndex } ) => { */ const onChange = ( newValue ) => { const { clientId, setAttributes } = parentBlockProps; - const parentAttributes = select( - 'core/block-editor' - ).getBlockAttributes( clientId ); + const parentAttributes = select( 'core/block-editor' ).getBlockAttributes( clientId ); const attr = { ...parentAttributes }; if ( undefined === rowIndex ) { @@ -80,8 +78,7 @@ const Fields = ( { fields, parentBlockProps, parentBlock, rowIndex } ) => { // This is in a repeater row. const attribute = attr[ field.parent ]; const defaultRows = [ {} ]; - const rows = - attribute && attribute.rows ? attribute.rows : defaultRows; + const rows = ( attribute && attribute.rows ) ? attribute.rows : defaultRows; if ( ! rows[ rowIndex ] ) { rows[ rowIndex ] = {}; @@ -109,15 +106,9 @@ const Fields = ( { fields, parentBlockProps, parentBlock, rowIndex } ) => { } ) => { const attr = { ...ownParentBlockProps.attributes }; - if ( - ownField.parent && - attr[ ownField.parent ] && - attr[ ownField.parent ].rows - ) { + if ( ownField.parent && attr[ ownField.parent ] && attr[ ownField.parent ].rows ) { // The ownField is probably in a repeater row, as it has a parent. - return attr[ ownField.parent ].rows[ ownRowIndex ][ - ownField.name - ]; + return attr[ ownField.parent ].rows[ ownRowIndex ][ ownField.name ]; } // The ownField is not in a repeater row. return attr[ ownField.name ]; @@ -125,22 +116,17 @@ const Fields = ( { fields, parentBlockProps, parentBlock, rowIndex } ) => { const Control = getControl( field ); - return ( - !! Control && ( -
- -
- ) + return !! Control && ( +
+ +
); } ); }; diff --git a/js/blocks/components/image.js b/js/blocks/components/image.js index 21567aeb7..3e17c0cd0 100644 --- a/js/blocks/components/image.js +++ b/js/blocks/components/image.js @@ -1,14 +1,7 @@ /** * WordPress dependencies */ -import { - BaseControl, - Button, - Placeholder, - DropZone, - FormFileUpload, - Spinner, -} from '@wordpress/components'; +import { BaseControl, Button, Placeholder, DropZone, FormFileUpload, Spinner } from '@wordpress/components'; import { withState } from '@wordpress/compose'; import { withSelect } from '@wordpress/data'; import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor'; @@ -21,13 +14,12 @@ const DEFAULT_IMG_ID = 0; const Image = withSelect( ( select, ownProps ) => { const { getValue } = ownProps; const fieldValue = getValue( ownProps ); - let media, - imageAlt, + let media, imageAlt, imageSrc = ''; if ( parseInt( fieldValue ) ) { media = select( 'core' ).getMedia( fieldValue ); - imageSrc = media && media.source_url ? media.source_url : ''; + imageSrc = ( media && media.source_url ) ? media.source_url : ''; } else if ( 'string' === typeof fieldValue ) { // Backwards-compatibility: this used to save the URL as the fieldValue, not the ID as it does now. imageSrc = fieldValue; @@ -37,14 +29,7 @@ const Image = withSelect( ( select, ownProps ) => { if ( media && media.alt ) { imageAlt = media.alt; } else if ( media && media.source_url ) { - imageAlt = sprintf( - /* translators: %s: the src of the image */ - __( - 'This image has no alt attribute, but its src is %s', - 'block-lab' - ), - media.source_url - ); + imageAlt = sprintf( __( 'This image has no alt attribute, but its src is %s', 'block-lab' ), media.source_url ); } else { imageAlt = __( 'This image has no alt attribute', 'block-lab' ); } @@ -53,149 +38,114 @@ const Image = withSelect( ( select, ownProps ) => { imageAlt, imageSrc, }; -} )( - withState()( ( ownProps ) => { - const { - field, - getValue, - imageAlt, - imageSrc, - instanceId, - isUploading, - onChange, - setState, - } = ownProps; - const uploadStart = () => { - setState( { isUploading: true } ); - }; +} )( withState()( ( ownProps ) => { + const { field, getValue, imageAlt, imageSrc, instanceId, isUploading, onChange, setState } = ownProps; + const uploadStart = () => { + setState( { isUploading: true } ); + }; - const uploadComplete = ( image ) => { - if ( image.hasOwnProperty( 'id' ) ) { - onChange( parseInt( image.id ) ); - } - setState( { isUploading: false } ); - }; + const uploadComplete = ( image ) => { + if ( image.hasOwnProperty( 'id' ) ) { + onChange( parseInt( image.id ) ); + } + setState( { isUploading: false } ); + }; - const onSelect = ( image ) => { - if ( - ! image.hasOwnProperty( 'url' ) || - ! image.hasOwnProperty( 'id' ) - ) { - return; - } - if ( 'blob' === image.url.substr( 0, 4 ) ) { - // Still uploading… - return; - } + const onSelect = ( image ) => { + if ( ! image.hasOwnProperty( 'url' ) || ! image.hasOwnProperty( 'id' ) ) { + return; + } + if ( 'blob' === image.url.substr( 0, 4 ) ) { + // Still uploading… + return; + } - uploadComplete( image ); - }; + uploadComplete( image ); + }; - const removeImage = () => { - // The attribute should be an int, so set it to 0 on removing an image. - onChange( DEFAULT_IMG_ID ); - }; + const removeImage = () => { + // The attribute should be an int, so set it to 0 on removing an image. + onChange( DEFAULT_IMG_ID ); + }; - const uploadFiles = ( files ) => { - mediaUpload( { - allowedTypes: ALLOWED_TYPES, - filesList: files, - onFileChange: ( image ) => { - onSelect( image[ 0 ] ); - }, - } ); - }; + const uploadFiles = ( files ) => { + mediaUpload( { + allowedTypes: ALLOWED_TYPES, + filesList: files, + onFileChange: ( image ) => { + onSelect( image[ 0 ] ); + }, + } ); + }; - return ( - - { !! field.help && ( -

- { field.help } -

- ) } - { ! isUploading && imageSrc && ( - { - ) } - { ! imageSrc && ( - + { !! field.help &&

{ field.help }

} + { ! isUploading && imageSrc && ( + { + ) } + { ! imageSrc && ( + + + { + if ( files.length ) { + uploadStart(); + uploadFiles( files ); + } + } } + > + { isUploading && ( + ) } - > - - { - if ( files.length ) { - uploadStart(); + { ! isUploading && ( + <> + { + const files = event.target.files; + uploadStart( files[ 0 ].name ); uploadFiles( files ); - } - } } - > - { isUploading && } - { ! isUploading && ( - <> - { - const files = event.target.files; - uploadStart( files[ 0 ].name ); - uploadFiles( files ); - } } - accept="image/*" - multiple={ false } - > - { __( 'Upload', 'block-lab' ) } - - ( -
- -
- ) } - /> - - ) } -
-
- ) } - { imageSrc && ( - - ) } -
- ); - } ) -); + } } + accept="image/*" + multiple={ false } + > + { __( 'Upload', 'block-lab' ) } + + ( +
+ +
+ ) } + /> + + ) } + + + ) } + { imageSrc && ( + + ) } +
+ ); +} ) ); export default Image; diff --git a/js/blocks/components/repeater-rows.js b/js/blocks/components/repeater-rows.js index d9129c5f0..e9f060dab 100644 --- a/js/blocks/components/repeater-rows.js +++ b/js/blocks/components/repeater-rows.js @@ -109,24 +109,17 @@ class RepeaterRows extends Component { move( from, to ) { const scrollView = () => { // Scroll the view. - const scrollContainer = getScrollContainer( - this.repeaterRows.current - ); - const rowRefs = this.repeaterRows.current.querySelectorAll( - '.block-lab-repeater--row' - ); + const scrollContainer = getScrollContainer( this.repeaterRows.current ); + const rowRefs = this.repeaterRows.current.querySelectorAll( '.block-lab-repeater--row' ); const rowRefFrom = rowRefs[ from ]; const rowRefTo = rowRefs[ to ]; - const scrollTop = - scrollContainer.scrollTop + - ( rowRefTo.offsetTop - rowRefFrom.offsetTop ); + const scrollTop = scrollContainer.scrollTop + ( rowRefTo.offsetTop - rowRefFrom.offsetTop ); rowRefTo.classList.add( 'row-to' ); rowRefFrom.classList.add( 'row-from' ); this.timeouts.push( - /* eslint-disable-next-line @wordpress/react-no-unsafe-timeout */ - setTimeout( () => { + setTimeout( () => { /* eslint-disable-line @wordpress/react-no-unsafe-timeout */ rowRefTo.classList.remove( 'row-to' ); rowRefFrom.classList.remove( 'row-from' ); }, 1000 ) @@ -163,85 +156,63 @@ class RepeaterRows extends Component { * @return {Object} The rows. */ getRows( attribute ) { - return attribute && attribute.rows ? attribute.rows : [ {} ]; + return ( attribute && attribute.rows ) ? attribute.rows : [ {} ]; } /** * Renders the repeater rows. */ render() { - const { - rows, - field, - subFields, - parentBlockProps, - parentBlock, - } = this.props; + const { rows, field, subFields, parentBlockProps, parentBlock } = this.props; return ( <> -
- { rows.map( ( row, rowIndex ) => { - const activeClass = - this.state.activeRow === parseInt( rowIndex ) - ? 'active' - : ''; // @todo: Make this dynamic. - - return ( - -
- -
- -
- - + { + rows.map( ( row, rowIndex ) => { + const activeClass = this.state.activeRow === parseInt( rowIndex ) ? 'active' : ''; // @todo: Make this dynamic. + + return ( + +
+ +
+ -
-
- ); - } ) } +
+ + +
+ + ); + } ) + }
); diff --git a/js/blocks/components/test/fetch-input.js b/js/blocks/components/test/fetch-input.js index 032e0b6d5..ba0157386 100644 --- a/js/blocks/components/test/fetch-input.js +++ b/js/blocks/components/test/fetch-input.js @@ -66,21 +66,16 @@ describe( 'FetchInput', () => { const { input } = setup( baseProps ); fireEvent.focus( input ); - await waitFor( () => - expect( screen.getByText( exampleResult ) ).toBeInTheDocument() - ); + await waitFor( () => expect( screen.getByText( exampleResult ) ).toBeInTheDocument() ); } ); it.each( [ [ [], true ], [ [ 'a-result' ], false ], [ [ 'first-result', 'another-result' ], false ], - ] )( - 'should only have the error class if there are no results after focusing', + ] )( 'should only have the error class if there are no results after focusing', async ( apiResults, expected ) => { - apiFetch.mockImplementationOnce( - () => new Promise( ( resolve ) => resolve( apiResults ) ) - ); + apiFetch.mockImplementationOnce( () => new Promise( ( resolve ) => resolve( apiResults ) ) ); const { input } = setup( baseProps ); fireEvent.focus( input ); diff --git a/js/blocks/components/test/fields.js b/js/blocks/components/test/fields.js index 98f890d73..bae855ab9 100644 --- a/js/blocks/components/test/fields.js +++ b/js/blocks/components/test/fields.js @@ -14,14 +14,12 @@ describe( 'Fields', () => { it( 'does not display a control that is supposed to be in the Inspector Controls', () => { render( ); @@ -32,14 +30,12 @@ describe( 'Fields', () => { it( 'displays a control that is supposed to be in the editor', () => { render( ); @@ -50,22 +46,18 @@ describe( 'Fields', () => { it( 'has a class name based on the width', () => { render( ); const classWithWidth = 'width-50'; - expect( - document.body.getElementsByClassName( classWithWidth )[ 0 ] - ).not.toBeNull(); + expect( document.body.getElementsByClassName( classWithWidth )[ 0 ] ).not.toBeNull(); } ); } ); diff --git a/js/blocks/components/tiny-mce.js b/js/blocks/components/tiny-mce.js index 7bb55b5fc..d5151f5dd 100644 --- a/js/blocks/components/tiny-mce.js +++ b/js/blocks/components/tiny-mce.js @@ -75,8 +75,7 @@ class TinyMCE extends Component { content_css: false, fixed_toolbar_container: `#toolbar-${ editorId }`, setup: this.onSetup, - toolbar1: - 'formatselect,bold,italic,bullist,numlist,outdent,indent,alignleft,aligncenter,alignright,link,unlink,wp_add_media,strikethrough', + toolbar1: 'formatselect,bold,italic,bullist,numlist,outdent,indent,alignleft,aligncenter,alignright,link,unlink,wp_add_media,strikethrough', toolbar2: '', }, } ); diff --git a/js/blocks/controls/classic-text.js b/js/blocks/controls/classic-text.js index 3e4a6caac..2fc239114 100644 --- a/js/blocks/controls/classic-text.js +++ b/js/blocks/controls/classic-text.js @@ -9,20 +9,10 @@ import { BaseControl } from '@wordpress/components'; import { TinyMCE } from '../components'; const BlockLabClassicTextControl = ( props ) => { - const { - field, - getValue, - onChange, - rowIndex, - parentBlockProps: { clientId }, - } = props; - const editorId = - 'number' === typeof rowIndex - ? `bl-${ clientId }-${ field.name }-rowIndex-${ rowIndex }` - : `bl-${ clientId }-${ field.name }`; + const { field, getValue, onChange, rowIndex, parentBlockProps: { clientId } } = props; + const editorId = 'number' === typeof rowIndex ? `bl-${ clientId }-${ field.name }-rowIndex-${ rowIndex }` : `bl-${ clientId }-${ field.name }`; const initialValue = getValue( props ); - const value = - 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = 'undefined' !== typeof initialValue ? initialValue : field.default; return ( { - const toggleVisible = () => { - setState( ( state ) => ( { isVisible: ! state.isVisible } ) ); - }; - const colorChange = ( value ) => { - let newColor = value.hex; - if ( value.rgb.a < 1 ) { - newColor = - 'rgba(' + - value.rgb.r + - ', ' + - value.rgb.g + - ', ' + - value.rgb.b + - ', ' + - value.rgb.a + - ')'; - } - setState( () => ( { color: newColor } ) ); - onUpdate( newColor ); - }; +const BlockLabColorPopover = withState( { +} )( ( { isVisible, color, onUpdate, setState } ) => { + const toggleVisible = () => { + setState( ( state ) => ( { isVisible: ! state.isVisible } ) ); + }; + const colorChange = ( value ) => { + let newColor = value.hex; + if ( value.rgb.a < 1 ) { + newColor = 'rgba(' + value.rgb.r + ', ' + value.rgb.g + ', ' + value.rgb.b + ', ' + value.rgb.a + ')'; + } + setState( () => ( { color: newColor } ) ); + onUpdate( newColor ); + }; - return ( - - { - event.preventDefault(); // Prevent the popover blur. - } } - onClick={ toggleVisible } - > - { isVisible && ( - { - event.stopPropagation(); - } } - onBlur={ ( event ) => { - if ( null === event.relatedTarget ) { - return; - } - if ( - event.relatedTarget.classList.contains( - 'wp-block' - ) - ) { - toggleVisible(); - } + return ( + + { + event.preventDefault(); // Prevent the popover blur. + } } + onClick={ toggleVisible } + > + { isVisible && ( + { + event.stopPropagation(); + } } + onBlur={ ( event ) => { + if ( null === event.relatedTarget ) { + return; + } + if ( event.relatedTarget.classList.contains( 'wp-block' ) ) { + toggleVisible(); + } + } } + > + { + colorChange( value ); } } - > - { - colorChange( value ); - } } - /> - - ) } - - - ); - } -); + /> + + ) } + + + ); +} ); const BlockLabColorControl = ( props ) => { const { field, getValue, instanceId, onChange } = props; const initialValue = getValue( props ); - const value = - 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = 'undefined' !== typeof initialValue ? initialValue : field.default; return ( - - + + { const { field, getValue, onChange } = props; const initialValue = getValue( props ); - const value = - 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = 'undefined' !== typeof initialValue ? initialValue : field.default; /** * Sets the Error Class for the Text Control. diff --git a/js/blocks/controls/image.js b/js/blocks/controls/image.js index e785830fa..0e93de218 100644 --- a/js/blocks/controls/image.js +++ b/js/blocks/controls/image.js @@ -4,7 +4,9 @@ import { Image } from '../components'; const BlockLabImageControl = ( props ) => { - return ; + return ( + + ); }; export default BlockLabImageControl; diff --git a/js/blocks/controls/number.js b/js/blocks/controls/number.js index 186a24872..fde99923a 100644 --- a/js/blocks/controls/number.js +++ b/js/blocks/controls/number.js @@ -11,8 +11,7 @@ import { TextControl } from '@wordpress/components'; const BlockLabNumberControl = ( props ) => { const { field, getValue, onChange } = props; const initialValue = getValue( props ); - const value = - 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = 'undefined' !== typeof initialValue ? initialValue : field.default; /** * Sets the Error Class for the Text Control. diff --git a/js/blocks/controls/post.js b/js/blocks/controls/post.js index 18a031e65..fafd76255 100644 --- a/js/blocks/controls/post.js +++ b/js/blocks/controls/post.js @@ -10,10 +10,7 @@ const BlockLabPostControl = ( props ) => { * @param {Object} apiResponse The API response in which to look for the post title. * @return {string} The post title from the response, or the default. */ - const getNameFromAPI = ( apiResponse ) => - apiResponse && apiResponse.title && apiResponse.title.rendered - ? apiResponse.title.rendered - : ''; + const getNameFromAPI = ( apiResponse ) => ( apiResponse && apiResponse.title && apiResponse.title.rendered ) ? apiResponse.title.rendered : ''; const contentProps = { ...props, getNameFromAPI }; return ; }; diff --git a/js/blocks/controls/repeater.js b/js/blocks/controls/repeater.js index 157700429..0e0b9a7b8 100644 --- a/js/blocks/controls/repeater.js +++ b/js/blocks/controls/repeater.js @@ -9,19 +9,11 @@ import { BaseControl, IconButton } from '@wordpress/components'; import { RepeaterRows } from '../components'; const BlockLabRepeaterControl = ( props ) => { - const { - field, - instanceId, - onChange, - parentBlock, - parentBlockProps, - } = props; + const { field, instanceId, onChange, parentBlock, parentBlockProps } = props; const { attributes, setAttributes } = parentBlockProps; const attr = { ...attributes }; const value = attr[ field.name ]; - const defaultRows = new Array( field.min ? field.min : 1 ).fill( { - '': '', - } ); + const defaultRows = new Array( field.min ? field.min : 1 ).fill( { '': '' } ); const hasRows = value && value.hasOwnProperty( 'rows' ); const rows = hasRows ? value.rows : defaultRows; @@ -44,12 +36,7 @@ const BlockLabRepeaterControl = ( props ) => { } return ( - + { className="block-lab-rich-text-control" help={ field.help } > - { /* - * @todo: Resolve known issue with toolbar not disappearing on blur - * @see: https://github.com/WordPress/gutenberg/issues/7463 - */ } + { + /* + * @todo: Resolve known issue with toolbar not disappearing on blur + * @see: https://github.com/WordPress/gutenberg/issues/7463 + */ + } { if ( '' === field.default ) { field.options = [ - { - label: __( '– Select –', 'block-lab' ), - value: '', - disabled: true, - }, + { label: __( '– Select –', 'block-lab' ), value: '', disabled: true }, ...field.options, ]; } diff --git a/js/blocks/controls/taxonomy.js b/js/blocks/controls/taxonomy.js index 26d90d732..d77b17b97 100644 --- a/js/blocks/controls/taxonomy.js +++ b/js/blocks/controls/taxonomy.js @@ -10,8 +10,7 @@ const BlockLabTaxonomyControl = ( props ) => { * @param {Object} apiResponse The API response in which to look for the post title. * @return {string} The post title from the response, or the default. */ - const getNameFromAPI = ( apiResponse ) => - apiResponse && apiResponse.name ? apiResponse.name : ''; + const getNameFromAPI = ( apiResponse ) => ( apiResponse && apiResponse.name ) ? apiResponse.name : ''; const contentProps = { ...props, getNameFromAPI }; return ; diff --git a/js/blocks/controls/test/classic-text.js b/js/blocks/controls/test/classic-text.js index 0e88bc849..ad574e7a4 100644 --- a/js/blocks/controls/test/classic-text.js +++ b/js/blocks/controls/test/classic-text.js @@ -41,9 +41,7 @@ test( 'classic text control', async () => { }, }; - const { findByText } = render( - - ); + const { findByText } = render( ); const control = await findByText( props.field.help ); expect( control ).toBeInTheDocument(); diff --git a/js/blocks/controls/test/color.js b/js/blocks/controls/test/color.js index 6a7f16977..a6136bd0e 100644 --- a/js/blocks/controls/test/color.js +++ b/js/blocks/controls/test/color.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { fireEvent, render } from '@testing-library/react'; +import { render } from '@testing-library/react'; import user from '@testing-library/user-event'; /** @@ -33,6 +33,6 @@ test( 'color control', async () => { // On entering a new color, it should be sent to the onChange handler. const enteredColor = '#fff'; user.clear( input ); - fireEvent.change( input, { target: { value: enteredColor } } ); + user.type( input, enteredColor ); expect( mockOnChange ).toHaveBeenCalledWith( enteredColor ); } ); diff --git a/js/blocks/controls/test/email.js b/js/blocks/controls/test/email.js index 9a6a4df4f..cb1743d10 100644 --- a/js/blocks/controls/test/email.js +++ b/js/blocks/controls/test/email.js @@ -31,8 +31,11 @@ describe( 'email control', () => { expect( control ).toHaveAttribute( 'value', props.field.default ); } ); - it.each( [ 'you@example.com', 'not-a-valid-email', ')$@$%*)#$*@)#$' ] )( - 'should send any entered text to the onChange handler, even if it is not a valid email', + it.each( [ + 'you@example.com', + 'not-a-valid-email', + ')$@$%*)#$*@)#$', + ] )( 'should send any entered text to the onChange handler, even if it is not a valid email', ( enteredText ) => { const props = getProps(); const { control } = setupControl( BlockLabEmailControl, props ); @@ -41,20 +44,18 @@ describe( 'email control', () => { } ); - it.each( [ true, false ] )( - 'should have an invalid class if the event object finds it is invalid', + it.each( [ + true, + false, + ] )( 'should have an invalid class if the event object finds it is invalid', ( isInputValid ) => { const props = getProps(); const { control } = setupControl( BlockLabEmailControl, props ); const mockCheckValidity = jest.fn(); mockCheckValidity.mockReturnValueOnce( isInputValid ); - fireEvent.blur( control, { - target: { checkValidity: mockCheckValidity }, - } ); - expect( - control.classList.contains( 'text-control__error' ) - ).toStrictEqual( ! isInputValid ); + fireEvent.blur( control, { target: { checkValidity: mockCheckValidity } } ); + expect( control.classList.contains( 'text-control__error' ) ).toStrictEqual( ! isInputValid ); } ); } ); diff --git a/js/blocks/controls/test/helpers/index.js b/js/blocks/controls/test/helpers/index.js index eef377760..b0fa5d5cd 100644 --- a/js/blocks/controls/test/helpers/index.js +++ b/js/blocks/controls/test/helpers/index.js @@ -12,7 +12,12 @@ import { render } from '@testing-library/react'; */ export const setupControl = ( Control, props ) => { const { field } = props; - const utils = render( ); + const utils = render( + + ); const control = utils.getByLabelText( field.label ); return { control, diff --git a/js/blocks/controls/test/multiselect.js b/js/blocks/controls/test/multiselect.js index 80fe65589..bf43c3aff 100644 --- a/js/blocks/controls/test/multiselect.js +++ b/js/blocks/controls/test/multiselect.js @@ -31,10 +31,7 @@ test( 'multiselect control', () => { field, onChange: jest.fn(), }; - const { control, getByText } = setupControl( - BlockLabMultiselectControl, - props - ); + const { control, getByText } = setupControl( BlockLabMultiselectControl, props ); getByText( field.help ); fireEvent.change( control, { target: { value: [ secondValue ] } } ); diff --git a/js/blocks/controls/test/number.js b/js/blocks/controls/test/number.js index e8a07aeda..8ca1dd8ff 100644 --- a/js/blocks/controls/test/number.js +++ b/js/blocks/controls/test/number.js @@ -32,17 +32,15 @@ describe( 'number control', () => { it( 'has the placeholder', async () => { const props = getProps(); - const { findByPlaceholderText } = setupControl( - BlockLabNumberControl, - props - ); - expect( - await findByPlaceholderText( props.field.placeholder ) - ).toBeInTheDocument(); + const { findByPlaceholderText } = setupControl( BlockLabNumberControl, props ); + expect( await findByPlaceholderText( props.field.placeholder ) ).toBeInTheDocument(); } ); - it.each( [ 0, 352343, 9523342951313513414 ] )( - 'sends a number to the onChange handler when it is entered', + it.each( [ + 0, + 352343, + 9523342951313513414, + ] )( 'sends a number to the onChange handler when it is entered', ( enteredText ) => { const props = getProps(); const { control } = setupControl( BlockLabNumberControl, props ); diff --git a/js/blocks/controls/test/post.js b/js/blocks/controls/test/post.js index 49ecca143..78f964834 100644 --- a/js/blocks/controls/test/post.js +++ b/js/blocks/controls/test/post.js @@ -34,9 +34,7 @@ const getProps = () => ( { test( 'post control', async () => { const props = getProps(); - const { findByRole, findByText, findByLabelText } = render( - - ); + const { findByRole, findByText, findByLabelText } = render( ); await findByLabelText( props.field.label ); await findByText( props.field.help ); @@ -62,8 +60,5 @@ test( 'post control', async () => { ); // The onChange handler should be called with the selected post. - expect( props.onChange ).toHaveBeenCalledWith( { - id: post.id, - name: post.title.rendered, - } ); + expect( props.onChange ).toHaveBeenCalledWith( { id: post.id, name: post.title.rendered } ); } ); diff --git a/js/blocks/controls/test/radio.js b/js/blocks/controls/test/radio.js index 90c70ad81..879292898 100644 --- a/js/blocks/controls/test/radio.js +++ b/js/blocks/controls/test/radio.js @@ -12,7 +12,10 @@ import BlockLabRadioControl from '../radio'; test( 'radio control', async () => { const firstOption = 'first'; const secondOption = 'second'; - const options = [ { value: firstOption }, { value: secondOption } ]; + const options = [ + { value: firstOption }, + { value: secondOption }, + ]; const field = { options, label: 'This is a label for the radio field', diff --git a/js/blocks/controls/test/select.js b/js/blocks/controls/test/select.js index 5752a8ee2..98e5622c2 100644 --- a/js/blocks/controls/test/select.js +++ b/js/blocks/controls/test/select.js @@ -34,17 +34,12 @@ test( 'select control', async () => { onChange: jest.fn(), }; - const { findByRole, findByText } = setupControl( - BlockLabSelectControl, - props - ); + const { findByRole, findByText } = setupControl( BlockLabSelectControl, props ); await findByText( field.help ); const control = await findByRole( 'combobox' ); // This should send the new value to the onChange handler. user.selectOptions( control, secondValue ); //fireEvent.change( control, { target: { value: secondValue } } ); - await waitFor( () => - expect( props.onChange ).toHaveBeenCalledWith( secondValue ) - ); + await waitFor( () => expect( props.onChange ).toHaveBeenCalledWith( secondValue ) ); } ); diff --git a/js/blocks/controls/test/taxonomy.js b/js/blocks/controls/test/taxonomy.js index c6e4a950d..730df10a3 100644 --- a/js/blocks/controls/test/taxonomy.js +++ b/js/blocks/controls/test/taxonomy.js @@ -25,9 +25,7 @@ test( 'taxonomy control', async () => { getValue: jest.fn(), onChange: jest.fn(), }; - const { getByLabelText, getByRole, getByText } = render( - - ); + const { getByLabelText, getByRole, getByText } = render( ); getByLabelText( props.field.label ); getByText( props.field.help ); @@ -47,11 +45,10 @@ test( 'taxonomy control', async () => { fireEvent.focus( input ); // Click to select a taxonomy. - await waitFor( () => fireEvent.click( getByText( taxonomy.name ) ) ); + await waitFor( () => + fireEvent.click( getByText( taxonomy.name ) ) + ); // The onChange handler should be called with the selected taxonomy. - expect( props.onChange ).toHaveBeenCalledWith( { - id: taxonomy.id, - name: taxonomy.name, - } ); + expect( props.onChange ).toHaveBeenCalledWith( { id: taxonomy.id, name: taxonomy.name } ); } ); diff --git a/js/blocks/controls/test/text.js b/js/blocks/controls/test/text.js index d89903118..9e187e04d 100644 --- a/js/blocks/controls/test/text.js +++ b/js/blocks/controls/test/text.js @@ -35,8 +35,7 @@ describe( 'text control', () => { '942', '#$ Special %()@$ characters @${}[]', 'Very long text that keeps going on and on and on and it continues longer than you would normally expect', - ] )( - 'Any text entered is sent to the onChange handler', + ] )( 'Any text entered is sent to the onChange handler', ( enteredText ) => { const props = getProps(); const { control } = setupControl( BlockLabTextControl, props ); diff --git a/js/blocks/controls/test/textarea.js b/js/blocks/controls/test/textarea.js index 0c6794de0..4360a0e7f 100644 --- a/js/blocks/controls/test/textarea.js +++ b/js/blocks/controls/test/textarea.js @@ -33,14 +33,9 @@ describe( 'textarea control', () => { it( 'has the placeholder', () => { const props = getProps(); - const { getByPlaceholderText } = setupControl( - BlockLabTextareaControl, - props - ); - - expect( - getByPlaceholderText( props.field.placeholder ) - ).toBeInTheDocument(); + const { getByPlaceholderText } = setupControl( BlockLabTextareaControl, props ); + + expect( getByPlaceholderText( props.field.placeholder ) ).toBeInTheDocument(); } ); it.each( [ @@ -48,8 +43,7 @@ describe( 'textarea control', () => { 'っていった', '987654321', 'This is long text that is entered into a textarea, it keeps going longer than one might normally type', - ] )( - 'Any text entered is sent to the onChange handler', + ] )( 'Any text entered is sent to the onChange handler', ( enteredText ) => { const props = getProps(); const { control } = setupControl( BlockLabTextareaControl, props ); diff --git a/js/blocks/controls/test/url.js b/js/blocks/controls/test/url.js index e69950f68..0c6e5d7d6 100644 --- a/js/blocks/controls/test/url.js +++ b/js/blocks/controls/test/url.js @@ -39,8 +39,10 @@ describe( 'url control', () => { expect( props.onChange ).toHaveBeenCalledWith( enteredUrl ); } ); - it.each( [ true, false ] )( - 'should have an invalid class if the event object finds it is invalid', + it.each( [ + true, + false, + ] )( 'should have an invalid class if the event object finds it is invalid', ( isInputValid ) => { const props = getProps(); const { control } = setupControl( BlockLabURLControl, props ); @@ -48,9 +50,7 @@ describe( 'url control', () => { mockEvent.target.checkValidity.mockReturnValueOnce( isInputValid ); fireEvent.blur( control, mockEvent ); - expect( - control.classList.contains( 'text-control__error' ) - ).toStrictEqual( ! isInputValid ); + expect( control.classList.contains( 'text-control__error' ) ).toStrictEqual( ! isInputValid ); } ); } ); diff --git a/js/blocks/controls/test/user.js b/js/blocks/controls/test/user.js index e50676a18..461931728 100644 --- a/js/blocks/controls/test/user.js +++ b/js/blocks/controls/test/user.js @@ -25,9 +25,7 @@ test( 'user control', async () => { onChange: jest.fn(), }; - const { getByLabelText, getByRole } = render( - - ); + const { getByLabelText, getByRole } = render( ); getByLabelText( props.field.label ); getByText( document, props.field.help ); @@ -46,11 +44,10 @@ test( 'user control', async () => { fireEvent.focus( input ); // Click to select a user. - await waitFor( () => fireEvent.click( getByText( document, user.name ) ) ); + await waitFor( () => + fireEvent.click( getByText( document, user.name ) ) + ); // The onChange handler should be called with the selected user. - expect( props.onChange ).toHaveBeenCalledWith( { - id: user.id, - userName: user.name, - } ); + expect( props.onChange ).toHaveBeenCalledWith( { id: user.id, userName: user.name } ); } ); diff --git a/js/blocks/controls/text.js b/js/blocks/controls/text.js index 82c3aab0a..846113972 100644 --- a/js/blocks/controls/text.js +++ b/js/blocks/controls/text.js @@ -6,8 +6,7 @@ import { TextControl } from '@wordpress/components'; const BlockLabTextControl = ( props ) => { const { field, getValue, onChange } = props; const initialValue = getValue( props ); - const value = - 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = 'undefined' !== typeof initialValue ? initialValue : field.default; return ( { const { getValue, field, onChange } = props; const initialValue = getValue( props ); - const value = - 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = 'undefined' !== typeof initialValue ? initialValue : field.default; return ( { const { field, onChange, getValue } = props; const initialValue = getValue( props ); - const value = - 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = 'undefined' !== typeof initialValue ? initialValue : field.default; return ( { const { field, getValue, onChange } = props; const initialValue = getValue( props ); - const value = - 'undefined' !== typeof initialValue ? initialValue : field.default; + const value = 'undefined' !== typeof initialValue ? initialValue : field.default; /** * Sets the Error Class for the Text Control. diff --git a/js/blocks/controls/user.js b/js/blocks/controls/user.js index 38eed54f6..87aa0883d 100644 --- a/js/blocks/controls/user.js +++ b/js/blocks/controls/user.js @@ -6,13 +6,10 @@ import { FetchInput } from '../components'; const BlockLabUserControl = ( props ) => { const { field, getValue, onChange } = props; const DEFAULT_ID = 0; - const getIdFromAPI = ( apiResponse ) => - apiResponse && apiResponse.id ? apiResponse.id : DEFAULT_ID; - const getNameFromAPI = ( apiResponse ) => - apiResponse && apiResponse.name ? apiResponse.name : ''; + const getIdFromAPI = ( apiResponse ) => ( apiResponse && apiResponse.id ) ? apiResponse.id : DEFAULT_ID; + const getNameFromAPI = ( apiResponse ) => ( apiResponse && apiResponse.name ) ? apiResponse.name : ''; - const initialValue = - 'object' === typeof getValue( props ) ? getValue( props ) : {}; + const initialValue = ( 'object' === typeof getValue( props ) ) ? getValue( props ) : {}; const userAttribute = { id: DEFAULT_ID, userName: '', ...initialValue }; return ( diff --git a/js/blocks/helpers/getSimplifiedFields.js b/js/blocks/helpers/getSimplifiedFields.js index 3a26b311c..3d214ede7 100644 --- a/js/blocks/helpers/getSimplifiedFields.js +++ b/js/blocks/helpers/getSimplifiedFields.js @@ -34,10 +34,12 @@ const getSimplifiedFields = ( fields ) => { } const field = fields[ fieldName ]; - fieldList.push( { - ...field, - name: fieldName, - } ); + fieldList.push( + { + ...field, + name: fieldName, + } + ); } fieldList.sort( compare ); // @todo: is this needed? Even then, it should only affect the Block Lab editor UI. diff --git a/js/blocks/helpers/registerBlocks.js b/js/blocks/helpers/registerBlocks.js index 768ef9b07..a13ce2ad0 100644 --- a/js/blocks/helpers/registerBlocks.js +++ b/js/blocks/helpers/registerBlocks.js @@ -28,10 +28,7 @@ const registerBlocks = ( blockLab, blockLabBlocks, EditComponent ) => { block.block_slug = blockName; // Don't register the block if it's excluded for this post type. - if ( - blockLab.hasOwnProperty( 'postType' ) && - block.hasOwnProperty( 'excluded' ) - ) { + if ( blockLab.hasOwnProperty( 'postType' ) && block.hasOwnProperty( 'excluded' ) ) { if ( -1 !== block.excluded.indexOf( blockLab.postType ) ) { continue; } @@ -40,19 +37,14 @@ const registerBlocks = ( blockLab, blockLabBlocks, EditComponent ) => { let icon = ''; if ( 'undefined' !== typeof icons[ block.icon ] ) { icon = ( - + ); } // Register the block. registerBlockType( blockName, { title: block.title, - category: - 'object' === typeof block.category - ? block.category.slug - : block.category, + category: 'object' === typeof block.category ? block.category.slug : block.category, icon, keywords: block.keywords, attributes: getBlockLabAttributes( block.fields ), diff --git a/js/blocks/helpers/test/getBlockLabAttributes.js b/js/blocks/helpers/test/getBlockLabAttributes.js index 53b91ad78..d978425f4 100644 --- a/js/blocks/helpers/test/getBlockLabAttributes.js +++ b/js/blocks/helpers/test/getBlockLabAttributes.js @@ -18,28 +18,24 @@ describe( 'getBlockFromContent', () => { } ); it( 'should not throw an error if certain attributes are not present', () => { - expect( getBlockLabAttributes( fieldsWithOnlyType ) ).toStrictEqual( - fieldsWithOnlyType - ); + expect( getBlockLabAttributes( fieldsWithOnlyType ) ).toStrictEqual( fieldsWithOnlyType ); } ); it( 'should return only the attributes of the fields', () => { - expect( - getBlockLabAttributes( { - example_text: { - type: 'text', - default: 'Here is some text', - help: 'This is the help text', - location: 'editor', - }, - example_url: { - type: 'url', - default: 'https://example.com/go-here', - help: 'Here is the help text', - location: 'inspector', - }, - } ) - ).toStrictEqual( { + expect( getBlockLabAttributes( { + example_text: { + type: 'text', + default: 'Here is some text', + help: 'This is the help text', + location: 'editor', + }, + example_url: { + type: 'url', + default: 'https://example.com/go-here', + help: 'Here is the help text', + location: 'inspector', + }, + } ) ).toStrictEqual( { example_text: { type: 'text', default: 'Here is some text', diff --git a/js/blocks/helpers/test/getSimplifiedFields.js b/js/blocks/helpers/test/getSimplifiedFields.js index 01379b4ea..2960d217d 100644 --- a/js/blocks/helpers/test/getSimplifiedFields.js +++ b/js/blocks/helpers/test/getSimplifiedFields.js @@ -9,29 +9,27 @@ describe( 'getBlockFromContent', () => { } ); it( 'should return simplified fields for an object of 3 fields', () => { - expect( - getSimplifiedFields( { - example_post: { - type: 'post', - help: 'This is some example help text', - location: 'editor', - post_type: 'posts', - width: '100', - }, - example_classic_text: { - type: 'classic_text', - default: 'https://example.com/go-here', - help: 'Here is the help text', - location: 'editor', - }, - example_user: { - type: 'user', - default: 'https://example.com/go-here', - help: 'Here is the help text', - location: 'inspector', - }, - } ) - ).toStrictEqual( [ + expect( getSimplifiedFields( { + example_post: { + type: 'post', + help: 'This is some example help text', + location: 'editor', + post_type: 'posts', + width: '100', + }, + example_classic_text: { + type: 'classic_text', + default: 'https://example.com/go-here', + help: 'Here is the help text', + location: 'editor', + }, + example_user: { + type: 'user', + default: 'https://example.com/go-here', + help: 'Here is the help text', + location: 'inspector', + }, + } ) ).toStrictEqual( [ { name: 'example_post', type: 'post', @@ -58,13 +56,11 @@ describe( 'getBlockFromContent', () => { } ); it( 'should still include falsy values in the simplified fields', () => { - expect( - getSimplifiedFields( { - test_taxonomy: { - default: '', - }, - } ) - ).toStrictEqual( [ + expect( getSimplifiedFields( { + test_taxonomy: { + default: '', + }, + } ) ).toStrictEqual( [ { name: 'test_taxonomy', default: '', diff --git a/package-lock.json b/package-lock.json index 5a9e90eac..4500fa948 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5357,12 +5357,6 @@ "requires": { "type-fest": "^0.8.1" } - }, - "prettier": { - "version": "npm:wp-prettier@2.0.5", - "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz", - "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==", - "dev": true } } }, @@ -6457,12 +6451,6 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, - "prettier": { - "version": "npm:wp-prettier@2.0.5", - "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz", - "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==", - "dev": true - }, "regexpp": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", @@ -9131,6 +9119,12 @@ "integrity": "sha512-sJAofoarcm76ZGpuooaO0eDy8saEy+YoZBLjC4h8srt4jeBnkYeOgqxgsJQTpyt2LjI5PTfLJHSL+41Yu4fEJA==", "dev": true }, + "cli-width": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", + "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", + "dev": true + }, "clipboard": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.6.tgz", @@ -10950,23 +10944,22 @@ } }, "eslint": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.6.0.tgz", - "integrity": "sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==", + "version": "6.8.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", + "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", + "chalk": "^2.1.0", + "cross-spawn": "^6.0.5", "debug": "^4.0.1", "doctrine": "^3.0.0", - "enquirer": "^2.3.5", - "eslint-scope": "^5.1.0", - "eslint-utils": "^2.1.0", - "eslint-visitor-keys": "^1.3.0", - "espree": "^7.2.0", - "esquery": "^1.2.0", + "eslint-scope": "^5.0.0", + "eslint-utils": "^1.4.3", + "eslint-visitor-keys": "^1.1.0", + "espree": "^6.1.2", + "esquery": "^1.0.1", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", @@ -10975,74 +10968,45 @@ "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", + "inquirer": "^7.0.0", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash": "^4.17.19", + "levn": "^0.3.0", + "lodash": "^4.17.14", "minimatch": "^3.0.4", + "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", + "optionator": "^0.8.3", "progress": "^2.0.0", - "regexpp": "^3.1.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", - "strip-json-comments": "^3.1.0", + "regexpp": "^2.0.1", + "semver": "^6.1.2", + "strip-ansi": "^5.2.0", + "strip-json-comments": "^3.0.1", "table": "^5.2.3", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", "dev": true, "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } } }, "doctrine": { @@ -11064,12 +11028,6 @@ "estraverse": "^4.1.1" } }, - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true - }, "glob-parent": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", @@ -11088,104 +11046,11 @@ "type-fest": "^0.8.1" } }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "levn": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", - "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - } - }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", - "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - } - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", - "dev": true - }, "semver": { - "version": "7.3.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", - "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", - "dev": true - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "type-check": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1" - } - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } } } }, @@ -11682,9 +11547,9 @@ } }, "eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", + "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" @@ -11697,14 +11562,14 @@ "dev": true }, "espree": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-7.2.0.tgz", - "integrity": "sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", + "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", "dev": true, "requires": { - "acorn": "^7.3.1", + "acorn": "^7.1.1", "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.3.0" + "eslint-visitor-keys": "^1.1.0" }, "dependencies": { "acorn": { @@ -11712,12 +11577,6 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true - }, - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", - "dev": true } } }, @@ -14761,6 +14620,117 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, + "inquirer": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", + "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", + "dev": true, + "requires": { + "ansi-escapes": "^4.2.1", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-width": "^3.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.19", + "mute-stream": "0.0.8", + "run-async": "^2.4.0", + "rxjs": "^6.6.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "through": "^2.3.6" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "internal-slot": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.2.tgz", @@ -21531,6 +21501,12 @@ "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", "dev": true }, + "prettier": { + "version": "npm:wp-prettier@2.0.5", + "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz", + "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==", + "dev": true + }, "prettier-linter-helpers": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", @@ -22488,9 +22464,9 @@ } }, "regexpp": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", - "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", + "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", "dev": true }, "regexpu-core": { @@ -23064,6 +23040,12 @@ "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", "dev": true }, + "run-async": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", + "dev": true + }, "run-parallel": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", @@ -23091,6 +23073,15 @@ "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=", "dev": true }, + "rxjs": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz", + "integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", diff --git a/tests/e2e/jest.config.js b/tests/e2e/jest.config.js index 9d726b1ea..f2c6e163a 100644 --- a/tests/e2e/jest.config.js +++ b/tests/e2e/jest.config.js @@ -5,5 +5,7 @@ module.exports = { '@wordpress/jest-console', 'expect-puppeteer', ], - testPathIgnorePatterns: [ '/node_modules/' ], + testPathIgnorePatterns: [ + '/node_modules/', + ], }; diff --git a/tests/e2e/specs/create-block.js b/tests/e2e/specs/create-block.js index de3b68af6..80c707a0d 100644 --- a/tests/e2e/specs/create-block.js +++ b/tests/e2e/specs/create-block.js @@ -22,7 +22,7 @@ const insertBlockFromInserter = async ( blockName ) => { await page.keyboard.type( blockName ); const insertButton = ( await page.$x( `//button//span[contains(text(), '${ blockName }')]` ) - )[ 0 ]; + )[ 0 ]; await insertButton.click(); }; @@ -58,13 +58,7 @@ describe( 'TextBlock', () => { const fieldSelector = '.components-base-control__field'; // The block should have the Text field. - expect( - await page.evaluate( - () => - document.querySelector( '.components-base-control__label' ) - .textContent - ) - ).toContain( fieldName ); + expect( await page.evaluate( () => document.querySelector( '.components-base-control__label' ).textContent ) ).toContain( fieldName ); // Type into the text field. await page.click( `${ fieldSelector } input` ); @@ -75,14 +69,8 @@ describe( 'TextBlock', () => { await page.waitForSelector( '.block-lab-editor__ssr p' ); // The should display the content from the block template in the plugin, and should show the text field value. - const ssrText = await page.evaluate( - () => document.querySelector( '.block-lab-editor__ssr p' ).innerText - ); - expect( ssrText ).toContain( - `Here is the result of calling block_value with the field name: ${ fieldValue }` - ); - expect( ssrText ).toContain( - `Here is the result of calling block_field with the field name: ${ fieldValue }` - ); + const ssrText = await page.evaluate( () => document.querySelector( '.block-lab-editor__ssr p' ).innerText ); + expect( ssrText ).toContain( `Here is the result of calling block_value with the field name: ${ fieldValue }` ); + expect( ssrText ).toContain( `Here is the result of calling block_field with the field name: ${ fieldValue }` ); } ); } ); diff --git a/webpack.config.js b/webpack.config.js index 300e02981..4e48e5dad 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,7 +3,7 @@ const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); const IgnoreEmitPlugin = require( 'ignore-emit-webpack-plugin' ); const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' ); -const { defaultRequestToExternal, defaultRequestToHandle } = require( '@wordpress/dependency-extraction-webpack-plugin/lib/util' ); +const { defaultRequestToExternal, defaultRequestToHandle } = require( '@wordpress/dependency-extraction-webpack-plugin/util' ); const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); const isProduction = process.env.NODE_ENV === 'production'; From 4f92f49ae3d994a50b94f37e6bf5504b48a46ce9 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Fri, 7 Aug 2020 15:56:20 -0500 Subject: [PATCH 12/15] Prevent ESLint from running Prettier --- .eslintrc | 2 +- js/blocks/components/fetch-input.js | 8 +++++++- js/blocks/components/image.js | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index ce3699b38..69bc8fbc1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,7 +1,7 @@ { "root": true, "extends": [ - "plugin:@wordpress/eslint-plugin/recommended", + "plugin:@wordpress/eslint-plugin/recommended-with-formatting", "plugin:import/recommended", "plugin:eslint-comments/recommended", "plugin:jsx-a11y/recommended", diff --git a/js/blocks/components/fetch-input.js b/js/blocks/components/fetch-input.js index 067715234..ae5962c82 100644 --- a/js/blocks/components/fetch-input.js +++ b/js/blocks/components/fetch-input.js @@ -29,6 +29,9 @@ const stopEventPropagation = ( event ) => event.stopPropagation(); class FetchInput extends Component { /** * Constructs the component class. + * + * @param {Object} props The component props. + * @param {Object} props.autocompleteRef The ref of the auto-complete. */ constructor( { autocompleteRef } ) { super( ...arguments ); @@ -129,7 +132,9 @@ class FetchInput extends Component { } ); if ( !! results.length ) { - this.props.debouncedSpeak( sprintf( _n( + this.props.debouncedSpeak( + /* translators: %d: the number of results */ + sprintf( _n( '%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', results.length, @@ -169,6 +174,7 @@ class FetchInput extends Component { } if ( ! isValid ) { + /* translators: %s: the control name */ this.inputRef.current.setCustomValidity( sprintf( __( 'Invalid %s', 'block-lab' ), this.props.field.control ) ); this.inputRef.current.reportValidity(); } else { diff --git a/js/blocks/components/image.js b/js/blocks/components/image.js index 3e17c0cd0..66d5ac3ae 100644 --- a/js/blocks/components/image.js +++ b/js/blocks/components/image.js @@ -29,6 +29,7 @@ const Image = withSelect( ( select, ownProps ) => { if ( media && media.alt ) { imageAlt = media.alt; } else if ( media && media.source_url ) { + /* translators: %s: the image src */ imageAlt = sprintf( __( 'This image has no alt attribute, but its src is %s', 'block-lab' ), media.source_url ); } else { imageAlt = __( 'This image has no alt attribute', 'block-lab' ); From 0d4a9916f1778c455df13c2c56e353b0c966c229 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Fri, 7 Aug 2020 16:05:09 -0500 Subject: [PATCH 13/15] Fix the directory of utility functions --- js/blocks/components/fetch-input.js | 10 +++++----- webpack.config.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/blocks/components/fetch-input.js b/js/blocks/components/fetch-input.js index ae5962c82..223d5a939 100644 --- a/js/blocks/components/fetch-input.js +++ b/js/blocks/components/fetch-input.js @@ -135,11 +135,11 @@ class FetchInput extends Component { this.props.debouncedSpeak( /* translators: %d: the number of results */ sprintf( _n( - '%d result found, use up and down arrow keys to navigate.', - '%d results found, use up and down arrow keys to navigate.', - results.length, - 'block-lab' - ), results.length ), 'assertive' ); + '%d result found, use up and down arrow keys to navigate.', + '%d results found, use up and down arrow keys to navigate.', + results.length, + 'block-lab' + ), results.length ), 'assertive' ); if ( null === this.state.selectedSuggestion && '' !== this.getInputValue() ) { this.setState( { diff --git a/webpack.config.js b/webpack.config.js index 4e48e5dad..300e02981 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,7 +3,7 @@ const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); const IgnoreEmitPlugin = require( 'ignore-emit-webpack-plugin' ); const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' ); -const { defaultRequestToExternal, defaultRequestToHandle } = require( '@wordpress/dependency-extraction-webpack-plugin/util' ); +const { defaultRequestToExternal, defaultRequestToHandle } = require( '@wordpress/dependency-extraction-webpack-plugin/lib/util' ); const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); const isProduction = process.env.NODE_ENV === 'production'; From adb761a59e08ddf80f1037c00e6f4e9357f8d21f Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Fri, 7 Aug 2020 16:13:16 -0500 Subject: [PATCH 14/15] Make the version 1.5.6 instead of 1.5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afea8e316..c79ae028f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## Changelog # -### 1.5.5 – 2020-08-10 ### +### 1.5.6 – 2020-08-10 ### Small bugfixes, improved testing From 04458083ebc9335413efa11f9da685864bb7d783 Mon Sep 17 00:00:00 2001 From: Ryan Kienstra Date: Fri, 7 Aug 2020 16:34:52 -0500 Subject: [PATCH 15/15] Fix failed JS test Use fireEvent instead of user to input the color. --- js/blocks/controls/test/color.js | 4 +- package-lock.json | 371 ++++++++++++++++--------------- 2 files changed, 192 insertions(+), 183 deletions(-) diff --git a/js/blocks/controls/test/color.js b/js/blocks/controls/test/color.js index a6136bd0e..6a7f16977 100644 --- a/js/blocks/controls/test/color.js +++ b/js/blocks/controls/test/color.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { render } from '@testing-library/react'; +import { fireEvent, render } from '@testing-library/react'; import user from '@testing-library/user-event'; /** @@ -33,6 +33,6 @@ test( 'color control', async () => { // On entering a new color, it should be sent to the onChange handler. const enteredColor = '#fff'; user.clear( input ); - user.type( input, enteredColor ); + fireEvent.change( input, { target: { value: enteredColor } } ); expect( mockOnChange ).toHaveBeenCalledWith( enteredColor ); } ); diff --git a/package-lock.json b/package-lock.json index 4500fa948..b04abb776 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5357,6 +5357,12 @@ "requires": { "type-fest": "^0.8.1" } + }, + "prettier": { + "version": "npm:wp-prettier@2.0.5", + "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.0.5.tgz", + "integrity": "sha512-5GCgdeevIXwR3cW4Qj5XWC5MO1iSCz8+IPn0mMw6awAt/PBiey8yyO7MhePRsaMqghJAhg6Q3QLYWSnUHWkG6A==", + "dev": true } } }, @@ -9119,12 +9125,6 @@ "integrity": "sha512-sJAofoarcm76ZGpuooaO0eDy8saEy+YoZBLjC4h8srt4jeBnkYeOgqxgsJQTpyt2LjI5PTfLJHSL+41Yu4fEJA==", "dev": true }, - "cli-width": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", - "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", - "dev": true - }, "clipboard": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.6.tgz", @@ -10944,22 +10944,23 @@ } }, "eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.6.0.tgz", + "integrity": "sha512-QlAManNtqr7sozWm5TF4wIH9gmUm2hE3vNRUvyoYAa4y1l5/jxD/PQStEjBMQtCqZmSep8UxrcecI60hOpe61w==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "ajv": "^6.10.0", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", - "eslint-scope": "^5.0.0", - "eslint-utils": "^1.4.3", - "eslint-visitor-keys": "^1.1.0", - "espree": "^6.1.2", - "esquery": "^1.0.1", + "enquirer": "^2.3.5", + "eslint-scope": "^5.1.0", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^1.3.0", + "espree": "^7.2.0", + "esquery": "^1.2.0", "esutils": "^2.0.2", "file-entry-cache": "^5.0.1", "functional-red-black-tree": "^1.0.1", @@ -10968,45 +10969,74 @@ "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", - "inquirer": "^7.0.0", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.14", + "levn": "^0.4.1", + "lodash": "^4.17.19", "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", "natural-compare": "^1.4.0", - "optionator": "^0.8.3", + "optionator": "^0.9.1", "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^6.1.2", - "strip-ansi": "^5.2.0", - "strip-json-comments": "^3.0.1", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", "table": "^5.2.3", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - }, - "dependencies": { - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - } + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" } }, "doctrine": { @@ -11028,6 +11058,12 @@ "estraverse": "^4.1.1" } }, + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true + }, "glob-parent": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", @@ -11046,11 +11082,104 @@ "type-fest": "^0.8.1" } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + } + }, + "optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "requires": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true + }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + }, + "type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "requires": { + "prelude-ls": "^1.2.1" + } + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } } } }, @@ -11547,9 +11676,9 @@ } }, "eslint-utils": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.3.tgz", - "integrity": "sha512-fbBN5W2xdY45KulGXmLHZ3c3FHfVYmKg0IrAKGOkT/464PQsx2UeIzfz1RmEci+KLm1bBaAzZAh8+/E+XAeZ8Q==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" @@ -11562,14 +11691,14 @@ "dev": true }, "espree": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-6.2.1.tgz", - "integrity": "sha512-ysCxRQY3WaXJz9tdbWOwuWr5Y/XrPTGX9Kiz3yoUXwW0VZ4w30HTkQLaGx/+ttFjF8i+ACbArnB4ce68a9m5hw==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.2.0.tgz", + "integrity": "sha512-H+cQ3+3JYRMEIOl87e7QdHX70ocly5iW4+dttuR8iYSPr/hXKFb+7dBsZ7+u1adC4VrnPlTkv0+OwuPnDop19g==", "dev": true, "requires": { - "acorn": "^7.1.1", + "acorn": "^7.3.1", "acorn-jsx": "^5.2.0", - "eslint-visitor-keys": "^1.1.0" + "eslint-visitor-keys": "^1.3.0" }, "dependencies": { "acorn": { @@ -11577,6 +11706,12 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", "integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==", "dev": true + }, + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true } } }, @@ -14620,117 +14755,6 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", "dev": true }, - "inquirer": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", - "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", - "dev": true, - "requires": { - "ansi-escapes": "^4.2.1", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-width": "^3.0.0", - "external-editor": "^3.0.3", - "figures": "^3.0.0", - "lodash": "^4.17.19", - "mute-stream": "0.0.8", - "run-async": "^2.4.0", - "rxjs": "^6.6.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "dev": true, - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", - "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "internal-slot": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.2.tgz", @@ -22464,9 +22488,9 @@ } }, "regexpp": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz", - "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", + "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", "dev": true }, "regexpu-core": { @@ -23040,12 +23064,6 @@ "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==", "dev": true }, - "run-async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", - "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", - "dev": true - }, "run-parallel": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", @@ -23073,15 +23091,6 @@ "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=", "dev": true }, - "rxjs": { - "version": "6.6.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz", - "integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==", - "dev": true, - "requires": { - "tslib": "^1.9.0" - } - }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",