Skip to content

Commit fb9ec32

Browse files
committed
Lint: fix eslint errors in WordPress.com components
1 parent 8fbc421 commit fb9ec32

File tree

9 files changed

+259
-228
lines changed

9 files changed

+259
-228
lines changed

components/wordpress_com/actions/create-post.mjs

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
site: {
1212
type: "string",
1313
label: "Site ID or domain",
14-
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com). Do not include 'https://' or 'www'."
14+
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com). Do not include 'https://' or 'www'.",
1515
},
1616
title: {
1717
type: "string",
@@ -40,13 +40,19 @@ export default {
4040
label: "Post Type",
4141
description: "The type of the post (post or page). For attachments, use the 'Upload Media' action.",
4242
options: [
43-
{ label: "Post", value: "post" },
44-
{ label: "Page", value: "page" },
43+
{
44+
label: "Post",
45+
value: "post",
46+
},
47+
{
48+
label: "Page",
49+
value: "page",
50+
},
4551
],
4652
default: "post",
47-
}
53+
},
4854
},
49-
55+
5056
async run({ $ }) {
5157

5258
const warnings = [];
@@ -61,22 +67,22 @@ export default {
6167

6268
let response;
6369

64-
try {
65-
response = await wordpress.createWordpressPost({ //TEST
66-
67-
$,
68-
site,
69-
data : {
70-
...fields
71-
}
72-
});
70+
try {
71+
response = await wordpress.createWordpressPost({ //TEST
72+
73+
$,
74+
site,
75+
data: {
76+
...fields,
77+
},
78+
});
7379

74-
} catch (error) {
75-
wordpress.throwCustomError("Could not create post", error, warnings);
76-
};
77-
78-
$.export("$summary", `Post successfully created. ID = ${response?.ID}` + "\n- " + warnings.join("\n- "));
80+
} catch (error) {
81+
wordpress.throwCustomError("Could not create post", error, warnings);
82+
};
83+
84+
$.export("$summary", `Post successfully created. ID = ${response?.ID}` + "\n- " + warnings.join("\n- "));
7985
},
80-
86+
8187
};
8288

components/wordpress_com/actions/delete-post.mjs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default {
1010
props: {
1111
wordpress,
1212
site: {
13+
label: "Domain or ID",
1314
type: "string",
1415
description: "Enter a site ID or domain (e.g. testsit38.wordpress.com).",
1516
},
@@ -19,31 +20,32 @@ export default {
1920
description: "The ID of the post you want to delete.",
2021
},
2122
},
22-
23+
2324
async run({ $ }) {
2425

2526
const warnings = [];
2627

2728
const {
2829
site,
2930
wordpress,
30-
postId
31+
postId,
3132
} = this;
3233

34+
warnings.push(...wordpress.checkDomainOrId(site));
3335

34-
warnings.push(...wordpress.checkDomainOrId(site));
35-
3636
let response;
3737

3838
try {
39-
response = await wordpress.deleteWordpressPost({$, site, postId});
39+
response = await wordpress.deleteWordpressPost({
40+
$,
41+
site,
42+
postId,
43+
});
4044
} catch (error) {
41-
wordpress.throwCustomError("Could not delete post", error, warnings);
45+
wordpress.throwCustomError("Could not delete post", error, warnings);
4246
};
43-
47+
4448
$.export("$summary", `Post ID = ${response?.ID} successfully deleted.` + "\n- " + warnings.join("\n- "));
4549
},
4650
};
4751

48-
49-

components/wordpress_com/actions/upload-media.mjs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {prepareMediaUpload} from "../common/utils.mjs";
1+
import { prepareMediaUpload } from "../common/utils.mjs";
22
import wordpress from "../wordpress_com.app.mjs";
33

44
export default {
@@ -10,7 +10,7 @@ export default {
1010
type: "action",
1111

1212
props: {
13-
wordpress,
13+
wordpress,
1414
site: {
1515
type: "string",
1616
label: "Site ID or domain",
@@ -30,11 +30,13 @@ export default {
3030
caption: {
3131
type: "string",
3232
label: "Caption",
33+
description: "Optional caption text to associate with the uploaded media.",
3334
optional: true,
3435
},
3536
description: {
3637
type: "string",
3738
label: "Description",
39+
descripion: "Optional description text to provide more details about the uploaded media.",
3840
optional: true,
3941
},
4042
},
@@ -43,20 +45,20 @@ export default {
4345

4446
const warnings = [];
4547

46-
const
47-
{
48-
wordpress,
49-
site,
50-
media,
51-
...fields
52-
} = this;
48+
const
49+
{
50+
wordpress,
51+
site,
52+
media,
53+
...fields
54+
} = this;
5355

5456
warnings.push(...wordpress.checkDomainOrId(site));
5557

5658
let form;
5759

5860
// If not form data
59-
if (wordpress.isFormData(media)){
61+
if (wordpress.isFormData(media)) {
6062

6163
console.log("Media was received as multipart/form-data");
6264
warnings.push("Media was received as multipart/form-data");
@@ -66,7 +68,7 @@ export default {
6668
} else {
6769

6870
warnings.push("Media was received as URL");
69-
warnings.push(...wordpress.checkIfUrlValid(media));
71+
warnings.push(...wordpress.checkIfUrlValid(media));
7072

7173
form = await prepareMediaUpload(media, fields, $);
7274
}
@@ -77,11 +79,11 @@ export default {
7779

7880
response = await wordpress.uploadWordpressMedia({
7981
$,
80-
contentType : form.getHeaders()["content-type"],
82+
contentType: form.getHeaders()["content-type"],
8183
site,
82-
data : form,
84+
data: form,
8385
});
84-
86+
8587
const media = response.media[0];
8688

8789
$.export("$summary", `Media "${media.title}" uploaded successfully (ID: ${media.ID})` + "\n- " + warnings.join("\n- "));
@@ -90,8 +92,8 @@ export default {
9092
return response;
9193

9294
} catch (error) {
93-
94-
wordpress.throwCustomError("Failed to upload media", error, warnings);
95+
96+
wordpress.throwCustomError("Failed to upload media", error, warnings);
9597

9698
};
9799
},

0 commit comments

Comments
 (0)