From 2643022ae75acb95c0f18ec3aa5a42ccb2eff3d8 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 27 Jun 2023 08:13:10 -0700 Subject: [PATCH 1/4] fix: correct dev-deps required for the recent estlin@8 upgrade The upgrade to eslint@8 in #3409 subtly broken peer-dependencies. `npm ls` unhelpfully does not complain, but `npm ls -a` shows some errors, and `./dev-utils/make-distribution.sh` was broken. The upgrade bumped "eslint-config-standard" from ^14.1.1 to ^16. However, v16 has: "peerDependencies": { "eslint": "^7.12.1", "eslint-plugin-import": "^2.22.1", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1 || ^5.0.0" }, so is incompatible with eslint@8. We need eslint-config-standard@17, which has: "peerDependencies": { "eslint": "^8.0.1", "eslint-plugin-import": "^2.25.2", "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", "eslint-plugin-promise": "^6.0.0" }, Note that also requires a change from eslint-plugin-node (unmaintained) to the replacement "eslint-plugin-n". --- package-lock.json | 238 ++++++++++++++++++++++++++++++++-------------- package.json | 4 +- 2 files changed, 169 insertions(+), 73 deletions(-) diff --git a/package-lock.json b/package-lock.json index 551640bb76..0add55c614 100644 --- a/package-lock.json +++ b/package-lock.json @@ -72,10 +72,10 @@ "diagnostics_channel": "^1.1.0", "elasticsearch": "^16.7.3", "eslint": "^8.42.0", - "eslint-config-standard": "^16", + "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-license-header": "^0.6.0", - "eslint-plugin-node": "^11.1.0", + "eslint-plugin-n": "^15.7.0", "eslint-plugin-promise": "^6.1.1", "express": "^4.17.1", "express-queue": "^0.0.13", @@ -6974,6 +6974,30 @@ "node": ">=4" } }, + "node_modules/builtins": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz", + "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==", + "dev": true, + "dependencies": { + "semver": "^7.0.0" + } + }, + "node_modules/builtins/node_modules/semver": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", + "integrity": "sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -8492,9 +8516,9 @@ } }, "node_modules/eslint-config-standard": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-16.0.3.tgz", - "integrity": "sha512-x4fmJL5hGqNJKGHSjnLdgA6U6h1YW/G2dW9fA+cyVur4SK6lyue8+UgNKWlZtUDTXvgKDD/Oa3GQjmB5kjtVvg==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz", + "integrity": "sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==", "dev": true, "funding": [ { @@ -8510,11 +8534,14 @@ "url": "https://feross.org/support" } ], + "engines": { + "node": ">=12.0.0" + }, "peerDependencies": { - "eslint": "^7.12.1", - "eslint-plugin-import": "^2.22.1", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1 || ^5.0.0" + "eslint": "^8.0.1", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-n": "^15.0.0 || ^16.0.0 ", + "eslint-plugin-promise": "^6.0.0" } }, "node_modules/eslint-import-resolver-node": { @@ -8564,9 +8591,9 @@ } }, "node_modules/eslint-plugin-es": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", - "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz", + "integrity": "sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==", "dev": true, "dependencies": { "eslint-utils": "^2.0.0", @@ -8597,16 +8624,13 @@ "url": "https://github.com/sponsors/mysticatea" } }, - "node_modules/eslint-plugin-es/node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "node_modules/eslint-plugin-es/node_modules/eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", "dev": true, "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" + "node": ">=4" } }, "node_modules/eslint-plugin-import": { @@ -8668,39 +8692,44 @@ "requireindex": "^1.2.0" } }, - "node_modules/eslint-plugin-node": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", - "integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==", + "node_modules/eslint-plugin-n": { + "version": "15.7.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.7.0.tgz", + "integrity": "sha512-jDex9s7D/Qial8AGVIHq4W7NswpUD5DPDL2RH8Lzd9EloWUuvUkHfv4FRLMipH5q2UtyurorBkPeNi1wVWNh3Q==", "dev": true, "dependencies": { - "eslint-plugin-es": "^3.0.0", - "eslint-utils": "^2.0.0", + "builtins": "^5.0.1", + "eslint-plugin-es": "^4.1.0", + "eslint-utils": "^3.0.0", "ignore": "^5.1.1", - "minimatch": "^3.0.4", - "resolve": "^1.10.1", - "semver": "^6.1.0" + "is-core-module": "^2.11.0", + "minimatch": "^3.1.2", + "resolve": "^1.22.1", + "semver": "^7.3.8" }, "engines": { - "node": ">=8.10.0" + "node": ">=12.22.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" }, "peerDependencies": { - "eslint": ">=5.16.0" + "eslint": ">=7.0.0" } }, - "node_modules/eslint-plugin-node/node_modules/eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "node_modules/eslint-plugin-n/node_modules/semver": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", + "integrity": "sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==", "dev": true, "dependencies": { - "eslint-visitor-keys": "^1.1.0" + "lru-cache": "^6.0.0" }, - "engines": { - "node": ">=6" + "bin": { + "semver": "bin/semver.js" }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" + "engines": { + "node": ">=10" } }, "node_modules/eslint-plugin-promise": { @@ -8731,13 +8760,31 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^2.0.0" + }, + "engines": { + "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + }, + "peerDependencies": { + "eslint": ">=5" + } + }, "node_modules/eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", "dev": true, "engines": { - "node": ">=4" + "node": ">=10" } }, "node_modules/eslint/node_modules/ajv": { @@ -14556,6 +14603,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + } + }, "node_modules/regexpu-core": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", @@ -22675,6 +22734,26 @@ "integrity": "sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==", "dev": true }, + "builtins": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz", + "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==", + "dev": true, + "requires": { + "semver": "^7.0.0" + }, + "dependencies": { + "semver": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", + "integrity": "sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -24011,9 +24090,9 @@ } }, "eslint-config-standard": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-16.0.3.tgz", - "integrity": "sha512-x4fmJL5hGqNJKGHSjnLdgA6U6h1YW/G2dW9fA+cyVur4SK6lyue8+UgNKWlZtUDTXvgKDD/Oa3GQjmB5kjtVvg==", + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz", + "integrity": "sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==", "dev": true }, "eslint-import-resolver-node": { @@ -24059,9 +24138,9 @@ } }, "eslint-plugin-es": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz", - "integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-4.1.0.tgz", + "integrity": "sha512-GILhQTnjYE2WorX5Jyi5i4dz5ALWxBIdQECVQavL6s7cI76IZTDWleTHkxz/QT3kvcs2QlGHvKLYsSlPOlPXnQ==", "dev": true, "requires": { "eslint-utils": "^2.0.0", @@ -24077,10 +24156,10 @@ "eslint-visitor-keys": "^1.1.0" } }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", "dev": true } } @@ -24137,27 +24216,29 @@ "requireindex": "^1.2.0" } }, - "eslint-plugin-node": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", - "integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==", + "eslint-plugin-n": { + "version": "15.7.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-15.7.0.tgz", + "integrity": "sha512-jDex9s7D/Qial8AGVIHq4W7NswpUD5DPDL2RH8Lzd9EloWUuvUkHfv4FRLMipH5q2UtyurorBkPeNi1wVWNh3Q==", "dev": true, "requires": { - "eslint-plugin-es": "^3.0.0", - "eslint-utils": "^2.0.0", + "builtins": "^5.0.1", + "eslint-plugin-es": "^4.1.0", + "eslint-utils": "^3.0.0", "ignore": "^5.1.1", - "minimatch": "^3.0.4", - "resolve": "^1.10.1", - "semver": "^6.1.0" + "is-core-module": "^2.11.0", + "minimatch": "^3.1.2", + "resolve": "^1.22.1", + "semver": "^7.3.8" }, "dependencies": { - "eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", - "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "semver": { + "version": "7.5.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.3.tgz", + "integrity": "sha512-QBlUtyVk/5EeHbi7X0fw6liDZc7BBmEaSYn01fMU1OUYbf6GPsbTtd8WmnqbI20SeycoHSeiybkE/q1Q+qlThQ==", "dev": true, "requires": { - "eslint-visitor-keys": "^1.1.0" + "lru-cache": "^6.0.0" } } } @@ -24178,10 +24259,19 @@ "estraverse": "^5.2.0" } }, + "eslint-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", + "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^2.0.0" + } + }, "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", - "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", "dev": true }, "esm": { @@ -28547,6 +28637,12 @@ "functions-have-names": "^1.2.2" } }, + "regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true + }, "regexpu-core": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.3.2.tgz", diff --git a/package.json b/package.json index c140ee6638..8e22c24259 100644 --- a/package.json +++ b/package.json @@ -149,10 +149,10 @@ "diagnostics_channel": "^1.1.0", "elasticsearch": "^16.7.3", "eslint": "^8.42.0", - "eslint-config-standard": "^16", + "eslint-config-standard": "^17.1.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-license-header": "^0.6.0", - "eslint-plugin-node": "^11.1.0", + "eslint-plugin-n": "^15.7.0", "eslint-plugin-promise": "^6.1.1", "express": "^4.17.1", "express-queue": "^0.0.13", From 8a7a6fce24597a524726e991c99c61753a79c368 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 27 Jun 2023 08:46:17 -0700 Subject: [PATCH 2/4] update 'eslint-disable-line node/*' usage to 'eslint-disable-line n/*' --- lib/instrumentation/modules/mysql.js | 2 +- lib/instrumentation/patch-async.js | 4 ++-- .../modules/http/aborted-requests-enabled.test.js | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/instrumentation/modules/mysql.js b/lib/instrumentation/modules/mysql.js index bfad3b991e..686283d4b4 100644 --- a/lib/instrumentation/modules/mysql.js +++ b/lib/instrumentation/modules/mysql.js @@ -81,7 +81,7 @@ module.exports = function (mysql, agent, { version, enabled }) { var cb = arguments[0] if (typeof cb === 'function') { - arguments[0] = agent._instrumentation.bindFunction(function wrapedCallback (err, connection) { // eslint-disable-line node/handle-callback-err + arguments[0] = agent._instrumentation.bindFunction(function wrapedCallback (err, connection) { // eslint-disable-line n/handle-callback-err if (connection) wrapQueryable(connection, 'getConnection() > connection', agent) return cb.apply(this, arguments) }) diff --git a/lib/instrumentation/patch-async.js b/lib/instrumentation/patch-async.js index 6cc81e106d..a6a8e56ef8 100644 --- a/lib/instrumentation/patch-async.js +++ b/lib/instrumentation/patch-async.js @@ -303,8 +303,8 @@ module.exports = function (ins) { } // only wrap lchown and lchmod on systems that have them. - if (fs.lchown) wrap(fs, 'lchown', activator) // eslint-disable-line node/no-deprecated-api - if (fs.lchmod) wrap(fs, 'lchmod', activator) // eslint-disable-line node/no-deprecated-api + if (fs.lchown) wrap(fs, 'lchown', activator) // eslint-disable-line n/no-deprecated-api + if (fs.lchmod) wrap(fs, 'lchmod', activator) // eslint-disable-line n/no-deprecated-api // only wrap ftruncate in versions of node that have it if (fs.ftruncate) wrap(fs, 'ftruncate', activator) diff --git a/test/instrumentation/modules/http/aborted-requests-enabled.test.js b/test/instrumentation/modules/http/aborted-requests-enabled.test.js index f0ca18a553..d4d4636da1 100644 --- a/test/instrumentation/modules/http/aborted-requests-enabled.test.js +++ b/test/instrumentation/modules/http/aborted-requests-enabled.test.js @@ -42,7 +42,7 @@ test('client-side abort below error threshold - call end', { timeout: 10000 }, f t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line n/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = function () { @@ -144,7 +144,7 @@ test('client-side abort below error threshold - don\'t call end', function (t) { t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line n/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = function () { @@ -222,7 +222,7 @@ test('server-side abort below error threshold and socket closed - call end', fun t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line n/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = function () { @@ -311,7 +311,7 @@ test('server-side abort below error threshold and socket closed - don\'t call en t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line n/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = function () { @@ -391,7 +391,7 @@ test('server-side abort below error threshold but socket not closed - call end', t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line n/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = addEndedTransaction @@ -429,7 +429,7 @@ test('server-side abort above error threshold but socket not closed - call end', t.strictEqual(agent._apmClient._writes.length, 0, 'should not have any samples to begin with') - agent.captureError = function (err, opts) { // eslint-disable-line node/handle-callback-err + agent.captureError = function (err, opts) { // eslint-disable-line n/handle-callback-err t.fail('should not register the closed socket as an error') } agent._instrumentation.addEndedTransaction = addEndedTransaction From 50f3722b3db52a870dcace7b1d1e16dbe01e781c Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 27 Jun 2023 08:51:53 -0700 Subject: [PATCH 3/4] update style for "object-shorthand" eslint rule eslint-config-standard@17 added https://eslint.org/docs/latest/rules/object-shorthand as a warning. It'll become "error" in a subsequent major. --- dev-utils/bitrot.js | 2 +- lib/agent.js | 2 +- lib/http-request.js | 4 ++-- lib/instrumentation/dropped-spans-stats.js | 2 +- lib/instrumentation/http-shared.js | 14 +++++++------- .../modules/@aws-sdk/client-s3.js | 2 +- lib/instrumentation/modules/elasticsearch.js | 6 +++--- lib/instrumentation/modules/generic-pool.js | 6 +++--- lib/instrumentation/modules/graphql.js | 2 +- lib/instrumentation/modules/http2.js | 2 +- lib/instrumentation/modules/mongodb-core.js | 12 ++++++------ lib/instrumentation/modules/redis.js | 4 ++-- lib/instrumentation/template-shared.js | 8 ++++---- lib/instrumentation/transaction.js | 4 ++-- lib/lambda.js | 4 ++-- lib/logging.js | 12 ++++++------ lib/stacktraces.js | 4 ++-- test/_mock_apm_server.js | 2 +- test/benchmarks/utils/bench.js | 2 +- test/cloud-metadata/test-server.test.js | 6 +++--- .../AJsAzureFnApp/HttpFnDistTraceA/index.js | 2 +- test/instrumentation/express-utils.test.js | 4 ++-- .../modules/@elastic/elasticsearch.test.js | 8 ++++---- .../modules/apollo-server-express.test.js | 10 +++++----- .../modules/aws-sdk/dynamodb.test.js | 4 ++-- .../modules/aws-sdk/sns.test.js | 4 ++-- .../modules/elasticsearch.test.js | 18 +++++++++--------- .../modules/express-queue.test.js | 4 ++-- test/instrumentation/modules/graphql.test.js | 4 ++-- .../instrumentation/modules/http/basic.test.js | 4 ++-- .../modules/http/github-179.test.js | 2 +- .../modules/http/ignoring.test.js | 4 ++-- test/instrumentation/modules/http/sse.test.js | 2 +- test/instrumentation/modules/http2.test.js | 2 +- .../modules/mysql/mysql.test.js | 8 ++++---- .../fixtures/createSpan-returns-null.js | 2 +- test/stacktraces/stacktraces.test.js | 4 ++-- test/transaction-sampling.test.js | 2 +- 38 files changed, 94 insertions(+), 94 deletions(-) diff --git a/dev-utils/bitrot.js b/dev-utils/bitrot.js index 6f0cce2ba2..c0536a3af7 100755 --- a/dev-utils/bitrot.js +++ b/dev-utils/bitrot.js @@ -351,7 +351,7 @@ const options = [ ] function main (argv) { - var parser = dashdash.createParser({ options: options }) + var parser = dashdash.createParser({ options }) try { var opts = parser.parse(argv) } catch (e) { diff --git a/lib/agent.js b/lib/agent.js index ca685f1efe..4947b64014 100644 --- a/lib/agent.js +++ b/lib/agent.js @@ -606,7 +606,7 @@ Agent.prototype.captureError = function (err, opts, cb) { errors.createAPMError({ log: agent.logger, - id: id, + id, exception: errIsError ? err : null, logMessage: errIsError ? null : err, shouldCaptureAttributes, diff --git a/lib/http-request.js b/lib/http-request.js index 56bf298691..fa697a3ec6 100644 --- a/lib/http-request.js +++ b/lib/http-request.js @@ -207,8 +207,8 @@ function main (argv) { const timeout = Number(argv[4]) var req = httpRequest(url, { - timeout: timeout, - connectTimeout: connectTimeout + timeout, + connectTimeout // TODO: log support }, function onRes (res) { res.pipe(process.stdout) diff --git a/lib/instrumentation/dropped-spans-stats.js b/lib/instrumentation/dropped-spans-stats.js index af0e966943..04fe470edc 100644 --- a/lib/instrumentation/dropped-spans-stats.js +++ b/lib/instrumentation/dropped-spans-stats.js @@ -60,7 +60,7 @@ class DroppedSpansStats { } }, destination_service_resource: resource, - outcome: outcome + outcome } if (serviceTargetType) { stats.service_target_type = serviceTargetType diff --git a/lib/instrumentation/http-shared.js b/lib/instrumentation/http-shared.js index c7636d0852..636d0a7163 100644 --- a/lib/instrumentation/http-shared.js +++ b/lib/instrumentation/http-shared.js @@ -99,7 +99,7 @@ exports.instrumentRequest = function (agent, moduleName) { const tracestate = req.headers.tracestate const trans = agent.startTransaction(null, null, { childOf: traceparent, - tracestate: tracestate + tracestate }) trans.type = 'request' trans.req = req @@ -186,7 +186,7 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) { const parentRunContext = ins.currRunContext() var span = ins.createSpan(null, 'external', 'http', { exitSpan: true }) var id = span && span.transaction.id - agent.logger.debug('intercepted call to %s.%s %o', moduleName, method, { id: id }) + agent.logger.debug('intercepted call to %s.%s %o', moduleName, method, { id }) // Reproduce the argument handling from node/lib/_http_client.js#ClientRequest(). // @@ -261,7 +261,7 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) { var req = ins.withRunContext(spanRunContext, orig, this, ...newArgs) var protocol = req.agent && req.agent.protocol - agent.logger.debug('request details: %o', { protocol: protocol, host: getSafeHost(req), id: id }) + agent.logger.debug('request details: %o', { protocol, host: getSafeHost(req), id }) ins.bindEmitter(req) @@ -280,7 +280,7 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) { const url = getUrlFromRequestAndOptions(req, options, moduleName + ':') if (!url) { - agent.logger.warn('unable to identify http.ClientRequest url %o', { id: id }) + agent.logger.warn('unable to identify http.ClientRequest url %o', { id }) } let statusCode return req @@ -288,7 +288,7 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) { // In case the request is ended prematurely function onAbort (type) { if (span.ended) return - agent.logger.debug('intercepted http.ClientRequest abort event %o', { id: id }) + agent.logger.debug('intercepted http.ClientRequest abort event %o', { id }) onEnd() } @@ -319,11 +319,11 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) { } function onResponse (res) { - agent.logger.debug('intercepted http.ClientRequest response event %o', { id: id }) + agent.logger.debug('intercepted http.ClientRequest response event %o', { id }) ins.bindEmitterToRunContext(parentRunContext, res) statusCode = res.statusCode res.prependListener('end', function () { - agent.logger.debug('intercepted http.IncomingMessage end event %o', { id: id }) + agent.logger.debug('intercepted http.IncomingMessage end event %o', { id }) onEnd() }) } diff --git a/lib/instrumentation/modules/@aws-sdk/client-s3.js b/lib/instrumentation/modules/@aws-sdk/client-s3.js index d53c5a4972..1dee0521b5 100644 --- a/lib/instrumentation/modules/@aws-sdk/client-s3.js +++ b/lib/instrumentation/modules/@aws-sdk/client-s3.js @@ -192,7 +192,7 @@ function s3MiddlewareFactory (client, agent) { context[elasticAPMStash] = { protocol: req.protocol, hostname: req.hostname, - port: port + port } return next(args) }, diff --git a/lib/instrumentation/modules/elasticsearch.js b/lib/instrumentation/modules/elasticsearch.js index c2a4da75f6..564e2c4f77 100644 --- a/lib/instrumentation/modules/elasticsearch.js +++ b/lib/instrumentation/modules/elasticsearch.js @@ -81,7 +81,7 @@ module.exports = function (elasticsearch, agent, { enabled }) { var method = params && params.method var path = params && params.path - agent.logger.debug('intercepted call to elasticsearch.Transport.prototype.request %o', { id: id, method: method, path: path }) + agent.logger.debug('intercepted call to elasticsearch.Transport.prototype.request %o', { id, method, path }) if (span && method && path) { span.name = `Elasticsearch: ${method} ${path}` @@ -145,7 +145,7 @@ module.exports = function (elasticsearch, agent, { enabled }) { shimmer.wrap(inspectedPromise, 'abort', function wrapAbort (originalAbort) { return function wrappedAbort () { if (span.ended) return - agent.logger.debug('intercepted call to elasticsearch.Transport.request.abort %o', { id: id, method: method, path: path }) + agent.logger.debug('intercepted call to elasticsearch.Transport.request.abort %o', { id, method, path }) const originalReturn = originalAbort.apply(this, args) span.end() return originalReturn @@ -155,7 +155,7 @@ module.exports = function (elasticsearch, agent, { enabled }) { return inspectedPromise } } else { - agent.logger.debug('could not instrument elasticsearch request %o', { id: id }) + agent.logger.debug('could not instrument elasticsearch request %o', { id }) return original.apply(this, arguments) } } diff --git a/lib/instrumentation/modules/generic-pool.js b/lib/instrumentation/modules/generic-pool.js index f9b050c124..55c6f49415 100644 --- a/lib/instrumentation/modules/generic-pool.js +++ b/lib/instrumentation/modules/generic-pool.js @@ -17,7 +17,7 @@ module.exports = function (generic, agent, { version }) { return function wrappedPool () { var trans = agent._instrumentation.currTransaction() var id = trans && trans.id - agent.logger.debug('intercepted call to generic-pool.Pool %o', { id: id }) + agent.logger.debug('intercepted call to generic-pool.Pool %o', { id }) var pool if (this instanceof generic.Pool) { @@ -32,7 +32,7 @@ module.exports = function (generic, agent, { version }) { return function wrappedAcquire () { var trans = agent._instrumentation.currTransaction() var id = trans && trans.id - agent.logger.debug('intercepted call to pool.acquire %o', { id: id }) + agent.logger.debug('intercepted call to pool.acquire %o', { id }) var cb = arguments[0] if (typeof cb === 'function') { @@ -59,7 +59,7 @@ module.exports = function (generic, agent, { version }) { return function wrappedEnqueue () { var trans = agent._instrumentation.currTransaction() var id = trans && trans.id - agent.logger.debug('intercepted call to generic-pool.PriorityQueue.prototype.enqueue %o', { id: id }) + agent.logger.debug('intercepted call to generic-pool.PriorityQueue.prototype.enqueue %o', { id }) var obj = arguments[0] // Expect obj to of type Deferred diff --git a/lib/instrumentation/modules/graphql.js b/lib/instrumentation/modules/graphql.js index 990c74c71f..ccbb549dc0 100644 --- a/lib/instrumentation/modules/graphql.js +++ b/lib/instrumentation/modules/graphql.js @@ -202,6 +202,6 @@ module.exports = function (graphql, agent, { version, enabled }) { agent.logger.debug('unexpected document format - skipping graphql query extraction') } - return { queries: queries, operation: operation } + return { queries, operation } } } diff --git a/lib/instrumentation/modules/http2.js b/lib/instrumentation/modules/http2.js index 2a8106b164..57c8ebe878 100644 --- a/lib/instrumentation/modules/http2.js +++ b/lib/instrumentation/modules/http2.js @@ -109,7 +109,7 @@ module.exports = function (http2, agent, { enabled }) { var tracestate = req.headers.tracestate const trans = agent.startTransaction(null, null, { childOf: traceparent, - tracestate: tracestate + tracestate }) trans.type = 'request' trans.req = req diff --git a/lib/instrumentation/modules/mongodb-core.js b/lib/instrumentation/modules/mongodb-core.js index ab08f7e671..2c6f55d695 100644 --- a/lib/instrumentation/modules/mongodb-core.js +++ b/lib/instrumentation/modules/mongodb-core.js @@ -45,7 +45,7 @@ module.exports = function (mongodb, agent, { version, enabled }) { var id = trans && trans.id var span - agent.logger.debug('intercepted call to mongodb-core.Server.prototype.command %o', { id: id, ns: ns }) + agent.logger.debug('intercepted call to mongodb-core.Server.prototype.command %o', { id, ns }) if (trans && arguments.length > 0) { var index = arguments.length - 1 @@ -69,7 +69,7 @@ module.exports = function (mongodb, agent, { version, enabled }) { return orig.apply(this, arguments) function wrappedCallback (_err, commandResult) { - agent.logger.debug('intercepted mongodb-core.Server.prototype.command callback %o', { id: id }) + agent.logger.debug('intercepted mongodb-core.Server.prototype.command callback %o', { id }) if (commandResult && commandResult.connection) { span._setDestinationContext(getDBDestination( commandResult.connection.host, commandResult.connection.port)) @@ -86,7 +86,7 @@ module.exports = function (mongodb, agent, { version, enabled }) { var id = trans && trans.id var span - agent.logger.debug('intercepted call to mongodb-core.Server.prototype.%s %o', name, { id: id, ns: ns }) + agent.logger.debug('intercepted call to mongodb-core.Server.prototype.%s %o', name, { id, ns }) if (trans && arguments.length > 0) { var index = arguments.length - 1 @@ -103,7 +103,7 @@ module.exports = function (mongodb, agent, { version, enabled }) { return orig.apply(this, arguments) function wrappedCallback (_err, commandResult) { - agent.logger.debug('intercepted mongodb-core.Server.prototype.%s callback %o', name, { id: id }) + agent.logger.debug('intercepted mongodb-core.Server.prototype.%s callback %o', name, { id }) if (commandResult && commandResult.connection) { span._setDestinationContext(getDBDestination( commandResult.connection.host, commandResult.connection.port)) @@ -119,7 +119,7 @@ module.exports = function (mongodb, agent, { version, enabled }) { var id = trans && trans.id var span - agent.logger.debug('intercepted call to mongodb-core.Cursor.prototype.%s %o', name, { id: id }) + agent.logger.debug('intercepted call to mongodb-core.Cursor.prototype.%s %o', name, { id }) if (trans && arguments.length > 0) { var cb = arguments[0] @@ -143,7 +143,7 @@ module.exports = function (mongodb, agent, { version, enabled }) { return orig.apply(this, arguments) function wrappedCallback () { - agent.logger.debug('intercepted mongodb-core.Cursor.prototype.%s callback %o', name, { id: id }) + agent.logger.debug('intercepted mongodb-core.Cursor.prototype.%s callback %o', name, { id }) span.end() return cb.apply(this, arguments) } diff --git a/lib/instrumentation/modules/redis.js b/lib/instrumentation/modules/redis.js index b8a4b507ba..19bd9135c3 100644 --- a/lib/instrumentation/modules/redis.js +++ b/lib/instrumentation/modules/redis.js @@ -79,7 +79,7 @@ module.exports = function (redis, agent, { version, enabled }) { } const command = commandObj.command - agent.logger.debug({ command: command }, 'intercepted call to RedisClient.prototype.internal_send_command') + agent.logger.debug({ command }, 'intercepted call to RedisClient.prototype.internal_send_command') const span = ins.createSpan(command.toUpperCase(), TYPE, SUBTYPE, ACTION, { exitSpan: true }) if (!span) { return original.apply(this, arguments) @@ -112,7 +112,7 @@ module.exports = function (redis, agent, { version, enabled }) { return original.apply(this, arguments) } - agent.logger.debug({ command: command }, 'intercepted call to RedisClient.prototype.send_command') + agent.logger.debug({ command }, 'intercepted call to RedisClient.prototype.send_command') var span = ins.createSpan(command.toUpperCase(), TYPE, SUBTYPE, ACTION, { exitSpan: true }) if (!span) { return original.apply(this, arguments) diff --git a/lib/instrumentation/template-shared.js b/lib/instrumentation/template-shared.js index 7fba111e4d..37ba8a943c 100644 --- a/lib/instrumentation/template-shared.js +++ b/lib/instrumentation/template-shared.js @@ -13,8 +13,8 @@ exports.wrapCompile = function (agent, moduleName) { var id = span && span.transaction.id agent.logger.debug('intercepted call to %s render %o', moduleName, { - id: id, - data: data + id, + data }) var ret = original.apply(this, arguments) @@ -30,8 +30,8 @@ exports.wrapCompile = function (agent, moduleName) { var id = span && span.transaction.id agent.logger.debug('intercepted call to %s compile %o', moduleName, { - id: id, - input: input + id, + input }) var ret = original.apply(this, arguments) diff --git a/lib/instrumentation/transaction.js b/lib/instrumentation/transaction.js index 49410ae06d..4f82528720 100644 --- a/lib/instrumentation/transaction.js +++ b/lib/instrumentation/transaction.js @@ -120,7 +120,7 @@ Object.defineProperty(Transaction.prototype, 'name', { this._agent.logger.debug('tried to set transaction.name on already ended transaction %o', { trans: this.id, parent: this.parentId, trace: this.traceId }) return } - this._agent.logger.debug('setting transaction name %o', { trans: this.id, parent: this.parentId, trace: this.traceId, name: name }) + this._agent.logger.debug('setting transaction name %o', { trans: this.id, parent: this.parentId, trace: this.traceId, name }) this._customName = name } }) @@ -136,7 +136,7 @@ Object.defineProperty(Transaction.prototype, 'result', { this._agent.logger.debug('tried to set transaction.result on already ended transaction %o', { trans: this.id, parent: this.parentId, trace: this.traceId }) return } - this._agent.logger.debug('setting transaction result %o', { trans: this.id, parent: this.parentId, trace: this.traceId, result: result }) + this._agent.logger.debug('setting transaction result %o', { trans: this.id, parent: this.parentId, trace: this.traceId, result }) this._result = result } }) diff --git a/lib/lambda.js b/lib/lambda.js index c5df9f6003..ef72468b52 100644 --- a/lib/lambda.js +++ b/lib/lambda.js @@ -391,7 +391,7 @@ function setSnsData (agent, trans, event, context, faasId, isColdStart) { const cloudContext = { origin: { provider: 'aws', - region: region, + region, service: { name: 'sns' }, @@ -625,7 +625,7 @@ function elasticApmAwsLambda (agent) { // Start the transaction and set some possibly trigger-specific data. const trans = agent.startTransaction(context.functionName, type, { childOf: traceparent, - tracestate: tracestate + tracestate }) switch (triggerType) { case TRIGGER_API_GATEWAY: diff --git a/lib/logging.js b/lib/logging.js index 4727eadade..69793eb104 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -129,7 +129,7 @@ function createLogger (levelName, customLogger) { } return customLogger.child({ - serializers: serializers + serializers }) } @@ -150,7 +150,7 @@ function createLogger (levelName, customLogger) { name: 'elastic-apm-node', base: {}, // Don't want pid and hostname fields. level: pinoLevel, - serializers: serializers, + serializers, ...ecsFormat({ apmIntegration: false }) }, dest) @@ -175,8 +175,8 @@ function setLogLevel (logger, levelName) { } module.exports = { - DEFAULT_LOG_LEVEL: DEFAULT_LOG_LEVEL, - createLogger: createLogger, - isLoggerCustom: isLoggerCustom, - setLogLevel: setLogLevel + DEFAULT_LOG_LEVEL, + createLogger, + isLoggerCustom, + setLogLevel } diff --git a/lib/stacktraces.js b/lib/stacktraces.js index b3ed19935e..59dfb5e68d 100644 --- a/lib/stacktraces.js +++ b/lib/stacktraces.js @@ -306,7 +306,7 @@ function frameFromCallSite (log, callsite, cwd, sourceLinesAppFrames, sourceLine let mappedLineno = null if (sourceMapErr) { - log.debug({ filename: filename, err: sourceMapErr }, + log.debug({ filename, err: sourceMapErr }, 'could not process file source map') } else if (sourceMapConsumer) { let pos @@ -316,7 +316,7 @@ function frameFromCallSite (log, callsite, cwd, sourceLinesAppFrames, sourceLine column: callsite.getColumnNumber() }) } catch (posErr) { - log.debug({ filename: filename, line: lineno, err: sourceMapErr }, + log.debug({ filename, line: lineno, err: sourceMapErr }, 'could not get position from sourcemap') pos = { source: null, diff --git a/test/_mock_apm_server.js b/test/_mock_apm_server.js index 353c970c3d..827f05e807 100644 --- a/test/_mock_apm_server.js +++ b/test/_mock_apm_server.js @@ -95,7 +95,7 @@ class MockAPMServer { method: req.method, url: req.url, headers: req.headers, - body: body + body }) res.end(resBody) }) diff --git a/test/benchmarks/utils/bench.js b/test/benchmarks/utils/bench.js index 5c0d24b00e..f2ddbfb8d9 100644 --- a/test/benchmarks/utils/bench.js +++ b/test/benchmarks/utils/bench.js @@ -41,7 +41,7 @@ module.exports = function (name, { agentConf, ...benchConf }) { }, onComplete (result) { process.stdout.write(JSON.stringify({ - name: name, + name, count: result.target.count, cycles: result.target.cycles, hz: result.target.hz, diff --git a/test/cloud-metadata/test-server.test.js b/test/cloud-metadata/test-server.test.js index 31707ea8ca..eecf39572d 100644 --- a/test/cloud-metadata/test-server.test.js +++ b/test/cloud-metadata/test-server.test.js @@ -47,7 +47,7 @@ tape.test('basic metadata request: gcp', function (t) { const listener = serverGcp.listen(0, function () { const url = `http://127.0.0.1:${listener.address().port}/computeMetadata/v1/?recursive=true` const options = { - url: url, + url, headers: { 'Metadata-Flavor': 'Google' } @@ -69,7 +69,7 @@ tape.test('basic metadata request: azure', function (t) { const listener = serverAzure.listen(0, function () { const url = `http://127.0.0.1:${listener.address().port}/metadata/instance?api-version=2020-09-01` const options = { - url: url, + url, headers: { Metadata: 'true' } @@ -101,7 +101,7 @@ tape.test('IMDSv2 token fetching: aws', function (t) { t.equals(rawBodyToken, 'AQAAAOaONNcThIsIsAfAkEtOkEn_b94UPLuLYRThIsIsAfAkEtOkEn==', 'returns correct fake token') const url = `http://127.0.0.1:${listener.address().port}/latest/dynamic/instance-identity/document` const options = { - url: url, + url, headers: { 'X-aws-ec2-metadata-token': rawBodyToken } diff --git a/test/instrumentation/azure-functions/fixtures/AJsAzureFnApp/HttpFnDistTraceA/index.js b/test/instrumentation/azure-functions/fixtures/AJsAzureFnApp/HttpFnDistTraceA/index.js index e187c08b44..1d86b7aace 100644 --- a/test/instrumentation/azure-functions/fixtures/AJsAzureFnApp/HttpFnDistTraceA/index.js +++ b/test/instrumentation/azure-functions/fixtures/AJsAzureFnApp/HttpFnDistTraceA/index.js @@ -25,7 +25,7 @@ async function callHttpFnDistTrace (req, suffix) { resolve({ statusCode: clientRes.statusCode, headers: clientRes.headers, - body: body + body }) }) clientRes.on('error', reject) diff --git a/test/instrumentation/express-utils.test.js b/test/instrumentation/express-utils.test.js index 2cc2c3a936..d5aebe2321 100644 --- a/test/instrumentation/express-utils.test.js +++ b/test/instrumentation/express-utils.test.js @@ -28,9 +28,9 @@ test('#getPathFromRequest', function (t) { function createRequest (url, host = 'example.com') { return { - url: url, + url, headers: { - host: host + host } } } diff --git a/test/instrumentation/modules/@elastic/elasticsearch.test.js b/test/instrumentation/modules/@elastic/elasticsearch.test.js index c0298f02e5..254f7d713e 100644 --- a/test/instrumentation/modules/@elastic/elasticsearch.test.js +++ b/test/instrumentation/modules/@elastic/elasticsearch.test.js @@ -175,7 +175,7 @@ if (semver.gte(process.version, '10.0.0')) { } const searchOpts = { index: 'myIndex*', - body: body + body } resetAgent(checkDataAndEnd( @@ -246,7 +246,7 @@ if (semver.gte(process.version, '10.0.0')) { } const searchOpts = { index: 'myIndex*', - body: body, + body, size: 2, sort: 'myField:asc' } @@ -329,7 +329,7 @@ if (semver.gte(process.version, '10.0.0')) { const searchOpts = { search_type: 'query_then_fetch', typed_keys: false, - body: body + body } const query = 'search_type=query_then_fetch&typed_keys=false' const statement = body.map(JSON.stringify).join('\n') + '\n' @@ -963,7 +963,7 @@ function checkDataAndEnd (t, expectedName, expectedHttpUrl, expectedStatusCode, const expectedDestination = { address: host.split(':')[0], - port: port, + port, service: { type: '', name: '', resource: 'elasticsearch' } } if (expectedHttpUrl) { diff --git a/test/instrumentation/modules/apollo-server-express.test.js b/test/instrumentation/modules/apollo-server-express.test.js index 1a6da041ea..3baa28371e 100644 --- a/test/instrumentation/modules/apollo-server-express.test.js +++ b/test/instrumentation/modules/apollo-server-express.test.js @@ -64,7 +64,7 @@ test('POST /graphql', function (t) { var port = server.address().port var opts = { method: 'POST', - port: port, + port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } @@ -110,7 +110,7 @@ test('GET /graphql', function (t) { var port = server.address().port var opts = { method: 'GET', - port: port, + port, path: '/graphql?' + query } var req = http.request(opts, function (res) { @@ -155,7 +155,7 @@ test('POST /graphql - named query', function (t) { var port = server.address().port var opts = { method: 'POST', - port: port, + port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } @@ -205,7 +205,7 @@ test('POST /graphql - sort multiple queries', function (t) { var port = server.address().port var opts = { method: 'POST', - port: port, + port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } @@ -270,7 +270,7 @@ test('POST /graphql - sub-query', function (t) { var port = server.address().port var opts = { method: 'POST', - port: port, + port, path: '/graphql', headers: { 'Content-Type': 'application/json' } } diff --git a/test/instrumentation/modules/aws-sdk/dynamodb.test.js b/test/instrumentation/modules/aws-sdk/dynamodb.test.js index e18905e26e..3ba26364dc 100644 --- a/test/instrumentation/modules/aws-sdk/dynamodb.test.js +++ b/test/instrumentation/modules/aws-sdk/dynamodb.test.js @@ -165,7 +165,7 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { t.deepEqual(span.context.service.target, { type: 'dynamodb', name: AWS_REGION }, 'span.context.service.target') t.deepEqual(span.context.destination, { address: 'localhost', - port: port, + port, cloud: { region: AWS_REGION }, service: { type: '', name: '', resource: `dynamodb/${AWS_REGION}` } }, 'span.context.destination') @@ -214,7 +214,7 @@ tape.test('AWS DynamoDB: End to End Test', function (test) { t.deepEqual(span.context.service.target, { type: 'dynamodb', name: AWS_REGION }, 'span.context.service.target') t.deepEqual(span.context.destination, { address: 'localhost', - port: port, + port, cloud: { region: AWS_REGION }, service: { type: '', name: '', resource: `dynamodb/${AWS_REGION}` } }, 'span.context.destination') diff --git a/test/instrumentation/modules/aws-sdk/sns.test.js b/test/instrumentation/modules/aws-sdk/sns.test.js index f54cc516a9..6c4969a09c 100644 --- a/test/instrumentation/modules/aws-sdk/sns.test.js +++ b/test/instrumentation/modules/aws-sdk/sns.test.js @@ -255,7 +255,7 @@ tape.test('AWS SNS: End to End Test', function (test) { 'span.context.service.target') t.deepEquals(span.context.destination, { address: 'localhost', - port: port, + port, cloud: { region: 'us-west-2' }, service: { type: '', name: '', resource: 'sns/topic-name' } }, 'span.context.destination') @@ -323,7 +323,7 @@ tape.test('AWS SNS: End to End Test', function (test) { 'span.context.service.target') t.deepEquals(span.context.destination, { address: 'localhost', - port: port, + port, cloud: { region: 'us-west-2' }, service: { type: '', name: '', resource: 'sns/topic-name' } }, 'span.context.destination') diff --git a/test/instrumentation/modules/elasticsearch.test.js b/test/instrumentation/modules/elasticsearch.test.js index 39860c77e1..9fe00516d3 100644 --- a/test/instrumentation/modules/elasticsearch.test.js +++ b/test/instrumentation/modules/elasticsearch.test.js @@ -37,7 +37,7 @@ test('client.ping with callback', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host }) client.ping(function (err) { t.error(err, 'no error from client.ping') @@ -52,7 +52,7 @@ test('client.ping with promise', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host }) client.ping().then(function () { agent.endTransaction() @@ -68,7 +68,7 @@ test('client.search with callback', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host }) var query = { q: 'pants' } client.search(query, function (err) { @@ -84,7 +84,7 @@ test('client.search with abort', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host }) var query = { q: 'pants' } var req = client.search(query) @@ -121,7 +121,7 @@ if (semver.satisfies(pkg.version, '>= 10')) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host }) client.searchTemplate({ body }, function (err) { t.error(err) @@ -151,7 +151,7 @@ if (semver.satisfies(pkg.version, '>= 13')) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host }) client.msearch({ body }, function (err) { t.error(err) @@ -184,7 +184,7 @@ if (semver.satisfies(pkg.version, '>= 13')) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host }) client.msearchTemplate({ body }, function (err) { t.error(err) @@ -200,7 +200,7 @@ test('client.count with callback', function userLandCode (t) { agent.startTransaction('foo') - var client = new elasticsearch.Client({ host: host }) + var client = new elasticsearch.Client({ host }) client.count(function (err) { t.error(err) agent.endTransaction() @@ -254,7 +254,7 @@ test('client with host=', function userLandCode (t) { agent.startTransaction('foo') const [hostname, port] = host.split(':') var client = new elasticsearch.Client({ - host: [{ host: hostname, port: port }] + host: [{ host: hostname, port }] }) client.ping(function (err) { t.error(err) diff --git a/test/instrumentation/modules/express-queue.test.js b/test/instrumentation/modules/express-queue.test.js index 9d7700f6e2..ae894b739c 100644 --- a/test/instrumentation/modules/express-queue.test.js +++ b/test/instrumentation/modules/express-queue.test.js @@ -65,8 +65,8 @@ function request (port, path) { return new Promise((resolve, reject) => { var opts = { method: 'GET', - port: port, - path: path, + port, + path, headers: { 'Content-Type': 'application/json' } diff --git a/test/instrumentation/modules/graphql.test.js b/test/instrumentation/modules/graphql.test.js index 4163f0d126..6f2ae369ea 100644 --- a/test/instrumentation/modules/graphql.test.js +++ b/test/instrumentation/modules/graphql.test.js @@ -211,9 +211,9 @@ if (!onlySupportsPositionalArgs) { var source = new graphql.Source(query) var documentAST = graphql.parse(source) var args = { - schema: schema, + schema, document: documentAST, - rootValue: rootValue + rootValue } agent.startTransaction('foo') diff --git a/test/instrumentation/modules/http/basic.test.js b/test/instrumentation/modules/http/basic.test.js index 1ab6ba8e34..b8b2194495 100644 --- a/test/instrumentation/modules/http/basic.test.js +++ b/test/instrumentation/modules/http/basic.test.js @@ -127,10 +127,10 @@ function sendRequest (server, timeout, useElasticHeader) { var req = http.request({ hostname: 'localhost', - port: port, + port, path: '/', method: 'GET', - headers: headers + headers }, function (res) { if (timeout) throw new Error('should not get to here') res.resume() diff --git a/test/instrumentation/modules/http/github-179.test.js b/test/instrumentation/modules/http/github-179.test.js index 05f69c55e5..7e05753e78 100644 --- a/test/instrumentation/modules/http/github-179.test.js +++ b/test/instrumentation/modules/http/github-179.test.js @@ -25,7 +25,7 @@ var echoServer = require('./_echo_server_util').echoServer test('https://github.com/opbeat/opbeat-node/issues/179', function (t) { echoServer(function (cp, port) { var opts = { - port: port, + port, headers: { 'Accept-Encoding': 'gzip' } } diff --git a/test/instrumentation/modules/http/ignoring.test.js b/test/instrumentation/modules/http/ignoring.test.js index ebd1567fae..c130a40f35 100644 --- a/test/instrumentation/modules/http/ignoring.test.js +++ b/test/instrumentation/modules/http/ignoring.test.js @@ -144,8 +144,8 @@ function request (path, headers, cb) { server.listen(function () { var opts = { port: server.address().port, - path: path, - headers: headers + path, + headers } http.request(opts, function (res) { res.on('end', function () { diff --git a/test/instrumentation/modules/http/sse.test.js b/test/instrumentation/modules/http/sse.test.js index 741e390103..ef2a9141c8 100644 --- a/test/instrumentation/modules/http/sse.test.js +++ b/test/instrumentation/modules/http/sse.test.js @@ -102,7 +102,7 @@ function assertSSEResponse (t, data) { function request (server) { server.listen(function () { var port = server.address().port - http.request({ port: port }, function (res) { + http.request({ port }, function (res) { res.on('end', function () { server.close() }) diff --git a/test/instrumentation/modules/http2.test.js b/test/instrumentation/modules/http2.test.js index e2b549fabb..0d27bfac92 100644 --- a/test/instrumentation/modules/http2.test.js +++ b/test/instrumentation/modules/http2.test.js @@ -467,7 +467,7 @@ test('handling HTTP/1.1 request to http2.createSecureServer with allowHTTP1:true agent: new https.Agent(), protocol: 'https:', host: 'localhost', - port: port, + port, path: '/', ALPNProtocols: ['http/1.1'], rejectUnauthorized: false diff --git a/test/instrumentation/modules/mysql/mysql.test.js b/test/instrumentation/modules/mysql/mysql.test.js index bd63205649..b0b98cd04f 100644 --- a/test/instrumentation/modules/mysql/mysql.test.js +++ b/test/instrumentation/modules/mysql/mysql.test.js @@ -88,7 +88,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - queryable.query({ sql: sql }, basicQueryCallback(t)) + queryable.query({ sql }, basicQueryCallback(t)) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') }) }) @@ -101,7 +101,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - queryable.query({ sql: sql }, [1], basicQueryCallback(t)) + queryable.query({ sql }, [1], basicQueryCallback(t)) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') }) }) @@ -192,7 +192,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + 1 AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query({ sql: sql }) + var stream = queryable.query({ sql }) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) @@ -206,7 +206,7 @@ factories.forEach(function (f) { var sql = 'SELECT 1 + ? AS solution' factory(function () { agent.startTransaction('foo') - var stream = queryable.query({ sql: sql }, [1]) + var stream = queryable.query({ sql }, [1]) t.equal(agent.currentSpan, null, 'mysql span should not bleed into calling code') basicQueryStream(stream, t) }) diff --git a/test/opentelemetry-bridge/fixtures/createSpan-returns-null.js b/test/opentelemetry-bridge/fixtures/createSpan-returns-null.js index 0fb2074cf4..a85870bf77 100644 --- a/test/opentelemetry-bridge/fixtures/createSpan-returns-null.js +++ b/test/opentelemetry-bridge/fixtures/createSpan-returns-null.js @@ -50,7 +50,7 @@ async function makeAClientRequest (port) { return new Promise(resolve => { http.get({ host: 'localhost', - port: port, + port, path: '/ping' }, (cRes) => { console.log('client response status:', cRes.statusCode) diff --git a/test/stacktraces/stacktraces.test.js b/test/stacktraces/stacktraces.test.js index 041eb5e956..ae03adb280 100644 --- a/test/stacktraces/stacktraces.test.js +++ b/test/stacktraces/stacktraces.test.js @@ -293,7 +293,7 @@ tape.test('stackTraceFromErrStackString()', function (t) { { filename: path.relative(process.cwd(), __filename), function: 'theFunction', - lineno: lineno, + lineno, library_frame: false, abs_path: __filename }, @@ -387,7 +387,7 @@ tape.test('gatherStackTrace()', function (suite) { gatherStackTrace(log, err, c.lines, c.lines, null, function (_, stacktrace) { const expectedTopFrame = { filename: path.relative(process.cwd(), __filename), - lineno: lineno, + lineno, function: 'thisIsMyFunction', library_frame: false, abs_path: __filename, diff --git a/test/transaction-sampling.test.js b/test/transaction-sampling.test.js index 03aa6476e1..27ff9bbf08 100644 --- a/test/transaction-sampling.test.js +++ b/test/transaction-sampling.test.js @@ -36,7 +36,7 @@ tape.test('various transactionSampleRate values', function (t) { )) var results = { - count: count, + count, numSampled: 0, numUnsampled: 0 } From 44b29cc75d270e2cf1c6aef1b312d87aaa3a317f Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 27 Jun 2023 14:25:14 -0700 Subject: [PATCH 4/4] also we can stop skipping these files with top-level await now that we are on eslint@8 --- .eslintrc.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 27f8fd03a3..2f98e99168 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -41,10 +41,6 @@ "/test/types/transpile/index.js", "/test/types/transpile-default/index.js", "/test_output", - "tmp", - // These files use top-level await, which is *fine* for ESM files but, IIUC, - // not supported by eslint until v8. - "/test/instrumentation/modules/fixtures/use-fastify.mjs", - "/test/instrumentation/modules/http/fixtures/use-dynamic-import.mjs" + "tmp" ] }