Skip to content

Commit 3e9c5a2

Browse files
committed
Prettier linting
1 parent 56b1045 commit 3e9c5a2

File tree

10 files changed

+134
-105
lines changed

10 files changed

+134
-105
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ body:
1616
label: Is there an existing issue for this?
1717
description: Search to see if an issue already exists for the bug you encountered.
1818
options:
19-
- label: I have searched the existing issues
20-
required: true
19+
- label: I have searched the existing issues
20+
required: true
2121
- type: textarea
2222
attributes:
2323
label: Current Behavior
@@ -36,7 +36,7 @@ body:
3636
description: |
3737
Version where you observed this issue
3838
placeholder: |
39-
vX.Y.Z
39+
vX.Y.Z
4040
render: markdown
4141
validations:
4242
required: true

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ body:
2929
render: markdown
3030
validations:
3131
required: false
32-

.github/workflows/automerge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: 'Dependabot auto-merge'
2+
name: "Dependabot auto-merge"
33
on: pull_request
44

55
permissions:
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: 'Dependency Review'
2+
name: "Dependency Review"
33
on: [pull_request]
44

55
permissions:
@@ -9,7 +9,7 @@ jobs:
99
dependency-review:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: 'Checkout Repository'
12+
- name: "Checkout Repository"
1313
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
14-
- name: 'Dependency Review'
14+
- name: "Dependency Review"
1515
uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4

.github/workflows/osv-scanner.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ name: OSV-Scanner
1414

1515
on:
1616
pull_request:
17-
branches: [ "main" ]
17+
branches: ["main"]
1818
push:
19-
branches: [ "main" ]
19+
branches: ["main"]
2020
schedule:
21-
- cron: '0 0 * * 0'
21+
- cron: "0 0 * * 0"
2222
workflow_dispatch:
2323

2424
permissions:

.github/workflows/yamllint.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ on:
55
push:
66
pull_request:
77
schedule:
8-
- cron: '0 0 * * 0'
8+
- cron: "0 0 * * 0"
99
workflow_dispatch:
1010

1111
permissions: {}
1212

1313
jobs:
14-
1514
check:
1615
name: Check with YAMLLint
1716
runs-on: ubuntu-latest
1817
steps:
19-
- name: Check out
20-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
21-
- name: Install YAMLLint
22-
run: sudo pip install yamllint
23-
- name: Run YAMLLint
24-
run: "yamllint -d '{extends: relaxed, rules: {line-length: disable, trailing-spaces: disable}}' ."
18+
- name: Check out
19+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
20+
- name: Install YAMLLint
21+
run: sudo pip install yamllint
22+
- name: Run YAMLLint
23+
run: "yamllint -d '{extends: relaxed, rules: {line-length: disable, trailing-spaces: disable}}' ."

birthday-reminders/Code.gs

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,74 @@
1-
'use strict'
1+
"use strict";
22

3-
function sendBirthdayRemindersByEmail () {
4-
const properties = PropertiesService.getScriptProperties()
3+
function sendBirthdayRemindersByEmail() {
4+
const properties = PropertiesService.getScriptProperties();
55

6-
let calendarName = properties.getProperty('calendar')
6+
let calendarName = properties.getProperty("calendar");
77
if (calendarName == null) {
8-
calendarName = 'Birthdays'
8+
calendarName = "Birthdays";
99
}
10-
console.log('calendarName=' + calendarName)
10+
console.log("calendarName=" + calendarName);
1111

12-
let offset = properties.getProperty('offset')
12+
let offset = properties.getProperty("offset");
1313
if (offset == null) {
14-
offset = 0
14+
offset = 0;
1515
}
16-
console.log('offset=' + offset)
16+
console.log("offset=" + offset);
1717

18-
const eventDate = new Date(new Date().getTime() + offset * 24 * 60 * 60 * 1000)
19-
console.log('eventDate=' + eventDate)
18+
const eventDate = new Date(
19+
new Date().getTime() + offset * 24 * 60 * 60 * 1000,
20+
);
21+
console.log("eventDate=" + eventDate);
2022

21-
const email = Session.getActiveUser().getEmail()
22-
console.log('email=' + email)
23+
const email = Session.getActiveUser().getEmail();
24+
console.log("email=" + email);
2325

24-
let subjectTemplate = properties.getProperty('emailSubjectTemplate')
26+
let subjectTemplate = properties.getProperty("emailSubjectTemplate");
2527
if (subjectTemplate == null) {
26-
subjectTemplate = '${event.getTitle()}'
28+
subjectTemplate = "${event.getTitle()}";
2729
}
28-
console.log('subjectTemplate=' + subjectTemplate)
30+
console.log("subjectTemplate=" + subjectTemplate);
2931

30-
let bodyTemplate = properties.getProperty('emailBodyTemplate')
32+
let bodyTemplate = properties.getProperty("emailBodyTemplate");
3133
if (bodyTemplate == null) {
32-
bodyTemplate = '${event.getDescription()}'
34+
bodyTemplate = "${event.getDescription()}";
3335
}
34-
console.log('bodyTemplate=' + bodyTemplate)
35-
36+
console.log("bodyTemplate=" + bodyTemplate);
37+
3638
CalendarApp.getCalendarsByName(calendarName).forEach(function (calendar) {
37-
console.log('Found calendar "' + calendar.getName() + '"')
39+
console.log('Found calendar "' + calendar.getName() + '"');
3840
calendar.getEventsForDay(eventDate).forEach(function (event) {
39-
console.log('Found event "' + event.getTitle() + '"')
40-
const subject = processTemplate(subjectTemplate, event, properties)
41-
const body = processTemplate(bodyTemplate, event, properties)
42-
console.log('Emailing "' + subject + '" to ' + email + ' with body "' + body + '"')
41+
console.log('Found event "' + event.getTitle() + '"');
42+
const subject = processTemplate(subjectTemplate, event, properties);
43+
const body = processTemplate(bodyTemplate, event, properties);
44+
console.log(
45+
'Emailing "' + subject + '" to ' + email + ' with body "' + body + '"',
46+
);
4347
MailApp.sendEmail({
4448
to: email,
4549
subject: subject,
46-
htmlBody: body
47-
})
48-
})
49-
})
50+
htmlBody: body,
51+
});
52+
});
53+
});
5054
}
5155

5256
function processTemplate(template, event, properties) {
53-
return template.replace(/\$\{(event|properties)\.([^\}]+)\}/g, function(match, p1, p2, offset, string, groups) {
54-
if (p1 == 'event') {
55-
console.log('Template matches ${event.' + p2 + '}')
56-
if (p2.endsWith('()')) {
57-
console.log('Invoking event.' + p2)
58-
return event[p2.slice(0, -2)]() || match
57+
return template.replace(
58+
/\$\{(event|properties)\.([^\}]+)\}/g,
59+
function (match, p1, p2, offset, string, groups) {
60+
if (p1 == "event") {
61+
console.log("Template matches ${event." + p2 + "}");
62+
if (p2.endsWith("()")) {
63+
console.log("Invoking event." + p2);
64+
return event[p2.slice(0, -2)]() || match;
65+
}
66+
return match;
67+
} else if (p1 == "properties") {
68+
console.log("Template matches ${properties." + p2 + "}");
69+
return properties.getProperty(p2) || match;
5970
}
60-
return match
61-
} else if (p1 == 'properties') {
62-
console.log('Template matches ${properties.' + p2 + '}')
63-
return properties.getProperty(p2) || match
64-
}
65-
return string
66-
})
71+
return string;
72+
},
73+
);
6774
}

birthday-reminders/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ Receive an email notification for each birthday in your 'Birthdays' calendar. Th
55
I run this daily using a [standalone script](https://developers.google.com/apps-script/guides/standalone) with [time-driven trigger](https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers).
66

77
The script has two optional [script properties](https://developers.google.com/apps-script/guides/properties#manage_script_properties_manually):
8+
89
- calendar: the name of the Google Calendar to monitor (default is 'Birthdays').
910
- offset: the numbers of days before an event that you want to receive the email (default is 0).
1011
- subjectTemplate: template used to generate the email subject, see syntax below (default is ${event.getTitle()}).
1112
- bodyTemplate: template used to generate the email body, see syntax below (default is ${event.getDescription()}).
1213

1314
The syntax for the template properties is a string where the following substitutions will be conducted:
15+
1416
- all occurrences of the ${event.getFoo()} where getFoo() is a method with no argument from the [Calendar event object](https://developers.google.com/apps-script/reference/calendar/calendar-event) will be replaced with the corresponding value returned by the method.
1517
- all occurrences of the ${properties.foo} where foo can be any [script property](https://developers.google.com/apps-script/guides/properties#manage_script_properties_manually) will be replaced with the corresponding value.

export-to-office/Code.gs

Lines changed: 65 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,94 @@
1-
'use strict'
1+
"use strict";
22

3-
function exportToOffice () {
4-
let expiry = PropertiesService.getScriptProperties().getProperty('expiry')
3+
function exportToOffice() {
4+
let expiry = PropertiesService.getScriptProperties().getProperty("expiry");
55
if (expiry == null) {
6-
expiry = 30
6+
expiry = 30;
77
}
8-
let folderName = PropertiesService.getScriptProperties().getProperty('folder')
8+
let folderName =
9+
PropertiesService.getScriptProperties().getProperty("folder");
910
if (folderName == null) {
10-
folderName = 'Export'
11+
folderName = "Export";
1112
}
12-
const modulo = new Date().getUTCHours()
13-
const now = new Date()
14-
const description = '#ExportedToOffice'
13+
const modulo = new Date().getUTCHours();
14+
const now = new Date();
15+
const description = "#ExportedToOffice";
1516
const conversions = [
16-
['application/vnd.google-apps.spreadsheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', '.xslx'],
17-
['application/vnd.google-apps.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', '.docx'],
18-
['application/vnd.google-apps.presentation', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', '.pptx']
19-
]
20-
const folders = DriveApp.getRootFolder().getFoldersByName(folderName)
17+
[
18+
"application/vnd.google-apps.spreadsheet",
19+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
20+
".xslx",
21+
],
22+
[
23+
"application/vnd.google-apps.document",
24+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
25+
".docx",
26+
],
27+
[
28+
"application/vnd.google-apps.presentation",
29+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
30+
".pptx",
31+
],
32+
];
33+
const folders = DriveApp.getRootFolder().getFoldersByName(folderName);
2134
if (!folders.hasNext()) {
22-
throw 'Folder "' + folderName + '" not found'
35+
throw 'Folder "' + folderName + '" not found';
2336
}
24-
const folder = folders.next()
37+
const folder = folders.next();
2538
if (folders.hasNext()) {
26-
throw 'More than one "' + folderName + '" folder'
39+
throw 'More than one "' + folderName + '" folder';
2740
}
28-
const oldFiles = folder.getFiles()
41+
const oldFiles = folder.getFiles();
2942
while (oldFiles.hasNext()) {
30-
const oldFile = oldFiles.next()
43+
const oldFile = oldFiles.next();
3144
if (oldFile.getDescription() === description) {
3245
if (oldFile.getDateCreated() - now > expiry) {
33-
console.log('Deleting obsolete file "' + oldFile.getName() + '"')
34-
oldFile.setTrashed(true)
46+
console.log('Deleting obsolete file "' + oldFile.getName() + '"');
47+
oldFile.setTrashed(true);
3548
} else if (oldFile.getName().charCodeAt(0) % 24 === modulo) {
36-
console.log('Deleting file "' + oldFile.getName() + '"')
37-
oldFile.setTrashed(true)
49+
console.log('Deleting file "' + oldFile.getName() + '"');
50+
oldFile.setTrashed(true);
3851
}
3952
}
4053
}
41-
for(var i = 0; i < conversions.length; i++) {
42-
const conversion = conversions[i]
43-
console.log('Searching for "' + conversion[0] + '" files...')
44-
const files = DriveApp.getFilesByType(conversion[0])
54+
for (var i = 0; i < conversions.length; i++) {
55+
const conversion = conversions[i];
56+
console.log('Searching for "' + conversion[0] + '" files...');
57+
const files = DriveApp.getFilesByType(conversion[0]);
4558
while (files.hasNext()) {
46-
const file = files.next()
59+
const file = files.next();
4760
if (file.isTrashed()) {
48-
console.log('Skipping trashed file "' + file.getName() + '"')
49-
continue
61+
console.log('Skipping trashed file "' + file.getName() + '"');
62+
continue;
5063
}
51-
if (file.getAccess(Session.getActiveUser()) !== DriveApp.Permission.OWNER) {
52-
console.log('Skipping shared file "' + file.getName() + '"')
53-
continue
64+
if (
65+
file.getAccess(Session.getActiveUser()) !== DriveApp.Permission.OWNER
66+
) {
67+
console.log('Skipping shared file "' + file.getName() + '"');
68+
continue;
5469
}
5570
if (file.getName().charCodeAt(0) % 24 === modulo) {
56-
console.log('Converting "' + file.getName() + '"')
57-
const blob = getFileAsBlob(file.getId(), conversion[1])
58-
const newFile = folder.createFile(blob)
59-
newFile.setName(file.getName() + conversion[2])
60-
newFile.setDescription(description)
71+
console.log('Converting "' + file.getName() + '"');
72+
const blob = getFileAsBlob(file.getId(), conversion[1]);
73+
const newFile = folder.createFile(blob);
74+
newFile.setName(file.getName() + conversion[2]);
75+
newFile.setDescription(description);
6176
}
6277
}
6378
}
6479
}
6580

66-
function getFileAsBlob (fileId, mimeType) {
67-
const response = UrlFetchApp.fetch('https://www.googleapis.com/drive/v3/files/' + fileId + '/export?mimeType=' + encodeURIComponent(mimeType), {
68-
headers: {
69-
Authorization: 'Bearer ' + ScriptApp.getOAuthToken(),
81+
function getFileAsBlob(fileId, mimeType) {
82+
const response = UrlFetchApp.fetch(
83+
"https://www.googleapis.com/drive/v3/files/" +
84+
fileId +
85+
"/export?mimeType=" +
86+
encodeURIComponent(mimeType),
87+
{
88+
headers: {
89+
Authorization: "Bearer " + ScriptApp.getOAuthToken(),
90+
},
7091
},
71-
})
72-
return response.getBlob()
92+
);
93+
return response.getBlob();
7394
}

export-to-office/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ Export all Google Docs, Google Spreasheets and Google Slides to Microsoft Word,
55
Since Apps Scripts have a 6-minute runtime limite, I run this script hourly using a [standalone script](https://developers.google.com/apps-script/guides/standalone) with [time-driven trigger](https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers). Each run exports 1/24th of the files in Google Drive so at the end of each day, all files should have been exported.
66

77
The script has two optional [script properties](https://developers.google.com/apps-script/guides/properties#manage_script_properties_manually):
8+
89
- folder: the name of the Google Drive folder to save the converted files (default is 'Export'). This folder must be at the root of your Google Drive (to avoid name collisions).
910
- expiry: the number of days after which an orphan exported file gets deleted (default is 30).

0 commit comments

Comments
 (0)