Skip to content

Commit 9895b9f

Browse files
Turn on eslint (#37)
1 parent 898c71f commit 9895b9f

26 files changed

+207
-215
lines changed

.eslintrc.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
module.exports = {
2-
"extends": "airbnb-base",
3-
"rules": {
4-
"indent": ["error", 4],
2+
'plugins': [
3+
'mocha'
4+
],
5+
'extends': 'airbnb-base',
6+
'rules': {
7+
'indent': ['error', 4, { 'SwitchCase': 1 }],
8+
'no-underscore-dangle': [0],
9+
'max-len': ['error', {
10+
'code': 140,
11+
'ignoreComments': true
12+
}],
13+
},
14+
'env': {
15+
'mocha': true,
516
}
6-
};
17+
};

codefresh.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ steps:
88
commands:
99
- yarn install --frozen-lockfile
1010

11-
# eslint:
12-
# title: 'Running linting logic'
13-
# image: codefresh/node-tester-image:8.8.0
14-
# commands:
15-
# - yarn lint
16-
#
11+
eslint:
12+
title: 'Running linting logic'
13+
image: codefresh/node-tester-image:8.8.0
14+
commands:
15+
- yarn eslint
16+
1717
# unit-tests:
1818
# title: 'Running unit tests'
1919
# image: codefresh/node-tester-image:8.8.0
@@ -48,4 +48,4 @@ steps:
4848
- NPM_TOKEN=${{NPM_TOKEN}} npm run ci-publish
4949
when:
5050
branch:
51-
only: [ master ]
51+
only: [ master ]

lib/logic/api/composition.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
const _ = require('lodash');
2-
const CFError = require('cf-errors');
1+
const _ = require('lodash');
2+
const CFError = require('cf-errors'); // eslint-disable-line
33
const { sendHttpRequest } = require('./helper');
4-
const Composition = require('../entities/Composition');
4+
const Composition = require('../entities/Composition');
55

66

7-
const _extractFieldsForCompositionwEntity = (composition) => {
8-
return {
9-
id: composition._id,
10-
name: composition.name,
11-
isAdvanced: composition.isAdvanced,
12-
created: composition.created,
13-
};
14-
};
7+
const _extractFieldsForCompositionwEntity = composition => ({
8+
id: composition._id,
9+
name: composition.name,
10+
isAdvanced: composition.isAdvanced,
11+
created: composition.created,
12+
});
1513

1614

1715
const createComposition = async (data) => {
@@ -21,7 +19,7 @@ const createComposition = async (data) => {
2119
body: data,
2220
};
2321

24-
return await sendHttpRequest(options);
22+
return sendHttpRequest(options);
2523
};
2624

2725
const replaceById = async (id, data) => {
@@ -33,10 +31,10 @@ const replaceById = async (id, data) => {
3331
body,
3432
};
3533

36-
return await sendHttpRequest(options);
34+
return sendHttpRequest(options);
3735
};
3836

39-
//TODO:need to add to cf-api
37+
// TODO:need to add to cf-api
4038
const applyById = async (id, data) => {
4139
const body = data;
4240

@@ -46,7 +44,7 @@ const applyById = async (id, data) => {
4644
body,
4745
};
4846

49-
return await sendHttpRequest(options);
47+
return sendHttpRequest(options);
5048
};
5149

5250
const getCompositionByIdentifier = async (id) => {
@@ -83,16 +81,15 @@ const deleteCompositionById = async (id) => {
8381
method: 'DELETE',
8482
};
8583

86-
return await sendHttpRequest(options);
84+
return sendHttpRequest(options);
8785
};
8886

8987

90-
9188
module.exports = {
9289
createComposition,
9390
replaceById,
9491
applyById,
9592
getCompositionByIdentifier,
9693
getCompositions,
9794
deleteCompositionById,
98-
};
95+
};

lib/logic/api/context.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
const _ = require('lodash');
2-
const CFError = require('cf-errors');
1+
const _ = require('lodash');
2+
const CFError = require('cf-errors'); // eslint-disable-line
33
const { sendHttpRequest } = require('./helper');
4-
const Context = require('../entities/Context');
5-
6-
const _extractFieldsForContextEntity = (context) => {
7-
return {
8-
apiVersion: context.apiVersion,
9-
kind: context.kind,
10-
name: context.metadata.name,
11-
owner: context.owner,
12-
type: context.spec.type,
13-
};
14-
};
4+
const Context = require('../entities/Context');
5+
6+
const _extractFieldsForContextEntity = context => ({
7+
apiVersion: context.apiVersion,
8+
kind: context.kind,
9+
name: context.metadata.name,
10+
owner: context.owner,
11+
type: context.spec.type,
12+
});
1513

1614

1715
const createContext = async (data) => {
@@ -21,7 +19,7 @@ const createContext = async (data) => {
2119
body: data,
2220
};
2321

24-
return await sendHttpRequest(options);
22+
return sendHttpRequest(options);
2523
};
2624

2725
const replaceByName = async (name, data) => {
@@ -33,7 +31,7 @@ const replaceByName = async (name, data) => {
3331
body,
3432
};
3533

36-
return await sendHttpRequest(options);
34+
return sendHttpRequest(options);
3735
};
3836

3937
const applyByName = async (name, data) => {
@@ -45,7 +43,7 @@ const applyByName = async (name, data) => {
4543
body,
4644
};
4745

48-
return await sendHttpRequest(options);
46+
return sendHttpRequest(options);
4947
};
5048

5149
const getContextByName = async (name, owner) => {
@@ -85,7 +83,7 @@ const deleteContextByName = async (name, owner) => {
8583
body: { owner },
8684
};
8785

88-
return await sendHttpRequest(options);
86+
return sendHttpRequest(options);
8987
};
9088

9189
module.exports = {
@@ -95,4 +93,4 @@ module.exports = {
9593
deleteContextByName,
9694
replaceByName,
9795
applyByName,
98-
};
96+
};

lib/logic/api/environment.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
const _ = require('lodash');
2-
const CFError = require('cf-errors');
1+
const _ = require('lodash');
2+
const CFError = require('cf-errors'); // eslint-disable-line
33
const { sendHttpRequest } = require('./helper');
4-
const Environment = require('../entities/Environment');
4+
const Environment = require('../entities/Environment');
55

6-
const _extractFieldsForEnvironmentEntity = (environment) => {
7-
return {
8-
id: environment._id,
9-
status: environment.creationStatus,
10-
name: environment.name,
11-
};
12-
};
6+
const _extractFieldsForEnvironmentEntity = environment => ({
7+
id: environment._id,
8+
status: environment.creationStatus,
9+
name: environment.name,
10+
});
1311

1412
const getEnvironmentById = async (id) => {
1513
const endcodeUri = encodeURIComponent(id);
@@ -46,12 +44,12 @@ const deleteEnvironment = async (id) => {
4644
method: 'GET',
4745
};
4846

49-
return await sendHttpRequest(userOptions);
47+
return sendHttpRequest(userOptions);
5048
};
5149

5250

5351
module.exports = {
5452
getEnvironmentById,
5553
getEnvironments,
5654
deleteEnvironment,
57-
};
55+
};

lib/logic/api/helper.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
const debug = require('debug')('codefresh:http');
2-
const rp = require('request-promise');
3-
const _ = require('lodash');
2+
const rp = require('request-promise');
3+
const _ = require('lodash');
44

55
const sendHttpRequest = async (httpOptions, authContext) => {
66
let finalAuthContext;
77
if (!authContext) {
8-
const authManager = require('../auth').manager;
9-
finalAuthContext = authManager.getCurrentContext();
8+
const authManager = require('../auth').manager; // eslint-disable-line
9+
finalAuthContext = authManager.getCurrentContext();
1010
} else {
1111
finalAuthContext = authContext;
1212
}
1313

1414
const finalOptions = _.assignIn(httpOptions, finalAuthContext.prepareHttpOptions(), { json: true });
15-
debug(`Sending http request:\n%O`, finalOptions);
15+
debug('Sending http request:\n%O', finalOptions);
1616
const response = await rp(finalOptions);
17-
debug(`Response:\n%O`, response);
17+
debug('Response:\n%O', response);
1818
return response;
1919
};
2020

2121
module.exports = {
2222
sendHttpRequest,
23-
};
23+
};

lib/logic/api/image.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
const _ = require('lodash');
2-
const CFError = require('cf-errors');
1+
const _ = require('lodash');
2+
const CFError = require('cf-errors');
33
const { sendHttpRequest } = require('./helper');
4-
const filesize = require('filesize');
5-
const moment = require('moment');
6-
const Image = require('../entities/Image');
7-
8-
9-
const _extractFieldsForImageEntity = (image, tag) => {
10-
return {
11-
name: image.imageDisplayName,
12-
tag: tag.tag,
13-
image_id: image.internalImageId.substring(0, 12),
14-
created: moment(tag.created).fromNow(),
15-
size: filesize(image.size),
16-
pull: `${tag.registry}/${tag.repository}:${tag.tag}`,
17-
};
18-
};
4+
const filesize = require('filesize');
5+
const moment = require('moment');
6+
const Image = require('../entities/Image');
7+
8+
9+
const _extractFieldsForImageEntity = (image, tag) => ({
10+
name: image.imageDisplayName,
11+
tag: tag.tag,
12+
image_id: image.internalImageId.substring(0, 12),
13+
created: moment(tag.created).fromNow(),
14+
size: filesize(image.size),
15+
pull: `${tag.registry}/${tag.repository}:${tag.tag}`,
16+
});
1917

2018

2119
const getAll = async (options) => {
@@ -27,7 +25,7 @@ const getAll = async (options) => {
2725
};
2826

2927
if (!options.volumeImages) {
30-
qs.metadata['cf_volume'] = false;
28+
qs.metadata.cf_volume = false;
3129
}
3230

3331
if (options.sha) {
@@ -62,12 +60,12 @@ const getImageById = async (imageId) => {
6260
url: `/api/images/${encodeURIComponent(imageId)}`,
6361
method: 'GET',
6462
};
65-
const image = await sendHttpRequest(options);
63+
const image = await sendHttpRequest(options);
6664
if (_.isEmpty(image)) {
6765
throw new CFError(`Error from server (NotFound): Image ${imageId} not found`);
6866
}
6967
const res = [];
70-
let data = {};
68+
let data = {};
7169
_.forEach(image.tags, (tag) => {
7270
data = _extractFieldsForImageEntity(image, tag);
7371
res.push(new Image(data));
@@ -106,12 +104,12 @@ const annotateImage = async (dockerImageId, annotations) => {
106104
body: annotations,
107105
};
108106

109-
return await sendHttpRequest(options);
107+
return sendHttpRequest(options);
110108
};
111109

112110
module.exports = {
113111
annotateImage,
114112
getDockerImageId,
115113
getAll,
116114
getImageById,
117-
};
115+
};

lib/logic/api/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
'use strict';
21

3-
const user = require('./user');
4-
const pipeline = require('./pipeline');
5-
const context = require('./context');
6-
const image = require('./image');
7-
const composition = require('./composition');
8-
const environment = require('./environment');
9-
const workflow = require('./workflow');
2+
3+
const user = require('./user');
4+
const pipeline = require('./pipeline');
5+
const context = require('./context');
6+
const image = require('./image');
7+
const composition = require('./composition');
8+
const environment = require('./environment');
9+
const workflow = require('./workflow');
1010

1111
module.exports = {
1212
user,
@@ -16,4 +16,4 @@ module.exports = {
1616
composition,
1717
environment,
1818
workflow,
19-
};
19+
};

0 commit comments

Comments
 (0)