From 00ee3b47e2421aba4ef243ed98c147795ef085d0 Mon Sep 17 00:00:00 2001 From: Vsevolod Strukchinsky Date: Fri, 15 Jan 2016 10:39:54 +0500 Subject: [PATCH] Revert "temporary fix for T2892 (`const` gives "read-only" error)" This reverts commit c4045e3de6685abd1d36c09e0a48676ba73b00a5. --- package.json | 5 +---- test/gzip.js | 2 +- test/headers.js | 10 +++++----- test/http.js | 2 +- test/https.js | 8 ++++---- test/json.js | 2 +- test/post.js | 24 ++++++++++++------------ test/unix-socket.js | 6 +++--- 8 files changed, 28 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index a6a6346..9245b71 100644 --- a/package.json +++ b/package.json @@ -69,9 +69,6 @@ "xo": "*" }, "xo": { - "esnext": true, - "rules": { - "prefer-const": 0 - } + "esnext": true } } diff --git a/test/gzip.js b/test/gzip.js index f06cf99..07466c4 100644 --- a/test/gzip.js +++ b/test/gzip.js @@ -3,7 +3,7 @@ import test from 'ava'; import got from '../'; import {createServer} from './helpers/server'; -let testContent = 'Compressible response content.\n'; +const testContent = 'Compressible response content.\n'; let s; diff --git a/test/headers.js b/test/headers.js index 2b0d192..820d71d 100644 --- a/test/headers.js +++ b/test/headers.js @@ -16,12 +16,12 @@ test.before('setup', async () => { }); test('user-agent', async t => { - let headers = (await got(s.url, {json: true})).body; + const headers = (await got(s.url, {json: true})).body; t.is(headers['user-agent'], 'https://github.com/sindresorhus/got'); }); test('accept-encoding', async t => { - let headers = (await got(s.url, {json: true})).body; + const headers = (await got(s.url, {json: true})).body; t.is(headers['accept-encoding'], 'gzip,deflate'); }); @@ -34,17 +34,17 @@ test('accept header with json option', async t => { }); test('host', async t => { - let headers = (await got(s.url, {json: true})).body; + const headers = (await got(s.url, {json: true})).body; t.is(headers.host, `localhost:${s.port}`); }); test('transform names to lowercase', async t => { - let headers = (await got(s.url, {headers: {'USER-AGENT': 'test'}, json: true})).body; + const headers = (await got(s.url, {headers: {'USER-AGENT': 'test'}, json: true})).body; t.is(headers['user-agent'], 'test'); }); test('zero content-length', async t => { - let headers = (await got(s.url, {headers: {'content-length': 0}, body: 'sup', json: true})).body; + const headers = (await got(s.url, {headers: {'content-length': 0}, body: 'sup', json: true})).body; t.is(headers['content-length'], '0'); }); diff --git a/test/http.js b/test/http.js index 77ebdf5..b9bdf4e 100644 --- a/test/http.js +++ b/test/http.js @@ -52,7 +52,7 @@ test('error with code', async t => { }); test('buffer on encoding === null', async t => { - let data = (await got(s.url, {encoding: null})).body; + const data = (await got(s.url, {encoding: null})).body; t.ok(Buffer.isBuffer(data)); }); diff --git a/test/https.js b/test/https.js index fc62bb2..59e79de 100644 --- a/test/https.js +++ b/test/https.js @@ -10,15 +10,15 @@ let cert; let caRootKey; let caRootCert; -let pemP = pify(pem, Promise); +const pemP = pify(pem, Promise); test.before('setup', async () => { - let caKeys = await pemP.createCertificate({days: 1, selfSigned: true}); + const caKeys = await pemP.createCertificate({days: 1, selfSigned: true}); caRootKey = caKeys.serviceKey; caRootCert = caKeys.certificate; - let keys = await pemP.createCertificate({ + const keys = await pemP.createCertificate({ serviceCertificate: caRootCert, serviceKey: caRootKey, serial: Date.now(), @@ -50,7 +50,7 @@ test('make request to https server', async t => { }); test('make request to https server with ca', async t => { - let {body} = await got(s.url, { + const {body} = await got(s.url, { strictSSL: true, ca: caRootCert, headers: {host: 'sindresorhus.com'} diff --git a/test/json.js b/test/json.js index 66486d7..2f0b2dc 100644 --- a/test/json.js +++ b/test/json.js @@ -38,7 +38,7 @@ test('parses response', async t => { }); test('not parses responses without a body', async t => { - let {body} = await got(`${s.url}/204`, {json: true}); + const {body} = await got(`${s.url}/204`, {json: true}); t.is(body, ''); }); diff --git a/test/post.js b/test/post.js index f0e68c0..d2cd97a 100644 --- a/test/post.js +++ b/test/post.js @@ -25,48 +25,48 @@ test.before('setup', async () => { }); test('GET can have body', async t => { - let {body, headers} = await got.get(s.url, {body: 'hi'}); + const {body, headers} = await got.get(s.url, {body: 'hi'}); t.is(body, 'hi'); t.is(headers.method, 'GET'); }); test('sends strings', async t => { - let {body} = await got(s.url, {body: 'wow'}); + const {body} = await got(s.url, {body: 'wow'}); t.is(body, 'wow'); }); test('sends Buffers', async t => { - let {body} = await got(s.url, {body: new Buffer('wow')}); + const {body} = await got(s.url, {body: new Buffer('wow')}); t.is(body, 'wow'); }); test('sends Streams', async t => { - let {body} = await got(s.url, {body: intoStream(['wow'])}); + const {body} = await got(s.url, {body: intoStream(['wow'])}); t.is(body, 'wow'); }); test('works with empty post response', async t => { - let {body} = await got(`${s.url}/empty`, {body: 'wow'}); + const {body} = await got(`${s.url}/empty`, {body: 'wow'}); t.is(body, ''); }); test('content-length header with string body', async t => { - let {body} = await got(`${s.url}/headers`, {body: 'wow', json: true}); + const {body} = await got(`${s.url}/headers`, {body: 'wow', json: true}); t.is(body['content-length'], '3'); }); test('content-length header with Buffer body', async t => { - let {body} = await got(`${s.url}/headers`, {body: new Buffer('wow'), json: true}); + const {body} = await got(`${s.url}/headers`, {body: new Buffer('wow'), json: true}); t.is(body['content-length'], '3'); }); test('content-length header with Stream body', async t => { - let {body} = await got(`${s.url}/headers`, {body: intoStream(['wow']), json: true}); + const {body} = await got(`${s.url}/headers`, {body: intoStream(['wow']), json: true}); t.is(body['content-length'], undefined); }); test('content-length header is not overriden', async t => { - let {body} = await got(`${s.url}/headers`, { + const {body} = await got(`${s.url}/headers`, { body: 'wow', json: true, headers: { @@ -77,7 +77,7 @@ test('content-length header is not overriden', async t => { }); test('content-length header disabled for chunked transfer-encoding', async t => { - let {body} = await got(`${s.url}/headers`, { + const {body} = await got(`${s.url}/headers`, { body: '3\r\nwow\r\n0\r\n', json: true, headers: { @@ -88,7 +88,7 @@ test('content-length header disabled for chunked transfer-encoding', async t => }); test('object in options.body treated as querystring', async t => { - let {body} = await got(s.url, { + const {body} = await got(s.url, { body: { such: 'wow' } @@ -97,7 +97,7 @@ test('object in options.body treated as querystring', async t => { }); test('content-type header is not overriden when object in options.body', async t => { - let {body} = await got(`${s.url}/headers`, { + const {body} = await got(`${s.url}/headers`, { headers: { 'content-type': 'doge' }, diff --git a/test/unix-socket.js b/test/unix-socket.js index 35e1585..5ea490f 100644 --- a/test/unix-socket.js +++ b/test/unix-socket.js @@ -4,7 +4,7 @@ import test from 'ava'; import got from '../'; import {createServer} from './helpers/server'; -let socketPath = tempfile('.socket'); +const socketPath = tempfile('.socket'); let s; @@ -19,12 +19,12 @@ test.before('setup', async () => { }); test('works', async t => { - let url = format('http://unix:%s:%s', socketPath, '/'); + const url = format('http://unix:%s:%s', socketPath, '/'); t.is((await got(url)).body, 'ok'); }); test('protocol-less works', async t => { - let url = format('unix:%s:%s', socketPath, '/'); + const url = format('unix:%s:%s', socketPath, '/'); t.is((await got(url)).body, 'ok'); });