From 9c1b097225c3d2ed0dbdff9d3607364c4936918e Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Mon, 17 Jun 2024 09:17:27 +0200 Subject: [PATCH] Autoformat e2e-tests package (#62572) * Remove prettier ignore for e2e-tests * Apply autoformatting --- Co-authored-by: sirreal Co-authored-by: Mamaduka --- .prettierignore | 1 - .../plugins/deprecated-node-matcher/index.js | 2 +- packages/e2e-tests/plugins/hooks-api/index.js | 2 +- .../plugins/iframed-block/jquery.test.js | 4 +- .../e2e-tests/plugins/iframed-block/script.js | 1 - .../iframed-enqueue-block-assets/script.js | 3 +- .../plugins/iframed-masonry-block/editor.js | 12 +- .../plugins/iframed-masonry-block/script.js | 1 - .../iframed-multiple-stylesheets/block.json | 6 +- .../inner-blocks-allowed-blocks/index.js | 16 ++- .../index.js | 72 ++++++------ .../plugins/inner-blocks-templates/index.js | 103 +++++++++++------- .../directive-context/view.js | 7 +- .../interactive-blocks/directive-each/view.js | 79 ++++++++------ .../interactive-blocks/directive-key/view.js | 2 +- .../directive-on-document/view.js | 4 +- .../directive-on-window/view.js | 6 +- .../directive-priorities/view.js | 9 +- .../interactive-blocks/directive-run/view.js | 40 ++++--- .../interactive-blocks/directive-text/view.js | 5 +- .../directive-watch/view.js | 4 +- .../interactive-blocks/namespace/view.js | 6 - .../router-navigate/view.js | 6 +- .../interactive-blocks/router-regions/view.js | 2 +- .../interactive-blocks/tovdom/cdata.js | 4 +- .../interactive-blocks/with-scope/view.js | 18 +-- .../plugins-api/annotations-sidebar.js | 11 +- .../plugins/plugins-api/error-boundary.js | 2 +- .../plugins/test-autocompleter/index.js | 10 +- 29 files changed, 242 insertions(+), 196 deletions(-) diff --git a/.prettierignore b/.prettierignore index 0b73d70681dbb0..642f7273d61043 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,7 +3,6 @@ build build-module build-types packages/block-serialization-spec-parser/parser.js -packages/e2e-tests/plugins packages/react-native-editor/bundle packages/url/src/test/fixtures vendor diff --git a/packages/e2e-tests/plugins/deprecated-node-matcher/index.js b/packages/e2e-tests/plugins/deprecated-node-matcher/index.js index 94b59f6190166e..3cb1afd56f18ef 100644 --- a/packages/e2e-tests/plugins/deprecated-node-matcher/index.js +++ b/packages/e2e-tests/plugins/deprecated-node-matcher/index.js @@ -70,7 +70,7 @@ } ); }, } ) - ) + ); }, save( { attributes } ) { return el( diff --git a/packages/e2e-tests/plugins/hooks-api/index.js b/packages/e2e-tests/plugins/hooks-api/index.js index 3b25ad15fbcae8..9c8fff9bfa4562 100644 --- a/packages/e2e-tests/plugins/hooks-api/index.js +++ b/packages/e2e-tests/plugins/hooks-api/index.js @@ -16,7 +16,7 @@ Button, { className: 'e2e-reset-block-button', - variant: "secondary", + variant: 'secondary', onClick() { const emptyBlock = createBlock( props.name ); props.onReplace( emptyBlock ); diff --git a/packages/e2e-tests/plugins/iframed-block/jquery.test.js b/packages/e2e-tests/plugins/iframed-block/jquery.test.js index 901a6f1281927b..03a790d3f3526c 100644 --- a/packages/e2e-tests/plugins/iframed-block/jquery.test.js +++ b/packages/e2e-tests/plugins/iframed-block/jquery.test.js @@ -1,6 +1,6 @@ ( ( $ ) => { - $.fn.test = function() { - return this.each( function() { + $.fn.test = function () { + return this.each( function () { $( this ).text( 'Iframed Block (set with jQuery)' ); } ); }; diff --git a/packages/e2e-tests/plugins/iframed-block/script.js b/packages/e2e-tests/plugins/iframed-block/script.js index f8872070f682b7..6da6a8487bdb2c 100644 --- a/packages/e2e-tests/plugins/iframed-block/script.js +++ b/packages/e2e-tests/plugins/iframed-block/script.js @@ -4,4 +4,3 @@ $( '.wp-block-test-iframed-block' ).test(); } ); } )( window ); - diff --git a/packages/e2e-tests/plugins/iframed-enqueue-block-assets/script.js b/packages/e2e-tests/plugins/iframed-enqueue-block-assets/script.js index f0eddd65c70ebe..4067d55bc5bea9 100644 --- a/packages/e2e-tests/plugins/iframed-enqueue-block-assets/script.js +++ b/packages/e2e-tests/plugins/iframed-enqueue-block-assets/script.js @@ -1,3 +1,4 @@ window.addEventListener( 'load', () => { - document.body.dataset.iframedEnqueueBlockAssetsL10n = window.iframedEnqueueBlockAssetsL10n.test; + document.body.dataset.iframedEnqueueBlockAssetsL10n = + window.iframedEnqueueBlockAssetsL10n.test; } ); diff --git a/packages/e2e-tests/plugins/iframed-masonry-block/editor.js b/packages/e2e-tests/plugins/iframed-masonry-block/editor.js index eebd7d370e085a..f481ad54b6ac60 100644 --- a/packages/e2e-tests/plugins/iframed-masonry-block/editor.js +++ b/packages/e2e-tests/plugins/iframed-masonry-block/editor.js @@ -6,18 +6,24 @@ const content = [ el( 'div', { className: 'grid-item' } ), - el( 'div', { className: 'grid-item grid-item--width2 grid-item--height2' } ), + el( 'div', { + className: 'grid-item grid-item--width2 grid-item--height2', + } ), el( 'div', { className: 'grid-item grid-item--height3' } ), el( 'div', { className: 'grid-item grid-item--height2' } ), el( 'div', { className: 'grid-item grid-item--width3' } ), el( 'div', { className: 'grid-item' } ), el( 'div', { className: 'grid-item' } ), el( 'div', { className: 'grid-item grid-item--height2' } ), - el( 'div', { className: 'grid-item grid-item--width2 grid-item--height3' } ), + el( 'div', { + className: 'grid-item grid-item--width2 grid-item--height3', + } ), el( 'div', { className: 'grid-item' } ), el( 'div', { className: 'grid-item grid-item--height2' } ), el( 'div', { className: 'grid-item' } ), - el( 'div', { className: 'grid-item grid-item--width2 grid-item--height2' } ), + el( 'div', { + className: 'grid-item grid-item--width2 grid-item--height2', + } ), el( 'div', { className: 'grid-item grid-item--width2' } ), el( 'div', { className: 'grid-item' } ), el( 'div', { className: 'grid-item grid-item--height2' } ), diff --git a/packages/e2e-tests/plugins/iframed-masonry-block/script.js b/packages/e2e-tests/plugins/iframed-masonry-block/script.js index e287e6ec2e9745..0b2ae603fcdc97 100644 --- a/packages/e2e-tests/plugins/iframed-masonry-block/script.js +++ b/packages/e2e-tests/plugins/iframed-masonry-block/script.js @@ -10,4 +10,3 @@ } ); } ); } )( window ); - diff --git a/packages/e2e-tests/plugins/iframed-multiple-stylesheets/block.json b/packages/e2e-tests/plugins/iframed-multiple-stylesheets/block.json index 82d60867af99e2..d803e6412ecb00 100644 --- a/packages/e2e-tests/plugins/iframed-multiple-stylesheets/block.json +++ b/packages/e2e-tests/plugins/iframed-multiple-stylesheets/block.json @@ -12,5 +12,9 @@ "textdomain": "iframed-multiple-stylesheets", "editorScript": "iframed-multiple-stylesheets-editor-script", "editorStyle": "file:./editor.css", - "style": [ "iframed-multiple-stylesheets-style", "iframed-multiple-stylesheets-style2", "file:./style3.css" ] + "style": [ + "iframed-multiple-stylesheets-style", + "iframed-multiple-stylesheets-style2", + "file:./style3.css" + ] } diff --git a/packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js b/packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js index 5bcfed61519833..5b382cfa7d6339 100644 --- a/packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js +++ b/packages/e2e-tests/plugins/inner-blocks-allowed-blocks/index.js @@ -10,7 +10,11 @@ const allowedBlocksWhenSingleEmptyChild = [ 'core/image', 'core/list' ]; const allowedBlocksWhenTwoChildren = [ 'core/gallery', 'core/video' ]; - const allowedBlocksWhenTreeOrMoreChildren = [ 'core/gallery', 'core/video', 'core/list' ]; + const allowedBlocksWhenTreeOrMoreChildren = [ + 'core/gallery', + 'core/video', + 'core/list', + ]; registerBlockType( 'test/allowed-blocks-dynamic', { apiVersion: 3, @@ -26,15 +30,15 @@ }, [ props.clientId ] ); - const blockProps = useBlockProps({ + const blockProps = useBlockProps( { ...divProps, 'data-number-of-children': numberOfChildren, - }); + } ); let allowedBlocks = allowedBlocksWhenSingleEmptyChild; if ( numberOfChildren === 2 ) { allowedBlocks = allowedBlocksWhenTwoChildren; - } else if( numberOfChildren > 2 ){ + } else if ( numberOfChildren > 2 ) { allowedBlocks = allowedBlocksWhenTreeOrMoreChildren; } @@ -42,12 +46,12 @@ 'div', blockProps, el( InnerBlocks, { - allowedBlocks + allowedBlocks, } ) ); }, save() { return el( 'div', divProps, el( InnerBlocks.Content ) ); - } + }, } ); } )(); diff --git a/packages/e2e-tests/plugins/inner-blocks-prioritized-inserter-blocks/index.js b/packages/e2e-tests/plugins/inner-blocks-prioritized-inserter-blocks/index.js index d5ded59237a182..b5b407a650c7cb 100644 --- a/packages/e2e-tests/plugins/inner-blocks-prioritized-inserter-blocks/index.js +++ b/packages/e2e-tests/plugins/inner-blocks-prioritized-inserter-blocks/index.js @@ -3,16 +3,14 @@ const { createElement: el } = wp.element; const { InnerBlocks } = wp.blockEditor; - const divProps = { + const divProps = { className: 'product', style: { outline: '1px solid gray', padding: 5 }, }; - // without a placeholder within the inner blocks it can be difficult to select the block using e2e tests - // especially using Puppeteer, so we use an image block which has a placeholder. - const template = [ - [ 'core/image' ], - ]; + // without a placeholder within the inner blocks it can be difficult to select the block using e2e tests + // especially using Puppeteer, so we use an image block which has a placeholder. + const template = [ [ 'core/image' ] ]; const save = function () { return el( 'div', divProps, el( InnerBlocks.Content ) ); @@ -38,11 +36,11 @@ 'div', divProps, el( InnerBlocks, { - template, + template, prioritizedInserterBlocks: [ - 'core/audio', + 'core/audio', 'core/spacer', - 'core/code', + 'core/code', ], } ) ); @@ -51,32 +49,34 @@ save, } ); - registerBlockType( 'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks', { - title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks', - icon: 'carrot', - category: 'text', - edit() { - return el( - 'div', - divProps, - el( InnerBlocks, { - template, - allowedBlocks: [ - 'core/spacer', - 'core/code', - 'core/paragraph', - 'core/heading' - ], - prioritizedInserterBlocks: [ - 'core/audio', // this is **not** in the allowedBlocks list - 'core/spacer', - 'core/code', - ], - } ) - ); - }, - - save, - } ); + registerBlockType( + 'test/prioritized-inserter-blocks-set-with-conflicting-allowed-blocks', + { + title: 'Prioritized Inserter Blocks Set With Conflicting Allowed Blocks', + icon: 'carrot', + category: 'text', + edit() { + return el( + 'div', + divProps, + el( InnerBlocks, { + template, + allowedBlocks: [ + 'core/spacer', + 'core/code', + 'core/paragraph', + 'core/heading', + ], + prioritizedInserterBlocks: [ + 'core/audio', // this is **not** in the allowedBlocks list + 'core/spacer', + 'core/code', + ], + } ) + ); + }, + save, + } + ); } )(); diff --git a/packages/e2e-tests/plugins/inner-blocks-templates/index.js b/packages/e2e-tests/plugins/inner-blocks-templates/index.js index b03b07e11e38a2..d3d9b3e3097d56 100644 --- a/packages/e2e-tests/plugins/inner-blocks-templates/index.js +++ b/packages/e2e-tests/plugins/inner-blocks-templates/index.js @@ -53,9 +53,13 @@ category: 'text', edit: function InnerBlocksNoLockingEdit() { - return el( 'div', useBlockProps(), el( InnerBlocks, { - template: TEMPLATE, - } ) ); + return el( + 'div', + useBlockProps(), + el( InnerBlocks, { + template: TEMPLATE, + } ) + ); }, save, @@ -68,10 +72,14 @@ category: 'text', edit: function InnerBlocksBlocksLockingAllEdit() { - return el( 'div', useBlockProps(), el( InnerBlocks, { - template: TEMPLATE, - templateLock: 'all', - } ) ); + return el( + 'div', + useBlockProps(), + el( InnerBlocks, { + template: TEMPLATE, + templateLock: 'all', + } ) + ); }, save, @@ -92,7 +100,9 @@ edit: function InnerBlocksUpdateLockedTemplateEdit( props ) { const hasUpdatedTemplated = props.attributes.hasUpdatedTemplate; - return el( 'div', null, + return el( + 'div', + null, el( 'button', { @@ -102,12 +112,16 @@ }, 'Update template' ), - el( 'div', useBlockProps(), el( InnerBlocks, { - template: hasUpdatedTemplated - ? TEMPLATE_TWO_PARAGRAPHS - : TEMPLATE, - templateLock: 'all', - } ) ), + el( + 'div', + useBlockProps(), + el( InnerBlocks, { + template: hasUpdatedTemplated + ? TEMPLATE_TWO_PARAGRAPHS + : TEMPLATE, + templateLock: 'all', + } ) + ) ); }, @@ -121,10 +135,14 @@ category: 'text', edit: function InnerBlocksParagraphPlaceholderEdit() { - return el( 'div', useBlockProps(), el( InnerBlocks, { - template: TEMPLATE_PARAGRAPH_PLACEHOLDER, - templateInsertUpdatesSelection: true, - } ) ); + return el( + 'div', + useBlockProps(), + el( InnerBlocks, { + template: TEMPLATE_PARAGRAPH_PLACEHOLDER, + templateInsertUpdatesSelection: true, + } ) + ); }, save, @@ -171,36 +189,41 @@ }, edit: function InnerBlocksTransformerTargetEdit() { - return el( 'div', useBlockProps(), el( InnerBlocks, { - template: TEMPLATE, - } ) ); + return el( + 'div', + useBlockProps(), + el( InnerBlocks, { + template: TEMPLATE, + } ) + ); }, save, } ); - registerBlockType( - 'test/test-inner-blocks-async-template', - { - apiVersion: 3, - title: 'Test Inner Blocks Async Template', - icon: 'cart', - category: 'text', + registerBlockType( 'test/test-inner-blocks-async-template', { + apiVersion: 3, + title: 'Test Inner Blocks Async Template', + icon: 'cart', + category: 'text', - edit: function InnerBlocksAsyncTemplateEdit() { - const [ template, setTemplate ] = useState( [] ); + edit: function InnerBlocksAsyncTemplateEdit() { + const [ template, setTemplate ] = useState( [] ); - setInterval( () => { - setTemplate( TEMPLATE_TWO_PARAGRAPHS ); - }, 1000 ); + setInterval( () => { + setTemplate( TEMPLATE_TWO_PARAGRAPHS ); + }, 1000 ); - return el('div', useBlockProps(), el( InnerBlocks, { + return el( + 'div', + useBlockProps(), + el( InnerBlocks, { template, - } ) ); - }, + } ) + ); + }, - // Purposely do not save inner blocks so that it's possible to test template resolution. - save() {}, - } - ); + // Purposely do not save inner blocks so that it's possible to test template resolution. + save() {}, + } ); } )(); diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-context/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-context/view.js index c1040cb4a7b5cf..7515ad5ad92266 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-context/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-context/view.js @@ -21,7 +21,7 @@ store( 'directive-context', { get isProxyPreservedOnCopy() { const { obj, obj2 } = getContext(); return obj === obj2; - } + }, }, actions: { updateContext( event ) { @@ -47,7 +47,7 @@ store( 'directive-context', { copyObj() { const ctx = getContext(); ctx.obj2 = ctx.obj; - } + }, }, } ); @@ -92,7 +92,6 @@ const { actions } = store( 'directive-context-navigate', { return routerActions.navigate( url, { force: true, html } ); } ); - }, *asyncNavigate() { yield actions.navigate(); @@ -118,4 +117,4 @@ store( 'directive-context-watch', { ctx.changes = ctx.changes + 1; }, }, -}); +} ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js index 129e4f61270bd8..e19821a2a2aff1 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-each/view.js @@ -1,7 +1,12 @@ /** * WordPress dependencies */ -import { store, getContext, useInit, privateApis } from '@wordpress/interactivity'; +import { + store, + getContext, + useInit, + privateApis, +} from '@wordpress/interactivity'; const { state } = store( 'directive-each' ); @@ -16,8 +21,8 @@ store( 'directive-each', { fruits: [ 'avocado', 'banana', 'cherimoya' ], get fruitId() { const { idPrefix, fruit } = getContext(); - return `${idPrefix}${fruit}`; - } + return `${ idPrefix }${ fruit }`; + }, }, actions: { removeFruit() { @@ -43,17 +48,17 @@ store( 'directive-each', { { title: 'A Game of Thrones', author: 'George R.R. Martin', - isbn: "9780553588484", + isbn: '9780553588484', }, { title: 'A Clash of Kings', author: 'George R.R. Martin', - isbn: "9780553381696", + isbn: '9780553381696', }, { title: 'A Storm of Swords', author: 'George R.R. Martin', - isbn: "9780553573428", + isbn: '9780553573428', }, ], }, @@ -70,7 +75,7 @@ store( 'directive-each', { const book = { title: 'A Feast for Crows', author: 'George R.R. Martin', - isbn: "9780553582024", + isbn: '9780553582024', }; state.books.splice( 0, 0, book ); }, @@ -78,7 +83,7 @@ store( 'directive-each', { const book = { title: 'A Feast for Crows', author: 'George R.R. Martin', - isbn: "9780553582024", + isbn: '9780553582024', }; state.books.splice( 0, 1, book ); }, @@ -101,58 +106,63 @@ store( 'directive-each', { if ( state.numbers.length > 0 ) { state.numbers.unshift( state.numbers[ 0 ] - 1 ); } - } + }, }, } ); store( 'directive-each', { state: { - emptyList: [] + emptyList: [], }, actions: { addItem() { state.emptyList.push( `item ${ state.emptyList.length }` ); - } + }, }, } ); store( 'directive-each', { state: { numbersAndNames: [ - { name: "two", value: 2 }, - { name: "three", value: 3 }, + { name: 'two', value: 2 }, + { name: 'three', value: 3 }, ], }, actions: { unshiftNumberAndName() { - state.numbersAndNames.unshift( { name: "one", value: 1 } ); - } + state.numbersAndNames.unshift( { name: 'one', value: 1 } ); + }, }, } ); store( 'directive-each', { state: { animalBreeds: [ - { name: "Dog", breeds: [ 'chihuahua', 'rottweiler' ] }, - { name: "Cat", breeds: [ 'sphynx', 'siamese' ] }, + { name: 'Dog', breeds: [ 'chihuahua', 'rottweiler' ] }, + { name: 'Cat', breeds: [ 'sphynx', 'siamese' ] }, ], }, actions: { addAnimal() { state.animalBreeds.unshift( { - name: "Rat", breeds: [ 'dumbo', 'rex' ] + name: 'Rat', + breeds: [ 'dumbo', 'rex' ], } ); }, addBreeds() { - state - .animalBreeds - .forEach( ( { name, breeds } ) => { - if ( name === 'Dog') {breeds.unshift( 'german shepherd' );} - if ( name === 'Cat') {breeds.unshift( 'maine coon' );} - if ( name === 'Rat') {breeds.unshift( 'satin' );} - } ); - } - } + state.animalBreeds.forEach( ( { name, breeds } ) => { + if ( name === 'Dog' ) { + breeds.unshift( 'german shepherd' ); + } + if ( name === 'Cat' ) { + breeds.unshift( 'maine coon' ); + } + if ( name === 'Rat' ) { + breeds.unshift( 'satin' ); + } + } ); + }, + }, } ); const html = ` @@ -180,14 +190,14 @@ store( 'directive-each', { actions: { *navigate() { const { actions } = yield import( - "@wordpress/interactivity-router" + '@wordpress/interactivity-router' ); return actions.navigate( window.location, { force: true, html, } ); }, - } + }, } ); const { directive } = privateApis( @@ -208,12 +218,11 @@ directive( { priority: 2 } ); -store('directive-each', { - callbacks: { +store( 'directive-each', { + callbacks: { updateCallbackRunCount() { const ctx = getContext(); ctx.callbackRunCount += 1; - } - }, -}); - + }, + }, +} ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-key/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-key/view.js index 8035757b7ea658..2efea222c0faf6 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-key/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-key/view.js @@ -19,7 +19,7 @@ store( 'directive-key', { actions: { *navigate() { const { actions } = yield import( - "@wordpress/interactivity-router" + '@wordpress/interactivity-router' ); return actions.navigate( window.location, { force: true, diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-on-document/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-on-document/view.js index eb32d6e6e15f08..19ffc2a530193b 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-on-document/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-on-document/view.js @@ -46,6 +46,6 @@ const { state } = store( 'directive-on-document', { }, keydownSecondHandler: () => { state.keydownSecondHandler = 'yes'; - } - } + }, + }, } ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-on-window/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-on-window/view.js index 57c75e9c4cb633..e22379ad4d0775 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-on-window/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-on-window/view.js @@ -34,7 +34,7 @@ const { state } = store( 'directive-on-window', { }, init() { state.isEventAttached = 'yes'; - } + }, }, actions: { visibilityHandler: () => { @@ -46,6 +46,6 @@ const { state } = store( 'directive-on-window', { }, resizeSecondHandler: () => { state.resizeSecondHandler = 'yes'; - } - } + }, + }, } ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-priorities/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-priorities/view.js index d43c8b8373cf38..c6cdf31b4909c8 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-priorities/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-priorities/view.js @@ -5,7 +5,7 @@ import { store, getContext, useEffect, - privateApis + privateApis, } from '@wordpress/interactivity'; const { directive, deepSignal, h } = privateApis( @@ -24,8 +24,11 @@ const namespace = 'directive-priorities'; */ const executionProof = ( n ) => { const el = document.querySelector( '[data-testid="execution order"]' ); - if ( ! el.textContent ) {el.textContent = n;} - else {el.textContent += `, ${ n }`;} + if ( ! el.textContent ) { + el.textContent = n; + } else { + el.textContent += `, ${ n }`; + } }; /** diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-run/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-run/view.js index a9d6927907c299..cb9be34b2460a8 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-run/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-run/view.js @@ -6,7 +6,7 @@ import { useInit, useWatch, getElement, - privateApis + privateApis, } from '@wordpress/interactivity'; const { directive, cloneElement } = privateApis( @@ -16,7 +16,11 @@ const { directive, cloneElement } = privateApis( // Custom directive to show hide the content elements in which it is placed. directive( 'show-children', - ( { directives: { 'show-children': showChildren }, element, evaluate } ) => { + ( { + directives: { 'show-children': showChildren }, + element, + evaluate, + } ) => { const entry = showChildren.find( ( { suffix } ) => suffix === 'default' ); @@ -51,7 +55,7 @@ const { state } = store( 'directive-run', { isHydrated: 'no', isMounted: 'no', renderCount: 0, - clickCount: 0 + clickCount: 0, }, actions: { toggle() { @@ -62,7 +66,7 @@ const { state } = store( 'directive-run', { }, *navigate() { const { actions } = yield import( - "@wordpress/interactivity-router" + '@wordpress/interactivity-router' ); return actions.navigate( window.location, { force: true, @@ -84,13 +88,13 @@ const { state } = store( 'directive-run', { // Runs only on first render. useInit( () => { const { ref } = getElement(); - ref - .closest( '[data-testid="wp-run hooks results"]') - .setAttribute( 'data-init', 'initialized' ); + ref.closest( + '[data-testid="wp-run hooks results"]' + ).setAttribute( 'data-init', 'initialized' ); return () => { - ref - .closest( '[data-testid="wp-run hooks results"]') - .setAttribute( 'data-init', 'cleaned up' ); + ref.closest( + '[data-testid="wp-run hooks results"]' + ).setAttribute( 'data-init', 'cleaned up' ); }; } ); @@ -99,15 +103,15 @@ const { state } = store( 'directive-run', { useWatch( () => { const { ref } = getElement(); const { clickCount } = state; - ref - .closest( '[data-testid="wp-run hooks results"]') - .setAttribute( 'data-watch', clickCount ); + ref.closest( + '[data-testid="wp-run hooks results"]' + ).setAttribute( 'data-watch', clickCount ); return () => { - ref - .closest( '[data-testid="wp-run hooks results"]') - .setAttribute( 'data-watch', 'cleaned up' ); + ref.closest( + '[data-testid="wp-run hooks results"]' + ).setAttribute( 'data-watch', 'cleaned up' ); }; } ); - } - } + }, + }, } ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-text/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-text/view.js index 239f13e8f61b6d..21ac110bf64395 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-text/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-text/view.js @@ -7,13 +7,12 @@ const { h } = privateApis( 'I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.' ); - const { state } = store( 'directive-context', { state: { text: 'Text 1', - component: () => ( h( 'div', {}, state.text ) ), + component: () => h( 'div', {}, state.text ), number: 1, - boolean: true + boolean: true, }, actions: { toggleStateText() { diff --git a/packages/e2e-tests/plugins/interactive-blocks/directive-watch/view.js b/packages/e2e-tests/plugins/interactive-blocks/directive-watch/view.js index 67402099e00a5a..af2d452a104319 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/directive-watch/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/directive-watch/view.js @@ -13,7 +13,9 @@ directive( 'show-mock', ( { directives: { 'show-mock': showMock }, element, evaluate } ) => { const entry = showMock.find( ( { suffix } ) => suffix === 'default' ); - if ( ! evaluate( entry ) ) {return null;} + if ( ! evaluate( entry ) ) { + return null; + } return element; } ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/namespace/view.js b/packages/e2e-tests/plugins/interactive-blocks/namespace/view.js index 5717387395ff24..24f61fb03290ad 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/namespace/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/namespace/view.js @@ -3,7 +3,6 @@ */ import { store } from '@wordpress/interactivity'; - store( '', { state: { url: '/empty-string-url', @@ -63,8 +62,3 @@ store( '"quoted string"', { url: '/quoted-url', }, } ); - - - - - diff --git a/packages/e2e-tests/plugins/interactive-blocks/router-navigate/view.js b/packages/e2e-tests/plugins/interactive-blocks/router-navigate/view.js index b2d4ad0dc1ddeb..bd1d6e11647799 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/router-navigate/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/router-navigate/view.js @@ -14,8 +14,8 @@ const { state } = store( 'router', { data: { get getterProp() { return `value from getter (${ state.data.prop1 })`; - } - } + }, + }, }, actions: { *navigate( e ) { @@ -29,7 +29,7 @@ const { state } = store( 'router', { const { timeout } = state; const { actions } = yield import( - "@wordpress/interactivity-router" + '@wordpress/interactivity-router' ); yield actions.navigate( e.target.href, { force, timeout } ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/router-regions/view.js b/packages/e2e-tests/plugins/interactive-blocks/router-regions/view.js index 2e78dd1592d33e..f3468eb88aff01 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/router-regions/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/router-regions/view.js @@ -20,7 +20,7 @@ const { state } = store( 'router-regions', { *navigate( e ) { e.preventDefault(); const { actions } = yield import( - "@wordpress/interactivity-router" + '@wordpress/interactivity-router' ); yield actions.navigate( e.target.href ); }, diff --git a/packages/e2e-tests/plugins/interactive-blocks/tovdom/cdata.js b/packages/e2e-tests/plugins/interactive-blocks/tovdom/cdata.js index 506e899e42850c..ca0f8009d1ae4f 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/tovdom/cdata.js +++ b/packages/e2e-tests/plugins/interactive-blocks/tovdom/cdata.js @@ -10,6 +10,4 @@ const cdata = ` const cdataElement = new DOMParser() .parseFromString( cdata, 'text/xml' ) .querySelector( 'div' ); -document - .getElementById( 'replace-with-cdata' ) - .replaceWith( cdataElement ); +document.getElementById( 'replace-with-cdata' ).replaceWith( cdataElement ); diff --git a/packages/e2e-tests/plugins/interactive-blocks/with-scope/view.js b/packages/e2e-tests/plugins/interactive-blocks/with-scope/view.js index 9df421a6f50b74..daa3b824d309ac 100644 --- a/packages/e2e-tests/plugins/interactive-blocks/with-scope/view.js +++ b/packages/e2e-tests/plugins/interactive-blocks/with-scope/view.js @@ -6,15 +6,19 @@ import { store, getContext, withScope } from '@wordpress/interactivity'; store( 'with-scope', { callbacks: { asyncInit: () => { - setTimeout( withScope(function*() { - yield new Promise(resolve => setTimeout(resolve, 1)); - const context = getContext() - context.asyncCounter += 1; - }, 1 )); + setTimeout( + withScope( function* () { + yield new Promise( ( resolve ) => + setTimeout( resolve, 1 ) + ); + const context = getContext(); + context.asyncCounter += 1; + }, 1 ) + ); }, syncInit: () => { - const context = getContext() + const context = getContext(); context.syncCounter += 1; - } + }, }, } ); diff --git a/packages/e2e-tests/plugins/plugins-api/annotations-sidebar.js b/packages/e2e-tests/plugins/plugins-api/annotations-sidebar.js index 0f7e15afaa8169..87ee3a4f65590c 100644 --- a/packages/e2e-tests/plugins/plugins-api/annotations-sidebar.js +++ b/packages/e2e-tests/plugins/plugins-api/annotations-sidebar.js @@ -48,15 +48,16 @@ el( Button, { - variant: "primary", + variant: 'primary', onClick: () => { dispatch( 'core/annotations' ).__experimentalAddAnnotation( { source: 'e2e-tests', - blockClientId: select( - 'core/block-editor' - ).getBlockOrder()[ 0 ], + blockClientId: + select( + 'core/block-editor' + ).getBlockOrder()[ 0 ], richTextIdentifier: 'content', range: { start: parseInt( this.state.start, 10 ), @@ -70,7 +71,7 @@ el( Button, { - variant: "primary", + variant: 'primary', onClick: () => { dispatch( 'core/annotations' diff --git a/packages/e2e-tests/plugins/plugins-api/error-boundary.js b/packages/e2e-tests/plugins/plugins-api/error-boundary.js index aca34d5c786ca9..5179555967b653 100644 --- a/packages/e2e-tests/plugins/plugins-api/error-boundary.js +++ b/packages/e2e-tests/plugins/plugins-api/error-boundary.js @@ -2,7 +2,7 @@ const registerPlugin = wp.plugins.registerPlugin; function MyErrorPlugin() { - throw new Error('Whoops!'); + throw new Error( 'Whoops!' ); } registerPlugin( 'my-error-plugin', { diff --git a/packages/e2e-tests/plugins/test-autocompleter/index.js b/packages/e2e-tests/plugins/test-autocompleter/index.js index 4f294e55b55cd3..738a86e137297e 100644 --- a/packages/e2e-tests/plugins/test-autocompleter/index.js +++ b/packages/e2e-tests/plugins/test-autocompleter/index.js @@ -1,4 +1,4 @@ -(function () { +( function () { const fruits = { name: 'fruit', // The prefix that triggers this completer @@ -20,9 +20,7 @@ // Declares that the Grapes option is disabled isOptionDisabled: ( option ) => option.name === 'Grapes', // Declares completions should be inserted as abbreviations - getOptionCompletion: ( option ) => ( - option.visual - ), + getOptionCompletion: ( option ) => option.visual, }; function duplicateUserMentions( completers ) { @@ -43,7 +41,7 @@ ? [ ...completers, fruits, copiedUsers ] : completers; } - + // Adding the filter with a priority of 11 // to ensure it fires after the default user mentions are added. wp.hooks.addFilter( @@ -52,4 +50,4 @@ appendTestCompleters, 11 ); -})() +} )();