Skip to content

Commit d8cf95e

Browse files
Fixed all ESLint issues
1 parent 8df3f1d commit d8cf95e

File tree

26 files changed

+58
-60
lines changed

26 files changed

+58
-60
lines changed

Diff for: authenticated-json-api/functions/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ const authenticate = async (req, res, next) => {
3939
const decodedIdToken = await admin.auth().verifyIdToken(idToken);
4040
req.user = decodedIdToken;
4141
next();
42+
return;
4243
} catch(e) {
4344
res.status(403).send('Unauthorized');
45+
return;
4446
}
4547
};
4648

@@ -103,7 +105,7 @@ app.get('/message/:messageId', async (req, res) => {
103105
return res.set('Cache-Control', 'private, max-age=300');
104106
} catch(error) {
105107
console.log('Error getting message details', messageId, error.message);
106-
res.sendStatus(500);
108+
return res.sendStatus(500);
107109
}
108110
});
109111

Diff for: authorized-https-endpoint/functions/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ const validateFirebaseIdToken = async (req, res, next) => {
6060
console.log('ID Token correctly decoded', decodedIdToken);
6161
req.user = decodedIdToken;
6262
next();
63+
return;
6364
} catch (error) {
6465
console.error('Error while verifying Firebase ID token:', error);
6566
res.status(403).send('Unauthorized');
67+
return;
6668
}
6769
};
6870

Diff for: child-count/functions/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ exports.countlikechange = functions.database.ref('/posts/{postid}/likes/{likeid}
4040
return (current || 0) + increment;
4141
});
4242
console.log('Counter updated.');
43+
return null;
4344
});
4445

4546
// If the number of likes gets deleted, recount the number of likes
@@ -50,5 +51,5 @@ exports.recountlikes = functions.database.ref('/posts/{postid}/likes_count').onD
5051
// Return the promise from counterRef.set() so our function
5152
// waits for this async event to complete before it exits.
5253
const messagesData = await collectionRef.once('value');
53-
await counterRef.set(messagesData.numChildren());
54+
return await counterRef.set(messagesData.numChildren());
5455
});

Diff for: convert-images/functions/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,5 @@ exports.imageToJPG = functions.storage.object().onFinalize(async (object) => {
6565
// Once the image has been converted delete the local files to free up disk space.
6666
fs.unlinkSync(tempLocalJPEGFile);
6767
fs.unlinkSync(tempLocalFile);
68+
return null;
6869
});

Diff for: coupon-on-purchase/functions/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ async function sendCouponViaFCM(uid, userLanguage) {
7272
// Send notifications to all tokens.
7373
return admin.messaging().sendToDevice(tokens, payload);
7474
}
75+
return null;
7576
}
7677

7778
/**
@@ -105,6 +106,7 @@ async function sendHighValueCouponViaFCM(uid, userLanguage) {
105106
// Send notifications to all tokens.
106107
return admin.messaging().sendToDevice(tokens, payload);
107108
}
109+
return null;
108110
}
109111

110112
/**

Diff for: crashlytics-integration/jira-issue/functions/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function calculateIssuePriority(eventType) {
4040
// new issues - return low priority
4141
return 4;
4242
}
43-
};
43+
}
4444

4545
// Helper function that parses the Jira project url and returns an object
4646
// of the url fragments
@@ -52,7 +52,7 @@ function parseUrl(url) {
5252
} else {
5353
throw new Error('Unexpected URL Format');
5454
}
55-
};
55+
}
5656

5757
// Helper function that posts to Jira to create a new issue
5858
function createJiraIssue(summary, description, priority) {
@@ -96,7 +96,7 @@ function createJiraIssue(summary, description, priority) {
9696
body: newIssue,
9797
json: true,
9898
});
99-
};
99+
}
100100

101101
exports.createNewIssue = functions.crashlytics.issue().onNew(async (issue) => {
102102
const issueId = issue.issueId;

Diff for: crashlytics-integration/slack-notifier/functions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function notifySlack(slackMessage) {
3030
},
3131
json: true,
3232
});
33-
};
33+
}
3434

3535
exports.postOnNewIssue = functions.crashlytics.issue().onNew(async (issue) => {
3636
const issueId = issue.issueId;

Diff for: delete-unused-accounts-cron/functions/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ exports.accountcleanup = functions.https.onRequest(async (req, res) => {
4848
await promisePool.start();
4949
console.log('User cleanup finished');
5050
res.send('User cleanup finished');
51+
return null;
5152
});
5253

5354
/**
@@ -59,9 +60,9 @@ function deleteInactiveUser(inactiveUsers) {
5960

6061
// Delete the inactive user.
6162
return admin.auth().deleteUser(userToDelete.uid).then(() => {
62-
console.log('Deleted user account', userToDelete.uid, 'because of inactivity');
63+
return console.log('Deleted user account', userToDelete.uid, 'because of inactivity');
6364
}).catch((error) => {
64-
console.error('Deletion of inactive user account', userToDelete.uid, 'failed:', error);
65+
return console.error('Deletion of inactive user account', userToDelete.uid, 'failed:', error);
6566
});
6667
} else {
6768
return null;

Diff for: email-confirmation/functions/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ exports.sendEmailConfirmation = functions.database.ref('/users/{uid}').onWrite(a
5858
} catch(error) {
5959
console.error('There was an error while sending the email:', error);
6060
}
61+
return null;
6162
});

Diff for: exif-images/functions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exports.metadata = functions.storage.object().onFinalize(async (object) => {
5757
// Cleanup temp directory after metadata is extracted
5858
// Remove the file from temp directory
5959
await fs.unlinkSync(tempLocalFile)
60-
console.log('cleanup successful!');
60+
return console.log('cleanup successful!');
6161
});
6262

6363
/**

Diff for: ffmpeg-convert-audio/functions/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ exports.generateMonoAudio = functions.storage.object().onFinalize(async (object)
8282
fs.unlinkSync(tempFilePath);
8383
fs.unlinkSync(targetTempFilePath);
8484

85-
console.log('Temporary files removed.', targetTempFilePath);
85+
return console.log('Temporary files removed.', targetTempFilePath);
8686
});

Diff for: fulltext-search-firestore/functions/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ async function getFirebaseUser(req, res, next) {
7070
const decodedIdToken = admin.auth().verifyIdToken(idToken);
7171
console.log('ID Token correctly decoded', decodedIdToken);
7272
req.user = decodedIdToken;
73-
next();
73+
return next();
7474
} catch(error) {
7575
console.error('Error while verifying Firebase ID token:', error);
76-
res.status(403).send('Unauthorized');
76+
return res.status(403).send('Unauthorized');
7777
}
7878
}
7979
// [END get_firebase_user]

Diff for: generate-thumbnail/functions/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ exports.generateThumbnail = functions.storage.object().onFinalize(async (object)
4949

5050
// Exit if this is triggered on a file that is not an image.
5151
if (!contentType.startsWith('image/')) {
52-
console.log('This is not an image.');
53-
return null;
52+
return console.log('This is not an image.');
5453
}
5554

5655
// Exit if the image is already a thumbnail.
5756
if (fileName.startsWith(THUMB_PREFIX)) {
58-
console.log('Already a Thumbnail.');
59-
return null;
57+
return console.log('Already a Thumbnail.');
6058
}
6159

6260
// Cloud Storage files.
@@ -99,5 +97,5 @@ exports.generateThumbnail = functions.storage.object().onFinalize(async (object)
9997
const fileUrl = originalResult[0];
10098
// Add the URLs to the Database
10199
await admin.database().ref('images').push({path: fileUrl, thumbnail: thumbFileUrl});
102-
console.log('Thumbnail URLs saved to database.');
100+
return console.log('Thumbnail URLs saved to database.');
103101
});

Diff for: github-to-slack/functions/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ exports.githubWebhook = functions.https.onRequest(async (req, res) => {
4242

4343
try {
4444
await postToSlack(req.body.compare, req.body.commits.length, req.body.repository);
45-
res.end();
45+
return res.end();
4646
} catch(error) {
4747
console.error(error);
48-
res.status(500).send('Something went wrong while posting the message to Slack.');
48+
return res.status(500).send('Something went wrong while posting the message to Slack.');
4949
}
5050
});
5151

Diff for: google-sheet-sync/functions/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ const DB_TOKEN_PATH = '/api_tokens';
6464
exports.oauthcallback = functions.https.onRequest(async (req, res) => {
6565
res.set('Cache-Control', 'private, max-age=0, s-maxage=0');
6666
const code = req.query.code;
67-
functionsOauthClient.getToken(code, (err, tokens) => {
67+
try {
68+
const tokens = await functionsOauthClient.getToken(code);
6869
// Now tokens contains an access_token and an optional refresh_token. Save them.
69-
if (err) {
70-
return res.status(400).send(err);
71-
}
7270
await admin.database().ref(DB_TOKEN_PATH).set(tokens);
7371
return res.status(200).send('App successfully configured with new Credentials. '
7472
+ 'You can now close this page.');
75-
});
73+
} catch (error) {
74+
return res.status(400).send(error);
75+
}
7676
});
7777

7878
// trigger function to write to Sheet when new data comes in on CONFIG_DATA_PATH

Diff for: google-sheet-sync/functions/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"dependencies": {
55
"firebase-admin": "^5.13.1",
66
"firebase-functions": "^2.0.0",
7-
"google-auth-library": "^1.3.1",
7+
"google-auth-library": "^1.6.1",
88
"googleapis": "^27.0.0"
99
},
1010
"devDependencies": {

Diff for: instagram-auth/functions/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ exports.token = functions.https.onRequest(async (req, res) => {
8484
const oauth2 = instagramOAuth2Client();
8585

8686
try {
87-
return cookieParser()(req, res, () => {
87+
return cookieParser()(req, res, async () => {
8888
console.log('Received verification state:', req.cookies.state);
8989
console.log('Received state:', req.query.state);
9090
if (!req.cookies.state) {
@@ -108,12 +108,10 @@ exports.token = functions.https.onRequest(async (req, res) => {
108108
// Create a Firebase account and get the Custom Auth Token.
109109
const firebaseToken = await createFirebaseAccount(instagramUserID, userName, profilePic, accessToken);
110110
// Serve an HTML page that signs the user in and updates the user profile.
111-
res.jsonp({
112-
token: firebaseToken,
113-
});
111+
return res.jsonp({ token: firebaseToken});
114112
});
115113
} catch(error) {
116-
res.jsonp({
114+
return res.jsonp({
117115
error: error.toString(),
118116
});
119117
}

Diff for: limit-children/functions/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ exports.truncate = functions.database.ref('/chat/{messageid}').onWrite(async (ch
3636
// Update the parent. This effectively removes the extra children.
3737
return parentRef.update(updates);
3838
}
39+
return null;
3940
});

Diff for: line-auth/functions/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ exports.verifyToken = functions.https.onRequest(async (req, res) => {
116116
const ret = {
117117
error_message: 'Access Token not found',
118118
};
119-
res.status(400).send(ret);
120-
return;
119+
return res.status(400).send(ret);
121120
}
122121

123122
const reqToken = req.body.token;
@@ -128,7 +127,7 @@ exports.verifyToken = functions.https.onRequest(async (req, res) => {
128127
const ret = {
129128
firebase_token: customAuthToken,
130129
};
131-
res.status(200).send(ret);
130+
return res.status(200).send(ret);
132131
} catch(err) {
133132
// If LINE access token verification failed, return error response to client
134133
const ret = {

Diff for: linkedin-auth/functions/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ exports.token = functions.https.onRequest((req, res) => {
107107
});
108108
});
109109
} catch (error) {
110-
res.jsonp({
111-
error: error.toString,
112-
});
110+
return res.jsonp({ error: error.toString });
113111
}
114112
});
115113

Diff for: moderate-images/functions/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ exports.blurOffensiveImages = functions.storage.object().onFinalize(async (objec
3838
if (safeSearch.adult || safeSearch.violence) {
3939
return blurImage(object.name, object.bucket, object.metadata);
4040
}
41+
return null;
4142
});
4243

4344
/**

Diff for: nextjs-with-firebase-hosting/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"description": "Host Next.js SSR app on Firebase Cloud Functions with Firebase Hosting redirects.",
55
"repository": "https://github.com/jthegedus/firebase-functions-next-example.git",
66
"scripts": {
7-
"install": "yarn build-all",
8-
"next": "yarn build-firebase && cd \"src/app\" && yarn && yarn dev",
9-
"preserve": "yarn build-all",
7+
"install": "npm run build-all",
8+
"next": "npm run build-firebase && cd \"src/app\" && npm install",
9+
"preserve": "npm run build-all",
1010
"serve": "firebase serve",
11-
"predeploy": "yarn build-all",
11+
"predeploy": "npm run build-all",
1212
"deploy": "firebase deploy",
13-
"build-all": "yarn build-next && yarn build-firebase",
14-
"build-next": "cd \"src/app\" && yarn && yarn build",
15-
"build-firebase": "cd \"src/functions\" && yarn"
13+
"build-all": "npm run build-next && npm run build-firebase",
14+
"build-next": "cd \"src/app\" && npm install && npm build",
15+
"build-firebase": "cd \"src/functions\" && npm install"
1616
}
1717
}

Diff for: paypal/functions/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"parserOptions": {
33
// Required for certain syntax usages
4-
"ecmaVersion": 6
4+
"ecmaVersion": 2017
55
},
66
"plugins": [
77
"promise"

Diff for: quickstarts/thumbnails/functions/index.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,14 @@ exports.generateThumbnail = functions.storage.object().onFinalize(async (object)
4141
// [START stopConditions]
4242
// Exit if this is triggered on a file that is not an image.
4343
if (!contentType.startsWith('image/')) {
44-
console.log('This is not an image.');
45-
return null;
44+
return console.log('This is not an image.');
4645
}
4746

4847
// Get the file name.
4948
const fileName = path.basename(filePath);
5049
// Exit if the image is already a thumbnail.
5150
if (fileName.startsWith('thumb_')) {
52-
console.log('Already a Thumbnail.');
53-
return null;
51+
return console.log('Already a Thumbnail.');
5452
}
5553
// [END stopConditions]
5654

@@ -75,7 +73,7 @@ exports.generateThumbnail = functions.storage.object().onFinalize(async (object)
7573
metadata: metadata,
7674
});
7775
// Once the thumbnail has been uploaded delete the local file to free up disk space.
78-
fs.unlinkSync(tempFilePath);
76+
return fs.unlinkSync(tempFilePath);
7977
// [END thumbnailGeneration]
8078
});
8179
// [END generateThumbnail]

Diff for: template-handlebars/functions/firebaseUser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function validateFirebaseIdToken (req, res, next) {
3131
await addDecodedIdTokenToRequest(idToken, req);
3232
}
3333
next();
34-
};
34+
}
3535

3636
/**
3737
* Returns a Promise with the Firebase ID Token if found in the Authorization or the __session cookie.

0 commit comments

Comments
 (0)