diff --git a/.eslintrc.json b/.eslintrc.json index 7bfdaa16916bd..9ba402ea092db 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -33,6 +33,7 @@ "rules": { "array-bracket-spacing": [ "error", "always" ], "brace-style": [ "error", "1tbs" ], + "comma-dangle": ["error", "always-multiline"], "comma-spacing": "error", "comma-style": "error", "computed-property-spacing": [ "error", "always" ], diff --git a/blocks/api/categories.js b/blocks/api/categories.js index e1343f3b98463..428895b0bb905 100644 --- a/blocks/api/categories.js +++ b/blocks/api/categories.js @@ -5,7 +5,7 @@ * @var {Array} categories */ const categories = [ - { slug: 'common', title: 'Common' } + { slug: 'common', title: 'Common' }, ]; /** diff --git a/blocks/api/factory.js b/blocks/api/factory.js index c5514147f121c..fca97f22c24e5 100644 --- a/blocks/api/factory.js +++ b/blocks/api/factory.js @@ -20,7 +20,7 @@ export function createBlock( blockType, attributes = {} ) { return { uid: uuid(), blockType, - attributes + attributes, }; } @@ -48,6 +48,6 @@ export function switchToBlockType( block, blockType ) { return Object.assign( { uid: block.uid, attributes: transformation.transform( block.attributes ), - blockType + blockType, } ); } diff --git a/blocks/api/index.js b/blocks/api/index.js index 5d010d41932d7..dff1c5456ab3e 100644 --- a/blocks/api/index.js +++ b/blocks/api/index.js @@ -14,5 +14,5 @@ export { setUnknownTypeHandler, getUnknownTypeHandler, getBlockSettings, - getBlocks + getBlocks, } from './registration'; diff --git a/blocks/api/test/factory.js b/blocks/api/test/factory.js index cb1a0265738d5..26a842d44b20b 100644 --- a/blocks/api/test/factory.js +++ b/blocks/api/test/factory.js @@ -20,12 +20,12 @@ describe( 'block factory', () => { describe( 'createBlock()', () => { it( 'should create a block given its blockType and attributes', () => { const block = createBlock( 'core/test-block', { - align: 'left' + align: 'left', } ); expect( block.blockType ).to.eql( 'core/test-block' ); expect( block.attributes ).to.eql( { - align: 'left' + align: 'left', } ); expect( block.uid ).to.be.a( 'string' ); } ); @@ -39,11 +39,11 @@ describe( 'block factory', () => { blocks: [ 'core/text-block' ], transform: ( { value } ) => { return { - value: 'chicken ' + value + value: 'chicken ' + value, }; - } - } ] - } + }, + } ], + }, } ); registerBlock( 'core/text-block', {} ); @@ -51,8 +51,8 @@ describe( 'block factory', () => { uid: 1, blockType: 'core/text-block', attributes: { - value: 'ribs' - } + value: 'ribs', + }, }; const updateBlock = switchToBlockType( block, 'core/updated-text-block' ); @@ -61,8 +61,8 @@ describe( 'block factory', () => { uid: 1, blockType: 'core/updated-text-block', attributes: { - value: 'chicken ribs' - } + value: 'chicken ribs', + }, } ); } ); @@ -74,19 +74,19 @@ describe( 'block factory', () => { blocks: [ 'core/updated-text-block' ], transform: ( { value } ) => { return { - value: 'chicken ' + value + value: 'chicken ' + value, }; - } - } ] - } + }, + } ], + }, } ); const block = { uid: 1, blockType: 'core/text-block', attributes: { - value: 'ribs' - } + value: 'ribs', + }, }; const updateBlock = switchToBlockType( block, 'core/updated-text-block' ); @@ -95,8 +95,8 @@ describe( 'block factory', () => { uid: 1, blockType: 'core/updated-text-block', attributes: { - value: 'chicken ribs' - } + value: 'chicken ribs', + }, } ); } ); @@ -108,8 +108,8 @@ describe( 'block factory', () => { uid: 1, blockType: 'core/text-block', attributes: { - value: 'ribs' - } + value: 'ribs', + }, }; const updateBlock = switchToBlockType( block, 'core/updated-text-block' ); diff --git a/blocks/api/test/parser.js b/blocks/api/test/parser.js index f752390139fb1..76b751e3627e4 100644 --- a/blocks/api/test/parser.js +++ b/blocks/api/test/parser.js @@ -33,27 +33,27 @@ describe( 'block parser', () => { const blockSettings = { attributes: function( rawContent ) { return { - content: rawContent + ' & Chicken' + content: rawContent + ' & Chicken', }; - } + }, }; expect( parseBlockAttributes( 'Ribs', blockSettings ) ).to.eql( { - content: 'Ribs & Chicken' + content: 'Ribs & Chicken', } ); } ); it( 'should use the query object implementation', () => { const blockSettings = { attributes: { - emphasis: text( 'strong' ) - } + emphasis: text( 'strong' ), + }, }; const rawContent = 'Ribs & Chicken'; expect( parseBlockAttributes( rawContent, blockSettings ) ).to.eql( { - emphasis: '& Chicken' + emphasis: '& Chicken', } ); } ); @@ -70,12 +70,12 @@ describe( 'block parser', () => { const blockSettings = { attributes: function( rawContent ) { return { - content: rawContent + ' & Chicken' + content: rawContent + ' & Chicken', }; }, defaultAttributes: { - topic: 'none' - } + topic: 'none', + }, }; const rawContent = 'Ribs'; @@ -84,7 +84,7 @@ describe( 'block parser', () => { expect( getBlockAttributes( blockSettings, rawContent, attrs ) ).to.eql( { align: 'left', topic: 'none', - content: 'Ribs & Chicken' + content: 'Ribs & Chicken', } ); } ); } ); @@ -146,7 +146,7 @@ describe( 'block parser', () => { return { content: rawContent, }; - } + }, } ); const parsed = parse( @@ -168,9 +168,9 @@ describe( 'block parser', () => { registerBlock( 'core/test-block', { attributes: function( rawContent ) { return { - content: rawContent + ' & Chicken' + content: rawContent + ' & Chicken', }; - } + }, } ); const parsed = parse( @@ -182,7 +182,7 @@ describe( 'block parser', () => { expect( parsed ).to.have.lengthOf( 1 ); expect( parsed[ 0 ].blockType ).to.equal( 'core/test-block' ); expect( parsed[ 0 ].attributes ).to.eql( { - content: 'Ribs & Chicken' + content: 'Ribs & Chicken', } ); expect( parsed[ 0 ].uid ).to.be.a( 'string' ); } ); @@ -215,7 +215,7 @@ describe( 'block parser', () => { return { content: rawContent, }; - } + }, } ); setUnknownTypeHandler( 'core/unknown-block' ); diff --git a/blocks/api/test/registration.js b/blocks/api/test/registration.js index 3af2d10dfe6c1..4299d900d66ea 100644 --- a/blocks/api/test/registration.js +++ b/blocks/api/test/registration.js @@ -15,7 +15,7 @@ import { setUnknownTypeHandler, getUnknownTypeHandler, getBlockSettings, - getBlocks + getBlocks, } from '../registration'; describe( 'blocks', () => { diff --git a/blocks/api/test/serializer.js b/blocks/api/test/serializer.js index 89790ba6af5a6..d50961f6c2d2e 100644 --- a/blocks/api/test/serializer.js +++ b/blocks/api/test/serializer.js @@ -66,9 +66,9 @@ describe( 'block serializer', () => { const attributes = getCommentAttributes( { fruit: 'bananas', category: 'food', - ripeness: 'ripe' + ripeness: 'ripe', }, { - fruit: 'bananas' + fruit: 'bananas', } ); expect( attributes ).to.equal( 'category:food ripeness:ripe ' ); @@ -78,9 +78,9 @@ describe( 'block serializer', () => { const attributes = getCommentAttributes( { fruit: 'bananas', category: 'food', - ripeness: undefined + ripeness: undefined, }, { - fruit: 'bananas' + fruit: 'bananas', } ); expect( attributes ).to.equal( 'category:food ' ); @@ -92,12 +92,12 @@ describe( 'block serializer', () => { const blockSettings = { attributes: ( rawContent ) => { return { - content: rawContent + content: rawContent, }; }, save( { attributes } ) { return

; - } + }, }; registerBlock( 'core/test-block', blockSettings ); const blockList = [ @@ -105,9 +105,9 @@ describe( 'block serializer', () => { blockType: 'core/test-block', attributes: { content: 'Ribs & Chicken', - align: 'left' - } - } + align: 'left', + }, + }, ]; const expectedPostContent = '

Ribs & Chicken

'; diff --git a/blocks/components/editable/format-toolbar.js b/blocks/components/editable/format-toolbar.js index 4dbbea38ee10d..65c330d31fddc 100644 --- a/blocks/components/editable/format-toolbar.js +++ b/blocks/components/editable/format-toolbar.js @@ -10,18 +10,18 @@ const FORMATTING_CONTROLS = [ { icon: 'editor-bold', title: wp.i18n.__( 'Bold' ), - format: 'bold' + format: 'bold', }, { icon: 'editor-italic', title: wp.i18n.__( 'Italic' ), - format: 'italic' + format: 'italic', }, { icon: 'editor-strikethrough', title: wp.i18n.__( 'Strikethrough' ), - format: 'strikethrough' - } + format: 'strikethrough', + }, ]; class FormatToolbar extends wp.element.Component { @@ -29,7 +29,7 @@ class FormatToolbar extends wp.element.Component { super( ...arguments ); this.state = { linkValue: props.formats.link ? props.formats.link.value : '', - isEditingLink: false + isEditingLink: false, }; this.addLink = this.addLink.bind( this ); this.editLink = this.editLink.bind( this ); @@ -46,7 +46,7 @@ class FormatToolbar extends wp.element.Component { componentWillReceiveProps( nextProps ) { const newState = { - linkValue: nextProps.formats.link ? nextProps.formats.link.value : '' + linkValue: nextProps.formats.link ? nextProps.formats.link.value : '', }; if ( ! this.props.formats.link || @@ -61,7 +61,7 @@ class FormatToolbar extends wp.element.Component { toggleFormat( format ) { return () => { this.props.onChange( { - [ format ]: ! this.props.formats[ format ] + [ format ]: ! this.props.formats[ format ], } ); }; } @@ -82,7 +82,7 @@ class FormatToolbar extends wp.element.Component { editLink( event ) { event.preventDefault(); this.setState( { - isEditingLink: true + isEditingLink: true, } ); } @@ -90,13 +90,13 @@ class FormatToolbar extends wp.element.Component { event.preventDefault(); this.props.onChange( { link: { value: this.state.linkValue } } ); this.setState( { - isEditingLink: false + isEditingLink: false, } ); } updateLinkValue( event ) { this.setState( { - linkValue: event.target.value + linkValue: event.target.value, } ); } @@ -114,13 +114,13 @@ class FormatToolbar extends wp.element.Component { .map( ( control ) => ( { ...control, onClick: this.toggleFormat( control.format ), - isActive: !! formats[ control.format ] + isActive: !! formats[ control.format ], } ) ) .concat( [ { icon: 'admin-links', title: wp.i18n.__( 'Link' ), onClick: this.addLink, - isActive: !! formats.link + isActive: !! formats.link, } ] ) } /> diff --git a/blocks/components/editable/index.js b/blocks/components/editable/index.js index befb5acf0ac1a..92e357d00d5e9 100644 --- a/blocks/components/editable/index.js +++ b/blocks/components/editable/index.js @@ -20,25 +20,25 @@ const KEYCODE_BACKSPACE = 8; const formatMap = { strong: 'bold', em: 'italic', - del: 'strikethrough' + del: 'strikethrough', }; const ALIGNMENT_CONTROLS = [ { icon: 'editor-alignleft', title: wp.i18n.__( 'Align left' ), - align: 'left' + align: 'left', }, { icon: 'editor-aligncenter', title: wp.i18n.__( 'Align center' ), - align: 'center' + align: 'center', }, { icon: 'editor-alignright', title: wp.i18n.__( 'Align right' ), - align: 'right' - } + align: 'right', + }, ]; function createElement( type, props, ...children ) { @@ -73,7 +73,7 @@ export default class Editable extends wp.element.Component { this.state = { formats: {}, alignment: null, - bookmark: null + bookmark: null, }; } @@ -92,8 +92,8 @@ export default class Editable extends wp.element.Component { convert_urls: false, setup: this.onSetup, formats: { - strikethrough: { inline: 'del' } - } + strikethrough: { inline: 'del' }, + }, }; tinymce.init( config ); @@ -138,7 +138,7 @@ export default class Editable extends wp.element.Component { const position = node.getBoundingClientRect(); return { top: position.top - editorPosition.top + 40 + ( position.height ), - left: position.left - editorPosition.left - 157 + left: position.left - editorPosition.left - 157, }; } @@ -347,7 +347,7 @@ export default class Editable extends wp.element.Component { } ); this.setState( { - formats: merge( {}, this.state.formats, formats ) + formats: merge( {}, this.state.formats, formats ), } ); } @@ -385,12 +385,12 @@ export default class Editable extends wp.element.Component { controls={ ALIGNMENT_CONTROLS.map( ( control ) => ( { ...control, onClick: () => this.toggleAlignment( control.align ), - isActive: this.isAlignmentActive( control.align ) + isActive: this.isAlignmentActive( control.align ), } ) ) } /> } , - element + element, ]; } diff --git a/blocks/library/embed/index.js b/blocks/library/embed/index.js index 3a02a8672fe80..73d6ac84b3fde 100644 --- a/blocks/library/embed/index.js +++ b/blocks/library/embed/index.js @@ -16,7 +16,7 @@ registerBlock( 'core/embed', { attributes: { url: attr( 'iframe', 'src' ), title: attr( 'iframe', 'title' ), - caption: children( 'figcaption' ) + caption: children( 'figcaption' ), }, edit( { attributes, setAttributes, focus, setFocus } ) { @@ -54,5 +54,5 @@ registerBlock( 'core/embed', {
{ caption }
); - } + }, } ); diff --git a/blocks/library/freeform/index.js b/blocks/library/freeform/index.js index 6869417377fe1..17cf18f0bc5ad 100644 --- a/blocks/library/freeform/index.js +++ b/blocks/library/freeform/index.js @@ -13,7 +13,7 @@ registerBlock( 'core/freeform', { category: 'common', attributes: { - html: html() + html: html(), }, edit( { attributes } ) { @@ -29,7 +29,7 @@ registerBlock( 'core/freeform', { save( { attributes } ) { return attributes.html; - } + }, } ); setUnknownTypeHandler( 'core/freeform' ); diff --git a/blocks/library/heading/index.js b/blocks/library/heading/index.js index 6d9104bba0a1c..811c90cc65680 100644 --- a/blocks/library/heading/index.js +++ b/blocks/library/heading/index.js @@ -15,7 +15,7 @@ registerBlock( 'core/heading', { attributes: { content: children( 'h1,h2,h3,h4,h5,h6' ), - nodeName: prop( 'h1,h2,h3,h4,h5,h6', 'nodeName' ) + nodeName: prop( 'h1,h2,h3,h4,h5,h6', 'nodeName' ), }, controls: [ @@ -26,8 +26,8 @@ registerBlock( 'core/heading', { onClick( attributes, setAttributes ) { setAttributes( { nodeName: 'H' + level } ); }, - subscript: level - } ) ) + subscript: level, + } ) ), ], transforms: { @@ -43,10 +43,10 @@ registerBlock( 'core/heading', { } return { nodeName: 'H2', - content + content, }; - } - } + }, + }, ], to: [ { @@ -54,16 +54,16 @@ registerBlock( 'core/heading', { blocks: [ 'core/text' ], transform: ( { content } ) => { return { - content: [ content ] + content: [ content ], }; - } - } - ] + }, + }, + ], }, merge( attributes, attributesToMerge ) { return { - content: wp.element.concatChildren( attributes.content, attributesToMerge.content ) + content: wp.element.concatChildren( attributes.content, attributesToMerge.content ), }; }, diff --git a/blocks/library/image/index.js b/blocks/library/image/index.js index 13ab903b179ae..b29b1a1d7d984 100644 --- a/blocks/library/image/index.js +++ b/blocks/library/image/index.js @@ -35,7 +35,7 @@ registerBlock( 'core/image', { url: attr( 'img', 'src' ), alt: attr( 'img', 'alt' ), caption: children( 'figcaption' ), - align: ( node ) => ( node.className.match( /\balign(\S+)/ ) || [] )[ 1 ] + align: ( node ) => ( node.className.match( /\balign(\S+)/ ) || [] )[ 1 ], }, controls: [ @@ -43,32 +43,32 @@ registerBlock( 'core/image', { icon: 'align-left', title: wp.i18n.__( 'Align left' ), isActive: ( { align } ) => 'left' === align, - onClick: applyOrUnset( 'left' ) + onClick: applyOrUnset( 'left' ), }, { icon: 'align-center', title: wp.i18n.__( 'Align center' ), isActive: ( { align } ) => 'center' === align, - onClick: applyOrUnset( 'center' ) + onClick: applyOrUnset( 'center' ), }, { icon: 'align-right', title: wp.i18n.__( 'Align right' ), isActive: ( { align } ) => 'right' === align, - onClick: applyOrUnset( 'right' ) + onClick: applyOrUnset( 'right' ), }, { icon: 'align-none', title: wp.i18n.__( 'No alignment' ), isActive: ( { align } ) => ! align || 'none' === align, - onClick: applyOrUnset( 'none' ) + onClick: applyOrUnset( 'none' ), }, { icon: 'align-full-width', title: wp.i18n.__( 'Wide width' ), isActive: ( { align } ) => 'wide' === align, - onClick: applyOrUnset( 'wide' ) - } + onClick: applyOrUnset( 'wide' ), + }, ], getEditWrapperProps( attributes ) { @@ -128,5 +128,5 @@ registerBlock( 'core/image', {
{ caption }
); - } + }, } ); diff --git a/blocks/library/list/index.js b/blocks/library/list/index.js index c197b6a5bff54..cb1f63fec806c 100644 --- a/blocks/library/list/index.js +++ b/blocks/library/list/index.js @@ -15,8 +15,8 @@ registerBlock( 'core/list', { attributes: { nodeName: prop( 'ol,ul', 'nodeName' ), items: query( 'li', { - value: children() - } ) + value: children(), + } ), }, controls: [ @@ -26,7 +26,7 @@ registerBlock( 'core/list', { isActive: ( { align } ) => ! align || 'left' === align, onClick( attributes, setAttributes ) { setAttributes( { align: undefined } ); - } + }, }, { icon: 'editor-aligncenter', @@ -34,7 +34,7 @@ registerBlock( 'core/list', { isActive: ( { align } ) => 'center' === align, onClick( attributes, setAttributes ) { setAttributes( { align: 'center' } ); - } + }, }, { icon: 'editor-alignright', @@ -42,7 +42,7 @@ registerBlock( 'core/list', { isActive: ( { align } ) => 'right' === align, onClick( attributes, setAttributes ) { setAttributes( { align: 'right' } ); - } + }, }, { icon: 'editor-justify', @@ -50,8 +50,8 @@ registerBlock( 'core/list', { isActive: ( { align } ) => 'justify' === align, onClick( attributes, setAttributes ) { setAttributes( { align: 'justify' } ); - } - } + }, + }, ], edit( { attributes, focus, setFocus } ) { @@ -81,5 +81,5 @@ registerBlock( 'core/list', {
  • { item.value }
  • ) ) ); - } + }, } ); diff --git a/blocks/library/quote/index.js b/blocks/library/quote/index.js index 807be717b6280..e5c838b12f461 100644 --- a/blocks/library/quote/index.js +++ b/blocks/library/quote/index.js @@ -27,7 +27,7 @@ registerBlock( 'core/quote', { } return Number( match[ 1 ] ); - } + }, }, controls: [ 1, 2 ].map( ( variation ) => ( { @@ -37,7 +37,7 @@ registerBlock( 'core/quote', { onClick( attributes, setAttributes ) { setAttributes( { style: variation } ); }, - subscript: variation + subscript: variation, } ) ), edit( { attributes, setAttributes, focus, setFocus } ) { @@ -50,7 +50,7 @@ registerBlock( 'core/quote', { value={ value } onChange={ ( nextValue ) => setAttributes( { - value: nextValue + value: nextValue, } ) } focus={ focusedEditable === 'value' ? focus : null } @@ -63,7 +63,7 @@ registerBlock( 'core/quote', { value={ citation } onChange={ ( nextCitation ) => setAttributes( { - citation: nextCitation + citation: nextCitation, } ) } focus={ focusedEditable === 'citation' ? focus : null } @@ -86,5 +86,5 @@ registerBlock( 'core/quote', { ); - } + }, } ); diff --git a/blocks/library/text/index.js b/blocks/library/text/index.js index d788e81f2f24b..e5b4766fa4ddc 100644 --- a/blocks/library/text/index.js +++ b/blocks/library/text/index.js @@ -18,12 +18,12 @@ registerBlock( 'core/text', { }, defaultAttributes: { - content:

    + content:

    , }, merge( attributes, attributesToMerge ) { return { - content: wp.element.concatChildren( attributes.content, attributesToMerge.content ) + content: wp.element.concatChildren( attributes.content, attributesToMerge.content ), }; }, @@ -35,7 +35,7 @@ registerBlock( 'core/text', { value={ content } onChange={ ( nextContent ) => { setAttributes( { - content: nextContent + content: nextContent, } ); } } focus={ focus } @@ -43,7 +43,7 @@ registerBlock( 'core/text', { onSplit={ ( before, after ) => { setAttributes( { content: before } ); insertBlockAfter( wp.blocks.createBlock( 'core/text', { - content: after + content: after, } ) ); } } onMerge={ mergeWithPrevious } @@ -55,5 +55,5 @@ registerBlock( 'core/text', { save( { attributes } ) { const { content } = attributes; return content; - } + }, } ); diff --git a/bootstrap-test.js b/bootstrap-test.js index e61e24b526797..05a0f6ff9e960 100644 --- a/bootstrap-test.js +++ b/bootstrap-test.js @@ -8,8 +8,8 @@ global.document = require( 'jsdom' ).jsdom( '', { features: { FetchExternalResources: false, ProcessExternalResources: false, - SkipExternalResources: true - } + SkipExternalResources: true, + }, } ); global.window = document.defaultView; global.requestAnimationFrame = setTimeout; diff --git a/editor/components/block-mover/index.js b/editor/components/block-mover/index.js index 5ee2b5b506c0e..e638aac39a15d 100644 --- a/editor/components/block-mover/index.js +++ b/editor/components/block-mover/index.js @@ -32,20 +32,20 @@ function BlockMover( { onMoveUp, onMoveDown, isFirst, isLast } ) { export default connect( ( state, ownProps ) => ( { isFirst: first( state.blocks.order ) === ownProps.uid, - isLast: last( state.blocks.order ) === ownProps.uid + isLast: last( state.blocks.order ) === ownProps.uid, } ), ( dispatch, ownProps ) => ( { onMoveDown() { dispatch( { type: 'MOVE_BLOCK_DOWN', - uid: ownProps.uid + uid: ownProps.uid, } ); }, onMoveUp() { dispatch( { type: 'MOVE_BLOCK_UP', - uid: ownProps.uid + uid: ownProps.uid, } ); - } + }, } ) )( BlockMover ); diff --git a/editor/components/block-switcher/index.js b/editor/components/block-switcher/index.js index 5c36e65534fdc..a4410335d5bca 100644 --- a/editor/components/block-switcher/index.js +++ b/editor/components/block-switcher/index.js @@ -16,7 +16,7 @@ class BlockSwitcher extends wp.element.Component { super( ...arguments ); this.toggleMenu = this.toggleMenu.bind( this ); this.state = { - open: false + open: false, }; } @@ -30,14 +30,14 @@ class BlockSwitcher extends wp.element.Component { toggleMenu() { this.setState( { - open: ! this.state.open + open: ! this.state.open, } ); } switchBlockType( blockType ) { return () => { this.setState( { - open: false + open: false, } ); this.props.onTransform( this.props.block, blockType ); }; @@ -92,15 +92,15 @@ class BlockSwitcher extends wp.element.Component { export default connect( ( state, ownProps ) => ( { - block: state.blocks.byUid[ ownProps.uid ] + block: state.blocks.byUid[ ownProps.uid ], } ), ( dispatch, ownProps ) => ( { onTransform( block, blockType ) { dispatch( { type: 'SWITCH_BLOCK_TYPE', uid: ownProps.uid, - block: wp.blocks.switchToBlockType( block, blockType ) + block: wp.blocks.switchToBlockType( block, blockType ), } ); - } + }, } ) )( clickOutside( BlockSwitcher ) ); diff --git a/editor/components/button/index.js b/editor/components/button/index.js index 4f56ecd2b7e46..2aabdc7d267a9 100644 --- a/editor/components/button/index.js +++ b/editor/components/button/index.js @@ -9,7 +9,7 @@ function Button( { isPrimary, isLarge, isToggled, className, ...additionalProps button: ( isPrimary || isLarge ), 'button-primary': isPrimary, 'button-large': isLarge, - 'is-toggled': isToggled + 'is-toggled': isToggled, } ); return ( diff --git a/editor/components/inserter/index.js b/editor/components/inserter/index.js index ad9eee3450c05..ec64119c418af 100644 --- a/editor/components/inserter/index.js +++ b/editor/components/inserter/index.js @@ -15,19 +15,19 @@ class Inserter extends wp.element.Component { this.toggle = this.toggle.bind( this ); this.close = this.close.bind( this ); this.state = { - opened: false + opened: false, }; } toggle() { this.setState( { - opened: ! this.state.opened + opened: ! this.state.opened, } ); } close() { this.setState( { - opened: false + opened: false, } ); } diff --git a/editor/components/inserter/menu.js b/editor/components/inserter/menu.js index 1e4a08b1ac85a..e87ece6cd472e 100644 --- a/editor/components/inserter/menu.js +++ b/editor/components/inserter/menu.js @@ -13,14 +13,14 @@ class InserterMenu extends wp.element.Component { constructor() { super( ...arguments ); this.state = { - filterValue: '' + filterValue: '', }; this.filter = this.filter.bind( this ); } filter( event ) { this.setState( { - filterValue: event.target.value + filterValue: event.target.value, } ); } @@ -89,8 +89,8 @@ export default connect( onInsertBlock( slug ) { dispatch( { type: 'INSERT_BLOCK', - block: wp.blocks.createBlock( slug ) + block: wp.blocks.createBlock( slug ), } ); - } + }, } ) )( InserterMenu ); diff --git a/editor/components/toolbar/index.js b/editor/components/toolbar/index.js index 627d691c16c7a..ae6e47b77e1a2 100644 --- a/editor/components/toolbar/index.js +++ b/editor/components/toolbar/index.js @@ -27,7 +27,7 @@ function Toolbar( { controls } ) { control.onClick(); } } className={ classNames( 'editor-toolbar__control', { - 'is-active': control.isActive + 'is-active': control.isActive, } ) } /> ) ) } diff --git a/editor/header/mode-switcher/index.js b/editor/header/mode-switcher/index.js index 0c4e0d893eb44..159066f5c8ab5 100644 --- a/editor/header/mode-switcher/index.js +++ b/editor/header/mode-switcher/index.js @@ -17,12 +17,12 @@ import Dashicon from 'components/dashicon'; const MODES = [ { value: 'visual', - label: wp.i18n.__( 'Visual' ) + label: wp.i18n.__( 'Visual' ), }, { value: 'text', - label: wp.i18n._x( 'Text', 'Name for the Text editor tab (formerly HTML)' ) - } + label: wp.i18n._x( 'Text', 'Name for the Text editor tab (formerly HTML)' ), + }, ]; function ModeSwitcher( { mode, onSwitch } ) { @@ -53,14 +53,14 @@ function ModeSwitcher( { mode, onSwitch } ) { export default connect( ( state ) => ( { - mode: state.mode + mode: state.mode, } ), ( dispatch ) => ( { onSwitch( mode ) { dispatch( { type: 'SWITCH_MODE', - mode: mode + mode: mode, } ); - } + }, } ) )( ModeSwitcher ); diff --git a/editor/header/tools/index.js b/editor/header/tools/index.js index f0089909da877..1419727950c7d 100644 --- a/editor/header/tools/index.js +++ b/editor/header/tools/index.js @@ -54,6 +54,6 @@ export default connect( ( dispatch ) => ( { undo: () => dispatch( { type: 'UNDO' } ), redo: () => dispatch( { type: 'REDO' } ), - toggleSidebar: () => dispatch( { type: 'TOGGLE_SIDEBAR' } ) + toggleSidebar: () => dispatch( { type: 'TOGGLE_SIDEBAR' } ), } ) )( Tools ); diff --git a/editor/index.js b/editor/index.js index 4a003fdf0de39..c6f66a7d5342b 100644 --- a/editor/index.js +++ b/editor/index.js @@ -21,7 +21,7 @@ export function createEditorInstance( id, post ) { const store = createReduxStore(); store.dispatch( { type: 'REPLACE_BLOCKS', - blockNodes: wp.blocks.parse( post.content.raw ) + blockNodes: wp.blocks.parse( post.content.raw ), } ); wp.element.render( diff --git a/editor/layout/index.js b/editor/layout/index.js index 757ea78a89e22..cff3eaa0cdd1d 100644 --- a/editor/layout/index.js +++ b/editor/layout/index.js @@ -15,7 +15,7 @@ import VisualEditor from 'modes/visual-editor'; function Layout( { mode, isSidebarOpened } ) { const className = classnames( 'editor-layout', { - 'is-sidebar-opened': isSidebarOpened + 'is-sidebar-opened': isSidebarOpened, } ); return ( @@ -32,5 +32,5 @@ function Layout( { mode, isSidebarOpened } ) { export default connect( ( state ) => ( { mode: state.mode, - isSidebarOpened: state.isSidebarOpened + isSidebarOpened: state.isSidebarOpened, } ) )( Layout ); diff --git a/editor/modes/text-editor/index.js b/editor/modes/text-editor/index.js index 91bed6ddad1d7..950e2558f3940 100644 --- a/editor/modes/text-editor/index.js +++ b/editor/modes/text-editor/index.js @@ -43,14 +43,14 @@ export default connect( ( state ) => ( { blocks: state.blocks.order.map( ( uid ) => ( state.blocks.byUid[ uid ] - ) ) + ) ), } ), ( dispatch ) => ( { onChange( value ) { dispatch( { type: 'REPLACE_BLOCKS', - blockNodes: wp.blocks.parse( value ) + blockNodes: wp.blocks.parse( value ), } ); - } + }, } ) )( TextEditor ); diff --git a/editor/modes/visual-editor/block.js b/editor/modes/visual-editor/block.js index 65c8ae65a5864..18d444c251e55 100644 --- a/editor/modes/visual-editor/block.js +++ b/editor/modes/visual-editor/block.js @@ -43,8 +43,8 @@ class VisualEditorBlock extends wp.element.Component { onChange( block.uid, { attributes: { ...block.attributes, - ...attributes - } + ...attributes, + }, } ); } @@ -95,8 +95,8 @@ class VisualEditorBlock extends wp.element.Component { onChange( previousBlock.uid, { attributes: { ...previousBlock.attributes, - ...updatedAttributes - } + ...updatedAttributes, + }, } ); onRemove( block.uid ); } @@ -127,7 +127,7 @@ class VisualEditorBlock extends wp.element.Component { const { isHovered, isSelected, isTyping, focus } = this.props; const className = classnames( 'editor-visual-editor__block', { 'is-selected': isSelected && ! isTyping, - 'is-hovered': isHovered + 'is-hovered': isHovered, } ); const { onSelect, onStartTyping, onHover, onMouseLeave, onFocus, onInsertAfter } = this.props; @@ -164,7 +164,7 @@ class VisualEditorBlock extends wp.element.Component { controls={ settings.controls.map( ( control ) => ( { ...control, onClick: () => control.onClick( block.attributes, this.setAttributes ), - isActive: control.isActive( block.attributes ) + isActive: control.isActive( block.attributes ), } ) ) } /> ) } @@ -196,7 +196,7 @@ export default connect( isHovered: state.hoveredBlock === ownProps.uid, focus: state.selectedBlock.uid === ownProps.uid ? state.selectedBlock.focus : null, isTyping: state.selectedBlock.uid === ownProps.uid ? state.selectedBlock.typing : false, - order + order, }; }, ( dispatch, ownProps ) => ( { @@ -204,41 +204,41 @@ export default connect( dispatch( { type: 'UPDATE_BLOCK', uid, - updates + updates, } ); }, onSelect() { dispatch( { type: 'TOGGLE_BLOCK_SELECTED', selected: true, - uid: ownProps.uid + uid: ownProps.uid, } ); }, onDeselect() { dispatch( { type: 'TOGGLE_BLOCK_SELECTED', selected: false, - uid: ownProps.uid + uid: ownProps.uid, } ); }, onStartTyping() { dispatch( { type: 'START_TYPING', - uid: ownProps.uid + uid: ownProps.uid, } ); }, onHover() { dispatch( { type: 'TOGGLE_BLOCK_HOVERED', hovered: true, - uid: ownProps.uid + uid: ownProps.uid, } ); }, onMouseLeave() { dispatch( { type: 'TOGGLE_BLOCK_HOVERED', hovered: false, - uid: ownProps.uid + uid: ownProps.uid, } ); }, @@ -246,7 +246,7 @@ export default connect( dispatch( { type: 'INSERT_BLOCK', after: ownProps.uid, - block + block, } ); }, @@ -254,15 +254,15 @@ export default connect( dispatch( { type: 'UPDATE_FOCUS', uid, - config + config, } ); }, onRemove( uid ) { dispatch( { type: 'REMOVE_BLOCK', - uid + uid, } ); - } + }, } ) )( VisualEditorBlock ); diff --git a/editor/modes/visual-editor/index.js b/editor/modes/visual-editor/index.js index fa63f1f66dd6b..3878729a54d70 100644 --- a/editor/modes/visual-editor/index.js +++ b/editor/modes/visual-editor/index.js @@ -22,5 +22,5 @@ function VisualEditor( { blocks } ) { } export default connect( ( state ) => ( { - blocks: state.blocks.order + blocks: state.blocks.order, } ) )( VisualEditor ); diff --git a/editor/state.js b/editor/state.js index 1ac3ac40dd9f8..48b90eb97cc43 100644 --- a/editor/state.js +++ b/editor/state.js @@ -28,20 +28,20 @@ export const blocks = combineUndoableReducers( { ...state, [ action.uid ]: { ...state[ action.uid ], - ...action.updates - } + ...action.updates, + }, }; case 'INSERT_BLOCK': return { ...state, - [ action.block.uid ]: action.block + [ action.block.uid ]: action.block, }; case 'SWITCH_BLOCK_TYPE': return { ...state, - [ action.uid ]: action.block + [ action.uid ]: action.block, }; case 'REMOVE_BLOCK': @@ -62,7 +62,7 @@ export const blocks = combineUndoableReducers( { return [ ...state.slice( 0, position ), action.block.uid, - ...state.slice( position ) + ...state.slice( position ), ]; case 'MOVE_BLOCK_UP': @@ -75,7 +75,7 @@ export const blocks = combineUndoableReducers( { ...state.slice( 0, index - 1 ), action.uid, swappedUid, - ...state.slice( index + 1 ) + ...state.slice( index + 1 ), ]; case 'MOVE_BLOCK_DOWN': @@ -88,7 +88,7 @@ export const blocks = combineUndoableReducers( { ...state.slice( 0, index ), swappedUid, action.uid, - ...state.slice( index + 2 ) + ...state.slice( index + 2 ), ]; case 'REMOVE_BLOCK': @@ -96,7 +96,7 @@ export const blocks = combineUndoableReducers( { } return state; - } + }, }, { resetTypes: [ 'REPLACE_BLOCKS' ] } ); /** @@ -117,7 +117,7 @@ export function selectedBlock( state = {}, action ) { : { uid: action.uid, typing: false, - focus: action.uid === state.uid ? state.focus : {} + focus: action.uid === state.uid ? state.focus : {}, }; case 'MOVE_BLOCK_UP': @@ -130,14 +130,14 @@ export function selectedBlock( state = {}, action ) { return { uid: action.block.uid, typing: false, - focus: {} + focus: {}, }; case 'UPDATE_FOCUS': return { uid: action.uid, typing: state.uid === action.uid ? state.typing : false, - focus: action.config || {} + focus: action.config || {}, }; case 'START_TYPING': @@ -145,13 +145,13 @@ export function selectedBlock( state = {}, action ) { return { uid: action.uid, typing: true, - focus: {} + focus: {}, }; } return { ...state, - typing: true + typing: true, }; } @@ -218,7 +218,7 @@ export function createReduxStore() { selectedBlock, hoveredBlock, mode, - isSidebarOpened + isSidebarOpened, } ); return createStore( diff --git a/editor/test/state.js b/editor/test/state.js index 688d6c7e64ae3..5b80929a6af41 100644 --- a/editor/test/state.js +++ b/editor/test/state.js @@ -14,7 +14,7 @@ import { selectedBlock, mode, isSidebarOpened, - createReduxStore + createReduxStore, } from '../state'; describe( 'state', () => { @@ -39,7 +39,7 @@ describe( 'state', () => { const original = blocks( undefined, {} ); const state = blocks( original, { type: 'REPLACE_BLOCKS', - blockNodes: [ { uid: 'bananas' } ] + blockNodes: [ { uid: 'bananas' } ], } ); expect( Object.keys( state.byUid ) ).to.have.lengthOf( 1 ); @@ -52,17 +52,17 @@ describe( 'state', () => { type: 'REPLACE_BLOCKS', blockNodes: [ { uid: 'kumquat', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { type: 'UPDATE_BLOCK', uid: 'kumquat', updates: { attributes: { - updated: true - } - } + updated: true, + }, + }, } ); expect( state.byUid.kumquat.attributes.updated ).to.be.true(); @@ -74,15 +74,15 @@ describe( 'state', () => { blockNodes: [ { uid: 'chicken', blockType: 'core/test-block', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { type: 'INSERT_BLOCK', block: { uid: 'ribs', - blockType: 'core/freeform' - } + blockType: 'core/freeform', + }, } ); expect( Object.keys( state.byUid ) ).to.have.lengthOf( 2 ); @@ -96,16 +96,16 @@ describe( 'state', () => { blockNodes: [ { uid: 'chicken', blockType: 'core/test-block', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { type: 'SWITCH_BLOCK_TYPE', uid: 'chicken', block: { uid: 'chicken', - blockType: 'core/freeform' - } + blockType: 'core/freeform', + }, } ); expect( Object.keys( state.byUid ) ).to.have.lengthOf( 1 ); @@ -118,16 +118,16 @@ describe( 'state', () => { blockNodes: [ { uid: 'chicken', blockType: 'core/test-block', - attributes: {} + attributes: {}, }, { uid: 'ribs', blockType: 'core/test-block', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { type: 'MOVE_BLOCK_UP', - uid: 'ribs' + uid: 'ribs', } ); expect( state.order ).to.eql( [ 'ribs', 'chicken' ] ); @@ -139,16 +139,16 @@ describe( 'state', () => { blockNodes: [ { uid: 'chicken', blockType: 'core/test-block', - attributes: {} + attributes: {}, }, { uid: 'ribs', blockType: 'core/test-block', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { type: 'MOVE_BLOCK_UP', - uid: 'chicken' + uid: 'chicken', } ); expect( state.order ).to.equal( original.order ); @@ -160,16 +160,16 @@ describe( 'state', () => { blockNodes: [ { uid: 'chicken', blockType: 'core/test-block', - attributes: {} + attributes: {}, }, { uid: 'ribs', blockType: 'core/test-block', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { type: 'MOVE_BLOCK_DOWN', - uid: 'chicken' + uid: 'chicken', } ); expect( state.order ).to.eql( [ 'ribs', 'chicken' ] ); @@ -181,16 +181,16 @@ describe( 'state', () => { blockNodes: [ { uid: 'chicken', blockType: 'core/test-block', - attributes: {} + attributes: {}, }, { uid: 'ribs', blockType: 'core/test-block', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { type: 'MOVE_BLOCK_DOWN', - uid: 'ribs' + uid: 'ribs', } ); expect( state.order ).to.equal( original.order ); @@ -202,16 +202,16 @@ describe( 'state', () => { blockNodes: [ { uid: 'chicken', blockType: 'core/test-block', - attributes: {} + attributes: {}, }, { uid: 'ribs', blockType: 'core/test-block', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { type: 'REMOVE_BLOCK', - uid: 'chicken' + uid: 'chicken', } ); expect( state.order ).to.eql( [ 'ribs' ] ); @@ -219,8 +219,8 @@ describe( 'state', () => { ribs: { uid: 'ribs', blockType: 'core/test-block', - attributes: {} - } + attributes: {}, + }, } ); } ); } ); @@ -230,7 +230,7 @@ describe( 'state', () => { const state = hoveredBlock( null, { type: 'TOGGLE_BLOCK_HOVERED', uid: 'kumquat', - hovered: true + hovered: true, } ); expect( state ).to.equal( 'kumquat' ); @@ -240,7 +240,7 @@ describe( 'state', () => { const state = hoveredBlock( 'kumquat', { type: 'TOGGLE_BLOCK_SELECTED', uid: 'kumquat', - selected: true + selected: true, } ); expect( state ).to.be.null(); @@ -252,7 +252,7 @@ describe( 'state', () => { const state = selectedBlock( undefined, { type: 'TOGGLE_BLOCK_SELECTED', uid: 'kumquat', - selected: true + selected: true, } ); expect( state ).to.eql( { uid: 'kumquat', typing: false, focus: {} } ); @@ -263,7 +263,7 @@ describe( 'state', () => { const state = selectedBlock( original, { type: 'TOGGLE_BLOCK_SELECTED', uid: 'kumquat', - selected: true + selected: true, } ); expect( state ).to.equal( original ); @@ -274,13 +274,13 @@ describe( 'state', () => { const state = selectedBlock( original, { type: 'TOGGLE_BLOCK_SELECTED', uid: 'kumquat', - selected: true + selected: true, } ); expect( state ).to.eql( { uid: 'kumquat', typing: false, - focus: { editable: 'content' } + focus: { editable: 'content' }, } ); } ); @@ -289,7 +289,7 @@ describe( 'state', () => { const state = selectedBlock( original, { type: 'TOGGLE_BLOCK_SELECTED', uid: 'kumquat', - selected: false + selected: false, } ); expect( state ).to.eql( {} ); @@ -300,7 +300,7 @@ describe( 'state', () => { const state = selectedBlock( original, { type: 'TOGGLE_BLOCK_SELECTED', uid: 'kumquat', - selected: false + selected: false, } ); expect( state ).to.equal( original ); @@ -311,8 +311,8 @@ describe( 'state', () => { type: 'INSERT_BLOCK', block: { uid: 'ribs', - blockType: 'core/freeform' - } + blockType: 'core/freeform', + }, } ); expect( state ).to.eql( { uid: 'ribs', typing: false, focus: {} } ); @@ -321,7 +321,7 @@ describe( 'state', () => { it( 'should return with block moved up', () => { const state = selectedBlock( undefined, { type: 'MOVE_BLOCK_UP', - uid: 'ribs' + uid: 'ribs', } ); expect( state ).to.eql( { uid: 'ribs', typing: false, focus: {} } ); @@ -330,7 +330,7 @@ describe( 'state', () => { it( 'should return with block moved down', () => { const state = selectedBlock( undefined, { type: 'MOVE_BLOCK_DOWN', - uid: 'chicken' + uid: 'chicken', } ); expect( state ).to.eql( { uid: 'chicken', typing: false, focus: {} } ); @@ -340,7 +340,7 @@ describe( 'state', () => { const original = deepFreeze( { uid: 'ribs', typing: true, focus: {} } ); const state = selectedBlock( original, { type: 'MOVE_BLOCK_UP', - uid: 'ribs' + uid: 'ribs', } ); expect( state ).to.equal( original ); @@ -350,7 +350,7 @@ describe( 'state', () => { const state = selectedBlock( undefined, { type: 'UPDATE_FOCUS', uid: 'chicken', - config: { editable: 'citation' } + config: { editable: 'citation' }, } ); expect( state ).to.eql( { uid: 'chicken', typing: false, focus: { editable: 'citation' } } ); @@ -361,7 +361,7 @@ describe( 'state', () => { const state = selectedBlock( original, { type: 'UPDATE_FOCUS', uid: 'ribs', - config: { editable: 'citation' } + config: { editable: 'citation' }, } ); expect( state ).to.eql( { uid: 'ribs', typing: true, focus: { editable: 'citation' } } ); @@ -370,7 +370,7 @@ describe( 'state', () => { it( 'should set the typing flag and selects the block', () => { const state = selectedBlock( undefined, { type: 'START_TYPING', - uid: 'chicken' + uid: 'chicken', } ); expect( state ).to.eql( { uid: 'chicken', typing: true, focus: {} } ); @@ -380,7 +380,7 @@ describe( 'state', () => { const original = deepFreeze( { uid: 'ribs', typing: false, focus: { editable: 'citation' } } ); const state = selectedBlock( original, { type: 'START_TYPING', - uid: 'ribs' + uid: 'ribs', } ); expect( state ).to.eql( { uid: 'ribs', typing: true, focus: { editable: 'citation' } } ); @@ -392,12 +392,12 @@ describe( 'state', () => { blockNodes: [ { uid: 'kumquat', blockType: 'core/test-block', - attributes: {} + attributes: {}, }, { uid: 'loquat', blockType: 'core/test-block', - attributes: {} - } ] + attributes: {}, + } ], } ); const state = blocks( original, { @@ -405,8 +405,8 @@ describe( 'state', () => { after: 'kumquat', block: { uid: 'persimmon', - blockType: 'core/freeform' - } + blockType: 'core/freeform', + }, } ); expect( Object.keys( state.byUid ) ).to.have.lengthOf( 3 ); @@ -424,7 +424,7 @@ describe( 'state', () => { it( 'should return switched mode', () => { const state = mode( null, { type: 'SWITCH_MODE', - mode: 'text' + mode: 'text', } ); expect( state ).to.equal( 'text' ); @@ -440,7 +440,7 @@ describe( 'state', () => { it( 'should toggle the sidebar open flag', () => { const state = isSidebarOpened( false, { - type: 'TOGGLE_SIDEBAR' + type: 'TOGGLE_SIDEBAR', } ); expect( state ).to.be.true(); @@ -464,7 +464,7 @@ describe( 'state', () => { 'selectedBlock', 'hoveredBlock', 'mode', - 'isSidebarOpened' + 'isSidebarOpened', ] ); } ); } ); diff --git a/editor/utils/test/undoable-reducer.js b/editor/utils/test/undoable-reducer.js index 6f30f0e1a93a5..5c85ec36276d1 100644 --- a/editor/utils/test/undoable-reducer.js +++ b/editor/utils/test/undoable-reducer.js @@ -21,7 +21,7 @@ describe( 'undoableReducer', () => { expect( reducer( undefined, {} ) ).to.eql( { past: [], present: 0, - future: [] + future: [], } ); } ); @@ -35,7 +35,7 @@ describe( 'undoableReducer', () => { expect( state ).to.eql( { past: [ 0 ], present: 1, - future: [] + future: [], } ); } ); @@ -50,7 +50,7 @@ describe( 'undoableReducer', () => { expect( state ).to.eql( { past: [], present: 0, - future: [ 1 ] + future: [ 1 ], } ); } ); @@ -66,7 +66,7 @@ describe( 'undoableReducer', () => { expect( state ).to.eql( { past: [ 0 ], present: 1, - future: [] + future: [], } ); } ); @@ -83,7 +83,7 @@ describe( 'undoableReducer', () => { expect( state ).to.eql( { past: [ 1, 2 ], present: 3, - future: [] + future: [], } ); } ); } ); @@ -91,7 +91,7 @@ describe( 'undoableReducer', () => { describe( 'combineUndoableReducers()', () => { it( 'should return a combined reducer with getters', () => { const reducer = combineUndoableReducers( { - count: ( state = 0 ) => state + count: ( state = 0 ) => state, } ); const state = reducer( undefined, {} ); @@ -101,9 +101,9 @@ describe( 'undoableReducer', () => { expect( state.history ).to.eql( { past: [], present: { - count: 0 + count: 0, }, - future: [] + future: [], } ); } ); } ); diff --git a/editor/utils/undoable-reducer.js b/editor/utils/undoable-reducer.js index f9644381f1c94..d254bcea3721f 100644 --- a/editor/utils/undoable-reducer.js +++ b/editor/utils/undoable-reducer.js @@ -17,7 +17,7 @@ export function undoable( reducer, options = {} ) { const initialState = { past: [], present: reducer( undefined, {} ), - future: [] + future: [], }; return ( state = initialState, action ) => { @@ -28,14 +28,14 @@ export function undoable( reducer, options = {} ) { return { past: past.slice( 0, past.length - 1 ), present: past[ past.length - 1 ], - future: [ present, ...future ] + future: [ present, ...future ], }; case 'REDO': return { past: [ ...past, present ], present: future[ 0 ], - future: future.slice( 1 ) + future: future.slice( 1 ), }; } @@ -45,7 +45,7 @@ export function undoable( reducer, options = {} ) { return { past: [], present: nextPresent, - future: [] + future: [], }; } @@ -56,7 +56,7 @@ export function undoable( reducer, options = {} ) { return { past: [ ...past, present ], present: nextPresent, - future: [] + future: [], }; }; } @@ -82,7 +82,7 @@ export function combineUndoableReducers( reducers, options ) { memo[ key ] = { get: function() { return this.history.present[ key ]; - } + }, }; return memo; diff --git a/element/index.js b/element/index.js index b575ae14d36d8..2ef9be0de596e 100644 --- a/element/index.js +++ b/element/index.js @@ -81,7 +81,7 @@ export function concatChildren( ...childrens ) { Children.forEach( children, ( child, j ) => { if ( 'string' !== typeof child ) { child = cloneElement( child, { - key: [ i, j ].join() + key: [ i, j ].join(), } ); } diff --git a/element/test/index.js b/element/test/index.js index 842ac6a0465e1..3c7806443a319 100644 --- a/element/test/index.js +++ b/element/test/index.js @@ -25,7 +25,7 @@ describe( 'element', () => { expect( renderToString( [ 'Zucchini ', createElement( 'em', null, 'is a' ), - ' summer squash' + ' summer squash', ] ) ).to.equal( 'Zucchini is a summer squash' ); } ); diff --git a/i18n/babel-plugin.js b/i18n/babel-plugin.js index df9607c9c57c7..2f96c5b5cde8a 100644 --- a/i18n/babel-plugin.js +++ b/i18n/babel-plugin.js @@ -44,7 +44,7 @@ const { writeFileSync } = require( 'fs' ); */ const DEFAULT_HEADERS = { 'content-type': 'text/plain; charset=UTF-8', - 'x-generator': 'babel-plugin-wp-i18n' + 'x-generator': 'babel-plugin-wp-i18n', }; /** @@ -58,7 +58,7 @@ const DEFAULT_FUNCTIONS = { __: [ 'msgid' ], _n: [ 'msgid', 'msgid_plural' ], _x: [ 'msgid', 'msgctxt' ], - _nx: [ 'msgid', 'msgctxt', 'msgid_plural' ] + _nx: [ 'msgid', 'msgctxt', 'msgid_plural' ], }; /** @@ -175,10 +175,10 @@ module.exports = function() { '': { '': { msgid: '', - msgstr: [] - } - } - } + msgstr: [], + }, + }, + }, }; for ( const key in baseData.headers ) { @@ -202,7 +202,7 @@ module.exports = function() { // Assign file reference comment const { filename } = this.file.opts; translation.comments = { - reference: relative( process.cwd(), filename ) + ':' + path.node.loc.start.line + reference: relative( process.cwd(), filename ) + ':' + path.node.loc.start.line, }; // If exists, also assign translator comment @@ -252,7 +252,7 @@ module.exports = function() { if ( isSameTranslation( translation, memo[ msgctxt ][ msgid ] ) ) { translation.comments.reference = uniq( [ memo[ msgctxt ][ msgid ].comments.reference, - translation.comments.reference + translation.comments.reference, ].join( '\n' ).split( '\n' ) ).join( '\n' ); } @@ -273,9 +273,9 @@ module.exports = function() { const compiled = po.compile( data ); writeFileSync( state.opts.output || DEFAULT_OUTPUT, compiled ); this.hasPendingWrite = false; - } - } - } + }, + }, + }, }; }; diff --git a/webpack.config.js b/webpack.config.js index 352778f3eedfc..198760222db7a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,36 +12,36 @@ const config = { i18n: './i18n/index.js', blocks: './blocks/index.js', editor: './editor/index.js', - element: './element/index.js' + element: './element/index.js', }, output: { filename: '[name]/build/index.js', path: __dirname, library: [ 'wp', '[name]' ], - libraryTarget: 'this' + libraryTarget: 'this', }, externals: { react: 'React', 'react-dom': 'ReactDOM', - 'react-dom/server': 'ReactDOMServer' + 'react-dom/server': 'ReactDOMServer', }, resolve: { alias: { // There are currently resolution errors on RSF's "mitt" dependency // when imported as native ES module - 'react-slot-fill': 'react-slot-fill/lib/rsf.js' - } + 'react-slot-fill': 'react-slot-fill/lib/rsf.js', + }, }, module: { rules: [ { test: /\.pegjs/, - use: 'pegjs-loader' + use: 'pegjs-loader', }, { test: /\.js$/, exclude: /node_modules/, - use: 'babel-loader' + use: 'babel-loader', }, { test: /\.s?css$/, @@ -55,32 +55,32 @@ const config = { includePaths: [ 'editor/assets/stylesheets' ], data: '@import "variables"; @import "mixins"; @import "animations";', outputStyle: 'production' === process.env.NODE_ENV ? - 'compressed' : 'nested' - } - } - ] - } ) - } - ] + 'compressed' : 'nested', + }, + }, + ], + } ), + }, + ], }, plugins: [ new ResolveEntryModulesPlugin(), new ExtractTextPlugin( { - filename: './[name]/build/style.css' + filename: './[name]/build/style.css', } ), new webpack.LoaderOptionsPlugin( { minimize: process.env.NODE_ENV === 'production', debug: process.env.NODE_ENV !== 'production', options: { postcss: [ - require( 'autoprefixer' ) - ] - } - } ) + require( 'autoprefixer' ), + ], + }, + } ), ], stats: { - children: false - } + children: false, + }, }; switch ( process.env.NODE_ENV ) { @@ -93,21 +93,21 @@ switch ( process.env.NODE_ENV ) { config.module.rules = [ ...[ 'i18n', 'element', 'blocks', 'editor' ].map( ( entry ) => ( { test: require.resolve( './' + entry + '/index.js' ), - use: 'expose-loader?wp.' + entry + use: 'expose-loader?wp.' + entry, } ) ), - ...config.module.rules + ...config.module.rules, ]; config.entry = [ './i18n/index.js', './element/index.js', './blocks/index.js', './editor/index.js', - ...glob.sync( `./{${ Object.keys( config.entry ).join() }}/**/test/*.js` ) + ...glob.sync( `./{${ Object.keys( config.entry ).join() }}/**/test/*.js` ), ]; config.externals = [ require( 'webpack-node-externals' )() ]; config.output = { filename: 'build/test.js', - path: __dirname + path: __dirname, }; config.plugins.push( new webpack.ProvidePlugin( { tinymce: 'tinymce/tinymce',