Skip to content

Commit 22c2baf

Browse files
chore: upgrade eslint and add fix command
1 parent 0d110da commit 22c2baf

File tree

4 files changed

+84
-83
lines changed

4 files changed

+84
-83
lines changed

lib/adapters/xhr.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ module.exports = function xhrAdapter(config) {
119119

120120
// Add xsrf header
121121
var xsrfValue = (config.withCredentials || isURLSameOrigin(config.url)) && config.xsrfCookieName ?
122-
cookies.read(config.xsrfCookieName) :
123-
undefined;
122+
cookies.read(config.xsrfCookieName) :
123+
undefined;
124124

125125
if (xsrfValue) {
126126
requestHeaders[config.xsrfHeaderName] = xsrfValue;

lib/helpers/cookies.js

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,48 @@ module.exports = (
66
utils.isStandardBrowserEnv() ?
77

88
// Standard browser envs support document.cookie
9-
(function standardBrowserEnv() {
10-
return {
11-
write: function write(name, value, expires, path, domain, secure) {
12-
var cookie = [];
13-
cookie.push(name + '=' + encodeURIComponent(value));
14-
15-
if (utils.isNumber(expires)) {
16-
cookie.push('expires=' + new Date(expires).toGMTString());
9+
(function standardBrowserEnv() {
10+
return {
11+
write: function write(name, value, expires, path, domain, secure) {
12+
var cookie = [];
13+
cookie.push(name + '=' + encodeURIComponent(value));
14+
15+
if (utils.isNumber(expires)) {
16+
cookie.push('expires=' + new Date(expires).toGMTString());
17+
}
18+
19+
if (utils.isString(path)) {
20+
cookie.push('path=' + path);
21+
}
22+
23+
if (utils.isString(domain)) {
24+
cookie.push('domain=' + domain);
25+
}
26+
27+
if (secure === true) {
28+
cookie.push('secure');
29+
}
30+
31+
document.cookie = cookie.join('; ');
32+
},
33+
34+
read: function read(name) {
35+
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36+
return (match ? decodeURIComponent(match[3]) : null);
37+
},
38+
39+
remove: function remove(name) {
40+
this.write(name, '', Date.now() - 86400000);
1741
}
18-
19-
if (utils.isString(path)) {
20-
cookie.push('path=' + path);
21-
}
22-
23-
if (utils.isString(domain)) {
24-
cookie.push('domain=' + domain);
25-
}
26-
27-
if (secure === true) {
28-
cookie.push('secure');
29-
}
30-
31-
document.cookie = cookie.join('; ');
32-
},
33-
34-
read: function read(name) {
35-
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36-
return (match ? decodeURIComponent(match[3]) : null);
37-
},
38-
39-
remove: function remove(name) {
40-
this.write(name, '', Date.now() - 86400000);
41-
}
42-
};
43-
})() :
42+
};
43+
})() :
4444

4545
// Non standard browser env (web workers, react-native) lack needed support.
46-
(function nonStandardBrowserEnv() {
47-
return {
48-
write: function write() {},
49-
read: function read() { return null; },
50-
remove: function remove() {}
51-
};
52-
})()
46+
(function nonStandardBrowserEnv() {
47+
return {
48+
write: function write() {},
49+
read: function read() { return null; },
50+
remove: function remove() {}
51+
};
52+
})()
5353
);

lib/helpers/isURLSameOrigin.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,62 +7,62 @@ module.exports = (
77

88
// Standard browser envs have full support of the APIs needed to test
99
// whether the request URL is of the same origin as current location.
10-
(function standardBrowserEnv() {
11-
var msie = /(msie|trident)/i.test(navigator.userAgent);
12-
var urlParsingNode = document.createElement('a');
13-
var originURL;
10+
(function standardBrowserEnv() {
11+
var msie = /(msie|trident)/i.test(navigator.userAgent);
12+
var urlParsingNode = document.createElement('a');
13+
var originURL;
1414

15-
/**
15+
/**
1616
* Parse a URL to discover it's components
1717
*
1818
* @param {String} url The URL to be parsed
1919
* @returns {Object}
2020
*/
21-
function resolveURL(url) {
22-
var href = url;
21+
function resolveURL(url) {
22+
var href = url;
2323

24-
if (msie) {
24+
if (msie) {
2525
// IE needs attribute set twice to normalize properties
26-
urlParsingNode.setAttribute('href', href);
27-
href = urlParsingNode.href;
28-
}
26+
urlParsingNode.setAttribute('href', href);
27+
href = urlParsingNode.href;
28+
}
2929

30-
urlParsingNode.setAttribute('href', href);
30+
urlParsingNode.setAttribute('href', href);
3131

32-
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33-
return {
34-
href: urlParsingNode.href,
35-
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36-
host: urlParsingNode.host,
37-
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38-
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39-
hostname: urlParsingNode.hostname,
40-
port: urlParsingNode.port,
41-
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42-
urlParsingNode.pathname :
43-
'/' + urlParsingNode.pathname
44-
};
45-
}
32+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33+
return {
34+
href: urlParsingNode.href,
35+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36+
host: urlParsingNode.host,
37+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39+
hostname: urlParsingNode.hostname,
40+
port: urlParsingNode.port,
41+
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42+
urlParsingNode.pathname :
43+
'/' + urlParsingNode.pathname
44+
};
45+
}
4646

47-
originURL = resolveURL(window.location.href);
47+
originURL = resolveURL(window.location.href);
4848

49-
/**
49+
/**
5050
* Determine if a URL shares the same origin as the current location
5151
*
5252
* @param {String} requestURL The URL to test
5353
* @returns {boolean} True if URL shares the same origin, otherwise false
5454
*/
55-
return function isURLSameOrigin(requestURL) {
56-
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57-
return (parsed.protocol === originURL.protocol &&
55+
return function isURLSameOrigin(requestURL) {
56+
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57+
return (parsed.protocol === originURL.protocol &&
5858
parsed.host === originURL.host);
59-
};
60-
})() :
59+
};
60+
})() :
6161

6262
// Non standard browser envs (web workers, react-native) lack needed support.
63-
(function nonStandardBrowserEnv() {
64-
return function isURLSameOrigin() {
65-
return true;
66-
};
67-
})()
63+
(function nonStandardBrowserEnv() {
64+
return function isURLSameOrigin() {
65+
return true;
66+
};
67+
})()
6868
);

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",
1212
"postversion": "git push && git push --tags",
1313
"examples": "node ./examples/server.js",
14-
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
14+
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
15+
"fix": "eslint --fix lib/**/*.js"
1516
},
1617
"repository": {
1718
"type": "git",
@@ -40,7 +41,7 @@
4041
"grunt-contrib-clean": "^1.1.0",
4142
"grunt-contrib-nodeunit": "^1.0.0",
4243
"grunt-contrib-watch": "^1.0.0",
43-
"grunt-eslint": "^19.0.0",
44+
"grunt-eslint": "^20.1.0",
4445
"grunt-karma": "^2.0.0",
4546
"grunt-ts": "^6.0.0-beta.19",
4647
"grunt-webpack": "^1.0.18",

0 commit comments

Comments
 (0)