Skip to content

Commit 2099b80

Browse files
authored
Revert "fix lint errors" (#47)
1 parent 4a699bf commit 2099b80

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

+258
-300
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@
88
"mocha": true
99
},
1010
"rules": {
11-
"no-param-reassign": 0,
12-
"global-require": 0,
13-
"func-names": 0,
14-
"no-mixed-operators": 0,
15-
"consistent-return": 0,
16-
"no-unused-expressions": 0,
17-
"newline-per-chained-call": 0,
18-
"no-underscore-dangle": 0,
19-
"import/no-extraneous-dependencies": ["error", {"devDependencies": true, "optionalDependencies": false, "peerDependencies": false}],
20-
"max-len": ["error", {
21-
"code": 120,
22-
"ignoreComments": true,
23-
"ignoreTrailingComments": true,
24-
"tabWidth": 2
25-
}],
2611
"valid-jsdoc": ["error", {
2712
"requireReturn": true,
2813
"requireReturnType": true,

config/sample.local.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
// force using test.json for unit tests
22

3-
let config;
3+
var config
44
if (process.env.NODE_ENV === 'test') {
5-
config = require('./test.json');
5+
config = require('./test.json')
66
} else {
77
config = {
8-
authSecret: 'secret',
9-
logLevel: 'debug',
10-
captureLogs: 'false',
11-
logentriesToken: '',
12-
rabbitmqURL: 'amqp://dockerhost:5672',
13-
fileServiceEndpoint: 'https://api.topcoder-dev.com/v3/files/',
14-
topicServiceEndpoint: 'https://api.topcoder-dev.com/v4/topics/',
15-
directProjectServiceEndpoint: 'https://api.topcoder-dev.com/v3/direct',
16-
userServiceUrl: 'https://api.topcoder-dev.com/v3/users',
17-
connectProjectsUrl: 'https://connect.topcoder-dev.com/projects/',
18-
salesforceLead: {
19-
webToLeadUrl: 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8',
20-
orgId: '00D2C0000000dO6',
21-
projectNameFieldId: 'title',
22-
projectDescFieldId: 'description',
23-
projectLinkFieldId: 'URL',
24-
projectIdFieldId: '00N2C000000Vxxx',
25-
},
26-
dbConfig: {
27-
masterUrl: 'postgres://coder:mysecretpassword@dockerhost:5432/projectsdb',
28-
maxPoolSize: 50,
29-
minPoolSize: 4,
30-
idleTimeout: 1000,
31-
},
32-
};
8+
"authSecret": "secret",
9+
"logLevel": "debug",
10+
"captureLogs": "false",
11+
"logentriesToken": "",
12+
"rabbitmqURL": "amqp://dockerhost:5672",
13+
"fileServiceEndpoint": "https://api.topcoder-dev.com/v3/files/",
14+
"topicServiceEndpoint": "https://api.topcoder-dev.com/v4/topics/",
15+
"directProjectServiceEndpoint": "https://api.topcoder-dev.com/v3/direct",
16+
"userServiceUrl": "https://api.topcoder-dev.com/v3/users",
17+
"connectProjectsUrl": "https://connect.topcoder-dev.com/projects/",
18+
"salesforceLead" : {
19+
"webToLeadUrl": 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8',
20+
"orgId": "00D2C0000000dO6",
21+
"projectNameFieldId": "title",
22+
"projectDescFieldId": "description",
23+
"projectLinkFieldId": "URL",
24+
"projectIdFieldId" : "00N2C000000Vxxx"
25+
},
26+
"dbConfig": {
27+
"masterUrl": "postgres://coder:mysecretpassword@dockerhost:5432/projectsdb",
28+
"maxPoolSize": 50,
29+
"minPoolSize": 4,
30+
"idleTimeout": 1000
31+
}
32+
}
3333
}
34-
module.exports = config;
34+
module.exports = config

migrations/sync.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1+
'use strict'
2+
13
/**
24
* Sync the database models to db tables.
35
*/
46

5-
import winston from 'winston';
6-
77
/**
88
* Make sure we are in development mode
99
* @type {String}
1010
*/
1111
// process.env.NODE_ENV = 'development'
1212

13-
require('../dist/models').default.sequelize.sync({ force: true })
13+
require('./dist/models').default.sequelize.sync({ force: true })
1414
.then(() => {
15-
winston.info('Database synced successfully');
16-
process.exit();
15+
console.log('Database synced successfully')
16+
process.exit()
1717
}).catch((err) => {
18-
winston.error('Error syncing database', err);
19-
process.exit(1);
20-
});
18+
console.error('Error syncing database', err)
19+
process.exit(1)
20+
})

newrelic.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
1+
'use strict'
22

33
/**
44
* New Relic agent configuration.
55
*
66
* See lib/config.defaults.js in the agent distribution for a more complete
77
* description of configuration variables and their potential values.
88
*/
9-
let appName = 'tc-projects-service';
9+
var appName = "tc-projects-service"
1010
if (process.env.NODE_ENV === 'development') {
11-
appName += '-dev';
11+
appName += "-dev"
1212
} else if (process.env.NODE_ENV === 'qa') {
13-
appName += '-qa';
13+
appName += "-qa"
1414
} else {
15-
appName += '-prod';
15+
appName += '-prod'
1616
}
1717

1818
exports.config = {
@@ -30,6 +30,6 @@ exports.config = {
3030
* issues with the agent, 'info' and higher will impose the least overhead on
3131
* production applications.
3232
*/
33-
level: 'info',
34-
},
35-
};
33+
level: 'info'
34+
}
35+
}

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"scripts": {
1010
"build": "babel src -d dist --presets es2015",
1111
"sync": "node migrations/sync.js",
12-
"lint": "./node_modules/.bin/eslint .",
13-
"lint:fix": "./node_modules/.bin/eslint . --fix || true",
12+
"lint": "./node_modules/.bin/eslint src",
1413
"prestart": "npm run -s build",
1514
"start": "node dist",
1615
"start:dev": "NODE_ENV=local PORT=8001 nodemon -w src --exec \"babel-node src --presets es2015\" | ./node_modules/.bin/bunyan",
@@ -48,8 +47,7 @@
4847
"pg": "^4.5.5",
4948
"pg-native": "^1.10.0",
5049
"sequelize": "^3.23.0",
51-
"tc-core-library-js": "^1.0.8",
52-
"winston": "^2.3.1"
50+
"tc-core-library-js": "^1.0.8"
5351
},
5452
"devDependencies": {
5553
"babel-cli": "^6.9.0",

src/events/projects/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
1+
import config from 'config';
2+
import querystring from 'querystring';
3+
import util from '../../util';
24

35
/**
46
* Creates a lead in salesforce for the connect project.

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22

3+
import models from './models';
4+
35
// include newrelic
46
if (process.env.NODE_ENV !== 'test' && process.env.NODE_ENV !== 'local') {
57
require('newrelic');
@@ -9,7 +11,6 @@ const app = require('./app');
911

1012
/**
1113
* Handle server shutdown gracefully
12-
* @return {Void} This function returns void
1314
*/
1415
function gracefulShutdown() {
1516
app.services.pubsub.disconnect()

src/middlewares/checkRole.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77
* @version 1.0
88
*/
99
import config from 'config';
10-
1110
const util = require('tc-core-library-js').util(config);
1211

1312
module.exports = function (roleName) {
1413
return function (req, res, next) {
15-
if (!req.authUser || !Array.isArray(req.authUser.roles) || req.authUser.roles.indexOf(roleName) === -1) {
14+
if (!req.authUser || !Array.isArray(req.authUser.roles) || req.authUser.roles.indexOf(roleName) == -1) {
1615
return res.status(403)
1716
.json(util.wrapErrorResponse(req.id, 403, 'You are not allowed to perform this action.'));
1817
}

src/mocks/addBillingAccount.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable max-len */
2-
import winston from 'winston';
3-
41
const http = require('https');
52

63
const options = {
@@ -26,7 +23,7 @@ const req = http.request(options, (res) => {
2623

2724
res.on('end', () => {
2825
const body = Buffer.concat(chunks);
29-
winston.info(body.toString());
26+
console.log(body.toString());
3027
});
3128
});
3229
req.write('{\n "billingAccountId": 123456789\n}');

src/mocks/addCopilot.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable max-len */
2-
import winston from 'winston';
3-
41
const http = require('https');
52

63
const options = {
@@ -26,7 +23,7 @@ const req = http.request(options, (res) => {
2623

2724
res.on('end', () => {
2825
const body = Buffer.concat(chunks);
29-
winston.info(body.toString());
26+
console.log(body.toString());
3027
});
3128
});
3229
req.write('{\n "copilotUserId": 123456789\n}');

src/mocks/createProject.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/* eslint-disable max-len */
2-
import winston from 'winston';
3-
41
const http = require('https');
52

63
const options = {
@@ -26,7 +23,7 @@ const req = http.request(options, (res) => {
2623

2724
res.on('end', () => {
2825
const body = Buffer.concat(chunks);
29-
winston.info(body.toString());
26+
console.log(body.toString());
3027
});
3128
});
3229

src/mocks/direct.js

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11

22

3-
import express, { Router } from 'express';
3+
import express from 'express';
44
import _ from 'lodash';
55
import bodyParser from 'body-parser';
66
import config from 'config';
77
import coreLib from 'tc-core-library-js';
88
import expressRequestId from 'express-request-id';
9+
import Router from 'express';
910
import https from 'https';
1011
import path from 'path';
1112
import fs from 'fs';
12-
13-
const util = require('tc-core-library-js').util(config);
14-
const jwtAuth = require('tc-core-library-js').middleware.jwtAuthenticator;
15-
1613
config.version = 'v3';
17-
14+
const util = require('tc-core-library-js').util(config);
1815
const app = express();
1916
app.use(bodyParser.urlencoded({
2017
extended: false,
@@ -36,9 +33,10 @@ app.use(coreLib.middleware.logger(null, logger));
3633
app.logger = logger;
3734

3835
const router = Router();
36+
const jwtAuth = require('tc-core-library-js').middleware.jwtAuthenticator;
3937
router.all('/v3/direct/projects*', jwtAuth());
4038

41-
const projectId = 2;
39+
let projectId = 2;
4240
const projects = {
4341
1: {
4442
projectName: 'test direct project1',
@@ -57,56 +55,55 @@ router.route('/v3/direct/projects')
5755
})
5856
.post((req, res) => {
5957
app.logger.info({ body: req.body }, 'create direct project');
60-
const newId = projectId + 1;
58+
const newId = projectId++;
6159
req.body.id = newId;
6260
projects[newId] = req.body;
6361
res.json(util.wrapResponse(req.id, { projectId: newId }));
6462
});
6563

6664
router.route('/v3/direct/projects/:projectId(\\d+)/billingaccount')
6765
.post((req, res) => {
68-
const pId = req.params.projectId;
69-
app.logger.info({ body: req.body, pId }, 'add billingaccount to Project');
70-
if (projects[pId]) {
71-
projects[pId] = _.merge(projects[pId], req.body);
72-
res.json(util.wrapResponse(req.id, { billingAccountName: 'mock account name for ' +
73-
`${req.body.billingAccountId}` }));
66+
const projectId = req.params.projectId;
67+
app.logger.info({ body: req.body, projectId }, 'add billingaccount to Project');
68+
if (projects[projectId]) {
69+
projects[projectId] = _.merge(projects[projectId], req.body);
70+
res.json(util.wrapResponse(req.id, { billingAccountName: `mock account name for ${req.body.billingAccountId}` }));
7471
} else {
75-
res.json(util.wrapErrorResponse(req.id, 404, `Cannot find direct project ${pId}`));
72+
res.json(util.wrapErrorResponse(req.id, 404, `Cannot find direct project ${projectId}`));
7673
}
7774
});
7875

7976

8077
router.route('/v3/direct/projects/:projectId(\\d+)/copilot')
8178
.post((req, res) => {
82-
const pId = req.params.projectId;
83-
app.logger.info({ body: req.body, pId }, 'add copilot to Project');
84-
if (projects[pId]) {
85-
projects[pId] = _.merge(projects[pId], req.body);
86-
res.json(util.wrapResponse(req.id, { copilotProjectId: pId }));
79+
const projectId = req.params.projectId;
80+
app.logger.info({ body: req.body, projectId }, 'add copilot to Project');
81+
if (projects[projectId]) {
82+
projects[projectId] = _.merge(projects[projectId], req.body);
83+
res.json(util.wrapResponse(req.id, { copilotProjectId: projectId }));
8784
} else {
88-
res.json(util.wrapErrorResponse(req.id, 404, `Cannot find direct project ${pId}`));
85+
res.json(util.wrapErrorResponse(req.id, 404, `Cannot find direct project ${projectId}`));
8986
}
9087
})
9188
.delete((req, res) => {
92-
const pId = req.params.projectId;
93-
app.logger.info({ body: req.body, pId }, 'remove copilot from Project');
94-
if (projects[pId]) {
95-
projects[pId] = _.omit(projects[pId], 'copilotUserId');
89+
const projectId = req.params.projectId;
90+
app.logger.info({ body: req.body, projectId }, 'remove copilot from Project');
91+
if (projects[projectId]) {
92+
projects[projectId] = _.omit(projects[projectId], 'copilotUserId');
9693
res.json(util.wrapResponse(req.id, true));
9794
} else {
98-
res.json(util.wrapErrorResponse(req.id, 404, `Cannot find direct project ${pId}`));
95+
res.json(util.wrapErrorResponse(req.id, 404, `Cannot find direct project ${projectId}`));
9996
}
10097
});
10198

10299
router.route('/v3/direct/projects/:projectId(\\d+)/permissions')
103100
.post((req, res) => {
104-
const pId = req.params.projectId;
105-
app.logger.info({ body: req.body, pId }, 'add permissions to Project');
106-
if (projects[pId]) {
101+
const projectId = req.params.projectId;
102+
app.logger.info({ body: req.body, projectId }, 'add permissions to Project');
103+
if (projects[projectId]) {
107104
res.json();
108105
} else {
109-
res.json(util.wrapErrorResponse(req.id, 404, `Cannot find direct project ${pId}`));
106+
res.json(util.wrapErrorResponse(req.id, 404, `Cannot find direct project ${projectId}`));
110107
}
111108
});
112109

0 commit comments

Comments
 (0)