Skip to content

Commit bf300c8

Browse files
authored
Add eslint (#27)
* clean up eslint issues * update example * fix eslnit for case * remove unused variable * bump version
1 parent c9074f8 commit bf300c8

File tree

7 files changed

+756
-23
lines changed

7 files changed

+756
-23
lines changed

app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const moesifOptions = {
2020
var moesifMiddleware = moesif(moesifOptions);
2121
moesifMiddleware.startCaptureOutgoing();
2222

23-
exports.handler = function (event, context, callback) {
23+
var handler = function (event, context, callback) {
2424
// Outgoing API call to third party
2525
https.get(
2626
{
@@ -49,7 +49,7 @@ exports.handler = function (event, context, callback) {
4949
});
5050
};
5151

52-
// Async Functions
52+
// Async Functions
5353
// For more details, please refer to - https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html.
5454

5555
// exports.handler = async (event, context) => {
@@ -60,4 +60,4 @@ exports.handler = function (event, context, callback) {
6060
// return response
6161
// }
6262

63-
exports.handler = moesif(moesifOptions, exports.handler);
63+
exports.handler = moesif(moesifOptions, handler);

eslint.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
4+
5+
export default [
6+
{files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}},
7+
{languageOptions: { globals: globals.node }},
8+
pluginJs.configs.recommended,
9+
];

lib/dataUtils.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,6 @@ function _getEventModelFromRequestandResponse(
229229
return logData;
230230
}
231231

232-
var logMessage = function(debug, functionName, message) {
233-
if (debug) {
234-
console.log('MOESIF: [' + functionName + '] ' + message);
235-
}
236-
};
237-
238232
module.exports = {
239233
getUrlFromRequestOptions: _getUrlFromRequestOptions,
240234
getEventModelFromRequestandResponse: _getEventModelFromRequestandResponse,

lib/governanceRulesManager.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ GovernanceRulesManager.prototype._cacheRules = function (rules) {
224224
break;
225225
case RULE_TYPES.USER:
226226
self.userRulesHashByRuleId[rule._id] = rule;
227+
break;
227228
case RULE_TYPES.REGEX:
228229
break;
229230
default:
@@ -471,7 +472,7 @@ GovernanceRulesManager.prototype.governRequest = function (config, userId, compa
471472
}
472473
} catch (err) {
473474
this.log('error trying to govern request ' + err.toString, {
474-
url: request && request.originalUrl,
475+
requestFields,
475476
userId,
476477
companyId,
477478
});

lib/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const governanceRulesManager = require('./governanceRulesManager');
66
const EventModel = moesifapi.EventModel;
77
const UserModel = moesifapi.UserModel;
88
const CompanyModel = moesifapi.CompanyModel;
9-
var startTime = Date.now();
9+
1010
var createRecorder = require('./outgoingRecorder');
1111
var patch = require('./outgoing');
1212
var createBatcher = require('./batcher');
@@ -229,13 +229,11 @@ module.exports = function (options, handler) {
229229
};
230230

231231
moesifMiddleware.updateUsersBatch = function(usersBatchModel, cb) {
232-
usersBatch = [];
232+
var usersBatch = [];
233233
for (let userModel of usersBatchModel) {
234234
usersBatch.push(new UserModel(userModel));
235235
}
236236
logMessage(options.debug, 'updateUsersBatch', 'usersBatchModel=' + JSON.stringify(usersBatchModel));
237-
ensureValidUsersBatchModel(usersBatch);
238-
logMessage(options.debug, 'updateUsersBatch', 'usersBatchModel valid');
239237
moesifController.updateUsersBatch(usersBatch, cb);
240238
};
241239

@@ -248,13 +246,11 @@ module.exports = function (options, handler) {
248246
}
249247

250248
moesifMiddleware.updateCompaniesBatch = function(companiesBatchModel, cb) {
251-
companiesBatch = [];
249+
var companiesBatch = [];
252250
for (let companyModel of companiesBatchModel) {
253251
companiesBatch.push(new CompanyModel(companyModel));
254252
}
255253
logMessage(options.debug, 'updateCompaniesBatch', 'companiesBatchModel=' + JSON.stringify(companiesBatchModel));
256-
ensureValidCompaniesBatchModel(companiesBatch);
257-
logMessage(options.debug, 'updateCompaniesBatch', 'companiesBatchModel valid');
258254
moesifController.updateCompaniesBatch(companiesBatch, cb);
259255
};
260256

0 commit comments

Comments
 (0)