Skip to content

Commit

Permalink
Resolve some ESLint console warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pdehaan authored and groovecoder committed May 17, 2018
1 parent 2a29fc8 commit 79b7b56
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
14 changes: 13 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,26 @@ module.exports = {
"eslint:recommended",
"plugin:node/recommended",
],
overrides: [
{
files: [
'scripts/*.js',
'tests/**/*.js',
],
rules: {
"no-console": "off",
"no-process-exit": "off",
}
}
],
plugins: [
"node",
],
root: true,
rules: {
"comma-dangle": ["error", {arrays: "always-multiline", objects: "always-multiline"}],
"eqeqeq": "warn",
"no-console": "warn",
"no-console": ["warn", {allow: ["error", "info", "warn"]}],
"no-process-env": "error",
"no-unused-vars": ["error", {vars: "all", args: "none", ignoreRestSiblings: false}],
"no-var": "error",
Expand Down
6 changes: 3 additions & 3 deletions email-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ const EmailUtils = {
// Allow a debug mode that will send JSON back to the client instead of sending emails.
// eslint-disable-next-line no-process-env
if (process.env.DEBUG_DUMMY_SMTP) {
console.log("Running in dummy SMTP mode, /user/breached will send a JSON response instead of sending emails.");
console.info("Running in dummy SMTP mode, /user/breached will send a JSON response instead of sending emails.");
gTransporter = {
sendMail(options, callback) {
callback(null, "dummy mode");
},
};
return Promise.resolve(true);
}
console.log("Attempting to get SMTP credentials from environment...");
console.info("Attempting to get SMTP credentials from environment...");
kSMTPUsername = AppConstants.SMTP_USERNAME;
const password = AppConstants.SMTP_PASSWORD;
const host = AppConstants.SMTP_HOST;
Expand All @@ -60,7 +60,7 @@ const EmailUtils = {
return new Promise((resolve, reject) => {
gTransporter.verify((error, success) => {
if (error) {
console.log(error);
console.error(error);
gTransporter = null;
reject(error);
return;
Expand Down
2 changes: 1 addition & 1 deletion hibp.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const HIBP = {
"User-Agent": HIBP_USER_AGENT,
};

console.log(`Fetching ${url}...`);
console.info(`Fetching ${url}...`);

try {
const response = await got(url, {headers});
Expand Down
2 changes: 1 addition & 1 deletion routes/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ router.get("/confirmed", jsonParser, async (req, res) => {
email: email,
});
} catch (err) {
console.log(err);
console.error(err);
res.send(err);
}
});
Expand Down
5 changes: 3 additions & 2 deletions routes/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ router.post("/add", urlEncodedParser, async (req, res) => {
const unverifiedEmailHash = await DBUtils.addUnverifiedEmailHash(email);

const url = `${AppConstants.SERVER_URL}/user/verify?token=${encodeURIComponent(unverifiedEmailHash.verification_token)}&email=${encodeURIComponent(email)}`;
console.log(url); // Temporary for debugging.
// TODO: Temporary for debugging.
console.log(url);

try {
await EmailUtils.sendEmail(
Expand All @@ -40,7 +41,7 @@ router.post("/add", urlEncodedParser, async (req, res) => {
email: email,
});
} catch (e) {
console.log(e);
console.error(e);
res.status(500).json({
error_code: ResponseCodes.InternalError,
info: "SMTP error.",
Expand Down
2 changes: 0 additions & 2 deletions scripts/get-hashsets.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ function getBreachHashset(breach) {
async function handleBreachesResponse(error, response, body) {
if (error) {
console.error(error);
// We can `process.exit()` here since it's a CLI script.
// eslint-disable-next-line no-process-exit
process.exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.use("/user", UserRoutes);

EmailUtils.init().then(() => {
const listener = app.listen(AppConstants.PORT, () => {
console.log(`Listening on ${listener.address().port}`);
console.info(`Listening on ${listener.address().port}`);
});
}).catch(error => {
console.error(error);
Expand Down

0 comments on commit 79b7b56

Please sign in to comment.