Skip to content

v6.x backport: tools: update ESLint to current version #11757

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 6 additions & 2 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ rules:
computed-property-spacing: 2
eol-last: 2
func-call-spacing: 2
indent: [2, 2, {SwitchCase: 1, MemberExpression: 1}]
func-name-matching: 2
indent: [2, 2, {ArrayExpression: first,
CallExpression: {arguments: first},
MemberExpression: 1,
ObjectExpression: first,
SwitchCase: 1}]
key-spacing: [2, {mode: minimum}]
keyword-spacing: 2
linebreak-style: [2, unix]
Expand Down Expand Up @@ -119,7 +124,6 @@ rules:
template-curly-spacing: 2

# Custom rules in tools/eslint-rules
align-function-arguments: 2
align-multiline-assignment: 2
assert-fail-single-argument: 2
assert-throws-arguments: [2, { requireTwo: false }]
Expand Down
6 changes: 3 additions & 3 deletions benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function runBenchmarks() {
if (!test)
return;

if (test.match(/^[\._]/))
if (test.match(/^[._]/))
return process.nextTick(runBenchmarks);

if (outputFormat == 'default')
Expand Down Expand Up @@ -86,7 +86,7 @@ function Benchmark(fn, options) {
this.fn = fn;
this.options = options;
this.config = parseOpts(options);
this._name = require.main.filename.split(/benchmark[\/\\]/).pop();
this._name = require.main.filename.split(/benchmark[/\\]/).pop();
this._start = [0, 0];
this._started = false;

Expand All @@ -101,7 +101,7 @@ function Benchmark(fn, options) {
Benchmark.prototype.http = function(p, args, cb) {
hasWrk();
var self = this;
var regexp = /Requests\/sec:[ \t]+([0-9\.]+)/;
var regexp = /Requests\/sec:[ \t]+([0-9.]+)/;
var url = 'http://127.0.0.1:' + exports.PORT + p;

args = args.concat(url);
Expand Down
2 changes: 1 addition & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ try {
printDeprecation('fs: re-evaluating native module sources is not ' +
'supported. If you are using the graceful-fs module, ' +
'please update it to a more recent version.',
false);
false);
}

function throwOptionsError(options) {
Expand Down
10 changes: 6 additions & 4 deletions lib/internal/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ function stripBOM(content) {
return content;
}

exports.builtinLibs = ['assert', 'buffer', 'child_process', 'cluster',
'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'net',
'os', 'path', 'punycode', 'querystring', 'readline', 'repl', 'stream',
'string_decoder', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib'];
exports.builtinLibs = [
'assert', 'buffer', 'child_process', 'cluster', 'crypto', 'dgram', 'dns',
'domain', 'events', 'fs', 'http', 'https', 'net', 'os', 'path', 'punycode',
'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'tls', 'tty',
'url', 'util', 'v8', 'vm', 'zlib'
];

function addBuiltinLibsToObject(object) {
// Make built-in modules available directly (loaded lazily).
Expand Down
1 change: 1 addition & 0 deletions lib/internal/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function setupConfig(_source) {
Intl.hasOwnProperty('v8BreakIterator') &&
!process.icu_data_dir) {
const des = Object.getOwnPropertyDescriptor(Intl, 'v8BreakIterator');
// eslint-disable-next-line func-name-matching
des.value = function v8BreakIterator() {
throw new Error('v8BreakIterator: full ICU data not installed. ' +
'See https://github.com/nodejs/node/wiki/Intl');
Expand Down
17 changes: 10 additions & 7 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,17 +1102,20 @@ function codePointAt(str, index) {
}
return code;
}
exports.codePointAt = internalUtil.deprecate(codePointAt,
'readline.codePointAt is deprecated. ' +
'Use String.prototype.codePointAt instead.');
exports.codePointAt = internalUtil.deprecate(
codePointAt,
'readline.codePointAt is deprecated. ' +
'Use String.prototype.codePointAt instead.');


exports.getStringWidth = internalUtil.deprecate(getStringWidth,
'getStringWidth is deprecated and will be removed.');
exports.getStringWidth = internalUtil.deprecate(
getStringWidth,
'getStringWidth is deprecated and will be removed.');


exports.isFullWidthCodePoint = internalUtil.deprecate(isFullWidthCodePoint,
'isFullWidthCodePoint is deprecated and will be removed.');
exports.isFullWidthCodePoint = internalUtil.deprecate(
isFullWidthCodePoint,
'isFullWidthCodePoint is deprecated and will be removed.');


exports.stripVTControlCharacters = internalUtil.deprecate(
Expand Down
27 changes: 14 additions & 13 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ const debug = util.debuglog('repl');
const parentModule = module;
const replMap = new WeakMap();

const GLOBAL_OBJECT_PROPERTIES = ['NaN', 'Infinity', 'undefined',
'eval', 'parseInt', 'parseFloat', 'isNaN', 'isFinite', 'decodeURI',
'decodeURIComponent', 'encodeURI', 'encodeURIComponent',
'Object', 'Function', 'Array', 'String', 'Boolean', 'Number',
'Date', 'RegExp', 'Error', 'EvalError', 'RangeError',
'ReferenceError', 'SyntaxError', 'TypeError', 'URIError',
'Math', 'JSON'];
const GLOBAL_OBJECT_PROPERTIES = [
'NaN', 'Infinity', 'undefined', 'eval', 'parseInt', 'parseFloat', 'isNaN',
'isFinite', 'decodeURI', 'decodeURIComponent', 'encodeURI',
'encodeURIComponent', 'Object', 'Function', 'Array', 'String', 'Boolean',
'Number', 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError',
'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'Math', 'JSON'
];
const GLOBAL_OBJECT_PROPERTY_MAP = {};
GLOBAL_OBJECT_PROPERTIES.forEach((p) => GLOBAL_OBJECT_PROPERTY_MAP[p] = p);

Expand Down Expand Up @@ -1215,12 +1215,13 @@ function addStandardGlobals(completionGroups, filter) {
// Common keywords. Exclude for completion on the empty string, b/c
// they just get in the way.
if (filter) {
completionGroups.push(['break', 'case', 'catch', 'const',
'continue', 'debugger', 'default', 'delete', 'do', 'else',
'export', 'false', 'finally', 'for', 'function', 'if',
'import', 'in', 'instanceof', 'let', 'new', 'null', 'return',
'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined',
'var', 'void', 'while', 'with', 'yield']);
completionGroups.push([
'break', 'case', 'catch', 'const', 'continue', 'debugger', 'default',
'delete', 'do', 'else', 'export', 'false', 'finally', 'for', 'function',
'if', 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return',
'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined', 'var',
'void', 'while', 'with', 'yield'
]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const portPattern = /:[0-9]*$/;
const hostPattern = /^\/\/[^@/]+@[^@/]+/;

// Special case for a simple path URL
const simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/;
const simplePathPattern = /^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/;

const hostnameMaxLen = 255;
// protocols that can allow "unsafe" and "unwise" chars.
Expand Down
6 changes: 3 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ function formatValue(ctx, value, recurseTimes) {
if (keys.length === 0) {
if (typeof value === 'function') {
return ctx.stylize(`[Function${value.name ? `: ${value.name}` : ''}]`,
'special');
'special');
}
if (isRegExp(value)) {
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
Expand Down Expand Up @@ -659,7 +659,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
for (var i = 0; i < maxLength; ++i) {
if (hasOwnProperty(value, String(i))) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
String(i), true));
String(i), true));
} else {
output.push('');
}
Expand All @@ -670,7 +670,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
keys.forEach(function(key) {
if (typeof key === 'symbol' || !key.match(/^\d+$/)) {
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
key, true));
key, true));
}
});
return output;
Expand Down
8 changes: 4 additions & 4 deletions test/inspector/test-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ function testSetBreakpointAndResume(session) {
const commands = [
{ 'method': 'Debugger.setBreakpointByUrl',
'params': { 'lineNumber': 5,
'url': session.mainScriptPath,
'columnNumber': 0,
'condition': ''
}
'url': session.mainScriptPath,
'columnNumber': 0,
'condition': ''
}
},
{ 'method': 'Debugger.resume'},
[ { 'method': 'Debugger.getScriptSource',
Expand Down
92 changes: 47 additions & 45 deletions test/internet/test-dns-ipv4.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,61 +36,61 @@ function checkWrap(req) {

TEST(function test_resolve4(done) {
const req = dns.resolve4('www.google.com',
common.mustCall((err, ips) => {
assert.ifError(err);
common.mustCall((err, ips) => {
assert.ifError(err);

assert.ok(ips.length > 0);
assert.ok(ips.length > 0);

for (let i = 0; i < ips.length; i++) {
assert.ok(isIPv4(ips[i]));
}
for (let i = 0; i < ips.length; i++) {
assert.ok(isIPv4(ips[i]));
}

done();
}));
done();
}));

checkWrap(req);
});

TEST(function test_reverse_ipv4(done) {
const req = dns.reverse('8.8.8.8',
common.mustCall((err, domains) => {
assert.ifError(err);
common.mustCall((err, domains) => {
assert.ifError(err);

assert.ok(domains.length > 0);
assert.ok(domains.length > 0);

for (let i = 0; i < domains.length; i++) {
assert.ok(domains[i]);
assert.ok(typeof domains[i] === 'string');
}
for (let i = 0; i < domains.length; i++) {
assert.ok(domains[i]);
assert.ok(typeof domains[i] === 'string');
}

done();
}));
done();
}));

checkWrap(req);
});

TEST(function test_lookup_ipv4_explicit(done) {
const req = dns.lookup('www.google.com', 4,
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(net.isIPv4(ip));
assert.strictEqual(family, 4);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(net.isIPv4(ip));
assert.strictEqual(family, 4);

done();
}));
done();
}));

checkWrap(req);
});

TEST(function test_lookup_ipv4_implicit(done) {
const req = dns.lookup('www.google.com',
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(net.isIPv4(ip));
assert.strictEqual(family, 4);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.ok(net.isIPv4(ip));
assert.strictEqual(family, 4);

done();
}));
done();
}));

checkWrap(req);
});
Expand Down Expand Up @@ -125,26 +125,26 @@ TEST(function test_lookup_ipv4_hint_addrconfig(done) {

TEST(function test_lookup_ip_ipv4(done) {
const req = dns.lookup('127.0.0.1',
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.strictEqual(ip, '127.0.0.1');
assert.strictEqual(family, 4);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.strictEqual(ip, '127.0.0.1');
assert.strictEqual(family, 4);

done();
}));
done();
}));

checkWrap(req);
});

TEST(function test_lookup_localhost_ipv4(done) {
const req = dns.lookup('localhost', 4,
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.strictEqual(ip, '127.0.0.1');
assert.strictEqual(family, 4);
common.mustCall((err, ip, family) => {
assert.ifError(err);
assert.strictEqual(ip, '127.0.0.1');
assert.strictEqual(family, 4);

done();
}));
done();
}));

checkWrap(req);
});
Expand All @@ -164,21 +164,23 @@ TEST(function test_lookup_all_ipv4(done) {
});

done();
}
));
})
);

checkWrap(req);
});

TEST(function test_lookupservice_ip_ipv4(done) {
const req = dns.lookupService('127.0.0.1', 80,
const req = dns.lookupService(
'127.0.0.1', 80,
common.mustCall((err, host, service) => {
assert.ifError(err);
assert.strictEqual(typeof host, 'string');
assert(host);
assert(['http', 'www', '80'].includes(service));
done();
}));
})
);

checkWrap(req);
});
Loading