tools: enable block-scoped-var eslint rule
PR-URL: https://github.com/nodejs/node/pull/27616 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
99b196d4ba
commit
55b80f9029
@ -59,6 +59,7 @@ module.exports = {
|
|||||||
'array-callback-return': 'error',
|
'array-callback-return': 'error',
|
||||||
'arrow-parens': ['error', 'always'],
|
'arrow-parens': ['error', 'always'],
|
||||||
'arrow-spacing': ['error', { before: true, after: true }],
|
'arrow-spacing': ['error', { before: true, after: true }],
|
||||||
|
'block-scoped-var': 'error',
|
||||||
'block-spacing': 'error',
|
'block-spacing': 'error',
|
||||||
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
||||||
'capitalized-comments': ['error', 'always', {
|
'capitalized-comments': ['error', 'always', {
|
||||||
|
@ -10,8 +10,9 @@ const storedUnicode = Object.create(null);
|
|||||||
const useDomains = process.env.NODE_USE_DOMAINS;
|
const useDomains = process.env.NODE_USE_DOMAINS;
|
||||||
|
|
||||||
// Set up one global domain.
|
// Set up one global domain.
|
||||||
|
let domain;
|
||||||
if (useDomains) {
|
if (useDomains) {
|
||||||
var domain = require('domain');
|
domain = require('domain');
|
||||||
const gdom = domain.create();
|
const gdom = domain.create();
|
||||||
gdom.on('error', (er) => {
|
gdom.on('error', (er) => {
|
||||||
console.error('Error on global domain', er);
|
console.error('Error on global domain', er);
|
||||||
|
@ -16,7 +16,7 @@ function main({ len, n }) {
|
|||||||
const headers = [];
|
const headers = [];
|
||||||
// Chose 7 because 9 showed "Connection error" / "Connection closed"
|
// Chose 7 because 9 showed "Connection error" / "Connection closed"
|
||||||
// An odd number could result in a better length dispersion.
|
// An odd number could result in a better length dispersion.
|
||||||
for (var i = 7; i <= 7 * 7 * 7; i *= 7)
|
for (let i = 7; i <= 7 * 7 * 7; i *= 7)
|
||||||
headers.push('o'.repeat(i));
|
headers.push('o'.repeat(i));
|
||||||
|
|
||||||
function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) {
|
function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) {
|
||||||
@ -31,7 +31,7 @@ function main({ len, n }) {
|
|||||||
'Chrome/39.0.2171.71 Safari/537.36');
|
'Chrome/39.0.2171.71 Safari/537.36');
|
||||||
todo.push('Accept-Encoding: gzip, deflate, sdch');
|
todo.push('Accept-Encoding: gzip, deflate, sdch');
|
||||||
todo.push('Accept-Language: en-US,en;q=0.8');
|
todo.push('Accept-Language: en-US,en;q=0.8');
|
||||||
for (var i = 0; i < extra_header_count; i++) {
|
for (let i = 0; i < extra_header_count; i++) {
|
||||||
// Utilize first three powers of a small integer for an odd cycle and
|
// Utilize first three powers of a small integer for an odd cycle and
|
||||||
// because the fourth power of some integers overloads the server.
|
// because the fourth power of some integers overloads the server.
|
||||||
todo.push(`X-Header-${i}: ${headers[i % 3]}`);
|
todo.push(`X-Header-${i}: ${headers[i % 3]}`);
|
||||||
@ -41,7 +41,7 @@ function main({ len, n }) {
|
|||||||
todo = todo.join('\r\n');
|
todo = todo.join('\r\n');
|
||||||
// Using odd numbers in many places may increase length coverage.
|
// Using odd numbers in many places may increase length coverage.
|
||||||
const chunksize = 37;
|
const chunksize = 37;
|
||||||
for (i = 0; i < todo.length; i += chunksize) {
|
for (let i = 0; i < todo.length; i += chunksize) {
|
||||||
const cur = todo.slice(i, i + chunksize);
|
const cur = todo.slice(i, i + chunksize);
|
||||||
channel.write(cur);
|
channel.write(cur);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,9 @@ const common = require('../common.js');
|
|||||||
const PORT = common.PORT;
|
const PORT = common.PORT;
|
||||||
|
|
||||||
const cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
|
let bench;
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
var bench = common.createBenchmark(main, {
|
bench = common.createBenchmark(main, {
|
||||||
// Unicode confuses ab on os x.
|
// Unicode confuses ab on os x.
|
||||||
type: ['bytes', 'buffer'],
|
type: ['bytes', 'buffer'],
|
||||||
len: [4, 1024, 102400],
|
len: [4, 1024, 102400],
|
||||||
|
@ -11,8 +11,9 @@ const common = require('../../common.js');
|
|||||||
// which is quite common for benchmarks. so in that case, just
|
// which is quite common for benchmarks. so in that case, just
|
||||||
// abort quietly.
|
// abort quietly.
|
||||||
|
|
||||||
|
let binding;
|
||||||
try {
|
try {
|
||||||
var binding = require(`./build/${common.buildType}/binding`);
|
binding = require(`./build/${common.buildType}/binding`);
|
||||||
} catch {
|
} catch {
|
||||||
console.error('misc/function_call.js Binding failed to load');
|
console.error('misc/function_call.js Binding failed to load');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
@ -10,9 +10,9 @@ function main({ n, type }) {
|
|||||||
const PriorityQueue = require('internal/priority_queue');
|
const PriorityQueue = require('internal/priority_queue');
|
||||||
const queue = new PriorityQueue();
|
const queue = new PriorityQueue();
|
||||||
bench.start();
|
bench.start();
|
||||||
for (var i = 0; i < n; i++)
|
for (let i = 0; i < n; i++)
|
||||||
queue.insert(Math.random() * 1e7 | 0);
|
queue.insert(Math.random() * 1e7 | 0);
|
||||||
for (i = 0; i < n; i++)
|
for (let i = 0; i < n; i++)
|
||||||
queue.shift();
|
queue.shift();
|
||||||
bench.end(n);
|
bench.end(n);
|
||||||
}
|
}
|
||||||
|
@ -91,8 +91,9 @@ function Socket(type, listener) {
|
|||||||
let recvBufferSize;
|
let recvBufferSize;
|
||||||
let sendBufferSize;
|
let sendBufferSize;
|
||||||
|
|
||||||
|
let options;
|
||||||
if (type !== null && typeof type === 'object') {
|
if (type !== null && typeof type === 'object') {
|
||||||
var options = type;
|
options = type;
|
||||||
type = options.type;
|
type = options.type;
|
||||||
lookup = options.lookup;
|
lookup = options.lookup;
|
||||||
recvBufferSize = options.recvBufferSize;
|
recvBufferSize = options.recvBufferSize;
|
||||||
|
@ -693,6 +693,8 @@ function setupChannel(target, channel) {
|
|||||||
options = { swallowErrors: options };
|
options = { swallowErrors: options };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let obj;
|
||||||
|
|
||||||
// Package messages with a handle object
|
// Package messages with a handle object
|
||||||
if (handle) {
|
if (handle) {
|
||||||
// This message will be handled by an internalMessage event handler
|
// This message will be handled by an internalMessage event handler
|
||||||
@ -727,7 +729,7 @@ function setupChannel(target, channel) {
|
|||||||
return this._handleQueue.length === 1;
|
return this._handleQueue.length === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var obj = handleConversion[message.type];
|
obj = handleConversion[message.type];
|
||||||
|
|
||||||
// convert TCP object to native handle object
|
// convert TCP object to native handle object
|
||||||
handle = handleConversion[message.type].send.call(target,
|
handle = handleConversion[message.type].send.call(target,
|
||||||
|
@ -316,12 +316,13 @@ promisify.custom = kCustomPromisifiedSymbol;
|
|||||||
function join(output, separator) {
|
function join(output, separator) {
|
||||||
let str = '';
|
let str = '';
|
||||||
if (output.length !== 0) {
|
if (output.length !== 0) {
|
||||||
for (var i = 0; i < output.length - 1; i++) {
|
const lastIndex = output.length - 1;
|
||||||
|
for (let i = 0; i < lastIndex; i++) {
|
||||||
// It is faster not to use a template string here
|
// It is faster not to use a template string here
|
||||||
str += output[i];
|
str += output[i];
|
||||||
str += separator;
|
str += separator;
|
||||||
}
|
}
|
||||||
str += output[i];
|
str += output[lastIndex];
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,8 @@ function strEscape(str) {
|
|||||||
|
|
||||||
let result = '';
|
let result = '';
|
||||||
let last = 0;
|
let last = 0;
|
||||||
for (var i = 0; i < str.length; i++) {
|
const lastIndex = str.length;
|
||||||
|
for (let i = 0; i < lastIndex; i++) {
|
||||||
const point = str.charCodeAt(i);
|
const point = str.charCodeAt(i);
|
||||||
if (point === singleQuote || point === 92 || point < 32) {
|
if (point === singleQuote || point === 92 || point < 32) {
|
||||||
if (last === i) {
|
if (last === i) {
|
||||||
@ -324,7 +325,7 @@ function strEscape(str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last !== i) {
|
if (last !== lastIndex) {
|
||||||
result += str.slice(last);
|
result += str.slice(last);
|
||||||
}
|
}
|
||||||
return addQuotes(result, singleQuote);
|
return addQuotes(result, singleQuote);
|
||||||
@ -1061,10 +1062,11 @@ function formatPrimitive(fn, value, ctx) {
|
|||||||
if (matches.length > 1) {
|
if (matches.length > 1) {
|
||||||
const indent = ' '.repeat(ctx.indentationLvl);
|
const indent = ' '.repeat(ctx.indentationLvl);
|
||||||
let res = `${fn(strEscape(matches[0]), 'string')} +\n`;
|
let res = `${fn(strEscape(matches[0]), 'string')} +\n`;
|
||||||
for (var i = 1; i < matches.length - 1; i++) {
|
const lastIndex = matches.length - 1;
|
||||||
|
for (let i = 1; i < lastIndex; i++) {
|
||||||
res += `${indent} ${fn(strEscape(matches[i]), 'string')} +\n`;
|
res += `${indent} ${fn(strEscape(matches[i]), 'string')} +\n`;
|
||||||
}
|
}
|
||||||
res += `${indent} ${fn(strEscape(matches[i]), 'string')}`;
|
res += `${indent} ${fn(strEscape(matches[lastIndex]), 'string')}`;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1187,10 +1189,10 @@ function formatTypedArray(ctx, value, recurseTimes) {
|
|||||||
const elementFormatter = value.length > 0 && typeof value[0] === 'number' ?
|
const elementFormatter = value.length > 0 && typeof value[0] === 'number' ?
|
||||||
formatNumber :
|
formatNumber :
|
||||||
formatBigInt;
|
formatBigInt;
|
||||||
for (var i = 0; i < maxLength; ++i)
|
for (let i = 0; i < maxLength; ++i)
|
||||||
output[i] = elementFormatter(ctx.stylize, value[i]);
|
output[i] = elementFormatter(ctx.stylize, value[i]);
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
output[i] = `... ${remaining} more item${remaining > 1 ? 's' : ''}`;
|
output[maxLength] = `... ${remaining} more item${remaining > 1 ? 's' : ''}`;
|
||||||
}
|
}
|
||||||
if (ctx.showHidden) {
|
if (ctx.showHidden) {
|
||||||
// .buffer goes last, it's not a primitive like the others.
|
// .buffer goes last, it's not a primitive like the others.
|
||||||
|
@ -267,9 +267,10 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
|
|||||||
// user@server is *always* interpreted as a hostname, and url
|
// user@server is *always* interpreted as a hostname, and url
|
||||||
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
||||||
// how the browser resolves relative URLs.
|
// how the browser resolves relative URLs.
|
||||||
|
let slashes;
|
||||||
if (slashesDenoteHost || proto || hostPattern.test(rest)) {
|
if (slashesDenoteHost || proto || hostPattern.test(rest)) {
|
||||||
var slashes = rest.charCodeAt(0) === CHAR_FORWARD_SLASH &&
|
slashes = rest.charCodeAt(0) === CHAR_FORWARD_SLASH &&
|
||||||
rest.charCodeAt(1) === CHAR_FORWARD_SLASH;
|
rest.charCodeAt(1) === CHAR_FORWARD_SLASH;
|
||||||
if (slashes && !(proto && hostlessProtocol.has(lowerProto))) {
|
if (slashes && !(proto && hostlessProtocol.has(lowerProto))) {
|
||||||
rest = rest.slice(2);
|
rest = rest.slice(2);
|
||||||
this.slashes = true;
|
this.slashes = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user