Skip to content

Commit 3a1b2d4

Browse files
authored
feat(2492): Update to eslint-config-screwdriver v5 (#31)
1 parent 43ed752 commit 3a1b2d4

File tree

4 files changed

+354
-397
lines changed

4 files changed

+354
-397
lines changed

index.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ScmRouter extends Scm {
2323
this.scms = {};
2424

2525
if (typeof scmsConfig === 'object') {
26-
Object.keys(scmsConfig).forEach((displayName) => {
26+
Object.keys(scmsConfig).forEach(displayName => {
2727
const scm = scmsConfig[displayName];
2828

2929
if (typeof scm !== 'object') {
@@ -95,17 +95,22 @@ class ScmRouter extends Scm {
9595
* @return {Promise} scm object
9696
*/
9797
chooseWebhookScm(headers, payload) {
98-
return new Promise((resolve) => {
98+
return new Promise(resolve => {
9999
// choose a webhook scm module, or null if there is no suitable one
100-
async.detect(this.scms, (scm, cb) => {
101-
scm.canHandleWebhook(headers, payload)
102-
.then((result) => {
103-
cb(result === false ? null : scm);
104-
}).catch((err) => {
105-
logger.error(err);
106-
cb(null);
107-
});
108-
}, ret => resolve(ret));
100+
async.detect(
101+
this.scms,
102+
(scm, cb) => {
103+
scm.canHandleWebhook(headers, payload)
104+
.then(result => {
105+
cb(result === false ? null : scm);
106+
})
107+
.catch(err => {
108+
logger.error(err);
109+
cb(null);
110+
});
111+
},
112+
ret => resolve(ret)
113+
);
109114
});
110115
}
111116

@@ -204,16 +209,15 @@ class ScmRouter extends Scm {
204209
* @return {Promise}
205210
*/
206211
_parseHook(headers, payload) {
207-
return this.chooseWebhookScm(headers, payload)
208-
.then((scm) => {
209-
if (!scm) {
210-
logger.info('Webhook does not match any expected events or actions.');
212+
return this.chooseWebhookScm(headers, payload).then(scm => {
213+
if (!scm) {
214+
logger.info('Webhook does not match any expected events or actions.');
211215

212-
return null;
213-
}
216+
return null;
217+
}
214218

215-
return scm.parseHook(headers, payload);
216-
});
219+
return scm.parseHook(headers, payload);
220+
});
217221
}
218222

219223
/**
@@ -387,7 +391,7 @@ class ScmRouter extends Scm {
387391
stats() {
388392
let result = {};
389393

390-
Object.keys(this.scms).forEach((key) => {
394+
Object.keys(this.scms).forEach(key => {
391395
result = Object.assign(result, this.scms[key].stats());
392396
});
393397

@@ -411,8 +415,7 @@ class ScmRouter extends Scm {
411415
* @return {String} Full scmContext (e.g. github:github.com)
412416
*/
413417
_getScmContext({ hostname }) {
414-
return Object.keys(this.scms).find(scmContext =>
415-
scmContext.split(':')[1] === hostname);
418+
return Object.keys(this.scms).find(scmContext => scmContext.split(':')[1] === hostname);
416419
}
417420

418421
/**

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@
3333
"Tiffany Kyi <tiffanykyi@gmail.com>"
3434
],
3535
"devDependencies": {
36-
"chai": "^3.5.0",
37-
"eslint": "^4.19.1",
38-
"eslint-config-screwdriver": "^3.0.1",
36+
"chai": "^4.2.0",
37+
"eslint": "^7.5.0",
38+
"eslint-config-screwdriver": "^5.0.1",
3939
"mocha": "^8.2.1",
4040
"mocha-multi-reporters": "^1.5.1",
4141
"mocha-sonarqube-reporter": "^1.0.2",
4242
"nyc": "^15.0.0",
4343
"mockery": "^2.0.0",
44-
"sinon": "^2.3.4"
44+
"sinon": "^9.0.0"
4545
},
4646
"dependencies": {
4747
"@hapi/hoek": "^9.0.4",

test/data/testScm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const ScmBase = require('screwdriver-scm-base');
44

55
module.exports = {
66
getBaseClass: () => ScmBase,
7-
createMock: (stubsMap) => {
7+
createMock: stubsMap => {
88
/**
99
* Generic scm class for testing
1010
* @type {Class}
@@ -15,7 +15,7 @@ module.exports = {
1515

1616
this.options = options;
1717

18-
Object.keys(stubsMap).forEach((key) => {
18+
Object.keys(stubsMap).forEach(key => {
1919
this[key] = stubsMap[key];
2020
});
2121
}

0 commit comments

Comments
 (0)