Skip to content

Commit

Permalink
Merge pull request #80 from davidgovea/bump-node
Browse files Browse the repository at this point in the history
Bump supported node version, and update xo lint rules
  • Loading branch information
niftylettuce committed Feb 15, 2019
2 parents 823b7ee + c8836e1 commit b23d7ea
Show file tree
Hide file tree
Showing 8 changed files with 509 additions and 139 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"presets": [
["@babel/env", {
"targets": {
"node": "6.4.0",
"node": "8.9.4",
"browsers": "last 2 versions"
}
}]
Expand Down
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
language: node_js
node_js:
- '6'
- '8'
- '9'
- '10'
install:
- yarn install --ignore-engines
script:
npm run test-coverage
after_success:
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
"remark-cli": "^5.0.0",
"remark-preset-github": "^0.0.8",
"sinon": "^5.0.7",
"xo": "0.21.0"
"xo": "0.24.0"
},
"engines": {
"node": ">=6.12.3 <7 || >=8.9.4"
"node": ">=8.9.4"
},
"files": [
"lib"
Expand Down Expand Up @@ -160,8 +160,7 @@
"capitalized-comments": "off",
"camelcase": "off",
"no-warning-comments": "off",
"prettier/prettier": "error",
"ava/use-t-well": "off"
"prettier/prettier": "error"
},
"space": true,
"overrides": [
Expand Down
16 changes: 9 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function createFrisbeeResponse(origResp) {

const headersObj = {};
origResp.headers.forEach(pair => {
headersObj[pair[0]] = pair[1]; // eslint-disable-line prefer-destructuring
headersObj[pair[0]] = pair[1];
});
Object.defineProperty(resp, 'headersObj', {
value: headersObj
Expand Down Expand Up @@ -153,12 +153,13 @@ class Frisbee {
) {
try {
opts.body = JSON.stringify(opts.body);
} catch (err) {
throw err;
} catch (error) {
throw error;
}
}
}

// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
try {
const fullUri = this.opts.baseURI
Expand Down Expand Up @@ -201,10 +202,11 @@ class Frisbee {
if (res.body.error.param)
res.err.param = res.body.error.param;
}
} catch (e) {
} catch (error) {
res.err = this.parseErr;
}
}

resolve(res);
return;
}
Expand All @@ -222,7 +224,7 @@ class Frisbee {
res.body = await res.text();
res.body = JSON.parse(res.body);
}
} catch (err) {
} catch (error) {
if (contentType === 'application/json') {
res.err = this.parseErr;
resolve(res);
Expand All @@ -234,8 +236,8 @@ class Frisbee {
}

resolve(res);
} catch (err) {
reject(err);
} catch (error) {
reject(error);
}
});
};
Expand Down
2 changes: 2 additions & 0 deletions src/interceptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = class Interceptor {
});
}

/* eslint-disable promise/prefer-await-to-then */
interceptedMethod(methodFn, ...args) {
const { interceptors } = this;
const reversedInterceptors = interceptors.slice().reverse();
Expand Down Expand Up @@ -40,6 +41,7 @@ module.exports = class Interceptor {

return promise;
}
/* eslint-enable promise/prefer-await-to-then */

register(interceptor) {
this.interceptors.push(interceptor);
Expand Down
4 changes: 2 additions & 2 deletions test/browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ test('should create Frisbee instance with all methods', t => {
const res = await api[method]('/', {});
t.true(_.isObject(res));
t.true(_.isObject(res.body));
} catch (err) {
throw err;
} catch (error) {
throw error;
}
});
});
12 changes: 5 additions & 7 deletions test/node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ standardMethods.forEach(method => {
const res = await api[method]('/', opts);
t.true(_.isObject(res));
t.true(_.isObject(res.body));
} catch (err) {
throw err;
} catch (error) {
throw error;
}
});
});
Expand Down Expand Up @@ -153,9 +153,7 @@ test(
should stringify querystring parameters with
arrayFormat for GET and DELETE requests`,
async t => {
const api = new Frisbee(
Object.assign({}, options, { formatArray: 'brackets' })
);
const api = new Frisbee({ ...options, formatArray: 'brackets' });
const querystring = {
a: 'blue',
b: 'cyan',
Expand Down Expand Up @@ -252,8 +250,8 @@ methods.forEach(method => {
try {
await api[method]('/');
t.true(interceptor.request.calledOnce);
} catch (err) {
throw err;
} catch (error) {
throw error;
}
});
});
Expand Down
Loading

0 comments on commit b23d7ea

Please sign in to comment.