Skip to content

Commit

Permalink
tools: add 'spaced-comment' into eslint rules
Browse files Browse the repository at this point in the history
PR-URL: #19596
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
starkwang committed Apr 1, 2018
1 parent f89f798 commit 2540581
Show file tree
Hide file tree
Showing 59 changed files with 169 additions and 193 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ module.exports = {
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': 'error',
'spaced-comment': ['error', 'always', {
'block': { 'balanced': true },
'exceptions': ['-']
}],
'strict': ['error', 'global'],
'symbol-description': 'error',
'template-curly-spacing': 'error',
Expand Down
2 changes: 1 addition & 1 deletion benchmark/buffers/buffer-swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const common = require('../common.js');

const bench = common.createBenchmark(main, {
aligned: ['true', 'false'],
method: ['swap16', 'swap32', 'swap64'/*, 'htons', 'htonl', 'htonll'*/],
method: ['swap16', 'swap32', 'swap64'/* , 'htons', 'htonl', 'htonll' */],
len: [8, 64, 128, 256, 512, 768, 1024, 1536, 2056, 4096, 8192],
n: [5e7]
});
Expand Down
2 changes: 1 addition & 1 deletion doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ assert.equal(1, '1');
assert.equal(1, 2);
// AssertionError: 1 == 2
assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
//AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
// AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
```

If the values are not equal, an `AssertionError` is thrown with a `message`
Expand Down
6 changes: 3 additions & 3 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ directly by the shell and special characters (vary based on
need to be dealt with accordingly:
```js
exec('"/path/to/test file/test.sh" arg1 arg2');
//Double quotes are used so that the space in the path is not interpreted as
//multiple arguments
// Double quotes are used so that the space in the path is not interpreted as
// multiple arguments

exec('echo "The \\$HOME variable is $HOME"');
//The $HOME variable is escaped in the first instance, but not in the second
// The $HOME variable is escaped in the first instance, but not in the second
```

**Never pass unsanitized user input to this function. Any input containing shell
Expand Down
12 changes: 6 additions & 6 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ settings do not take effect until the `'localSettings'` event is emitted.
session.settings({ enablePush: false });

session.on('localSettings', (settings) => {
/** use the new settings **/
/* Use the new settings */
});
```

Expand All @@ -218,7 +218,7 @@ of the remote settings.

```js
session.on('remoteSettings', (settings) => {
/** use the new settings **/
/* Use the new settings */
});
```

Expand Down Expand Up @@ -280,7 +280,7 @@ activity on the `Http2Session` after the configured number of milliseconds.

```js
session.setTimeout(2000);
session.on('timeout', () => { /** .. **/ });
session.on('timeout', () => { /* .. */ });
```

#### http2session.alpnProtocol
Expand Down Expand Up @@ -706,8 +706,8 @@ const {
const req = clientSession.request({ [HTTP2_HEADER_PATH]: '/' });
req.on('response', (headers) => {
console.log(headers[HTTP2_HEADER_STATUS]);
req.on('data', (chunk) => { /** .. **/ });
req.on('end', () => { /** .. **/ });
req.on('data', (chunk) => { /* .. */ });
req.on('end', () => { /* .. */ });
});
```

Expand Down Expand Up @@ -1928,7 +1928,7 @@ Returns a `ClientHttp2Session` instance.
const http2 = require('http2');
const client = http2.connect('https://localhost:1234');

/** use the client **/
/* Use the client */

client.close();
```
Expand Down
2 changes: 1 addition & 1 deletion doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ in the [`net.createServer()`][] section:
```js
const net = require('net');
const client = net.createConnection({ port: 8124 }, () => {
//'connect' listener
// 'connect' listener
console.log('connected to server!');
client.write('world!\r\n');
});
Expand Down
4 changes: 2 additions & 2 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ Agent.prototype.getName = function getName(options) {
return name;
};

Agent.prototype.addRequest = function addRequest(req, options, port/*legacy*/,
localAddress/*legacy*/) {
Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
localAddress/* legacy */) {
// Legacy API: addRequest(req, host, port, localAddress)
if (typeof options === 'string') {
options = {
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function ClientRequest(options, cb) {
var posColon = hostHeader.indexOf(':');
if (posColon !== -1 &&
hostHeader.indexOf(':', posColon + 1) !== -1 &&
hostHeader.charCodeAt(0) !== 91/*'['*/) {
hostHeader.charCodeAt(0) !== 91/* '[' */) {
hostHeader = `[${hostHeader}]`;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
* Verifies that the given val is a valid HTTP token
* per the rules defined in RFC 7230
* See https://tools.ietf.org/html/rfc7230#section-3.2.6
**/
*/
function checkIsHttpToken(val) {
return tokenRegExp.test(val);
}
Expand All @@ -248,7 +248,7 @@ const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
* field-value = *( field-content / obs-fold )
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
* field-vchar = VCHAR / obs-text
**/
*/
function checkInvalidHeaderChar(val) {
return headerCharRegex.test(val);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const doFlaggedDeprecation =
* runtime deprecation would introduce too much breakage at this time. It's not
* likely that the Buffer constructors would ever actually be removed.
* Deprecation Code: DEP0005
**/
*/
function Buffer(arg, encodingOrOffset, length) {
doFlaggedDeprecation();
// Common case.
Expand All @@ -196,7 +196,7 @@ Object.defineProperty(Buffer, Symbol.species, {
* Buffer.from(array)
* Buffer.from(buffer)
* Buffer.from(arrayBuffer[, byteOffset[, length]])
**/
*/
Buffer.from = function from(value, encodingOrOffset, length) {
if (typeof value === 'string')
return fromString(value, encodingOrOffset);
Expand Down Expand Up @@ -260,7 +260,7 @@ function assertSize(size) {
/**
* Creates a new filled Buffer instance.
* alloc(size[, fill[, encoding]])
**/
*/
Buffer.alloc = function alloc(size, fill, encoding) {
assertSize(size);
if (fill !== undefined && size > 0) {
Expand All @@ -272,7 +272,7 @@ Buffer.alloc = function alloc(size, fill, encoding) {
/**
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer
* instance. If `--zero-fill-buffers` is set, will zero-fill the buffer.
**/
*/
Buffer.allocUnsafe = function allocUnsafe(size) {
assertSize(size);
return allocate(size);
Expand All @@ -282,7 +282,7 @@ Buffer.allocUnsafe = function allocUnsafe(size) {
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled
* Buffer instance that is not allocated off the pre-initialized pool.
* If `--zero-fill-buffers` is set, will zero-fill the buffer.
**/
*/
Buffer.allocUnsafeSlow = function allocUnsafeSlow(size) {
assertSize(size);
return createUnsafeBuffer(size);
Expand Down
14 changes: 7 additions & 7 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function stdioStringToArray(option) {
}
}

exports.fork = function(modulePath /*, args, options*/) {
exports.fork = function(modulePath /* , args, options */) {

// Get options and args arguments.
var execArgv;
Expand Down Expand Up @@ -143,7 +143,7 @@ function normalizeExecArgs(command, options, callback) {
}


exports.exec = function(command /*, options, callback*/) {
exports.exec = function(command /* , options, callback */) {
var opts = normalizeExecArgs.apply(null, arguments);
return exports.execFile(opts.file,
opts.options,
Expand Down Expand Up @@ -172,7 +172,7 @@ Object.defineProperty(exports.exec, util.promisify.custom, {
value: customPromiseExecFunction(exports.exec)
});

exports.execFile = function(file /*, args, options, callback*/) {
exports.execFile = function(file /* , args, options, callback */) {
var args = [];
var callback;
var options = {
Expand Down Expand Up @@ -511,7 +511,7 @@ function normalizeSpawnArguments(file, args, options) {
}


var spawn = exports.spawn = function(/*file, args, options*/) {
var spawn = exports.spawn = function(/* file, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);
var options = opts.options;
var child = new ChildProcess();
Expand All @@ -534,7 +534,7 @@ var spawn = exports.spawn = function(/*file, args, options*/) {
return child;
};

function spawnSync(/*file, args, options*/) {
function spawnSync(/* file, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);

var options = opts.options;
Expand Down Expand Up @@ -602,7 +602,7 @@ function checkExecSyncError(ret, args, cmd) {
}


function execFileSync(/*command, args, options*/) {
function execFileSync(/* command, args, options */) {
var opts = normalizeSpawnArguments.apply(null, arguments);
var inheritStderr = !opts.options.stdio;

Expand All @@ -621,7 +621,7 @@ function execFileSync(/*command, args, options*/) {
exports.execFileSync = execFileSync;


function execSync(command /*, options*/) {
function execSync(command /* , options */) {
var opts = normalizeExecArgs.apply(null, arguments);
var inheritStderr = !opts.options.stdio;

Expand Down
2 changes: 1 addition & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function bufferSize(self, size, buffer) {
return ret;
}

Socket.prototype.bind = function(port_, address_ /*, callback*/) {
Socket.prototype.bind = function(port_, address_ /* , callback */) {
let port = port_;

this._healthCheck();
Expand Down
4 changes: 2 additions & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fs.Stats = Stats;
function isFileType(fileType) {
// Use stats array directly to avoid creating an fs.Stats instance just for
// our internal use.
return (statValues[1/*mode*/] & S_IFMT) === fileType;
return (statValues[1/* mode */] & S_IFMT) === fileType;
}

// Don't allow mode to accidentally be overwritten.
Expand Down Expand Up @@ -1442,7 +1442,7 @@ function StatWatcher() {
this._handle.onchange = function(newStatus) {
if (oldStatus === -1 &&
newStatus === -1 &&
statValues[2/*new nlink*/] === statValues[16/*old nlink*/]) return;
statValues[2/* new nlink */] === statValues[16/* old nlink */]) return;

oldStatus = newStatus;
self.emit('change', statsFromValues(), statsFromPrevValues());
Expand Down
4 changes: 2 additions & 2 deletions lib/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ async function readFileHandle(filehandle, options) {
const statFields = await binding.fstat(filehandle.fd, kUsePromises);

let size;
if ((statFields[1/*mode*/] & S_IFMT) === S_IFREG) {
size = statFields[8/*size*/];
if ((statFields[1/* mode */] & S_IFMT) === S_IFREG) {
size = statFields[8/* size */];
} else {
size = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ Module._extensions['.json'] = function(module, filename) {
};


//Native extension for .node
// Native extension for .node
Module._extensions['.node'] = function(module, filename) {
return process.dlopen(module, path.toNamespacedPath(filename));
};
Expand Down
12 changes: 7 additions & 5 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ function parseParams(qs) {
const code = qs.charCodeAt(i);

// Try matching key/value pair separator
if (code === 38/*&*/) {
if (code === 38/* & */) {
if (pairStart === i) {
// We saw an empty substring between pair separators
lastPos = pairStart = i + 1;
Expand All @@ -738,7 +738,7 @@ function parseParams(qs) {
}

// Try matching key/value separator (e.g. '=') if we haven't already
if (!seenSep && code === 61/*=*/) {
if (!seenSep && code === 61/* = */) {
// Key/value separator match!
if (lastPos < i)
buf += qs.slice(lastPos, i);
Expand All @@ -755,15 +755,15 @@ function parseParams(qs) {
}

// Handle + and percent decoding.
if (code === 43/*+*/) {
if (code === 43/* + */) {
if (lastPos < i)
buf += qs.slice(lastPos, i);
buf += ' ';
lastPos = i + 1;
} else if (!encoded) {
// Try to match an (valid) encoded byte (once) to minimize unnecessary
// calls to string decoding functions
if (code === 37/*%*/) {
if (code === 37/* % */) {
encodeCheck = 1;
} else if (encodeCheck > 0) {
// eslint-disable-next-line no-extra-boolean-cast
Expand Down Expand Up @@ -799,7 +799,9 @@ function parseParams(qs) {
// Adapted from querystring's implementation.
// Ref: https://url.spec.whatwg.org/#concept-urlencoded-byte-serializer
const noEscape = [
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
/*
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
*/
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 - 0x0F
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 - 0x1F
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, // 0x20 - 0x2F
Expand Down
12 changes: 6 additions & 6 deletions lib/querystring.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ function unescapeBuffer(s, decodeSpaces) {
var hasHex = false;
while (index < s.length) {
currentChar = s.charCodeAt(index);
if (currentChar === 43 /*'+'*/ && decodeSpaces) {
if (currentChar === 43 /* '+' */ && decodeSpaces) {
out[outIndex++] = 32; // ' '
index++;
continue;
}
if (currentChar === 37 /*'%'*/ && index < maxLength) {
if (currentChar === 37 /* '%' */ && index < maxLength) {
currentChar = s.charCodeAt(++index);
hexHigh = unhexTable[currentChar];
if (!(hexHigh >= 0)) {
Expand Down Expand Up @@ -365,7 +365,7 @@ function parse(qs, sep, eq, options) {
if (!keyEncoded) {
// Try to match an (valid) encoded byte once to minimize unnecessary
// calls to string decoding functions
if (code === 37/*%*/) {
if (code === 37/* % */) {
encodeCheck = 1;
continue;
} else if (encodeCheck > 0) {
Expand All @@ -380,23 +380,23 @@ function parse(qs, sep, eq, options) {
}
}
}
if (code === 43/*+*/) {
if (code === 43/* + */) {
if (lastPos < i)
key += qs.slice(lastPos, i);
key += plusChar;
lastPos = i + 1;
continue;
}
}
if (code === 43/*+*/) {
if (code === 43/* + */) {
if (lastPos < i)
value += qs.slice(lastPos, i);
value += plusChar;
lastPos = i + 1;
} else if (!valEncoded) {
// Try to match an (valid) encoded byte (once) to minimize unnecessary
// calls to string decoding functions
if (code === 37/*%*/) {
if (code === 37/* % */) {
encodeCheck = 1;
} else if (encodeCheck > 0) {
// eslint-disable-next-line no-extra-boolean-cast
Expand Down
Loading

0 comments on commit 2540581

Please sign in to comment.