Skip to content

Commit a29bf44

Browse files
authored
Update linting and formatting for test plugin files. (#28033)
* Remove test plugins folder from eslint ignore to ensure prettier formats plugin code correctly * Fix formatting/linting errors
1 parent cff6131 commit a29bf44

File tree

21 files changed

+274
-334
lines changed

21 files changed

+274
-334
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ build-module
44
build-types
55
node_modules
66
packages/block-serialization-spec-parser/parser.js
7-
packages/e2e-tests/plugins
87
packages/react-native-editor/bundle
98
vendor
109
!.*.js

packages/e2e-tests/plugins/align-hook/index.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
( function() {
2-
var registerBlockType = wp.blocks.registerBlockType;
3-
var el = wp.element.createElement;
4-
var InnerBlocks = wp.blockEditor.InnerBlocks;
5-
var __ = wp.i18n.__;
6-
var TEMPLATE = [
7-
[ 'core/paragraph', { fontSize: 'large', content: __( 'Content…' ) } ],
8-
];
1+
( function () {
2+
const registerBlockType = wp.blocks.registerBlockType;
3+
const el = wp.element.createElement;
94

10-
var baseBlock = {
5+
const baseBlock = {
116
icon: 'cart',
127
category: 'text',
13-
edit: function( props ) {
8+
edit() {
149
return el(
1510
'div',
1611
{ style: { outline: '1px solid gray', padding: 5 } },
1712
'Test Align Hook'
1813
);
1914
},
20-
save: function() {
15+
save() {
2116
return el(
2217
'div',
2318
{ style: { outline: '1px solid gray', padding: 5 } },

packages/e2e-tests/plugins/block-icons/index.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
( function() {
2-
var registerBlockType = wp.blocks.registerBlockType;
3-
var el = wp.element.createElement;
4-
var InnerBlocks = wp.blockEditor.InnerBlocks;
5-
var circle = el( 'circle', {
1+
( function () {
2+
const registerBlockType = wp.blocks.registerBlockType;
3+
const el = wp.element.createElement;
4+
const InnerBlocks = wp.blockEditor.InnerBlocks;
5+
const circle = el( 'circle', {
66
cx: 10,
77
cy: 10,
88
r: 10,
99
fill: 'red',
1010
stroke: 'blue',
1111
strokeWidth: '10',
1212
} );
13-
var svg = el(
13+
const svg = el(
1414
'svg',
1515
{ width: 20, height: 20, viewBox: '0 0 20 20' },
1616
circle
@@ -21,7 +21,7 @@
2121
icon: svg,
2222
category: 'text',
2323

24-
edit: function() {
24+
edit() {
2525
return el(
2626
'div',
2727
{
@@ -42,7 +42,7 @@
4242
);
4343
},
4444

45-
save: function() {
45+
save() {
4646
return el(
4747
'div',
4848
{
@@ -59,7 +59,7 @@
5959
icon: 'cart',
6060
category: 'text',
6161

62-
edit: function() {
62+
edit() {
6363
return el(
6464
'div',
6565
{
@@ -80,7 +80,7 @@
8080
);
8181
},
8282

83-
save: function() {
83+
save() {
8484
return el(
8585
'div',
8686
{
@@ -94,12 +94,12 @@
9494

9595
registerBlockType( 'test/test-function-icon', {
9696
title: 'TestFunctionIcon',
97-
icon: function() {
97+
icon() {
9898
return svg;
9999
},
100100
category: 'text',
101101

102-
edit: function() {
102+
edit() {
103103
return el(
104104
'div',
105105
{
@@ -120,7 +120,7 @@
120120
);
121121
},
122122

123-
save: function() {
123+
save() {
124124
return el(
125125
'div',
126126
{
@@ -141,7 +141,7 @@
141141
},
142142
category: 'text',
143143

144-
edit: function() {
144+
edit() {
145145
return el(
146146
'div',
147147
{
@@ -162,7 +162,7 @@
162162
);
163163
},
164164

165-
save: function() {
165+
save() {
166166
return el(
167167
'div',
168168
{
@@ -182,7 +182,7 @@
182182
},
183183
category: 'text',
184184

185-
edit: function() {
185+
edit() {
186186
return el(
187187
'div',
188188
{
@@ -203,7 +203,7 @@
203203
);
204204
},
205205

206-
save: function() {
206+
save() {
207207
return el(
208208
'div',
209209
{

packages/e2e-tests/plugins/block-variations/index.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
( function() {
2-
var el = wp.element.createElement;
3-
var registerBlockVariation = wp.blocks.registerBlockVariation;
4-
var __ = wp.i18n.__;
5-
var Circle = wp.primitives.Circle;
6-
var SVG = wp.primitives.SVG;
1+
( function () {
2+
const el = wp.element.createElement;
3+
const registerBlockVariation = wp.blocks.registerBlockVariation;
4+
const __ = wp.i18n.__;
5+
const Circle = wp.primitives.Circle;
6+
const SVG = wp.primitives.SVG;
77

8-
var redCircle = el( Circle, {
8+
const redCircle = el( Circle, {
99
cx: 24,
1010
cy: 24,
1111
r: 15,
1212
fill: 'red',
1313
stroke: 'blue',
1414
strokeWidth: '10',
1515
} );
16-
var redCircleIcon = el(
16+
17+
const redCircleIcon = el(
1718
SVG,
1819
{ width: 48, height: 48, viewBox: '0 0 48 48' },
1920
redCircle
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
( function() {
1+
( function () {
22
const { InnerBlocks } = wp.blockEditor;
33
const { createElement: el } = wp.element;
44
const { registerBlockType } = wp.blocks;
@@ -9,19 +9,11 @@
99
category: 'text',
1010

1111
edit() {
12-
return el(
13-
'div',
14-
{},
15-
el( InnerBlocks )
16-
);
12+
return el( 'div', {}, el( InnerBlocks ) );
1713
},
1814

1915
save() {
20-
return el(
21-
'div',
22-
{},
23-
el( InnerBlocks.Content )
24-
);
16+
return el( 'div', {}, el( InnerBlocks.Content ) );
2517
},
2618
} );
2719

@@ -34,19 +26,14 @@
3426
return el(
3527
'div',
3628
{},
37-
el(
38-
InnerBlocks,
39-
{ allowedBlocks: [ 'core/paragraph', 'core/image' ] }
40-
)
29+
el( InnerBlocks, {
30+
allowedBlocks: [ 'core/paragraph', 'core/image' ],
31+
} )
4132
);
4233
},
4334

4435
save() {
45-
return el(
46-
'div',
47-
{},
48-
el( InnerBlocks.Content )
49-
);
36+
return el( 'div', {}, el( InnerBlocks.Content ) );
5037
},
5138
} );
5239

@@ -61,19 +48,11 @@
6148
],
6249

6350
edit() {
64-
return el(
65-
'div',
66-
{},
67-
'Child'
68-
);
51+
return el( 'div', {}, 'Child' );
6952
},
7053

7154
save() {
72-
return el(
73-
'div',
74-
{},
75-
'Child'
76-
);
55+
return el( 'div', {}, 'Child' );
7756
},
7857
} );
7958
} )();

packages/e2e-tests/plugins/container-without-paragraph/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
( function() {
1+
( function () {
22
wp.blocks.registerBlockType( 'test/container-without-paragraph', {
33
title: 'Container without paragraph',
44
category: 'text',

packages/e2e-tests/plugins/custom-grouping-block/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
( function() {
1+
( function () {
22
wp.blocks.registerBlockType( 'test/alternative-group-block', {
33
title: 'Alternative Group Block',
44
category: 'design',

packages/e2e-tests/plugins/deprecated-node-matcher/index.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
( function() {
2-
var registerBlockType = wp.blocks.registerBlockType;
3-
var RichText = wp.blockEditor.RichText;
4-
var el = wp.element.createElement;
1+
( function () {
2+
const registerBlockType = wp.blocks.registerBlockType;
3+
const RichText = wp.blockEditor.RichText;
4+
const el = wp.element.createElement;
55

66
registerBlockType( 'core/deprecated-children-matcher', {
77
title: 'Deprecated Children Matcher',
@@ -13,16 +13,16 @@
1313
},
1414
},
1515
category: 'text',
16-
edit: function( { attributes, setAttributes } ) {
16+
edit( { attributes, setAttributes } ) {
1717
return el( RichText, {
1818
tagName: 'p',
1919
value: attributes.value,
20-
onChange: function( nextValue ) {
20+
onChange( nextValue ) {
2121
setAttributes( { value: nextValue } );
2222
},
2323
} );
2424
},
25-
save: function( { attributes } ) {
25+
save( { attributes } ) {
2626
return el( RichText.Content, {
2727
tagName: 'p',
2828
value: attributes.value,
@@ -31,13 +31,15 @@
3131
} );
3232

3333
function toRichTextValue( value ) {
34-
return _.map( value, function( subValue ) {
34+
// eslint-disable-next-line no-undef
35+
return _.map( value, function ( subValue ) {
3536
return subValue.children;
3637
} );
3738
}
3839

3940
function fromRichTextValue( value ) {
40-
return _.map( value, function( subValue ) {
41+
// eslint-disable-next-line no-undef
42+
return _.map( value, function ( subValue ) {
4143
return {
4244
children: subValue,
4345
};
@@ -59,22 +61,22 @@
5961
},
6062
},
6163
category: 'text',
62-
edit: function( { attributes, setAttributes } ) {
64+
edit( { attributes, setAttributes } ) {
6365
return el(
6466
'blockquote',
6567
{},
6668
el( RichText, {
6769
multiline: 'p',
6870
value: toRichTextValue( attributes.value ),
69-
onChange: function( nextValue ) {
71+
onChange( nextValue ) {
7072
setAttributes( {
7173
value: fromRichTextValue( nextValue ),
7274
} );
7375
},
7476
} )
7577
);
7678
},
77-
save: function( { attributes } ) {
79+
save( { attributes } ) {
7880
return el(
7981
'blockquote',
8082
{},

0 commit comments

Comments
 (0)