Skip to content

Commit 1e4e4f8

Browse files
committed
Initial JS linting using wp-scripts.
1 parent 11d6a98 commit 1e4e4f8

File tree

11 files changed

+1595
-1299
lines changed

11 files changed

+1595
-1299
lines changed

package-lock.json

Lines changed: 669 additions & 623 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
"scripts": {
77
"build": "wp-scripts build",
88
"build:dev": "wp-scripts build --env dev",
9+
"lint:css": "wp-scripts lint-style",
10+
"lint:js": "wp-scripts lint-js",
11+
"lint:js:src": "wp-scripts lint-js ./src",
12+
"lint:js:src-fix": "wp-scripts lint-js ./src --fix",
13+
"lint:md:docs": "wp-scripts lint-md-docs",
14+
"lint:pkg-json": "wp-scripts lint-pkg-json",
915
"test": "echo \"Error: no test specified\" && exit 1"
1016
},
1117
"repository": {
@@ -19,7 +25,7 @@
1925
},
2026
"homepage": "https://github.com/FiveMountains-co/stream-wordpress#readme",
2127
"dependencies": {
22-
"@wordpress/scripts": "^23.7.0",
23-
"tus-js-client": "^3.0.0"
28+
"@wordpress/scripts": "^24.1.0",
29+
"tus-js-client": "^3.0.1"
2430
}
2531
}

src/block/block.js

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,28 @@ import edit from './edit';
1818
import { streamIframeSource } from './lib';
1919

2020
/* Deprecated version of block */
21-
import { deprecated_108 } from './deprecated_108';
21+
import { deprecated_108 } from './deprecated_108';
2222

2323
const { __ } = wp.i18n; // Import __() from wp.i18n
2424
const { registerBlockType } = wp.blocks; // Import registerBlockType() from wp.blocks;
2525

2626
/**
2727
* Cloudflare Stream SVG path icon
28-
*/
29-
cloudflareStream.icon = wp.element.createElement( 'svg', { width: 20, height: 20, viewBox: '0 0 68.66 49.14', className: 'cls-1 dashicon' },
30-
wp.element.createElement( 'path', { d: 'M61.05,42.28H1.75A.76.76,0,0,1,1,41.52V1.73A.75.75,0,0,1,1.75,1h59.3a.75.75,0,0,1,.76.75V41.52A.76.76,0,0,1,61.05,42.28ZM2.51,40.77H60.3V2.49H2.51Z' } ),
31-
wp.element.createElement( 'path', { d: 'M45.6,26.09,31.44,17.91a1.17,1.17,0,0,0-1.19-.09,1.19,1.19,0,0,0-.51,1.07V35.25a1.17,1.17,0,0,0,.51,1.06.91.91,0,0,0,.48.13,1.41,1.41,0,0,0,.71-.21L45.6,28.05a1.05,1.05,0,0,0,0-2ZM65.13,48.14H7.86a2.52,2.52,0,0,1-2.52-2.52V7.86A2.52,2.52,0,0,1,7.86,5.34H65.13a2.52,2.52,0,0,1,2.53,2.52V45.62A2.52,2.52,0,0,1,65.13,48.14Zm-56.77-3H64.63V8.36H8.36Z' } )
28+
*/
29+
cloudflareStream.icon = wp.element.createElement(
30+
'svg',
31+
{
32+
width: 20,
33+
height: 20,
34+
viewBox: '0 0 68.66 49.14',
35+
className: 'cls-1 dashicon',
36+
},
37+
wp.element.createElement( 'path', {
38+
d: 'M61.05,42.28H1.75A.76.76,0,0,1,1,41.52V1.73A.75.75,0,0,1,1.75,1h59.3a.75.75,0,0,1,.76.75V41.52A.76.76,0,0,1,61.05,42.28ZM2.51,40.77H60.3V2.49H2.51Z',
39+
} ),
40+
wp.element.createElement( 'path', {
41+
d: 'M45.6,26.09,31.44,17.91a1.17,1.17,0,0,0-1.19-.09,1.19,1.19,0,0,0-.51,1.07V35.25a1.17,1.17,0,0,0,.51,1.06.91.91,0,0,0,.48.13,1.41,1.41,0,0,0,.71-.21L45.6,28.05a1.05,1.05,0,0,0,0-2ZM65.13,48.14H7.86a2.52,2.52,0,0,1-2.52-2.52V7.86A2.52,2.52,0,0,1,7.86,5.34H65.13a2.52,2.52,0,0,1,2.53,2.52V45.62A2.52,2.52,0,0,1,65.13,48.14Zm-56.77-3H64.63V8.36H8.36Z',
42+
} )
3243
);
3344

3445
/**
@@ -39,8 +50,8 @@ cloudflareStream.icon = wp.element.createElement( 'svg', { width: 20, height: 20
3950
* editor interface where blocks are implemented.
4051
*
4152
* @link https://wordpress.org/gutenberg/handbook/block-api/
42-
* @param {string} name Block name.
43-
* @param {Object} settings Block settings.
53+
* @param {string} name Block name.
54+
* @param {Object} settings Block settings.
4455
* @return {?WPBlock} The block, if it has been successfully
4556
* registered; otherwise `undefined`.
4657
*/
@@ -55,9 +66,7 @@ registerBlockType( 'cloudflare-stream/block-video', {
5566
__( 'video', 'cloudflare-stream-wordpress' ),
5667
],
5768

58-
deprecated: [
59-
deprecated_108
60-
],
69+
deprecated: [ deprecated_108 ],
6170

6271
attributes: {
6372
alignment: {
@@ -118,47 +127,41 @@ registerBlockType( 'cloudflare-stream/block-video', {
118127
* The "save" property must be specified and must be a valid function.
119128
*
120129
* @link https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/
121-
* @param {object} props Block Properties.
122-
* @returns {object} A WordPress block.
130+
* @param {Object} props Block Properties.
131+
* @return {Object} A WordPress block.
123132
*/
124-
save: function( props ) {
125-
const { uid, controls, autoplay, loop, muted, className } = props.attributes;
133+
save( props ) {
134+
const { uid, controls, autoplay, loop, muted, className } =
135+
props.attributes;
126136
if ( uid !== false ) {
127137
// Create block UI using WordPress createElement
128138
return wp.element.createElement(
129139
'figure',
130140
{
131-
className: className,
141+
className,
132142
key: uid,
133143
},
134144
[
135145
wp.element.createElement(
136146
'div',
137147
{
138-
className: 'player-wrapper'
148+
className: 'player-wrapper',
139149
},
140150
[
141-
wp.element.createElement(
142-
'iframe',
143-
{
144-
className: 'player-frame',
145-
src: streamIframeSource( props.attributes ),
146-
allow: "accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;",
147-
allowfullscreen: "true"
148-
}
149-
)
151+
wp.element.createElement( 'iframe', {
152+
className: 'player-frame',
153+
src: streamIframeSource( props.attributes ),
154+
allow: 'accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;',
155+
allowfullscreen: 'true',
156+
} ),
150157
]
151158
),
152159
]
153160
);
154161
}
155162

156-
return wp.element.createElement(
157-
'figure',
158-
{
159-
className: className,
160-
},
161-
);
163+
return wp.element.createElement( 'figure', {
164+
className,
165+
} );
162166
},
163-
164167
} );

src/block/deprecated_108.js

Lines changed: 92 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,101 @@
1-
21
const attributes = {
3-
alignment: {
4-
type: 'string',
5-
},
6-
uid: {
7-
type: 'string',
8-
default: false,
9-
},
10-
fingerprint: {
11-
type: 'string',
12-
default: false,
13-
},
14-
thumbnail: {
15-
type: 'string',
16-
default: false,
17-
},
18-
autoplay: {
19-
type: 'boolean',
20-
source: 'attribute',
21-
selector: 'stream',
22-
attribute: 'autoplay',
23-
default: false,
24-
},
25-
loop: {
26-
type: 'boolean',
27-
source: 'attribute',
28-
selector: 'stream',
29-
attribute: 'loop',
30-
default: false,
31-
},
32-
muted: {
33-
type: 'boolean',
34-
source: 'attribute',
35-
selector: 'stream',
36-
attribute: 'muted',
37-
default: false,
38-
},
39-
controls: {
40-
type: 'boolean',
41-
source: 'attribute',
42-
selector: 'stream',
43-
attribute: 'controls',
44-
default: true,
45-
},
46-
transform: {
47-
type: 'boolean',
48-
source: 'attribute',
49-
selector: 'stream',
50-
attribute: 'transform',
51-
default: false,
52-
},
2+
alignment: {
3+
type: 'string',
4+
},
5+
uid: {
6+
type: 'string',
7+
default: false,
8+
},
9+
fingerprint: {
10+
type: 'string',
11+
default: false,
12+
},
13+
thumbnail: {
14+
type: 'string',
15+
default: false,
16+
},
17+
autoplay: {
18+
type: 'boolean',
19+
source: 'attribute',
20+
selector: 'stream',
21+
attribute: 'autoplay',
22+
default: false,
23+
},
24+
loop: {
25+
type: 'boolean',
26+
source: 'attribute',
27+
selector: 'stream',
28+
attribute: 'loop',
29+
default: false,
30+
},
31+
muted: {
32+
type: 'boolean',
33+
source: 'attribute',
34+
selector: 'stream',
35+
attribute: 'muted',
36+
default: false,
37+
},
38+
controls: {
39+
type: 'boolean',
40+
source: 'attribute',
41+
selector: 'stream',
42+
attribute: 'controls',
43+
default: true,
44+
},
45+
transform: {
46+
type: 'boolean',
47+
source: 'attribute',
48+
selector: 'stream',
49+
attribute: 'transform',
50+
default: false,
51+
},
5352
};
5453

5554
const supports = {
56-
align: true,
55+
align: true,
5756
};
5857

59-
const save = function( props ) {
60-
const { uid, controls, autoplay, loop, muted, className } = props.attributes;
61-
if ( uid !== false ) {
62-
// Create block UI using WordPress createElement
63-
return wp.element.createElement(
64-
'figure',
65-
{
66-
className: className,
67-
key: uid,
68-
},
69-
[
70-
wp.element.createElement(
71-
'stream',
72-
{
73-
src: uid,
74-
controls: controls,
75-
autoplay: autoplay,
76-
loop: loop,
77-
muted: muted,
78-
},
79-
),
80-
wp.element.createElement(
81-
'div',
82-
{
83-
className: 'target',
84-
}
85-
),
86-
wp.element.createElement(
87-
'script',
88-
{
89-
'data-cfasync': false,
90-
defer: true,
91-
type: 'text/javascript',
92-
src: 'https://embed.videodelivery.net/embed/r4xu.fla9.latest.js?video=' + uid,
93-
},
94-
),
95-
]
96-
);
97-
}
58+
const save = function ( props ) {
59+
const { uid, controls, autoplay, loop, muted, className } =
60+
props.attributes;
61+
if ( uid !== false ) {
62+
// Create block UI using WordPress createElement
63+
return wp.element.createElement(
64+
'figure',
65+
{
66+
className,
67+
key: uid,
68+
},
69+
[
70+
wp.element.createElement( 'stream', {
71+
src: uid,
72+
controls,
73+
autoplay,
74+
loop,
75+
muted,
76+
} ),
77+
wp.element.createElement( 'div', {
78+
className: 'target',
79+
} ),
80+
wp.element.createElement( 'script', {
81+
'data-cfasync': false,
82+
defer: true,
83+
type: 'text/javascript',
84+
src:
85+
'https://embed.videodelivery.net/embed/r4xu.fla9.latest.js?video=' +
86+
uid,
87+
} ),
88+
]
89+
);
90+
}
9891

99-
return wp.element.createElement(
100-
'figure',
101-
{
102-
className: className,
103-
},
104-
);
92+
return wp.element.createElement( 'figure', {
93+
className,
94+
} );
10595
};
10696

107-
export const deprecated_108 = { attributes: attributes, supports: supports, save: save };
97+
export const deprecated_108 = {
98+
attributes,
99+
supports,
100+
save,
101+
};

0 commit comments

Comments
 (0)