Skip to content

Commit 09d7788

Browse files
committed
style: execute prettier on all code files
chore: update prettier config
1 parent b525e79 commit 09d7788

File tree

10 files changed

+449
-439
lines changed

10 files changed

+449
-439
lines changed

.prettierrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"bracketSpacing": false,
3+
"printWidth": 80,
4+
"semi": true,
5+
"singleQuote": true,
6+
"tabWidth": 2,
7+
"trailingComma": "none",
8+
"useTabs": false,
9+
"arrowParens": "always"
10+
}

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import fn from "./lib/http.js";
1+
import fn from './lib/http.js';
22
export default fn;

lib/http.js

+58-58
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
/*!
1515
* Module dependencies.
1616
*/
17-
import net from "net";
18-
import url from "url";
19-
import Cookie from "cookiejar";
20-
import charset from "charset";
21-
import qs from "qs";
22-
import * as _request from "./request.js";
17+
import net from 'net';
18+
import url from 'url';
19+
import Cookie from 'cookiejar';
20+
import charset from 'charset';
21+
import qs from 'qs';
22+
import * as _request from './request.js';
2323

2424
/**
2525
*
@@ -48,9 +48,9 @@ export default function (chai, _) {
4848
*/
4949

5050
const contentTypes = {
51-
json: "application/json",
52-
text: "text/plain",
53-
html: "text/html",
51+
json: 'application/json',
52+
text: 'text/plain',
53+
html: 'text/html'
5454
};
5555

5656
/*!
@@ -81,27 +81,27 @@ export default function (chai, _) {
8181
* @api public
8282
*/
8383

84-
Assertion.addMethod("status", function (code) {
84+
Assertion.addMethod('status', function (code) {
8585
const hasStatus = Boolean(
86-
"status" in this._obj || "statusCode" in this._obj,
86+
'status' in this._obj || 'statusCode' in this._obj
8787
);
8888
new Assertion(hasStatus).assert(
8989
hasStatus,
9090
"expected #{act} to have keys 'status', or 'statusCode'",
9191
null, // never negated
9292
hasStatus, // expected
9393
this._obj, // actual
94-
false, // no diff
94+
false // no diff
9595
);
9696

9797
const status = this._obj.status || this._obj.statusCode;
9898

9999
this.assert(
100100
status == code,
101-
"expected #{this} to have status code #{exp} but got #{act}",
102-
"expected #{this} to not have status code #{act}",
101+
'expected #{this} to have status code #{exp} but got #{act}',
102+
'expected #{this} to not have status code #{act}',
103103
code,
104-
status,
104+
status
105105
);
106106
});
107107

@@ -130,14 +130,14 @@ export default function (chai, _) {
130130
* @api public
131131
*/
132132

133-
Assertion.addMethod("header", function (key, value) {
133+
Assertion.addMethod('header', function (key, value) {
134134
const header = getHeader(this._obj, key);
135135

136136
if (arguments.length < 2) {
137137
this.assert(
138-
"undefined" !== typeof header || null === header,
138+
'undefined' !== typeof header || null === header,
139139
"expected header '" + key + "' to exist",
140-
"expected header '" + key + "' to not exist",
140+
"expected header '" + key + "' to not exist"
141141
);
142142
} else if (arguments[1] instanceof RegExp) {
143143
this.assert(
@@ -146,16 +146,16 @@ export default function (chai, _) {
146146
key +
147147
"' to match " +
148148
value +
149-
" but got " +
149+
' but got ' +
150150
i(header),
151151
"expected header '" +
152152
key +
153153
"' not to match " +
154154
value +
155-
" but got " +
155+
' but got ' +
156156
i(header),
157157
value,
158-
header,
158+
header
159159
);
160160
} else {
161161
this.assert(
@@ -164,11 +164,11 @@ export default function (chai, _) {
164164
key +
165165
"' to have value " +
166166
value +
167-
" but got " +
167+
' but got ' +
168168
i(header),
169169
"expected header '" + key + "' to not have value " + value,
170170
value,
171-
header,
171+
header
172172
);
173173
}
174174
});
@@ -192,11 +192,11 @@ export default function (chai, _) {
192192
* @api public
193193
*/
194194

195-
Assertion.addProperty("headers", function () {
195+
Assertion.addProperty('headers', function () {
196196
this.assert(
197197
this._obj.headers || this._obj.getHeader,
198-
"expected #{this} to have headers or getHeader method",
199-
"expected #{this} to not have headers or getHeader method",
198+
'expected #{this} to have headers or getHeader method',
199+
'expected #{this} to not have headers or getHeader method'
200200
);
201201
});
202202

@@ -214,11 +214,11 @@ export default function (chai, _) {
214214
* @api public
215215
*/
216216

217-
Assertion.addProperty("ip", function () {
217+
Assertion.addProperty('ip', function () {
218218
this.assert(
219219
net.isIP(this._obj),
220-
"expected #{this} to be an ip",
221-
"expected #{this} to not be an ip",
220+
'expected #{this} to be an ip',
221+
'expected #{this} to not be an ip'
222222
);
223223
});
224224

@@ -244,13 +244,13 @@ export default function (chai, _) {
244244

245245
Assertion.addProperty(name, function () {
246246
new Assertion(this._obj).to.have.headers;
247-
const ct = getHeader(this._obj, "content-type"),
248-
ins = i(ct) === "undefined" ? "headers" : i(ct);
247+
const ct = getHeader(this._obj, 'content-type'),
248+
ins = i(ct) === 'undefined' ? 'headers' : i(ct);
249249

250250
this.assert(
251251
ct && ~ct.indexOf(val),
252-
"expected " + ins + " to include '" + val + "'",
253-
"expected " + ins + " to not include '" + val + "'",
252+
'expected ' + ins + " to include '" + val + "'",
253+
'expected ' + ins + " to not include '" + val + "'"
254254
);
255255
});
256256
}
@@ -270,7 +270,7 @@ export default function (chai, _) {
270270
* @api public
271271
*/
272272

273-
Assertion.addMethod("charset", function (value) {
273+
Assertion.addMethod('charset', function (value) {
274274
value = value.toLowerCase();
275275

276276
const headers = this._obj.headers;
@@ -280,14 +280,14 @@ export default function (chai, _) {
280280
* Fix charset() treating "utf8" as a special case
281281
* See https://github.com/node-modules/charset/issues/12
282282
*/
283-
if (cs === "utf8") {
284-
cs = "utf-8";
283+
if (cs === 'utf8') {
284+
cs = 'utf-8';
285285
}
286286

287287
this.assert(
288288
cs != null && value === cs,
289-
"expected content type to have " + value + " charset",
290-
"expected content type to not have " + value + " charset",
289+
'expected content type to have ' + value + ' charset',
290+
'expected content type to not have ' + value + ' charset'
291291
);
292292
});
293293

@@ -304,15 +304,15 @@ export default function (chai, _) {
304304
* @api public
305305
*/
306306

307-
Assertion.addProperty("redirect", function () {
307+
Assertion.addProperty('redirect', function () {
308308
const redirectCodes = [301, 302, 303, 307, 308],
309309
status = this._obj.status,
310310
redirects = this._obj.redirects;
311311

312312
this.assert(
313313
redirectCodes.indexOf(status) >= 0 || (redirects && redirects.length),
314-
"expected redirect with 30X status code but got " + status,
315-
"expected not to redirect but got " + status + " status",
314+
'expected redirect with 30X status code but got ' + status,
315+
'expected not to redirect but got ' + status + ' status'
316316
);
317317
});
318318

@@ -330,36 +330,36 @@ export default function (chai, _) {
330330
* @api public
331331
*/
332332

333-
Assertion.addMethod("redirectTo", function (destination) {
333+
Assertion.addMethod('redirectTo', function (destination) {
334334
const redirects = this._obj.redirects;
335335

336336
new Assertion(this._obj).to.redirect;
337337

338338
if (redirects && redirects.length) {
339339
let hasRedirected;
340340

341-
if (Object.prototype.toString.call(destination) === "[object RegExp]") {
341+
if (Object.prototype.toString.call(destination) === '[object RegExp]') {
342342
hasRedirected = redirects.some((redirect) =>
343-
destination.test(redirect),
343+
destination.test(redirect)
344344
);
345345
} else {
346346
hasRedirected = redirects.indexOf(destination) > -1;
347347
}
348348
this.assert(
349349
hasRedirected,
350-
"expected redirect to " +
350+
'expected redirect to ' +
351351
destination +
352-
" but got " +
353-
redirects.join(" then "),
354-
"expected not to redirect to " +
352+
' but got ' +
353+
redirects.join(' then '),
354+
'expected not to redirect to ' +
355355
destination +
356-
" but got " +
357-
redirects.join(" then "),
356+
' but got ' +
357+
redirects.join(' then ')
358358
);
359359
} else {
360360
const assertion = new Assertion(this._obj);
361361
_.transferFlags(this, assertion);
362-
assertion.with.header("location", destination);
362+
assertion.with.header('location', destination);
363363
}
364364
});
365365

@@ -381,7 +381,7 @@ export default function (chai, _) {
381381
* @api public
382382
*/
383383

384-
Assertion.addMethod("param", function (name, value) {
384+
Assertion.addMethod('param', function (name, value) {
385385
const assertion = new Assertion();
386386
_.transferFlags(this, assertion);
387387
assertion._obj = qs.parse(url.parse(this._obj.url).query);
@@ -412,12 +412,12 @@ export default function (chai, _) {
412412
* @api public
413413
*/
414414

415-
Assertion.addMethod("cookie", function (key, value) {
416-
let header = getHeader(this._obj, "set-cookie"),
415+
Assertion.addMethod('cookie', function (key, value) {
416+
let header = getHeader(this._obj, 'set-cookie'),
417417
cookie;
418418

419419
if (!header) {
420-
header = (getHeader(this._obj, "cookie") || "").split(";");
420+
header = (getHeader(this._obj, 'cookie') || '').split(';');
421421
}
422422

423423
if (this._obj instanceof chai.request.agent && this._obj.jar) {
@@ -434,13 +434,13 @@ export default function (chai, _) {
434434
"expected cookie '" + key + "' to have value #{exp} but got #{act}",
435435
"expected cookie '" + key + "' to not have value #{exp}",
436436
value,
437-
cookie.value,
437+
cookie.value
438438
);
439439
} else {
440440
this.assert(
441-
"undefined" !== typeof cookie || null === cookie,
441+
'undefined' !== typeof cookie || null === cookie,
442442
"expected cookie '" + key + "' to exist",
443-
"expected cookie '" + key + "' to not exist",
443+
"expected cookie '" + key + "' to not exist"
444444
);
445445
}
446446
});

lib/net.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
/*!
88
* net.isIP shim for browsers
99
*/
10-
export { isIP, isIPv4, isIPv6 } from "is-ip";
10+
export {isIP, isIPv4, isIPv6} from 'is-ip';

0 commit comments

Comments
 (0)