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

Commit

Permalink
Refactor code due to eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksym Shykov committed Jun 26, 2020
1 parent 8dbb901 commit cbf0e82
Show file tree
Hide file tree
Showing 11 changed files with 964 additions and 610 deletions.
28 changes: 17 additions & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
'use strict';

module.exports = {
extends: [
'@macpaw/eslint-config-webservices/rules/base',
'@macpaw/eslint-config-webservices/rules/filenames',
'@macpaw/eslint-config-webservices/rules/promise',
'@macpaw/eslint-config-webservices-base',
],
parser: 'espree',

plugins: [
'async-await',
],

env: {
node: true,
es6: true,
browser: true,
},

parserOptions: {
ecmaVersion: 8,
sourceType: 'script',
},
plugins: ['async-await'],

rules: {
strict: ['warn', 'global'],
'no-unused-expressions': ['off'],
'newline-after-var': ['off'],
'filenames/match-regex': ['off'],
'no-console': 'off',
},
};
};
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@macpaw:registry=https://npm.pkg.github.com
29 changes: 29 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
NPM_CREDENTIALS_ID = '982beb9e-1cb8-4a93-90f7-2fd8dce6c097'
GITHUB_PACKAGES_CREDENTIALS_ID = 'github-access-token'

pipeline {
agent {
docker {
image 'node:10'
label 'docker'
}
}
stages {
stage('Install dependencies') {
environment {
NPM_TOKEN = credentials("$NPM_CREDENTIALS_ID")
GITHUB_PACKAGES_TOKEN = credentials("$GITHUB_PACKAGES_CREDENTIALS_ID")
}
steps {
sh 'npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN'
sh 'npm config set //npm.pkg.github.com/:_authToken=$GITHUB_PACKAGES_TOKEN'
sh 'yarn install'
}
}
stage('Lint code') {
steps {
sh 'npm run lint --silent'
}
}
}
}
8 changes: 0 additions & 8 deletions api-services/index.js

This file was deleted.

10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
'use strict';

const logger = require('./lib/logger');
const request = require('./lib/request');
const requestHelper = require('./lib/request-helper');
const waiters = require('./lib/waiters');

module.exports = {
apiServices: require('./api-services/'),
logger,
request,
requestHelper,
waiters,
};
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions api-services/libs/request.js → lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

const {browser} = global;

module.exports = {
get(url, options) {
const response = browser.call(() => requestHelper.getResponseBody('GET', url, options));
Expand Down
8 changes: 5 additions & 3 deletions api-services/libs/waiters.js → lib/waiters.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

module.exports = {
*waitFor(func, strategy, {timeout = 90000, interval = 2500, message, time}) {
* waitFor(func, strategy, {
timeout = 90000, interval = 2500, message, time,
}) {
const timeStart = Date.now();

const getData = () => new Promise((resolve) => {
Expand All @@ -15,11 +17,11 @@ module.exports = {
while (true) {
if (strategy(result, time)) {
return result;
} else if (Date.now() - timeStart < timeout) {
} if (Date.now() - timeStart < timeout) {
result = yield getData();
} else {
throw new Error(message || 'Timeout reached');
}
}
},
};
};
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "qa-api-services",
"version": "0.0.1",
"description": "QA API libraries for Macpaw projects",
"description": "QA API libraries for MacPaw projects",
"main": "index.js",
"author": "Volodymyr Dobrygin",
"contributors": [
Expand All @@ -15,18 +15,19 @@
},
"license": "UNLICENSED",
"scripts": {
"lint": "$(npm bin)/eslint --max-warnings 0 ."
"lint": "eslint ."
},
"dependencies": {
"chalk": "^2.4.1",
"chalk": "^4.1.0",
"then-request": "^6.0.2"
},
"devDependencies": {
"@macpaw/eslint-config-webservices": "^1.1.0",
"babel-eslint": "^8.2.3",
"eslint": "^4.19.1",
"eslint-plugin-async-await": "0.0.0",
"eslint-plugin-filenames": "^1.2.0",
"eslint-plugin-promise": "^3.7.0"
"@macpaw/eslint-config-webservices": "^3.1.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.3.1",
"eslint-plugin-async-await": "^0.0.0",
"eslint-plugin-filenames": "^1.3.2",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-promise": "^4.2.1"
}
}
Loading

0 comments on commit cbf0e82

Please sign in to comment.