Skip to content

Commit

Permalink
Merge pull request #212 from golopot/eslint
Browse files Browse the repository at this point in the history
Add eslint and fix lint errors
  • Loading branch information
bithavoc authored Jun 12, 2019
2 parents df81eb9 + a334522 commit 0401a8d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": ["eslint:recommended"],
"env": {
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"no-unused-vars": [2, { "args": "none" }]
},
"overrides": [
{
"files": "test/**",
"env": {
"mocha": true
}
}
]
}
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function filterObject(originalObj, whiteList, initialFilter) {
if(typeof (value) !== 'undefined') {
obj[propName] = value;
fieldsSet = true;
};
}
});

return fieldsSet?obj:undefined;
Expand Down Expand Up @@ -249,7 +249,7 @@ exports.logger = function logger(options) {
return function (req, res, next) {
var coloredRes = {};

var currentUrl = req.originalUrl || req.url;
var currentUrl = req.originalUrl || req.url;
if (currentUrl && _.includes(options.ignoredRoutes, currentUrl)) return next();
if (options.ignoreRoute(req, res)) return next();

Expand All @@ -273,7 +273,7 @@ exports.logger = function logger(options) {
res.end = end;
res.end(chunk, encoding);

req.url = req.originalUrl || req.url;
req.url = req.originalUrl || req.url;

var meta = {};

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
},
"main": "index.js",
"scripts": {
"test": "nyc mocha && nyc report --reporter lcov"
"pretest": "eslint .",
"test": "node_modules/.bin/mocha --reporter spec"
},
"dependencies": {
"chalk": "^2.4.1",
"lodash": "^4.17.10"
},
"devDependencies": {
"eslint": "^5.16.0",
"mocha": "^5.2.0",
"node-mocks-http": "^1.5.1",
"nyc": "^14.1.1",
Expand Down
10 changes: 1 addition & 9 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
var util = require('util');

var mocks = require('node-mocks-http');
var should = require('should');
var _ = require('lodash');
var winston = require('winston');
var Transport = require('winston-transport');

var expressWinston = require('../index.js');
Expand Down Expand Up @@ -264,11 +261,6 @@ describe('express-winston', function () {
return errorLoggerTestHelper(testHelperOptionsWithBlacklist).then(function (result) {
result.log.meta.should.not.have.property('trace');
});

var testHelperOptionsWithoutBlacklist = { loggerOptions: {} };
return errorLoggerTestHelper(testHelperOptionsWithoutBlacklist).then(function (result) {
result.log.meta.should.have.property('trace');
});
});
});

Expand Down Expand Up @@ -676,7 +668,7 @@ describe('express-winston', function () {

describe('when middleware function is invoked on a route that returns JSON', function() {
it('should parse JSON in response body', function() {
var bodyObject = { "message": "Hi! I\'m a chunk!" };
var bodyObject = { "message": "Hi! I'm a chunk!" };
function next(req, res, next) {
// Set Content-Type in a couple different case types, just in case.
// Seems like the mock response doesn't quite handle the case
Expand Down

0 comments on commit 0401a8d

Please sign in to comment.