From 94abcbde8b94fe050aa72aca27ceedcd45b507ce Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Jan 2022 07:45:35 -0800 Subject: [PATCH 1/6] tools: enable ESLint no-loss-of-precision rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Geoffrey Booth --- .eslintrc.js | 1 + test/js-native-api/test_number/test.js | 2 ++ test/parallel/test-buffer-readdouble.js | 1 + test/parallel/test-util-format.js | 1 + test/parallel/test-util-inspect.js | 1 + 5 files changed, 6 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 5f1d0894373cae..0fd0a15eb393dc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -201,6 +201,7 @@ module.exports = { 'no-invalid-regexp': 'error', 'no-irregular-whitespace': 'error', 'no-lonely-if': 'error', + 'no-loss-of-precision': 'error', 'no-misleading-character-class': 'error', 'no-mixed-requires': 'error', 'no-mixed-spaces-and-tabs': 'error', diff --git a/test/js-native-api/test_number/test.js b/test/js-native-api/test_number/test.js index 8ab8ad5e8be7f3..33d2699bc563c1 100644 --- a/test/js-native-api/test_number/test.js +++ b/test/js-native-api/test_number/test.js @@ -19,10 +19,12 @@ testNumber(-1233); testNumber(986583); testNumber(-976675); +/* eslint-disable no-loss-of-precision */ testNumber( 98765432213456789876546896323445679887645323232436587988766545658); testNumber( -4350987086545760976737453646576078997096876957864353245245769809); +/* eslint-enable no-loss-of-precision */ testNumber(Number.MIN_SAFE_INTEGER); testNumber(Number.MAX_SAFE_INTEGER); testNumber(Number.MAX_SAFE_INTEGER + 10); diff --git a/test/parallel/test-buffer-readdouble.js b/test/parallel/test-buffer-readdouble.js index 4a86ebe4ce382f..504df8bd3923fb 100644 --- a/test/parallel/test-buffer-readdouble.js +++ b/test/parallel/test-buffer-readdouble.js @@ -35,6 +35,7 @@ assert.strictEqual(buffer.readDoubleLE(0), 1.0000000000000004); buffer[0] = 1; buffer[6] = 0; buffer[7] = 0; +// eslint-disable-next-line no-loss-of-precision assert.strictEqual(buffer.readDoubleBE(0), 7.291122019556398e-304); assert.strictEqual(buffer.readDoubleLE(0), 5e-324); diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js index 121510acc691e3..36c98bcb9790b5 100644 --- a/test/parallel/test-util-format.js +++ b/test/parallel/test-util-format.js @@ -85,6 +85,7 @@ assert.strictEqual( assert.strictEqual( util.format( + // eslint-disable-next-line no-loss-of-precision '%d %s %i', 118059162071741130342, 118059162071741130342, 123_123_123), '118_059_162_071_741_140_000 118_059_162_071_741_140_000 123_123_123' ); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 34cc5cc56af48b..26b21c4a8854fe 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -3187,6 +3187,7 @@ assert.strictEqual( util.inspect.defaultOptions.numericSeparator = true; assert.strictEqual( + // eslint-disable-next-line no-loss-of-precision util.inspect(1234567891234567891234), '1.234567891234568e+21' ); From 9bfe60fc20cd7d4a53b5480532a77153fd165987 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Jan 2022 07:57:37 -0800 Subject: [PATCH 2/6] tools: enable ESLint no-sparse-arrays rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Geoffrey Booth --- .eslintrc.js | 1 + lib/internal/modules/esm/get_format.js | 2 +- test/parallel/test-assert-deep.js | 2 ++ test/parallel/test-util-inspect.js | 3 ++- test/parallel/test-util-isDeepStrictEqual.js | 2 ++ 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0fd0a15eb393dc..76941cd1a6a773 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -275,6 +275,7 @@ module.exports = { 'no-self-compare': 'error', 'no-setter-return': 'error', 'no-shadow-restricted-names': 'error', + 'no-sparse-arrays': 'error', 'no-tabs': 'error', 'no-template-curly-in-string': 'error', 'no-this-before-super': 'error', diff --git a/lib/internal/modules/esm/get_format.js b/lib/internal/modules/esm/get_format.js index 175988b17446d8..9712890139596d 100644 --- a/lib/internal/modules/esm/get_format.js +++ b/lib/internal/modules/esm/get_format.js @@ -45,7 +45,7 @@ const protocolHandlers = ObjectAssign(ObjectCreate(null), { const { 1: mime } = RegExpPrototypeExec( /^([^/]+\/[^;,]+)(?:[^,]*?)(;base64)?,/, parsed.pathname, - ) || [, null]; + ) || [, null]; // eslint-disable-line no-sparse-arrays const format = ({ '__proto__': null, 'text/javascript': 'module', diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 22e01afff15211..e6b7c010c289aa 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -567,8 +567,10 @@ assertNotDeepOrStrict( // Handle sparse arrays. { + /* eslint-disable no-sparse-arrays */ assertDeepAndStrictEqual([1, , , 3], [1, , , 3]); assertNotDeepOrStrict([1, , , 3], [1, , , 3, , , ]); + /* eslint-enable no-sparse-arrays */ const a = new Array(3); const b = new Array(3); a[2] = true; diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 26b21c4a8854fe..029b7cde8a06f8 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -434,7 +434,7 @@ assert.strictEqual( // Array with extra properties. { - const arr = [1, 2, 3, , ]; + const arr = [1, 2, 3, , ]; // eslint-disable-line no-sparse-arrays arr.foo = 'bar'; assert.strictEqual(util.inspect(arr), "[ 1, 2, 3, <1 empty item>, foo: 'bar' ]"); @@ -2142,6 +2142,7 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'"); [function() {}, '[Function (anonymous)]'], [() => {}, '[Function (anonymous)]'], [[1, 2], '[ 1, 2 ]'], + // eslint-disable-next-line no-sparse-arrays [[, , 5, , , , ], '[ <2 empty items>, 5, <3 empty items> ]'], [{ a: 5 }, '{ a: 5 }'], [new Set([1, 2]), 'Set(2) { 1, 2 }'], diff --git a/test/parallel/test-util-isDeepStrictEqual.js b/test/parallel/test-util-isDeepStrictEqual.js index 1ad64c2ff81a57..da266fc84ce0bb 100644 --- a/test/parallel/test-util-isDeepStrictEqual.js +++ b/test/parallel/test-util-isDeepStrictEqual.js @@ -409,8 +409,10 @@ notUtilIsDeepStrict( } // Handle sparse arrays +/* eslint-disable no-sparse-arrays */ utilIsDeepStrict([1, , , 3], [1, , , 3]); notUtilIsDeepStrict([1, , , 3], [1, , , 3, , , ]); +/* eslint-enable no-sparse-arrays */ // Handle different error messages { From 592f1845faaafb35a378aad15718da5cd73321a1 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Jan 2022 08:23:28 -0800 Subject: [PATCH 3/6] tools: enable ESLint require-yield rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Geoffrey Booth --- .eslintrc.js | 1 + test/parallel/test-readable-from.js | 2 +- test/parallel/test-stream-compose.js | 2 +- test/parallel/test-stream-duplex-from.js | 2 +- test/parallel/test-stream-pipeline.js | 33 +++++++++---------- ...er-message-port-terminate-transfer-list.js | 1 + 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 76941cd1a6a773..3231e3dff3f37a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -320,6 +320,7 @@ module.exports = { 'quotes': ['error', 'single', { avoidEscape: true }], 'quote-props': ['error', 'consistent'], 'rest-spread-spacing': 'error', + 'require-yield': 'error', 'semi': 'error', 'semi-spacing': 'error', 'space-before-blocks': ['error', 'always'], diff --git a/test/parallel/test-readable-from.js b/test/parallel/test-readable-from.js index 24dee0dce20050..b844574dc9e347 100644 --- a/test/parallel/test-readable-from.js +++ b/test/parallel/test-readable-from.js @@ -126,7 +126,7 @@ async function toReadableOnDataNonObject() { } async function destroysTheStreamWhenThrowing() { - async function* generate() { + async function* generate() { // eslint-disable-line require-yield throw new Error('kaboom'); } diff --git a/test/parallel/test-stream-compose.js b/test/parallel/test-stream-compose.js index c3d52e08e0048e..3b336a8c1c73b3 100644 --- a/test/parallel/test-stream-compose.js +++ b/test/parallel/test-stream-compose.js @@ -234,7 +234,7 @@ const assert = require('assert'); callback(null, chunk); }) }), - async function*(source) { + async function*(source) { // eslint-disable-line require-yield let tmp = ''; for await (const chunk of source) { tmp += chunk; diff --git a/test/parallel/test-stream-duplex-from.js b/test/parallel/test-stream-duplex-from.js index 446768d6eef3e3..6c9c59a5c82d52 100644 --- a/test/parallel/test-stream-duplex-from.js +++ b/test/parallel/test-stream-duplex-from.js @@ -134,7 +134,7 @@ const { Duplex, Readable, Writable, pipeline } = require('stream'); } yield rest; }), - async function * (source) { + async function * (source) { // eslint-disable-line require-yield let ret = ''; for await (const x of source) { ret += x; diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index bf1cb84ecda341..192f971b29daca 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -699,8 +699,8 @@ const tsp = require('timers/promises'); const ret = pipeline(async function*() { await Promise.resolve(); yield 'hello'; - }, async function*(source) { - for await (const chunk of source) {} + }, async function*(source) { // eslint-disable-line require-yield + for await (const chunk of source) {} // eslint-disable-line no-unused-vars }, common.mustCall((err) => { assert.strictEqual(err, undefined); })); @@ -712,11 +712,11 @@ const tsp = require('timers/promises'); // AsyncFunction destination is not returned and error is // propagated. - const ret = pipeline(async function*() { + const ret = pipeline(async function*() { // eslint-disable-line require-yield await Promise.resolve(); throw new Error('kaboom'); - }, async function*(source) { - for await (const chunk of source) {} + }, async function*(source) { // eslint-disable-line require-yield + for await (const chunk of source) {} // eslint-disable-line no-unused-vars }, common.mustCall((err) => { assert.strictEqual(err.message, 'kaboom'); })); @@ -726,7 +726,7 @@ const tsp = require('timers/promises'); { const s = new PassThrough(); - pipeline(async function*() { + pipeline(async function*() { // eslint-disable-line require-yield throw new Error('kaboom'); }, s, common.mustCall((err) => { assert.strictEqual(err.message, 'kaboom'); @@ -736,7 +736,7 @@ const tsp = require('timers/promises'); { const s = new PassThrough(); - pipeline(async function*() { + pipeline(async function*() { // eslint-disable-line require-yield throw new Error('kaboom'); }(), s, common.mustCall((err) => { assert.strictEqual(err.message, 'kaboom'); @@ -746,7 +746,7 @@ const tsp = require('timers/promises'); { const s = new PassThrough(); - pipeline(function*() { + pipeline(function*() { // eslint-disable-line require-yield throw new Error('kaboom'); }, s, common.mustCall((err, val) => { assert.strictEqual(err.message, 'kaboom'); @@ -756,7 +756,7 @@ const tsp = require('timers/promises'); { const s = new PassThrough(); - pipeline(function*() { + pipeline(function*() { // eslint-disable-line require-yield throw new Error('kaboom'); }(), s, common.mustCall((err, val) => { assert.strictEqual(err.message, 'kaboom'); @@ -771,7 +771,7 @@ const tsp = require('timers/promises'); yield 'hello'; yield 'world'; }, s, async function(source) { - for await (const chunk of source) { + for await (const chunk of source) { // eslint-disable-line no-unused-vars throw new Error('kaboom'); } }, common.mustCall((err, val) => { @@ -784,8 +784,8 @@ const tsp = require('timers/promises'); const s = new PassThrough(); const ret = pipeline(function() { return ['hello', 'world']; - }, s, async function*(source) { - for await (const chunk of source) { + }, s, async function*(source) { // eslint-disable-line require-yield + for await (const chunk of source) { // eslint-disable-line no-unused-vars throw new Error('kaboom'); } }, common.mustCall((err) => { @@ -1054,12 +1054,11 @@ const tsp = require('timers/promises'); const ws = new Writable({ write: common.mustNotCall() }); - pipeline(rs, async function*(stream) { - /* eslint no-unused-vars: off */ - for await (const chunk of stream) { + pipeline(rs, async function*(stream) { // eslint-disable-line require-yield + for await (const chunk of stream) { // eslint-disable-line no-unused-vars throw new Error('kaboom'); } - }, async function *(source) { + }, async function *(source) { // eslint-disable-line require-yield for await (const chunk of source) { res += chunk; } @@ -1394,7 +1393,7 @@ const tsp = require('timers/promises'); const ac = new AbortController(); const signal = ac.signal; pipelinep( - async function * ({ signal }) { + async function * ({ signal }) { // eslint-disable-line require-yield await tsp.setTimeout(1e6, signal); }, async function(source) { diff --git a/test/parallel/test-worker-message-port-terminate-transfer-list.js b/test/parallel/test-worker-message-port-terminate-transfer-list.js index a066405d9d14de..a5c7a34c55ed72 100644 --- a/test/parallel/test-worker-message-port-terminate-transfer-list.js +++ b/test/parallel/test-worker-message-port-terminate-transfer-list.js @@ -18,6 +18,7 @@ if (!process.env.HAS_STARTED_WORKER) { // Make sure we don’t end up running JS after the infinite loop is broken. port1.postMessage({}, { + // eslint-disable-next-line require-yield transfer: (function*() { while (true); })() }); From dcc368f4bef5b763b8ef20ef7dacbfec27c2eadd Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Jan 2022 08:45:19 -0800 Subject: [PATCH 4/6] tools,lib,test: enable ESLint no-regex-spaces rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Geoffrey Booth --- .eslintrc.js | 1 + lib/internal/util/inspect.js | 2 +- test/parallel/test-assert-deep.js | 2 +- test/parallel/test-assert.js | 2 +- test/parallel/test-debugger-address.js | 2 +- .../test-events-uncaught-exception-stack.js | 2 +- test/parallel/test-http2-stream-client.js | 6 +++--- test/parallel/test-repl-definecommand.js | 2 +- test/parallel/test-repl-underscore.js | 2 +- test/parallel/test-repl.js | 20 +++++++++---------- test/sequential/test-debugger-pid.js | 2 +- .../test-tick-processor-unknown.js | 2 +- 12 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3231e3dff3f37a..b724276db5ffa2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -215,6 +215,7 @@ module.exports = { 'no-path-concat': 'error', 'no-proto': 'error', 'no-redeclare': ['error', { 'builtinGlobals': false }], + 'no-regex-spaces': 'error', 'no-restricted-modules': ['error', 'sys'], /* eslint-disable max-len */ 'no-restricted-properties': [ diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 3e2309a00bcb91..814e5bf0f37cd4 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -188,7 +188,7 @@ const strEscapeSequencesReplacerSingle = /[\x00-\x1f\x5c\x7f-\x9f]|[\ud800-\udbf const keyStrRegExp = /^[a-zA-Z_][a-zA-Z_0-9]*$/; const numberRegExp = /^(0|[1-9][0-9]*)$/; -const coreModuleRegExp = /^ at (?:[^/\\(]+ \(|)node:(.+):\d+:\d+\)?$/; +const coreModuleRegExp = /^ {4}at (?:[^/\\(]+ \(|)node:(.+):\d+:\d+\)?$/; const nodeModulesRegExp = /[/\\]node_modules[/\\](.+?)(?=[/\\])/g; const classRegExp = /^(\s+[^(]*?)\s*{/; diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index e6b7c010c289aa..a52fee3b7b0914 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -1125,7 +1125,7 @@ assert.throws( { code: 'ERR_ASSERTION', name: 'AssertionError', - message: /a: \[Getter: 5]\n- a: \[Getter: 6]\n / + message: /a: \[Getter: 5]\n- {3}a: \[Getter: 6]\n {2}/ } ); diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 84cce7e8a5e740..24a72091c08399 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -1247,7 +1247,7 @@ assert.throws( assert.deepStrictEqual(Array(100).fill(1), 'foobar'); } catch (err) { threw = true; - assert.match(inspect(err), /actual: \[Array],\n expected: 'foobar',/); + assert.match(inspect(err), /actual: \[Array],\n {2}expected: 'foobar',/); } assert(threw); } diff --git a/test/parallel/test-debugger-address.js b/test/parallel/test-debugger-address.js index 95dd1c6e3f8283..bffc28ac916e8d 100644 --- a/test/parallel/test-debugger-address.js +++ b/test/parallel/test-debugger-address.js @@ -65,7 +65,7 @@ function launchTarget(...args) { .then(() => { assert.match( cli.output, - /> 3 \+\+x;/, + /> 3 {3}\+\+x;/, 'marks the 3rd line'); }) .then(() => cleanup()) diff --git a/test/parallel/test-events-uncaught-exception-stack.js b/test/parallel/test-events-uncaught-exception-stack.js index 793a6b0c2ae5e9..e330f254aea3c5 100644 --- a/test/parallel/test-events-uncaught-exception-stack.js +++ b/test/parallel/test-events-uncaught-exception-stack.js @@ -9,7 +9,7 @@ process.on('uncaughtException', common.mustCall((err) => { const lines = err.stack.split('\n'); assert.strictEqual(lines[0], 'Error'); lines.slice(1).forEach((line) => { - assert.match(line, /^ at/); + assert.match(line, /^ {4}at/); }); })); diff --git a/test/parallel/test-http2-stream-client.js b/test/parallel/test-http2-stream-client.js index f975e90cbdac61..89a571b27efc22 100644 --- a/test/parallel/test-http2-stream-client.js +++ b/test/parallel/test-http2-stream-client.js @@ -12,9 +12,9 @@ server.on('stream', common.mustCall((stream) => { assert.strictEqual(stream.aborted, false); const insp = util.inspect(stream); assert.match(insp, /Http2Stream {/); - assert.match(insp, / state:/); - assert.match(insp, / readableState:/); - assert.match(insp, / writableState:/); + assert.match(insp, / {2}state:/); + assert.match(insp, / {2}readableState:/); + assert.match(insp, / {2}writableState:/); stream.end('ok'); })); server.listen(0, common.mustCall(() => { diff --git a/test/parallel/test-repl-definecommand.js b/test/parallel/test-repl-definecommand.js index 0057eb51ebdd4e..f3973f25d69412 100644 --- a/test/parallel/test-repl-definecommand.js +++ b/test/parallel/test-repl-definecommand.js @@ -35,7 +35,7 @@ r.defineCommand('say2', function() { }); inputStream.write('.help\n'); -assert.match(output, /\n\.say1 help for say1\n/); +assert.match(output, /\n\.say1 {5}help for say1\n/); assert.match(output, /\n\.say2\n/); inputStream.write('.say1 node developer\n'); assert.ok(output.startsWith('hello node developer\n'), diff --git a/test/parallel/test-repl-underscore.js b/test/parallel/test-repl-underscore.js index 8f4470b94963b3..3abd01ba9d0cbc 100644 --- a/test/parallel/test-repl-underscore.js +++ b/test/parallel/test-repl-underscore.js @@ -179,7 +179,7 @@ function testError() { // The sync error, with individual property echoes /^Uncaught Error: ENOENT: no such file or directory, scandir '.*nonexistent\?'/, /Object\.readdirSync/, - /^ errno: -(2|4058),$/, + /^ {2}errno: -(2|4058),$/, " syscall: 'scandir',", " code: 'ENOENT',", " path: '/nonexistent?'", diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 3f4e87f8a9a529..b70fce93ba7c49 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -571,10 +571,10 @@ const errorTests = [ /^Uncaught Error: Cannot find module 'internal\/repl'/, /^Require stack:/, /^- /, - /^ at .*/, - /^ at .*/, - /^ at .*/, - /^ at .*/, + /^ {4}at .*/, + /^ {4}at .*/, + /^ {4}at .*/, + /^ {4}at .*/, " code: 'MODULE_NOT_FOUND',", " requireStack: [ '' ]", '}', @@ -776,12 +776,12 @@ const errorTests = [ ' group: [Function: group],', ' groupEnd: [Function: groupEnd],', ' table: [Function: table],', - / debug: \[Function: (debug|log)],/, - / info: \[Function: (info|log)],/, - / dirxml: \[Function: (dirxml|log)],/, - / error: \[Function: (error|warn)],/, - / groupCollapsed: \[Function: (groupCollapsed|group)],/, - / Console: \[Function: Console],?/, + / {2}debug: \[Function: (debug|log)],/, + / {2}info: \[Function: (info|log)],/, + / {2}dirxml: \[Function: (dirxml|log)],/, + / {2}error: \[Function: (error|warn)],/, + / {2}groupCollapsed: \[Function: (groupCollapsed|group)],/, + / {2}Console: \[Function: Console],?/, ...process.features.inspector ? [ ' profile: [Function: profile],', ' profileEnd: [Function: profileEnd],', diff --git a/test/sequential/test-debugger-pid.js b/test/sequential/test-debugger-pid.js index 402c1f86dd4ed9..0056113ecaecd3 100644 --- a/test/sequential/test-debugger-pid.js +++ b/test/sequential/test-debugger-pid.js @@ -44,7 +44,7 @@ function launchTarget(...args) { .then(() => { assert.match( cli.output, - /> 3 \+\+x;/, + /> 3 {3}\+\+x;/, 'marks the 3rd line'); }) .then(() => cleanup()) diff --git a/test/tick-processor/test-tick-processor-unknown.js b/test/tick-processor/test-tick-processor-unknown.js index 42208f3bb36d36..d5e6a9359e52eb 100644 --- a/test/tick-processor/test-tick-processor-unknown.js +++ b/test/tick-processor/test-tick-processor-unknown.js @@ -14,7 +14,7 @@ const base = require('./tick-processor-base.js'); // Unknown checked for to prevent flakiness, if pattern is not found, // then a large number of unknown ticks should be present base.runTest({ - pattern: /LazyCompile.*\[eval]:1|.*% UNKNOWN/, + pattern: /LazyCompile.*\[eval]:1|.*% {2}UNKNOWN/, code: `function f() { for (let i = 0; i < 1000000; i++) { i++; From 5bce5b706ff192bd30138ced1b0862dcbe957f6c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Jan 2022 11:38:04 -0800 Subject: [PATCH 5/6] tools: enable ESLint no-constant-condition rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Geoffrey Booth --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index b724276db5ffa2..7e162b1cfa4430 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -179,6 +179,7 @@ module.exports = { 'no-class-assign': 'error', 'no-confusing-arrow': 'error', 'no-const-assign': 'error', + 'no-constant-condition': ['error', { checkLoops: false }], 'no-constructor-return': 'error', 'no-control-regex': 'error', 'no-debugger': 'error', From 2b0d61f0639e6fdca497619b36657054b86642e8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 9 Jan 2022 14:00:08 -0800 Subject: [PATCH 6/6] tools: enable ESLint recommended configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen Reviewed-By: Michaël Zasso Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Geoffrey Booth --- .eslintrc.js | 59 +++++++--------------------------------------------- 1 file changed, 8 insertions(+), 51 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 7e162b1cfa4430..3f2d4ace7c0c19 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -35,7 +35,7 @@ Module._findPath = (request, paths, isMain) => { module.exports = { root: true, - extends: ['plugin:jsdoc/recommended'], + extends: ['eslint:recommended', 'plugin:jsdoc/recommended'], plugins: ['jsdoc', 'markdown', 'node-core'], parser: '@babel/eslint-parser', parserOptions: { @@ -142,17 +142,14 @@ module.exports = { 'comma-spacing': 'error', 'comma-style': 'error', 'computed-property-spacing': 'error', - 'constructor-super': 'error', 'default-case-last': 'error', 'dot-location': ['error', 'property'], 'dot-notation': 'error', 'eol-last': 'error', 'eqeqeq': ['error', 'smart'], - 'for-direction': 'error', 'func-call-spacing': 'error', 'func-name-matching': 'error', 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], - 'getter-return': 'error', 'indent': ['error', 2, { ArrayExpression: 'first', CallExpression: { arguments: 'first' }, @@ -174,49 +171,20 @@ module.exports = { tabWidth: 2, }], 'new-parens': 'error', - 'no-async-promise-executor': 'error', - 'no-case-declarations': 'error', - 'no-class-assign': 'error', 'no-confusing-arrow': 'error', - 'no-const-assign': 'error', 'no-constant-condition': ['error', { checkLoops: false }], 'no-constructor-return': 'error', - 'no-control-regex': 'error', - 'no-debugger': 'error', - 'no-delete-var': 'error', - 'no-dupe-args': 'error', - 'no-dupe-class-members': 'error', - 'no-dupe-keys': 'error', - 'no-dupe-else-if': 'error', - 'no-duplicate-case': 'error', 'no-duplicate-imports': 'error', 'no-else-return': ['error', { allowElseIf: true }], - 'no-empty-character-class': 'error', - 'no-ex-assign': 'error', - 'no-extra-boolean-cast': 'error', 'no-extra-parens': ['error', 'functions'], - 'no-extra-semi': 'error', - 'no-fallthrough': 'error', - 'no-func-assign': 'error', - 'no-global-assign': 'error', - 'no-invalid-regexp': 'error', - 'no-irregular-whitespace': 'error', 'no-lonely-if': 'error', - 'no-loss-of-precision': 'error', - 'no-misleading-character-class': 'error', 'no-mixed-requires': 'error', - 'no-mixed-spaces-and-tabs': 'error', 'no-multi-spaces': ['error', { ignoreEOLComments: true }], 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0, maxBOF: 0 }], 'no-new-require': 'error', - 'no-new-symbol': 'error', - 'no-nonoctal-decimal-escape': 'error', - 'no-obj-calls': 'error', - 'no-octal': 'error', 'no-path-concat': 'error', 'no-proto': 'error', 'no-redeclare': ['error', { 'builtinGlobals': false }], - 'no-regex-spaces': 'error', 'no-restricted-modules': ['error', 'sys'], /* eslint-disable max-len */ 'no-restricted-properties': [ @@ -273,41 +241,26 @@ module.exports = { ], /* eslint-enable max-len */ 'no-return-await': 'error', - 'no-self-assign': 'error', 'no-self-compare': 'error', - 'no-setter-return': 'error', - 'no-shadow-restricted-names': 'error', - 'no-sparse-arrays': 'error', 'no-tabs': 'error', 'no-template-curly-in-string': 'error', - 'no-this-before-super': 'error', 'no-throw-literal': 'error', 'no-trailing-spaces': 'error', 'no-undef': ['error', { typeof: true }], 'no-undef-init': 'error', - 'no-unexpected-multiline': 'error', - 'no-unreachable': 'error', - 'no-unsafe-finally': 'error', - 'no-unsafe-negation': 'error', - 'no-unsafe-optional-chaining': 'error', 'no-unused-expressions': ['error', { allowShortCircuit: true }], - 'no-unused-labels': 'error', 'no-unused-vars': ['error', { args: 'none', caughtErrors: 'all' }], 'no-use-before-define': ['error', { classes: true, functions: false, variables: false, }], - 'no-useless-backreference': 'error', 'no-useless-call': 'error', - 'no-useless-catch': 'error', 'no-useless-concat': 'error', 'no-useless-constructor': 'error', - 'no-useless-escape': 'error', 'no-useless-return': 'error', 'no-void': 'error', 'no-whitespace-before-property': 'error', - 'no-with': 'error', 'object-curly-newline': 'error', 'object-curly-spacing': ['error', 'always'], 'one-var': ['error', { initialized: 'never' }], @@ -322,7 +275,6 @@ module.exports = { 'quotes': ['error', 'single', { avoidEscape: true }], 'quote-props': ['error', 'consistent'], 'rest-spread-spacing': 'error', - 'require-yield': 'error', 'semi': 'error', 'semi-spacing': 'error', 'space-before-blocks': ['error', 'always'], @@ -342,10 +294,15 @@ module.exports = { 'symbol-description': 'error', 'template-curly-spacing': 'error', 'unicode-bom': 'error', - 'use-isnan': 'error', 'valid-typeof': ['error', { requireStringLiterals: true }], - // JSDoc rules + // ESLint recommended rules that we disable + 'no-cond-assign': 'off', + 'no-empty': 'off', + 'no-inner-declarations': 'off', + 'no-prototype-builtins': 'off', + + // JSDoc recommended rules that we disable 'jsdoc/require-jsdoc': 'off', 'jsdoc/require-param-description': 'off', 'jsdoc/newline-after-description': 'off',