Skip to content

Commit 362d67d

Browse files
committed
Fix 1000+ lint errors
1 parent d8444a9 commit 362d67d

File tree

45 files changed

+938
-239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+938
-239
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
moment.gs

.eslintrc.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
"extends": "google",
33
"parserOptions": {
4-
"ecmaVersion": 3,
4+
"ecmaVersion": 6,
55
},
66
"env": {
77
"node": true,
@@ -11,8 +11,9 @@ module.exports = {
1111
"camelcase": "off", // Off for destructuring
1212
"async-await/space-after-async": 2,
1313
"async-await/space-after-await": 2,
14+
"guard-for-in": "off",
1415
"no-var": "off", // ES3
1516
"no-unused-vars": "off" // functions aren't used.
1617
},
17-
"plugins": ["async-await"],
18+
"plugins": ["async-await"]
1819
};

adminSDK/directory/quickstart.gs

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
* limitations under the License.
1515
*/
1616
// [START admin_sdk_directory_quickstart]
17+
/**
18+
* Lists users in a G Suite domain.
19+
*/
1720
function listUsers() {
1821
var optionalArgs = {
1922
customer: 'my_customer',
2023
maxResults: 10,
21-
orderBy: 'email'
24+
orderBy: 'email',
2225
};
2326
var response = AdminDirectory.Users.list(optionalArgs);
2427
var users = response.users;

adminSDK/reports/quickstart.gs

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@
1414
* limitations under the License.
1515
*/
1616
// [START admin_sdk_reports_quickstart]
17+
/**
18+
* List login events for a G Suite domain.
19+
*/
1720
function listLogins() {
1821
var userKey = 'all';
1922
var applicationName = 'login';
2023
var optionalArgs = {
21-
maxResults: 10
24+
maxResults: 10,
2225
};
23-
var response = AdminReports.Activities.list(userKey, applicationName, optionalArgs)
26+
var response = AdminReports.Activities.list(userKey, applicationName, optionalArgs);
2427
var activities = response.items;
2528
if (activities && activities.length > 0) {
2629
Logger.log('Logins:');

adminSDK/reseller/quickstart.gs

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
* limitations under the License.
1515
*/
1616
// [START admin_sdk_reseller_quickstart]
17+
/**
18+
* List Admin SDK reseller subscriptions.
19+
*/
1720
function listSubscriptions() {
1821
var optionalArgs = {
19-
maxResults: 10
22+
maxResults: 10,
2023
};
2124
var response = AdminReseller.Subscriptions.list(optionalArgs);
2225
var subscriptions = response.subscriptions;

android/mobile-translate/Code.gs

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ function getSelectedText() {
9696
}
9797
}
9898
}
99-
if (text.length == 0) {
100-
throw 'Please select some text.';
99+
if (text.length) {
100+
throw new Error('Please select some text.');
101101
}
102102
return text;
103103
} else {
104-
throw 'Please select some text.';
104+
throw new Error('Please select some text.');
105105
}
106106
}
107107

@@ -118,7 +118,7 @@ function getPreferences() {
118118
var userProperties = PropertiesService.getUserProperties();
119119
var languagePrefs = {
120120
originLang: userProperties.getProperty('originLang'),
121-
destLang: userProperties.getProperty('destLang')
121+
destLang: userProperties.getProperty('destLang'),
122122
};
123123
return languagePrefs;
124124
}
@@ -170,7 +170,7 @@ function insertText(newText) {
170170
if (elements.length == 1 &&
171171
elements[0].getElement().getType() ==
172172
DocumentApp.ElementType.INLINE_IMAGE) {
173-
throw "Can't insert text into an image.";
173+
throw new Error('Can\'t insert text into an image.');
174174
}
175175
for (var i = 0; i < elements.length; i++) {
176176
if (elements[i].isPartial()) {

calendar/quickstart/quickstart.gs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function listUpcomingEvents() {
2424
showDeleted: false,
2525
singleEvents: true,
2626
maxResults: 10,
27-
orderBy: 'startTime'
27+
orderBy: 'startTime',
2828
};
2929
var response = Calendar.Events.list(calendarId, optionalArgs);
3030
var events = response.items;

calendar/vacationCalendar/vacationCalendar.gs

+18-17
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function syncTeamVacationCalendar() {
5454
events.forEach(function(event) {
5555
event.summary = '[' + username + '] ' + event.summary;
5656
event.organizer = {
57-
id: TEAM_CALENDAR_ID
57+
id: TEAM_CALENDAR_ID,
5858
};
5959
event.attendees = [];
6060
Logger.log('Importing: %s', event.summary);
@@ -74,26 +74,26 @@ function syncTeamVacationCalendar() {
7474
Logger.log('Execution time about to hit quota limit; execution stopped.');
7575
}
7676
var executionTime = ((new Date()).getTime() - today.getTime()) / 1000.0;
77-
Logger.log('Total execution time (s) : ' + executionTime);;
77+
Logger.log('Total execution time (s) : ' + executionTime); ;
7878
}
7979

8080
/**
8181
* In a given user's calendar, look for occurrences of the given keyword
8282
* in events within the specified date range and return any such events
8383
* found.
84-
* @param user the user's primary email String.
85-
* @param keyword the keyword String to look for.
86-
* @param start the starting Date of the range to examine.
87-
* @param end the ending Date of the range to examine.
88-
* @param opt_since a Date indicating the last time this script was run.
89-
* @return an array of calendar event Objects.
84+
* @param {string} user the user's primary email String.
85+
* @param {string} keyword the keyword String to look for.
86+
* @param {Date} start the starting Date of the range to examine.
87+
* @param {Date} end the ending Date of the range to examine.
88+
* @param {Date} opt_since a Date indicating the last time this script was run.
89+
* @return {object[]} an array of calendar event Objects.
9090
*/
9191
function findEvents(user, keyword, start, end, opt_since) {
9292
var params = {
9393
q: keyword,
9494
timeMin: formatDate(start),
9595
timeMax: formatDate(end),
96-
showDeleted: true
96+
showDeleted: true,
9797
};
9898
if (opt_since) {
9999
// This prevents the script from examining events that have not been
@@ -134,18 +134,19 @@ function findEvents(user, keyword, start, end, opt_since) {
134134

135135
/**
136136
* Return a list of the primary emails of users in this domain.
137-
* @return array of user email Strings.
137+
* @return {string[]} An array of user email strings.
138138
*/
139139
function getDomainUsers() {
140-
var pageToken, page;
140+
var pageToken;
141+
var page;
141142
var userEmails = [];
142143
do {
143144
page = AdminDirectory.Users.list({
144145
customer: 'my_customer',
145146
orderBy: 'givenName',
146147
maxResults: 100,
147148
pageToken: pageToken,
148-
viewType: 'domain_public'
149+
viewType: 'domain_public',
149150
});
150151
var users = page.users;
151152
if (users) {
@@ -163,8 +164,8 @@ function getDomainUsers() {
163164
/**
164165
* Return an RFC3339 formated date String corresponding to the given
165166
* Date object.
166-
* @param date a Date.
167-
* @return a formatted date string.
167+
* @param {Date} date a Date.
168+
* @return {string} a formatted date string.
168169
*/
169170
function formatDate(date) {
170171
return Utilities.formatDate(date, 'UTC', 'yyyy-MM-dd\'T\'HH:mm:ssZ');
@@ -174,9 +175,9 @@ function formatDate(date) {
174175
* Compares two Date objects and returns true if the difference
175176
* between them is more than the maximum specified run time.
176177
*
177-
* @param start the first Date object.
178-
* @param now the (later) Date object.
179-
* @returns true if the time difference is greater than
178+
* @param {Date} start the first Date object.
179+
* @param {Date} now the (later) Date object.
180+
* @return {boolean} true if the time difference is greater than
180181
* MAX_PROP_RUNTIME_MS (in milliseconds).
181182
*/
182183
function isTimeUp(start, now) {

classroom/quickstart/quickstart.gs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
function listCourses() {
2121
var optionalArgs = {
22-
pageSize: 10
22+
pageSize: 10,
2323
};
2424
var response = Classroom.Courses.list(optionalArgs);
2525
var courses = response.courses;

docs/cursorInspector/cursorInspector.gs

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function getDocumentInfo() {
5555
element: getElementInfo(cursor.getElement()),
5656
offset: cursor.getOffset(),
5757
surroundingText: cursor.getSurroundingText().getText(),
58-
surroundingTextOffset: cursor.getSurroundingTextOffset()
58+
surroundingTextOffset: cursor.getSurroundingTextOffset(),
5959
};
6060
}
6161
if (selection) {
@@ -65,10 +65,10 @@ function getDocumentInfo() {
6565
element: getElementInfo(selectedElement.getElement()),
6666
partial: selectedElement.isPartial(),
6767
startOffset: selectedElement.getStartOffset(),
68-
endOffsetInclusive: selectedElement.getEndOffsetInclusive()
69-
}
70-
})
71-
}
68+
endOffsetInclusive: selectedElement.getEndOffsetInclusive(),
69+
};
70+
}),
71+
};
7272
}
7373
return result;
7474
}

docs/dialog2sidebar/Code.gs

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function showSidebar() {
3636

3737
/**
3838
* Open a dialog in the document.
39+
* @return {string} The dialog ID.
3940
*/
4041
function openDialog() {
4142
var dialogId = Utilities.base64Encode(Math.random());
@@ -50,6 +51,8 @@ function openDialog() {
5051

5152
/**
5253
* Include the contents of the given file into the HTML content.
54+
* @param {string} filename The filename
55+
* @return {string} The content of the rendered file.
5356
*/
5457
function include(filename) {
5558
return HtmlService.createHtmlOutputFromFile(filename).getContent();

docs/translate/translate.gs

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
16+
// [START docs_translate_quickstart]
1717
/**
1818
* @OnlyCurrentDoc
1919
*
@@ -98,11 +98,11 @@ function getSelectedText() {
9898
}
9999
}
100100
if (!text.length) {
101-
throw 'Please select some text.';
101+
throw new Error('Please select some text.');
102102
}
103103
return text;
104104
} else {
105-
throw 'Please select some text.';
105+
throw new Error('Please select some text.');
106106
}
107107
}
108108

@@ -119,7 +119,7 @@ function getPreferences() {
119119
var userProperties = PropertiesService.getUserProperties();
120120
return {
121121
originLang: userProperties.getProperty('originLang'),
122-
destLang: userProperties.getProperty('destLang')
122+
destLang: userProperties.getProperty('destLang'),
123123
};
124124
}
125125

@@ -146,7 +146,7 @@ function getTextAndTranslation(origin, dest, savePrefs) {
146146
var text = getSelectedText().join('\n');
147147
return {
148148
text: text,
149-
translation: translateText(text, origin, dest)
149+
translation: translateText(text, origin, dest),
150150
};
151151
}
152152

@@ -166,7 +166,7 @@ function insertText(newText) {
166166
var elements = selection.getSelectedElements();
167167
if (elements.length === 1 && elements[0].getElement().getType() ===
168168
DocumentApp.ElementType.INLINE_IMAGE) {
169-
throw "Can't insert text into an image.";
169+
throw new Error('Can\'t insert text into an image.');
170170
}
171171
for (var i = 0; i < elements.length; ++i) {
172172
if (elements[i].isPartial()) {
@@ -250,3 +250,4 @@ function translateText(text, origin, dest) {
250250
if (origin === dest) return text;
251251
return LanguageApp.translate(text, origin, dest);
252252
}
253+
// [END docs_translate_quickstart]

drive/activity/quickstart.gs

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
* limitations under the License.
1515
*/
1616
// [START drive_activity_quickstart]
17+
/**
18+
* Lists activity for a Drive user.
19+
*/
1720
function listActivity() {
1821
var optionalArgs = {
19-
source: 'drive.google.com',
22+
'source': 'drive.google.com',
2023
'drive.ancestorId': 'root',
21-
pageSize: 10
24+
'pageSize': 10,
2225
};
2326
var response = AppsActivity.Activities.list(optionalArgs);
2427
var activities = response.activities;

drive/quickstart/quickstart.gs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
function listFiles() {
2121
var files = Drive.Files.list({
22-
fields: "nextPageToken, files(id, name)",
23-
pageSize: 10
22+
fields: 'nextPageToken, files(id, name)',
23+
pageSize: 10,
2424
}).files;
2525
for (var i = 0; i < files.length; i++) {
2626
var file = files[i];

0 commit comments

Comments
 (0)