2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Using more strict eslint rules

This commit is contained in:
Matt Zabriskie
2015-12-14 20:06:57 -07:00
parent 2b147fb0b7
commit f28a4a8248
16 changed files with 230 additions and 93 deletions
+14 -21
View File
@@ -6,8 +6,9 @@ var dispatchRequest = require('./core/dispatchRequest');
var InterceptorManager = require('./core/InterceptorManager');
var isAbsoluteURL = require('./helpers/isAbsoluteURL');
var combineURLs = require('./helpers/combineURLs');
var bind = require('./helpers/bind');
function Axios (defaultConfig) {
function Axios(defaultConfig) {
this.defaultConfig = utils.merge({
headers: {},
timeout: defaults.timeout,
@@ -21,7 +22,8 @@ function Axios (defaultConfig) {
};
}
Axios.prototype.request = function (config) {
Axios.prototype.request = function request(config) {
/*eslint no-param-reassign:0*/
// Allow for axios('example/url'[, config]) a la fetch API
if (typeof config === 'string') {
config = utils.merge({
@@ -42,11 +44,11 @@ Axios.prototype.request = function (config) {
var chain = [dispatchRequest, undefined];
var promise = Promise.resolve(config);
this.interceptors.request.forEach(function (interceptor) {
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
chain.unshift(interceptor.fulfilled, interceptor.rejected);
});
this.interceptors.response.forEach(function (interceptor) {
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
chain.push(interceptor.fulfilled, interceptor.rejected);
});
@@ -61,7 +63,7 @@ var defaultInstance = new Axios();
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
axios.create = function (defaultConfig) {
axios.create = function create(defaultConfig) {
return new Axios(defaultConfig);
};
@@ -69,7 +71,7 @@ axios.create = function (defaultConfig) {
axios.defaults = defaults;
// Expose all/spread
axios.all = function (promises) {
axios.all = function all(promises) {
return Promise.all(promises);
};
axios.spread = require('./helpers/spread');
@@ -77,20 +79,10 @@ axios.spread = require('./helpers/spread');
// Expose interceptors
axios.interceptors = defaultInstance.interceptors;
// Helpers
function bind (fn, thisArg) {
return function () {
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
return fn.apply(thisArg, args);
};
}
// Provide aliases for supported request methods
utils.forEach(['delete', 'get', 'head'], function (method) {
Axios.prototype[method] = function (url, config) {
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
/*eslint func-names:0*/
Axios.prototype[method] = function(url, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url
@@ -99,8 +91,9 @@ utils.forEach(['delete', 'get', 'head'], function (method) {
axios[method] = bind(Axios.prototype[method], defaultInstance);
});
utils.forEach(['post', 'put', 'patch'], function (method) {
Axios.prototype[method] = function (url, data, config) {
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
/*eslint func-names:0*/
Axios.prototype[method] = function(url, data, config) {
return this.request(utils.merge(config || {}, {
method: method,
url: url,