Skip to content

Commit 88d0345

Browse files
committed
[pkg] Update prettier to version 2.0.5
1 parent b6ae22a commit 88d0345

File tree

10 files changed

+36
-36
lines changed

10 files changed

+36
-36
lines changed

.prettierrc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ arrowParens: always
22
endOfLine: lf
33
proseWrap: always
44
singleQuote: true
5+
trailingComma: none

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ os:
1010
- osx
1111
- windows
1212
script:
13-
- if [ "${TRAVIS_NODE_VERSION}" == "14" ] && [ "${TRAVIS_OS_NAME}" == linux ]; then npm run lint; fi
13+
- if [ "${TRAVIS_NODE_VERSION}" == "14" ] && [ "${TRAVIS_OS_NAME}" == linux ];
14+
then npm run lint; fi
1415
- npm test
1516
after_success:
1617
- nyc report --reporter=text-lcov | coveralls

browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
module.exports = function() {
3+
module.exports = function () {
44
throw new Error(
55
'ws does not work in the browser. Browser clients must use the native ' +
66
'WebSocket object'

examples/express-session-parse/index.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const sessionParser = session({
2626
app.use(express.static('public'));
2727
app.use(sessionParser);
2828

29-
app.post('/login', function(req, res) {
29+
app.post('/login', function (req, res) {
3030
//
3131
// "Log in" user and set userId to session.
3232
//
@@ -37,11 +37,11 @@ app.post('/login', function(req, res) {
3737
res.send({ result: 'OK', message: 'Session updated' });
3838
});
3939

40-
app.delete('/logout', function(request, response) {
40+
app.delete('/logout', function (request, response) {
4141
const ws = map.get(request.session.userId);
4242

4343
console.log('Destroying session');
44-
request.session.destroy(function() {
44+
request.session.destroy(function () {
4545
if (ws) ws.close();
4646

4747
response.send({ result: 'OK', message: 'Session destroyed' });
@@ -54,7 +54,7 @@ app.delete('/logout', function(request, response) {
5454
const server = http.createServer(app);
5555
const wss = new WebSocket.Server({ clientTracking: false, noServer: true });
5656

57-
server.on('upgrade', function(request, socket, head) {
57+
server.on('upgrade', function (request, socket, head) {
5858
console.log('Parsing session from request...');
5959

6060
sessionParser(request, {}, () => {
@@ -65,32 +65,32 @@ server.on('upgrade', function(request, socket, head) {
6565

6666
console.log('Session is parsed!');
6767

68-
wss.handleUpgrade(request, socket, head, function(ws) {
68+
wss.handleUpgrade(request, socket, head, function (ws) {
6969
wss.emit('connection', ws, request);
7070
});
7171
});
7272
});
7373

74-
wss.on('connection', function(ws, request) {
74+
wss.on('connection', function (ws, request) {
7575
const userId = request.session.userId;
7676

7777
map.set(userId, ws);
7878

79-
ws.on('message', function(message) {
79+
ws.on('message', function (message) {
8080
//
8181
// Here we can now use session parameters.
8282
//
8383
console.log(`Received message ${message} from user ${userId}`);
8484
});
8585

86-
ws.on('close', function() {
86+
ws.on('close', function () {
8787
map.delete(userId);
8888
});
8989
});
9090

9191
//
9292
// Start the server.
9393
//
94-
server.listen(8080, function() {
94+
server.listen(8080, function () {
9595
console.log('Listening on http://localhost:8080');
9696
});

examples/express-session-parse/public/app.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function() {
1+
(function () {
22
const messages = document.querySelector('#messages');
33
const wsButton = document.querySelector('#wsButton');
44
const wsSendButton = document.querySelector('#wsSendButton');
@@ -16,46 +16,46 @@
1616
: Promise.reject(new Error('Unexpected response'));
1717
}
1818

19-
login.onclick = function() {
19+
login.onclick = function () {
2020
fetch('/login', { method: 'POST', credentials: 'same-origin' })
2121
.then(handleResponse)
2222
.then(showMessage)
23-
.catch(function(err) {
23+
.catch(function (err) {
2424
showMessage(err.message);
2525
});
2626
};
2727

28-
logout.onclick = function() {
28+
logout.onclick = function () {
2929
fetch('/logout', { method: 'DELETE', credentials: 'same-origin' })
3030
.then(handleResponse)
3131
.then(showMessage)
32-
.catch(function(err) {
32+
.catch(function (err) {
3333
showMessage(err.message);
3434
});
3535
};
3636

3737
let ws;
3838

39-
wsButton.onclick = function() {
39+
wsButton.onclick = function () {
4040
if (ws) {
4141
ws.onerror = ws.onopen = ws.onclose = null;
4242
ws.close();
4343
}
4444

4545
ws = new WebSocket(`ws://${location.host}`);
46-
ws.onerror = function() {
46+
ws.onerror = function () {
4747
showMessage('WebSocket error');
4848
};
49-
ws.onopen = function() {
49+
ws.onopen = function () {
5050
showMessage('WebSocket connection established');
5151
};
52-
ws.onclose = function() {
52+
ws.onclose = function () {
5353
showMessage('WebSocket connection closed');
5454
ws = null;
5555
};
5656
};
5757

58-
wsSendButton.onclick = function() {
58+
wsSendButton.onclick = function () {
5959
if (!ws) {
6060
showMessage('No WebSocket connection');
6161
return;

examples/server-stats/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ app.use(express.static(path.join(__dirname, '/public')));
1212
const server = createServer(app);
1313
const wss = new WebSocket.Server({ server });
1414

15-
wss.on('connection', function(ws) {
16-
const id = setInterval(function() {
17-
ws.send(JSON.stringify(process.memoryUsage()), function() {
15+
wss.on('connection', function (ws) {
16+
const id = setInterval(function () {
17+
ws.send(JSON.stringify(process.memoryUsage()), function () {
1818
//
1919
// Ignore errors.
2020
//
2121
});
2222
}, 100);
2323
console.log('started client interval');
2424

25-
ws.on('close', function() {
25+
ws.on('close', function () {
2626
console.log('stopping client interval');
2727
clearInterval(id);
2828
});
2929
});
3030

31-
server.listen(8080, function() {
31+
server.listen(8080, function () {
3232
console.log('Listening on http://localhost:8080');
3333
});

lib/stream.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function createWebSocketStream(ws, options) {
8989
duplex.push(null);
9090
});
9191

92-
duplex._destroy = function(err, callback) {
92+
duplex._destroy = function (err, callback) {
9393
if (ws.readyState === ws.CLOSED) {
9494
callback(err);
9595
process.nextTick(emitClose, duplex);
@@ -110,7 +110,7 @@ function createWebSocketStream(ws, options) {
110110
ws.terminate();
111111
};
112112

113-
duplex._final = function(callback) {
113+
duplex._final = function (callback) {
114114
if (ws.readyState === ws.CONNECTING) {
115115
ws.once('open', function open() {
116116
duplex._final(callback);
@@ -138,14 +138,14 @@ function createWebSocketStream(ws, options) {
138138
}
139139
};
140140

141-
duplex._read = function() {
141+
duplex._read = function () {
142142
if (ws.readyState === ws.OPEN && !resumeOnReceiverDrain) {
143143
resumeOnReceiverDrain = true;
144144
if (!ws._receiver._writableState.needDrain) ws._socket.resume();
145145
}
146146
};
147147

148-
duplex._write = function(chunk, encoding, callback) {
148+
duplex._write = function (chunk, encoding, callback) {
149149
if (ws.readyState === ws.CONNECTING) {
150150
ws.once('open', function open() {
151151
duplex._write(chunk, encoding, callback);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"eslint-plugin-prettier": "^3.0.1",
5252
"mocha": "^7.0.0",
5353
"nyc": "^15.0.0",
54-
"prettier": "^1.17.0",
54+
"prettier": "^2.0.5",
5555
"utf-8-validate": "^5.0.2"
5656
}
5757
}

test/websocket-server.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('WebSocketServer', () => {
112112
});
113113
});
114114

115-
it('uses a precreated http server listening on unix socket', function(done) {
115+
it('uses a precreated http server listening on unix socket', function (done) {
116116
//
117117
// Skip this test on Windows as it throws errors for obvious reasons.
118118
//

test/websocket.test.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('WebSocket', () => {
2626
);
2727
});
2828

29-
it('accepts `url.URL` objects as url', function(done) {
29+
it('accepts `url.URL` objects as url', function (done) {
3030
const agent = new CustomAgent();
3131

3232
agent.addRequest = (req, opts) => {
@@ -1345,9 +1345,7 @@ describe('WebSocket', () => {
13451345
'Invalid WebSocket frame: MASK must be set'
13461346
);
13471347
assert.ok(
1348-
Buffer.concat(chunks)
1349-
.slice(0, 2)
1350-
.equals(Buffer.from('8102', 'hex'))
1348+
Buffer.concat(chunks).slice(0, 2).equals(Buffer.from('8102', 'hex'))
13511349
);
13521350

13531351
ws.on('close', (code, reason) => {

0 commit comments

Comments
 (0)