Browse Source

tools: lint for object literal spacing

There has been occasional nits for spacing in object literals in PRs but
the project does not lint for it and it is not always handled
consistently in the existing code, even on adjacent lines of a file.

This change enables a linting rule requiring no space between the key
and the colon, and requiring at least one space (but allowing for more
so property values can be lined up if desired) between the colon and the
value. This appears to be the most common style used in the current code
base.

Example code the complies with lint rule:

    myObj = { foo: 'bar' };

Examples that do not comply with the lint rule:

    myObj = { foo : 'bar' };
    myObj = { foo:'bar' };

PR-URL: https://github.com/nodejs/node/pull/6592
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
process-exit-stdio-flushing
Rich Trott 9 years ago
parent
commit
4e6dc00401
  1. 1
      .eslintrc
  2. 124
      lib/_http_server.js
  3. 26
      lib/util.js
  4. 10
      test/doctool/test-doctool-json.js
  5. 4
      test/parallel/test-console.js
  6. 8
      test/parallel/test-crypto-binary-default.js
  7. 8
      test/parallel/test-crypto.js
  8. 2
      test/parallel/test-domain-http-server.js
  9. 2
      test/parallel/test-domain-top-level-error-handler-throw.js
  10. 2
      test/parallel/test-http-chunk-problem.js
  11. 2
      test/parallel/test-http-client-pipe-end.js
  12. 2
      test/parallel/test-http-client-reject-chunked-with-content-length.js
  13. 2
      test/parallel/test-http-client-reject-cr-no-lf.js
  14. 2
      test/parallel/test-http-client-response-domain.js
  15. 2
      test/parallel/test-http-client-timeout-with-data.js
  16. 4
      test/parallel/test-http-expect-continue.js
  17. 2
      test/parallel/test-http-remove-header-stays-removed.js
  18. 2
      test/parallel/test-http-response-multi-content-length.js
  19. 2
      test/parallel/test-http-response-multiheaders.js
  20. 4
      test/parallel/test-http-response-splitting.js
  21. 2
      test/parallel/test-http-server-multiheaders.js
  22. 2
      test/parallel/test-http-server-multiheaders2.js
  23. 2
      test/parallel/test-http-server-reject-cr-no-lf.js
  24. 4
      test/parallel/test-listen-fd-ebadf.js
  25. 2
      test/parallel/test-net-listen-fd0.js
  26. 8
      test/parallel/test-stream-transform-split-objectmode.js
  27. 2
      test/parallel/test-stream2-transform.js
  28. 2
      test/parallel/test-tls-alert.js
  29. 6
      test/parallel/test-url.js
  30. 14
      test/parallel/test-util.js
  31. 2
      test/parallel/test-vm-context.js
  32. 16
      test/pummel/test-crypto-dh.js
  33. 2
      test/pummel/test-fs-watch-file-slow.js
  34. 2
      test/sequential/test-fs-watch.js
  35. 4
      tools/doc/html.js

1
.eslintrc

@ -57,6 +57,7 @@ rules:
comma-spacing: 2 comma-spacing: 2
eol-last: 2 eol-last: 2
indent: [2, 2, {SwitchCase: 1}] indent: [2, 2, {SwitchCase: 1}]
key-spacing: [2, {mode: "minimum"}]
keyword-spacing: 2 keyword-spacing: 2
max-len: [2, 80, 2] max-len: [2, 80, 2]
new-parens: 2 new-parens: 2

124
lib/_http_server.js

@ -15,68 +15,68 @@ const httpSocketSetup = common.httpSocketSetup;
const OutgoingMessage = require('_http_outgoing').OutgoingMessage; const OutgoingMessage = require('_http_outgoing').OutgoingMessage;
const STATUS_CODES = exports.STATUS_CODES = { const STATUS_CODES = exports.STATUS_CODES = {
100 : 'Continue', 100: 'Continue',
101 : 'Switching Protocols', 101: 'Switching Protocols',
102 : 'Processing', // RFC 2518, obsoleted by RFC 4918 102: 'Processing', // RFC 2518, obsoleted by RFC 4918
200 : 'OK', 200: 'OK',
201 : 'Created', 201: 'Created',
202 : 'Accepted', 202: 'Accepted',
203 : 'Non-Authoritative Information', 203: 'Non-Authoritative Information',
204 : 'No Content', 204: 'No Content',
205 : 'Reset Content', 205: 'Reset Content',
206 : 'Partial Content', 206: 'Partial Content',
207 : 'Multi-Status', // RFC 4918 207: 'Multi-Status', // RFC 4918
208 : 'Already Reported', 208: 'Already Reported',
226 : 'IM Used', 226: 'IM Used',
300 : 'Multiple Choices', 300: 'Multiple Choices',
301 : 'Moved Permanently', 301: 'Moved Permanently',
302 : 'Found', 302: 'Found',
303 : 'See Other', 303: 'See Other',
304 : 'Not Modified', 304: 'Not Modified',
305 : 'Use Proxy', 305: 'Use Proxy',
307 : 'Temporary Redirect', 307: 'Temporary Redirect',
308 : 'Permanent Redirect', // RFC 7238 308: 'Permanent Redirect', // RFC 7238
400 : 'Bad Request', 400: 'Bad Request',
401 : 'Unauthorized', 401: 'Unauthorized',
402 : 'Payment Required', 402: 'Payment Required',
403 : 'Forbidden', 403: 'Forbidden',
404 : 'Not Found', 404: 'Not Found',
405 : 'Method Not Allowed', 405: 'Method Not Allowed',
406 : 'Not Acceptable', 406: 'Not Acceptable',
407 : 'Proxy Authentication Required', 407: 'Proxy Authentication Required',
408 : 'Request Timeout', 408: 'Request Timeout',
409 : 'Conflict', 409: 'Conflict',
410 : 'Gone', 410: 'Gone',
411 : 'Length Required', 411: 'Length Required',
412 : 'Precondition Failed', 412: 'Precondition Failed',
413 : 'Payload Too Large', 413: 'Payload Too Large',
414 : 'URI Too Long', 414: 'URI Too Long',
415 : 'Unsupported Media Type', 415: 'Unsupported Media Type',
416 : 'Range Not Satisfiable', 416: 'Range Not Satisfiable',
417 : 'Expectation Failed', 417: 'Expectation Failed',
418 : 'I\'m a teapot', // RFC 2324 418: 'I\'m a teapot', // RFC 2324
421 : 'Misdirected Request', 421: 'Misdirected Request',
422 : 'Unprocessable Entity', // RFC 4918 422: 'Unprocessable Entity', // RFC 4918
423 : 'Locked', // RFC 4918 423: 'Locked', // RFC 4918
424 : 'Failed Dependency', // RFC 4918 424: 'Failed Dependency', // RFC 4918
425 : 'Unordered Collection', // RFC 4918 425: 'Unordered Collection', // RFC 4918
426 : 'Upgrade Required', // RFC 2817 426: 'Upgrade Required', // RFC 2817
428 : 'Precondition Required', // RFC 6585 428: 'Precondition Required', // RFC 6585
429 : 'Too Many Requests', // RFC 6585 429: 'Too Many Requests', // RFC 6585
431 : 'Request Header Fields Too Large', // RFC 6585 431: 'Request Header Fields Too Large', // RFC 6585
451 : 'Unavailable For Legal Reasons', 451: 'Unavailable For Legal Reasons',
500 : 'Internal Server Error', 500: 'Internal Server Error',
501 : 'Not Implemented', 501: 'Not Implemented',
502 : 'Bad Gateway', 502: 'Bad Gateway',
503 : 'Service Unavailable', 503: 'Service Unavailable',
504 : 'Gateway Timeout', 504: 'Gateway Timeout',
505 : 'HTTP Version Not Supported', 505: 'HTTP Version Not Supported',
506 : 'Variant Also Negotiates', // RFC 2295 506: 'Variant Also Negotiates', // RFC 2295
507 : 'Insufficient Storage', // RFC 4918 507: 'Insufficient Storage', // RFC 4918
508 : 'Loop Detected', 508: 'Loop Detected',
509 : 'Bandwidth Limit Exceeded', 509: 'Bandwidth Limit Exceeded',
510 : 'Not Extended', // RFC 2774 510: 'Not Extended', // RFC 2774
511 : 'Network Authentication Required' // RFC 6585 511: 'Network Authentication Required' // RFC 6585
}; };
const kOnExecute = HTTPParser.kOnExecute | 0; const kOnExecute = HTTPParser.kOnExecute | 0;

26
lib/util.js

@ -151,19 +151,19 @@ exports.inspect = inspect;
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
inspect.colors = { inspect.colors = {
'bold' : [1, 22], 'bold': [1, 22],
'italic' : [3, 23], 'italic': [3, 23],
'underline' : [4, 24], 'underline': [4, 24],
'inverse' : [7, 27], 'inverse': [7, 27],
'white' : [37, 39], 'white': [37, 39],
'grey' : [90, 39], 'grey': [90, 39],
'black' : [30, 39], 'black': [30, 39],
'blue' : [34, 39], 'blue': [34, 39],
'cyan' : [36, 39], 'cyan': [36, 39],
'green' : [32, 39], 'green': [32, 39],
'magenta' : [35, 39], 'magenta': [35, 39],
'red' : [31, 39], 'red': [31, 39],
'yellow' : [33, 39] 'yellow': [33, 39]
}; };
// Don't use 'blue' not visible on cmd.exe // Don't use 'blue' not visible on cmd.exe

10
test/doctool/test-doctool-json.js

@ -17,7 +17,7 @@ var testData = [
'source': 'foo', 'source': 'foo',
'modules': [ { 'textRaw': 'Sample Markdown', 'modules': [ { 'textRaw': 'Sample Markdown',
'name': 'sample_markdown', 'name': 'sample_markdown',
'modules': [ { 'textRaw':'Seussian Rhymes', 'modules': [ { 'textRaw': 'Seussian Rhymes',
'name': 'seussian_rhymes', 'name': 'seussian_rhymes',
'desc': '<ol>\n<li>fish</li>\n<li><p>fish</p>\n</li>\n<li>' + 'desc': '<ol>\n<li>fish</li>\n<li><p>fish</p>\n</li>\n<li>' +
'<p>Red fish</p>\n</li>\n<li>Blue fish</li>\n</ol>\n', '<p>Red fish</p>\n</li>\n<li>Blue fish</li>\n</ol>\n',
@ -32,7 +32,7 @@ var testData = [
{ {
'file': common.fixturesDir + '/order_of_end_tags_5873.md', 'file': common.fixturesDir + '/order_of_end_tags_5873.md',
'json': { 'json': {
'source':'foo', 'source': 'foo',
'modules': [ { 'modules': [ {
'textRaw': 'Title', 'textRaw': 'Title',
'name': 'title', 'name': 'title',
@ -41,8 +41,8 @@ var testData = [
'name': 'subsection', 'name': 'subsection',
'classMethods': [ { 'classMethods': [ {
'textRaw': 'Class Method: Buffer.from(array)', 'textRaw': 'Class Method: Buffer.from(array)',
'type':'classMethod', 'type': 'classMethod',
'name':'from', 'name': 'from',
'signatures': [ { 'signatures': [ {
'params': [ { 'params': [ {
'textRaw': '`array` {Array} ', 'textRaw': '`array` {Array} ',
@ -51,7 +51,7 @@ var testData = [
} ] } ]
}, },
{ {
'params' : [ { 'params': [ {
'name': 'array' 'name': 'array'
} ] } ]
} }

4
test/parallel/test-console.js

@ -66,8 +66,8 @@ console.warn(custom_inspect);
// test console.dir() // test console.dir()
console.dir(custom_inspect); console.dir(custom_inspect);
console.dir(custom_inspect, { showHidden: false }); console.dir(custom_inspect, { showHidden: false });
console.dir({ foo : { bar : { baz : true } } }, { depth: 0 }); console.dir({ foo: { bar: { baz: true } } }, { depth: 0 });
console.dir({ foo : { bar : { baz : true } } }, { depth: 1 }); console.dir({ foo: { bar: { baz: true } } }, { depth: 1 });
// test console.trace() // test console.trace()
console.trace('This is a %j %d', { formatted: 'trace' }, 10, 'foo'); console.trace('This is a %j %d', { formatted: 'trace' }, 10, 'foo');

8
test/parallel/test-crypto-binary-default.js

@ -30,19 +30,19 @@ var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem',
// PFX tests // PFX tests
assert.doesNotThrow(function() { assert.doesNotThrow(function() {
tls.createSecureContext({pfx:certPfx, passphrase:'sample'}); tls.createSecureContext({pfx: certPfx, passphrase: 'sample'});
}); });
assert.throws(function() { assert.throws(function() {
tls.createSecureContext({pfx:certPfx}); tls.createSecureContext({pfx: certPfx});
}, 'mac verify failure'); }, 'mac verify failure');
assert.throws(function() { assert.throws(function() {
tls.createSecureContext({pfx:certPfx, passphrase:'test'}); tls.createSecureContext({pfx: certPfx, passphrase: 'test'});
}, 'mac verify failure'); }, 'mac verify failure');
assert.throws(function() { assert.throws(function() {
tls.createSecureContext({pfx:'sample', passphrase:'test'}); tls.createSecureContext({pfx: 'sample', passphrase: 'test'});
}, 'not enough data'); }, 'not enough data');
// Test HMAC // Test HMAC

8
test/parallel/test-crypto.js

@ -32,19 +32,19 @@ assert.throws(function() {
// PFX tests // PFX tests
assert.doesNotThrow(function() { assert.doesNotThrow(function() {
tls.createSecureContext({pfx:certPfx, passphrase:'sample'}); tls.createSecureContext({pfx: certPfx, passphrase: 'sample'});
}); });
assert.throws(function() { assert.throws(function() {
tls.createSecureContext({pfx:certPfx}); tls.createSecureContext({pfx: certPfx});
}, 'mac verify failure'); }, 'mac verify failure');
assert.throws(function() { assert.throws(function() {
tls.createSecureContext({pfx:certPfx, passphrase:'test'}); tls.createSecureContext({pfx: certPfx, passphrase: 'test'});
}, 'mac verify failure'); }, 'mac verify failure');
assert.throws(function() { assert.throws(function() {
tls.createSecureContext({pfx:'sample', passphrase:'test'}); tls.createSecureContext({pfx: 'sample', passphrase: 'test'});
}, 'not enough data'); }, 'not enough data');

2
test/parallel/test-domain-http-server.js

@ -20,7 +20,7 @@ var server = http.createServer(function(req, res) {
serverCaught++; serverCaught++;
console.log('horray! got a server error', er); console.log('horray! got a server error', er);
// try to send a 500. If that fails, oh well. // try to send a 500. If that fails, oh well.
res.writeHead(500, {'content-type':'text/plain'}); res.writeHead(500, {'content-type': 'text/plain'});
res.end(er.stack || er.message || 'Unknown error'); res.end(er.stack || er.message || 'Unknown error');
}); });

2
test/parallel/test-domain-top-level-error-handler-throw.js

@ -29,7 +29,7 @@ if (process.argv[2] === 'child') {
var fork = require('child_process').fork; var fork = require('child_process').fork;
var assert = require('assert'); var assert = require('assert');
var child = fork(process.argv[1], ['child'], {silent:true}); var child = fork(process.argv[1], ['child'], {silent: true});
var stderrOutput = ''; var stderrOutput = '';
if (child) { if (child) {
child.stderr.on('data', function onStderrData(data) { child.stderr.on('data', function onStderrData(data) {

2
test/parallel/test-http-chunk-problem.js

@ -11,7 +11,7 @@ if (process.argv[2] === 'request') {
const http = require('http'); const http = require('http');
const options = { const options = {
port: common.PORT, port: common.PORT,
path : '/' path: '/'
}; };
http.get(options, (res) => { http.get(options, (res) => {

2
test/parallel/test-http-client-pipe-end.js

@ -18,7 +18,7 @@ common.refreshTmpDir();
server.listen(common.PIPE, function() { server.listen(common.PIPE, function() {
var req = http.request({ var req = http.request({
socketPath: common.PIPE, socketPath: common.PIPE,
headers: {'Content-Length':'1'}, headers: {'Content-Length': '1'},
method: 'POST', method: 'POST',
path: '/' path: '/'
}); });

2
test/parallel/test-http-client-reject-chunked-with-content-length.js

@ -17,7 +17,7 @@ server.listen(common.PORT, () => {
// The callback should not be called because the server is sending // The callback should not be called because the server is sending
// both a Content-Length header and a Transfer-Encoding: chunked // both a Content-Length header and a Transfer-Encoding: chunked
// header, which is a violation of the HTTP spec. // header, which is a violation of the HTTP spec.
const req = http.get({port:common.PORT}, (res) => { const req = http.get({port: common.PORT}, (res) => {
assert.fail(null, null, 'callback should not be called'); assert.fail(null, null, 'callback should not be called');
}); });
req.on('error', common.mustCall((err) => { req.on('error', common.mustCall((err) => {

2
test/parallel/test-http-client-reject-cr-no-lf.js

@ -16,7 +16,7 @@ const server = net.createServer((socket) => {
server.listen(common.PORT, () => { server.listen(common.PORT, () => {
// The callback should not be called because the server is sending a // The callback should not be called because the server is sending a
// header field that ends only in \r with no following \n // header field that ends only in \r with no following \n
const req = http.get({port:common.PORT}, (res) => { const req = http.get({port: common.PORT}, (res) => {
assert.fail(null, null, 'callback should not be called'); assert.fail(null, null, 'callback should not be called');
}); });
req.on('error', common.mustCall((err) => { req.on('error', common.mustCall((err) => {

2
test/parallel/test-http-client-response-domain.js

@ -34,7 +34,7 @@ function test() {
var req = http.get({ var req = http.get({
socketPath: common.PIPE, socketPath: common.PIPE,
headers: {'Content-Length':'1'}, headers: {'Content-Length': '1'},
method: 'POST', method: 'POST',
path: '/' path: '/'
}); });

2
test/parallel/test-http-client-timeout-with-data.js

@ -19,7 +19,7 @@ const options = {
}; };
const server = http.createServer(function(req, res) { const server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Length':'2'}); res.writeHead(200, {'Content-Length': '2'});
res.write('*'); res.write('*');
setTimeout(function() { res.end('*'); }, common.platformTimeout(100)); setTimeout(function() { res.end('*'); }, common.platformTimeout(100));
}); });

4
test/parallel/test-http-expect-continue.js

@ -13,8 +13,8 @@ function handler(req, res) {
assert.equal(sent_continue, true, 'Full response sent before 100 Continue'); assert.equal(sent_continue, true, 'Full response sent before 100 Continue');
console.error('Server sending full response...'); console.error('Server sending full response...');
res.writeHead(200, { res.writeHead(200, {
'Content-Type' : 'text/plain', 'Content-Type': 'text/plain',
'ABCD' : '1' 'ABCD': '1'
}); });
res.end(test_res_body); res.end(test_res_body);
} }

2
test/parallel/test-http-remove-header-stays-removed.js

@ -30,7 +30,7 @@ process.on('exit', function() {
server.listen(common.PORT, function() { server.listen(common.PORT, function() {
http.get({ port: common.PORT }, function(res) { http.get({ port: common.PORT }, function(res) {
assert.equal(200, res.statusCode); assert.equal(200, res.statusCode);
assert.deepStrictEqual(res.headers, { date : 'coffee o clock' }); assert.deepStrictEqual(res.headers, { date: 'coffee o clock' });
res.setEncoding('ascii'); res.setEncoding('ascii');
res.on('data', function(chunk) { res.on('data', function(chunk) {

2
test/parallel/test-http-response-multi-content-length.js

@ -33,7 +33,7 @@ server.listen(common.PORT, common.mustCall(() => {
// case, the error handler must be called because the client // case, the error handler must be called because the client
// is not allowed to accept multiple content-length headers. // is not allowed to accept multiple content-length headers.
http.get( http.get(
{port:common.PORT, headers:{'x-num': n}}, {port: common.PORT, headers: {'x-num': n}},
(res) => { (res) => {
assert(false, 'client allowed multiple content-length headers.'); assert(false, 'client allowed multiple content-length headers.');
} }

2
test/parallel/test-http-response-multiheaders.js

@ -56,7 +56,7 @@ server.listen(common.PORT, common.mustCall(function() {
// value should be reported for the header fields listed // value should be reported for the header fields listed
// in the norepeat array. // in the norepeat array.
http.get( http.get(
{port:common.PORT, headers:{'x-num': n}}, {port: common.PORT, headers: {'x-num': n}},
common.mustCall(function(res) { common.mustCall(function(res) {
if (++count === 2) server.close(); if (++count === 2) server.close();
for (const name of norepeat) { for (const name of norepeat) {

4
test/parallel/test-http-response-splitting.js

@ -29,12 +29,12 @@ const server = http.createServer((req, res) => {
break; break;
case 1: case 1:
assert.throws(common.mustCall(() => { assert.throws(common.mustCall(() => {
res.writeHead(200, {'foo' : x}); res.writeHead(200, {'foo': x});
})); }));
break; break;
case 2: case 2:
assert.throws(common.mustCall(() => { assert.throws(common.mustCall(() => {
res.writeHead(200, {'foo' : y}); res.writeHead(200, {'foo': y});
})); }));
break; break;
default: default:

2
test/parallel/test-http-server-multiheaders.js

@ -18,7 +18,7 @@ var srv = http.createServer(function(req, res) {
assert.equal(req.headers['sec-websocket-extensions'], 'foo; 1, bar; 2, baz'); assert.equal(req.headers['sec-websocket-extensions'], 'foo; 1, bar; 2, baz');
assert.equal(req.headers['constructor'], 'foo, bar, baz'); assert.equal(req.headers['constructor'], 'foo, bar, baz');
res.writeHead(200, {'Content-Type' : 'text/plain'}); res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('EOF'); res.end('EOF');
srv.close(); srv.close();

2
test/parallel/test-http-server-multiheaders2.js

@ -58,7 +58,7 @@ var srv = http.createServer(function(req, res) {
'foo, bar', 'header parsed incorrectly: ' + header); 'foo, bar', 'header parsed incorrectly: ' + header);
}); });
res.writeHead(200, {'Content-Type' : 'text/plain'}); res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('EOF'); res.end('EOF');
srv.close(); srv.close();

2
test/parallel/test-http-server-reject-cr-no-lf.js

@ -20,7 +20,7 @@ server.on('clientError', common.mustCall((err) => {
server.close(); server.close();
})); }));
server.listen(common.PORT, () => { server.listen(common.PORT, () => {
const client = net.connect({port:common.PORT}, () => { const client = net.connect({port: common.PORT}, () => {
client.on('data', (chunk) => { client.on('data', (chunk) => {
assert.fail(null, null, 'this should not be called'); assert.fail(null, null, 'this should not be called');
}); });

4
test/parallel/test-listen-fd-ebadf.js

@ -9,8 +9,8 @@ process.on('exit', function() {
assert.equal(gotError, 2); assert.equal(gotError, 2);
}); });
net.createServer(common.fail).listen({fd:2}).on('error', onError); net.createServer(common.fail).listen({fd: 2}).on('error', onError);
net.createServer(common.fail).listen({fd:42}).on('error', onError); net.createServer(common.fail).listen({fd: 42}).on('error', onError);
function onError(ex) { function onError(ex) {
assert.equal(ex.code, 'EINVAL'); assert.equal(ex.code, 'EINVAL');

2
test/parallel/test-net-listen-fd0.js

@ -10,7 +10,7 @@ process.on('exit', function() {
}); });
// this should fail with an async EINVAL error, not throw an exception // this should fail with an async EINVAL error, not throw an exception
net.createServer(common.fail).listen({fd:0}).on('error', function(e) { net.createServer(common.fail).listen({fd: 0}).on('error', function(e) {
switch (e.code) { switch (e.code) {
case 'EINVAL': case 'EINVAL':
case 'ENOTSOCK': case 'ENOTSOCK':

8
test/parallel/test-stream-transform-split-objectmode.js

@ -4,7 +4,7 @@ var assert = require('assert');
var Transform = require('stream').Transform; var Transform = require('stream').Transform;
var parser = new Transform({ readableObjectMode : true }); var parser = new Transform({ readableObjectMode: true });
assert(parser._readableState.objectMode); assert(parser._readableState.objectMode);
assert(!parser._writableState.objectMode); assert(!parser._writableState.objectMode);
@ -12,7 +12,7 @@ assert(parser._readableState.highWaterMark === 16);
assert(parser._writableState.highWaterMark === (16 * 1024)); assert(parser._writableState.highWaterMark === (16 * 1024));
parser._transform = function(chunk, enc, callback) { parser._transform = function(chunk, enc, callback) {
callback(null, { val : chunk[0] }); callback(null, { val: chunk[0] });
}; };
var parsed; var parsed;
@ -28,7 +28,7 @@ process.on('exit', function() {
}); });
var serializer = new Transform({ writableObjectMode : true }); var serializer = new Transform({ writableObjectMode: true });
assert(!serializer._readableState.objectMode); assert(!serializer._readableState.objectMode);
assert(serializer._writableState.objectMode); assert(serializer._writableState.objectMode);
@ -45,7 +45,7 @@ serializer.on('data', function(chunk) {
serialized = chunk; serialized = chunk;
}); });
serializer.write({ val : 42 }); serializer.write({ val: 42 });
process.on('exit', function() { process.on('exit', function() {
assert(serialized[0] === 42); assert(serialized[0] === 42);

2
test/parallel/test-stream2-transform.js

@ -267,7 +267,7 @@ test('assymetric transform (compress)', function(t) {
test('complex transform', function(t) { test('complex transform', function(t) {
var count = 0; var count = 0;
var saved = null; var saved = null;
var pt = new Transform({highWaterMark:3}); var pt = new Transform({highWaterMark: 3});
pt._transform = function(c, e, cb) { pt._transform = function(c, e, cb) {
if (count++ === 1) if (count++ === 1)
saved = c; saved = c;

2
test/parallel/test-tls-alert.js

@ -29,7 +29,7 @@ function loadPEM(n) {
var server = tls.Server({ var server = tls.Server({
secureProtocol: 'TLSv1_2_server_method', secureProtocol: 'TLSv1_2_server_method',
key: loadPEM('agent2-key'), key: loadPEM('agent2-key'),
cert:loadPEM('agent2-cert') cert: loadPEM('agent2-cert')
}, null).listen(common.PORT, function() { }, null).listen(common.PORT, function() {
var args = ['s_client', '-quiet', '-tls1_1', var args = ['s_client', '-quiet', '-tls1_1',
'-connect', '127.0.0.1:' + common.PORT]; '-connect', '127.0.0.1:' + common.PORT];

6
test/parallel/test-url.js

@ -822,7 +822,7 @@ var parseTests = {
query: '@c' query: '@c'
}, },
'http://a\r" \t\n<\'b:b@c\r\nd/e?f':{ 'http://a\r" \t\n<\'b:b@c\r\nd/e?f': {
protocol: 'http:', protocol: 'http:',
slashes: true, slashes: true,
auth: 'a\r" \t\n<\'b:b', auth: 'a\r" \t\n<\'b:b',
@ -1129,7 +1129,7 @@ var formatTests = {
// `#`,`?` in path // `#`,`?` in path
'/path/to/%%23%3F+=&.txt?foo=theA1#bar': { '/path/to/%%23%3F+=&.txt?foo=theA1#bar': {
href : '/path/to/%%23%3F+=&.txt?foo=theA1#bar', href: '/path/to/%%23%3F+=&.txt?foo=theA1#bar',
pathname: '/path/to/%#?+=&.txt', pathname: '/path/to/%#?+=&.txt',
query: { query: {
foo: 'theA1' foo: 'theA1'
@ -1139,7 +1139,7 @@ var formatTests = {
// `#`,`?` in path + `#` in query // `#`,`?` in path + `#` in query
'/path/to/%%23%3F+=&.txt?foo=the%231#bar': { '/path/to/%%23%3F+=&.txt?foo=the%231#bar': {
href : '/path/to/%%23%3F+=&.txt?foo=the%231#bar', href: '/path/to/%%23%3F+=&.txt?foo=the%231#bar',
pathname: '/path/to/%#?+=&.txt', pathname: '/path/to/%#?+=&.txt',
query: { query: {
foo: 'the#1' foo: 'the#1'

14
test/parallel/test-util.js

@ -76,10 +76,10 @@ assert.equal(false, util.isBuffer('foo'));
assert.equal(true, util.isBuffer(Buffer.from('foo'))); assert.equal(true, util.isBuffer(Buffer.from('foo')));
// _extend // _extend
assert.deepStrictEqual(util._extend({a:1}), {a:1}); assert.deepStrictEqual(util._extend({a: 1}), {a: 1});
assert.deepStrictEqual(util._extend({a:1}, []), {a:1}); assert.deepStrictEqual(util._extend({a: 1}, []), {a: 1});
assert.deepStrictEqual(util._extend({a:1}, null), {a:1}); assert.deepStrictEqual(util._extend({a: 1}, null), {a: 1});
assert.deepStrictEqual(util._extend({a:1}, true), {a:1}); assert.deepStrictEqual(util._extend({a: 1}, true), {a: 1});
assert.deepStrictEqual(util._extend({a:1}, false), {a:1}); assert.deepStrictEqual(util._extend({a: 1}, false), {a: 1});
assert.deepStrictEqual(util._extend({a:1}, {b:2}), {a:1, b:2}); assert.deepStrictEqual(util._extend({a: 1}, {b: 2}), {a: 1, b: 2});
assert.deepStrictEqual(util._extend({a:1, b:2}, {b:3}), {a:1, b:3}); assert.deepStrictEqual(util._extend({a: 1, b: 2}, {b: 3}), {a: 1, b: 3});

2
test/parallel/test-vm-context.js

@ -52,7 +52,7 @@ console.error('test RegExp as argument to assert.throws');
script = vm.createScript('var assert = require(\'assert\'); assert.throws(' + script = vm.createScript('var assert = require(\'assert\'); assert.throws(' +
'function() { throw "hello world"; }, /hello/);', 'function() { throw "hello world"; }, /hello/);',
'some.js'); 'some.js');
script.runInNewContext({ require : require }); script.runInNewContext({ require: require });
// Issue GH-7529 // Issue GH-7529
script = vm.createScript('delete b'); script = vm.createScript('delete b');

16
test/pummel/test-crypto-dh.js

@ -19,14 +19,14 @@ assert.throws(function() {
}); });
var hashes = { var hashes = {
modp1 : '630e9acd2cc63f7e80d8507624ba60ac0757201a', modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a',
modp2 : '18f7aa964484137f57bca64b21917a385b6a0b60', modp2: '18f7aa964484137f57bca64b21917a385b6a0b60',
modp5 : 'c0a8eec0c2c8a5ec2f9c26f9661eb339a010ec61', modp5: 'c0a8eec0c2c8a5ec2f9c26f9661eb339a010ec61',
modp14 : 'af5455606fe74cec49782bb374e4c63c9b1d132c', modp14: 'af5455606fe74cec49782bb374e4c63c9b1d132c',
modp15 : '7bdd39e5cdbb9748113933e5c2623b559c534e74', modp15: '7bdd39e5cdbb9748113933e5c2623b559c534e74',
modp16 : 'daea5277a7ad0116e734a8e0d2f297ef759d1161', modp16: 'daea5277a7ad0116e734a8e0d2f297ef759d1161',
modp17 : '3b62aaf0142c2720f0bf26a9589b0432c00eadc1', modp17: '3b62aaf0142c2720f0bf26a9589b0432c00eadc1',
modp18 : 'a870b491bbbec9b131ae9878d07449d32e54f160' modp18: 'a870b491bbbec9b131ae9878d07449d32e54f160'
}; };
for (const name in hashes) { for (const name in hashes) {

2
test/pummel/test-fs-watch-file-slow.js

@ -16,7 +16,7 @@ catch (e) {
// swallow // swallow
} }
fs.watchFile(FILENAME, {interval:TIMEOUT - 250}, function(curr, prev) { fs.watchFile(FILENAME, {interval: TIMEOUT - 250}, function(curr, prev) {
console.log([curr, prev]); console.log([curr, prev]);
switch (++nevents) { switch (++nevents) {
case 1: case 1:

2
test/sequential/test-fs-watch.js

@ -119,7 +119,7 @@ assert.throws(function() {
oldhandle.close(); // clean up oldhandle.close(); // clean up
assert.throws(function() { assert.throws(function() {
var w = fs.watchFile(__filename, {persistent:false}, function() {}); var w = fs.watchFile(__filename, {persistent: false}, function() {});
oldhandle = w._handle; oldhandle = w._handle;
w._handle = { stop: w._handle.stop }; w._handle = { stop: w._handle.stop };
w.stop(); w.stop();

4
tools/doc/html.js

@ -152,7 +152,7 @@ function parseLists(input) {
if (tok.type === 'list_start') { if (tok.type === 'list_start') {
state = 'LIST'; state = 'LIST';
if (depth === 0) { if (depth === 0) {
output.push({ type:'html', text: '<div class="signature">' }); output.push({ type: 'html', text: '<div class="signature">' });
} }
depth++; depth++;
output.push(tok); output.push(tok);
@ -176,7 +176,7 @@ function parseLists(input) {
output.push(tok); output.push(tok);
if (depth === 0) { if (depth === 0) {
state = null; state = null;
output.push({ type:'html', text: '</div>' }); output.push({ type: 'html', text: '</div>' });
} }
return; return;
} }

Loading…
Cancel
Save