Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit cbf0e82

Browse files
author
Maksym Shykov
committed
Refactor code due to eslint rules
1 parent 8dbb901 commit cbf0e82

File tree

11 files changed

+964
-610
lines changed

11 files changed

+964
-610
lines changed

.eslintrc.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
1+
'use strict';
2+
13
module.exports = {
24
extends: [
3-
'@macpaw/eslint-config-webservices/rules/base',
4-
'@macpaw/eslint-config-webservices/rules/filenames',
5-
'@macpaw/eslint-config-webservices/rules/promise',
5+
'@macpaw/eslint-config-webservices-base',
66
],
7-
parser: 'espree',
7+
8+
plugins: [
9+
'async-await',
10+
],
11+
12+
env: {
13+
node: true,
14+
es6: true,
15+
browser: true,
16+
},
17+
818
parserOptions: {
9-
ecmaVersion: 8,
1019
sourceType: 'script',
1120
},
12-
plugins: ['async-await'],
21+
1322
rules: {
14-
strict: ['warn', 'global'],
15-
'no-unused-expressions': ['off'],
16-
'newline-after-var': ['off'],
17-
'filenames/match-regex': ['off'],
23+
'no-console': 'off',
1824
},
19-
};
25+
};

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@macpaw:registry=https://npm.pkg.github.com

Jenkinsfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
NPM_CREDENTIALS_ID = '982beb9e-1cb8-4a93-90f7-2fd8dce6c097'
2+
GITHUB_PACKAGES_CREDENTIALS_ID = 'github-access-token'
3+
4+
pipeline {
5+
agent {
6+
docker {
7+
image 'node:10'
8+
label 'docker'
9+
}
10+
}
11+
stages {
12+
stage('Install dependencies') {
13+
environment {
14+
NPM_TOKEN = credentials("$NPM_CREDENTIALS_ID")
15+
GITHUB_PACKAGES_TOKEN = credentials("$GITHUB_PACKAGES_CREDENTIALS_ID")
16+
}
17+
steps {
18+
sh 'npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN'
19+
sh 'npm config set //npm.pkg.github.com/:_authToken=$GITHUB_PACKAGES_TOKEN'
20+
sh 'yarn install'
21+
}
22+
}
23+
stage('Lint code') {
24+
steps {
25+
sh 'npm run lint --silent'
26+
}
27+
}
28+
}
29+
}

api-services/index.js

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

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
'use strict';
22

3+
const logger = require('./lib/logger');
4+
const request = require('./lib/request');
5+
const requestHelper = require('./lib/request-helper');
6+
const waiters = require('./lib/waiters');
7+
38
module.exports = {
4-
apiServices: require('./api-services/'),
9+
logger,
10+
request,
11+
requestHelper,
12+
waiters,
513
};
File renamed without changes.
File renamed without changes.

api-services/libs/request.js renamed to lib/request.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
const requestHelper = require('./request-helper');
44

5+
const {browser} = global;
6+
57
module.exports = {
68
get(url, options) {
79
const response = browser.call(() => requestHelper.getResponseBody('GET', url, options));

api-services/libs/waiters.js renamed to lib/waiters.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
'use strict';
22

33
module.exports = {
4-
*waitFor(func, strategy, {timeout = 90000, interval = 2500, message, time}) {
4+
* waitFor(func, strategy, {
5+
timeout = 90000, interval = 2500, message, time,
6+
}) {
57
const timeStart = Date.now();
68

79
const getData = () => new Promise((resolve) => {
@@ -15,11 +17,11 @@ module.exports = {
1517
while (true) {
1618
if (strategy(result, time)) {
1719
return result;
18-
} else if (Date.now() - timeStart < timeout) {
20+
} if (Date.now() - timeStart < timeout) {
1921
result = yield getData();
2022
} else {
2123
throw new Error(message || 'Timeout reached');
2224
}
2325
}
2426
},
25-
};
27+
};

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "qa-api-services",
33
"version": "0.0.1",
4-
"description": "QA API libraries for Macpaw projects",
4+
"description": "QA API libraries for MacPaw projects",
55
"main": "index.js",
66
"author": "Volodymyr Dobrygin",
77
"contributors": [
@@ -15,18 +15,19 @@
1515
},
1616
"license": "UNLICENSED",
1717
"scripts": {
18-
"lint": "$(npm bin)/eslint --max-warnings 0 ."
18+
"lint": "eslint ."
1919
},
2020
"dependencies": {
21-
"chalk": "^2.4.1",
21+
"chalk": "^4.1.0",
2222
"then-request": "^6.0.2"
2323
},
2424
"devDependencies": {
25-
"@macpaw/eslint-config-webservices": "^1.1.0",
26-
"babel-eslint": "^8.2.3",
27-
"eslint": "^4.19.1",
28-
"eslint-plugin-async-await": "0.0.0",
29-
"eslint-plugin-filenames": "^1.2.0",
30-
"eslint-plugin-promise": "^3.7.0"
25+
"@macpaw/eslint-config-webservices": "^3.1.0",
26+
"babel-eslint": "^10.1.0",
27+
"eslint": "^7.3.1",
28+
"eslint-plugin-async-await": "^0.0.0",
29+
"eslint-plugin-filenames": "^1.3.2",
30+
"eslint-plugin-import": "^2.21.2",
31+
"eslint-plugin-promise": "^4.2.1"
3132
}
3233
}

0 commit comments

Comments
 (0)