Skip to content

Commit 3000188

Browse files
authored
fix: correct dev-deps required for the recent eslint@8 upgrade (#3449)
The upgrade to eslint@8 in #3409 subtly broke 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" }, Also: - eslint-plugin-node (unmaintained) is replaced by "eslint-plugin-n" - eslint-config-standard@17 added https://eslint.org/docs/latest/rules/object-shorthand as a warning. It'll become "error" in a subsequent major. - eslint@8 means support for top-level await, so there are some files we no longer need to skip
1 parent 1da91fe commit 3000188

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+273
-181
lines changed

.eslintrc.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
"/test/types/transpile/index.js",
4242
"/test/types/transpile-default/index.js",
4343
"/test_output",
44-
"tmp",
45-
// These files use top-level await, which is *fine* for ESM files but, IIUC,
46-
// not supported by eslint until v8.
47-
"/test/instrumentation/modules/fixtures/use-fastify.mjs",
48-
"/test/instrumentation/modules/http/fixtures/use-dynamic-import.mjs"
44+
"tmp"
4945
]
5046
}

dev-utils/bitrot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ const options = [
351351
]
352352

353353
function main (argv) {
354-
var parser = dashdash.createParser({ options: options })
354+
var parser = dashdash.createParser({ options })
355355
try {
356356
var opts = parser.parse(argv)
357357
} catch (e) {

lib/agent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ Agent.prototype.captureError = function (err, opts, cb) {
610610

611611
errors.createAPMError({
612612
log: agent.logger,
613-
id: id,
613+
id,
614614
exception: errIsError ? err : null,
615615
logMessage: errIsError ? null : err,
616616
shouldCaptureAttributes,

lib/http-request.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ function main (argv) {
207207
const timeout = Number(argv[4])
208208

209209
var req = httpRequest(url, {
210-
timeout: timeout,
211-
connectTimeout: connectTimeout
210+
timeout,
211+
connectTimeout
212212
// TODO: log support
213213
}, function onRes (res) {
214214
res.pipe(process.stdout)

lib/instrumentation/dropped-spans-stats.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class DroppedSpansStats {
6060
}
6161
},
6262
destination_service_resource: resource,
63-
outcome: outcome
63+
outcome
6464
}
6565
if (serviceTargetType) {
6666
stats.service_target_type = serviceTargetType

lib/instrumentation/http-shared.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ exports.instrumentRequest = function (agent, moduleName) {
9999
const tracestate = req.headers.tracestate
100100
const trans = agent.startTransaction(null, null, {
101101
childOf: traceparent,
102-
tracestate: tracestate
102+
tracestate
103103
})
104104
trans.type = 'request'
105105
trans.req = req
@@ -186,7 +186,7 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) {
186186
const parentRunContext = ins.currRunContext()
187187
var span = ins.createSpan(null, 'external', 'http', { exitSpan: true })
188188
var id = span && span.transaction.id
189-
agent.logger.debug('intercepted call to %s.%s %o', moduleName, method, { id: id })
189+
agent.logger.debug('intercepted call to %s.%s %o', moduleName, method, { id })
190190

191191
// Reproduce the argument handling from node/lib/_http_client.js#ClientRequest().
192192
//
@@ -261,7 +261,7 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) {
261261
var req = ins.withRunContext(spanRunContext, orig, this, ...newArgs)
262262

263263
var protocol = req.agent && req.agent.protocol
264-
agent.logger.debug('request details: %o', { protocol: protocol, host: getSafeHost(req), id: id })
264+
agent.logger.debug('request details: %o', { protocol, host: getSafeHost(req), id })
265265

266266
ins.bindEmitter(req)
267267

@@ -280,15 +280,15 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) {
280280

281281
const url = getUrlFromRequestAndOptions(req, options, moduleName + ':')
282282
if (!url) {
283-
agent.logger.warn('unable to identify http.ClientRequest url %o', { id: id })
283+
agent.logger.warn('unable to identify http.ClientRequest url %o', { id })
284284
}
285285
let statusCode
286286
return req
287287

288288
// In case the request is ended prematurely
289289
function onAbort (type) {
290290
if (span.ended) return
291-
agent.logger.debug('intercepted http.ClientRequest abort event %o', { id: id })
291+
agent.logger.debug('intercepted http.ClientRequest abort event %o', { id })
292292

293293
onEnd()
294294
}
@@ -319,11 +319,11 @@ exports.traceOutgoingRequest = function (agent, moduleName, method) {
319319
}
320320

321321
function onResponse (res) {
322-
agent.logger.debug('intercepted http.ClientRequest response event %o', { id: id })
322+
agent.logger.debug('intercepted http.ClientRequest response event %o', { id })
323323
ins.bindEmitterToRunContext(parentRunContext, res)
324324
statusCode = res.statusCode
325325
res.prependListener('end', function () {
326-
agent.logger.debug('intercepted http.IncomingMessage end event %o', { id: id })
326+
agent.logger.debug('intercepted http.IncomingMessage end event %o', { id })
327327
onEnd()
328328
})
329329
}

lib/instrumentation/modules/@aws-sdk/client-s3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function s3MiddlewareFactory (client, agent) {
192192
context[elasticAPMStash] = {
193193
protocol: req.protocol,
194194
hostname: req.hostname,
195-
port: port
195+
port
196196
}
197197
return next(args)
198198
},

lib/instrumentation/modules/elasticsearch.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = function (elasticsearch, agent, { enabled }) {
8181
var method = params && params.method
8282
var path = params && params.path
8383

84-
agent.logger.debug('intercepted call to elasticsearch.Transport.prototype.request %o', { id: id, method: method, path: path })
84+
agent.logger.debug('intercepted call to elasticsearch.Transport.prototype.request %o', { id, method, path })
8585

8686
if (span && method && path) {
8787
span.name = `Elasticsearch: ${method} ${path}`
@@ -145,7 +145,7 @@ module.exports = function (elasticsearch, agent, { enabled }) {
145145
shimmer.wrap(inspectedPromise, 'abort', function wrapAbort (originalAbort) {
146146
return function wrappedAbort () {
147147
if (span.ended) return
148-
agent.logger.debug('intercepted call to elasticsearch.Transport.request.abort %o', { id: id, method: method, path: path })
148+
agent.logger.debug('intercepted call to elasticsearch.Transport.request.abort %o', { id, method, path })
149149
const originalReturn = originalAbort.apply(this, args)
150150
span.end()
151151
return originalReturn
@@ -155,7 +155,7 @@ module.exports = function (elasticsearch, agent, { enabled }) {
155155
return inspectedPromise
156156
}
157157
} else {
158-
agent.logger.debug('could not instrument elasticsearch request %o', { id: id })
158+
agent.logger.debug('could not instrument elasticsearch request %o', { id })
159159
return original.apply(this, arguments)
160160
}
161161
}

lib/instrumentation/modules/generic-pool.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function (generic, agent, { version }) {
1717
return function wrappedPool () {
1818
var trans = agent._instrumentation.currTransaction()
1919
var id = trans && trans.id
20-
agent.logger.debug('intercepted call to generic-pool.Pool %o', { id: id })
20+
agent.logger.debug('intercepted call to generic-pool.Pool %o', { id })
2121

2222
var pool
2323
if (this instanceof generic.Pool) {
@@ -32,7 +32,7 @@ module.exports = function (generic, agent, { version }) {
3232
return function wrappedAcquire () {
3333
var trans = agent._instrumentation.currTransaction()
3434
var id = trans && trans.id
35-
agent.logger.debug('intercepted call to pool.acquire %o', { id: id })
35+
agent.logger.debug('intercepted call to pool.acquire %o', { id })
3636

3737
var cb = arguments[0]
3838
if (typeof cb === 'function') {
@@ -59,7 +59,7 @@ module.exports = function (generic, agent, { version }) {
5959
return function wrappedEnqueue () {
6060
var trans = agent._instrumentation.currTransaction()
6161
var id = trans && trans.id
62-
agent.logger.debug('intercepted call to generic-pool.PriorityQueue.prototype.enqueue %o', { id: id })
62+
agent.logger.debug('intercepted call to generic-pool.PriorityQueue.prototype.enqueue %o', { id })
6363

6464
var obj = arguments[0]
6565
// Expect obj to of type Deferred

lib/instrumentation/modules/graphql.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,6 @@ module.exports = function (graphql, agent, { version, enabled }) {
202202
agent.logger.debug('unexpected document format - skipping graphql query extraction')
203203
}
204204

205-
return { queries: queries, operation: operation }
205+
return { queries, operation }
206206
}
207207
}

lib/instrumentation/modules/http2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module.exports = function (http2, agent, { enabled }) {
113113
const tracestate = req.headers.tracestate
114114
const trans = agent.startTransaction(null, null, {
115115
childOf: traceparent,
116-
tracestate: tracestate
116+
tracestate
117117
})
118118
trans.type = 'request'
119119
trans.req = req

lib/instrumentation/modules/mongodb-core.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = function (mongodb, agent, { version, enabled }) {
4545
var id = trans && trans.id
4646
var span
4747

48-
agent.logger.debug('intercepted call to mongodb-core.Server.prototype.command %o', { id: id, ns: ns })
48+
agent.logger.debug('intercepted call to mongodb-core.Server.prototype.command %o', { id, ns })
4949

5050
if (trans && arguments.length > 0) {
5151
var index = arguments.length - 1
@@ -69,7 +69,7 @@ module.exports = function (mongodb, agent, { version, enabled }) {
6969
return orig.apply(this, arguments)
7070

7171
function wrappedCallback (_err, commandResult) {
72-
agent.logger.debug('intercepted mongodb-core.Server.prototype.command callback %o', { id: id })
72+
agent.logger.debug('intercepted mongodb-core.Server.prototype.command callback %o', { id })
7373
if (commandResult && commandResult.connection) {
7474
span._setDestinationContext(getDBDestination(
7575
commandResult.connection.host, commandResult.connection.port))
@@ -86,7 +86,7 @@ module.exports = function (mongodb, agent, { version, enabled }) {
8686
var id = trans && trans.id
8787
var span
8888

89-
agent.logger.debug('intercepted call to mongodb-core.Server.prototype.%s %o', name, { id: id, ns: ns })
89+
agent.logger.debug('intercepted call to mongodb-core.Server.prototype.%s %o', name, { id, ns })
9090

9191
if (trans && arguments.length > 0) {
9292
var index = arguments.length - 1
@@ -103,7 +103,7 @@ module.exports = function (mongodb, agent, { version, enabled }) {
103103
return orig.apply(this, arguments)
104104

105105
function wrappedCallback (_err, commandResult) {
106-
agent.logger.debug('intercepted mongodb-core.Server.prototype.%s callback %o', name, { id: id })
106+
agent.logger.debug('intercepted mongodb-core.Server.prototype.%s callback %o', name, { id })
107107
if (commandResult && commandResult.connection) {
108108
span._setDestinationContext(getDBDestination(
109109
commandResult.connection.host, commandResult.connection.port))
@@ -119,7 +119,7 @@ module.exports = function (mongodb, agent, { version, enabled }) {
119119
var id = trans && trans.id
120120
var span
121121

122-
agent.logger.debug('intercepted call to mongodb-core.Cursor.prototype.%s %o', name, { id: id })
122+
agent.logger.debug('intercepted call to mongodb-core.Cursor.prototype.%s %o', name, { id })
123123

124124
if (trans && arguments.length > 0) {
125125
var cb = arguments[0]
@@ -143,7 +143,7 @@ module.exports = function (mongodb, agent, { version, enabled }) {
143143
return orig.apply(this, arguments)
144144

145145
function wrappedCallback () {
146-
agent.logger.debug('intercepted mongodb-core.Cursor.prototype.%s callback %o', name, { id: id })
146+
agent.logger.debug('intercepted mongodb-core.Cursor.prototype.%s callback %o', name, { id })
147147
span.end()
148148
return cb.apply(this, arguments)
149149
}

lib/instrumentation/modules/mysql.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = function (mysql, agent, { version, enabled }) {
8181
var cb = arguments[0]
8282

8383
if (typeof cb === 'function') {
84-
arguments[0] = agent._instrumentation.bindFunction(function wrapedCallback (err, connection) { // eslint-disable-line node/handle-callback-err
84+
arguments[0] = agent._instrumentation.bindFunction(function wrapedCallback (err, connection) { // eslint-disable-line n/handle-callback-err
8585
if (connection) wrapQueryable(connection, 'getConnection() > connection', agent)
8686
return cb.apply(this, arguments)
8787
})

lib/instrumentation/modules/redis.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = function (redis, agent, { version, enabled }) {
7979
}
8080

8181
const command = commandObj.command
82-
agent.logger.debug({ command: command }, 'intercepted call to RedisClient.prototype.internal_send_command')
82+
agent.logger.debug({ command }, 'intercepted call to RedisClient.prototype.internal_send_command')
8383
const span = ins.createSpan(command.toUpperCase(), TYPE, SUBTYPE, ACTION, { exitSpan: true })
8484
if (!span) {
8585
return original.apply(this, arguments)
@@ -112,7 +112,7 @@ module.exports = function (redis, agent, { version, enabled }) {
112112
return original.apply(this, arguments)
113113
}
114114

115-
agent.logger.debug({ command: command }, 'intercepted call to RedisClient.prototype.send_command')
115+
agent.logger.debug({ command }, 'intercepted call to RedisClient.prototype.send_command')
116116
var span = ins.createSpan(command.toUpperCase(), TYPE, SUBTYPE, ACTION, { exitSpan: true })
117117
if (!span) {
118118
return original.apply(this, arguments)

lib/instrumentation/patch-async.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ module.exports = function (ins) {
303303
}
304304

305305
// only wrap lchown and lchmod on systems that have them.
306-
if (fs.lchown) wrap(fs, 'lchown', activator) // eslint-disable-line node/no-deprecated-api
307-
if (fs.lchmod) wrap(fs, 'lchmod', activator) // eslint-disable-line node/no-deprecated-api
306+
if (fs.lchown) wrap(fs, 'lchown', activator) // eslint-disable-line n/no-deprecated-api
307+
if (fs.lchmod) wrap(fs, 'lchmod', activator) // eslint-disable-line n/no-deprecated-api
308308

309309
// only wrap ftruncate in versions of node that have it
310310
if (fs.ftruncate) wrap(fs, 'ftruncate', activator)

lib/instrumentation/template-shared.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ exports.wrapCompile = function (agent, moduleName) {
1313
var id = span && span.transaction.id
1414

1515
agent.logger.debug('intercepted call to %s render %o', moduleName, {
16-
id: id,
17-
data: data
16+
id,
17+
data
1818
})
1919

2020
var ret = original.apply(this, arguments)
@@ -30,8 +30,8 @@ exports.wrapCompile = function (agent, moduleName) {
3030
var id = span && span.transaction.id
3131

3232
agent.logger.debug('intercepted call to %s compile %o', moduleName, {
33-
id: id,
34-
input: input
33+
id,
34+
input
3535
})
3636

3737
var ret = original.apply(this, arguments)

lib/instrumentation/transaction.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Object.defineProperty(Transaction.prototype, 'name', {
120120
this._agent.logger.debug('tried to set transaction.name on already ended transaction %o', { trans: this.id, parent: this.parentId, trace: this.traceId })
121121
return
122122
}
123-
this._agent.logger.debug('setting transaction name %o', { trans: this.id, parent: this.parentId, trace: this.traceId, name: name })
123+
this._agent.logger.debug('setting transaction name %o', { trans: this.id, parent: this.parentId, trace: this.traceId, name })
124124
this._customName = name
125125
}
126126
})
@@ -136,7 +136,7 @@ Object.defineProperty(Transaction.prototype, 'result', {
136136
this._agent.logger.debug('tried to set transaction.result on already ended transaction %o', { trans: this.id, parent: this.parentId, trace: this.traceId })
137137
return
138138
}
139-
this._agent.logger.debug('setting transaction result %o', { trans: this.id, parent: this.parentId, trace: this.traceId, result: result })
139+
this._agent.logger.debug('setting transaction result %o', { trans: this.id, parent: this.parentId, trace: this.traceId, result })
140140
this._result = result
141141
}
142142
})

lib/lambda.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ function setSnsData (agent, trans, event, context, faasId, isColdStart) {
391391
const cloudContext = {
392392
origin: {
393393
provider: 'aws',
394-
region: region,
394+
region,
395395
service: {
396396
name: 'sns'
397397
},
@@ -625,7 +625,7 @@ function elasticApmAwsLambda (agent) {
625625
// Start the transaction and set some possibly trigger-specific data.
626626
const trans = agent.startTransaction(context.functionName, type, {
627627
childOf: traceparent,
628-
tracestate: tracestate
628+
tracestate
629629
})
630630
switch (triggerType) {
631631
case TRIGGER_API_GATEWAY:

lib/logging.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function createLogger (levelName, customLogger) {
129129
}
130130

131131
return customLogger.child({
132-
serializers: serializers
132+
serializers
133133
})
134134
}
135135

@@ -150,7 +150,7 @@ function createLogger (levelName, customLogger) {
150150
name: 'elastic-apm-node',
151151
base: {}, // Don't want pid and hostname fields.
152152
level: pinoLevel,
153-
serializers: serializers,
153+
serializers,
154154
...ecsFormat({ apmIntegration: false })
155155
}, dest)
156156

@@ -175,8 +175,8 @@ function setLogLevel (logger, levelName) {
175175
}
176176

177177
module.exports = {
178-
DEFAULT_LOG_LEVEL: DEFAULT_LOG_LEVEL,
179-
createLogger: createLogger,
180-
isLoggerCustom: isLoggerCustom,
181-
setLogLevel: setLogLevel
178+
DEFAULT_LOG_LEVEL,
179+
createLogger,
180+
isLoggerCustom,
181+
setLogLevel
182182
}

lib/stacktraces.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ function frameFromCallSite (log, callsite, cwd, sourceLinesAppFrames, sourceLine
306306
let mappedLineno = null
307307

308308
if (sourceMapErr) {
309-
log.debug({ filename: filename, err: sourceMapErr },
309+
log.debug({ filename, err: sourceMapErr },
310310
'could not process file source map')
311311
} else if (sourceMapConsumer) {
312312
let pos
@@ -316,7 +316,7 @@ function frameFromCallSite (log, callsite, cwd, sourceLinesAppFrames, sourceLine
316316
column: callsite.getColumnNumber()
317317
})
318318
} catch (posErr) {
319-
log.debug({ filename: filename, line: lineno, err: sourceMapErr },
319+
log.debug({ filename, line: lineno, err: sourceMapErr },
320320
'could not get position from sourcemap')
321321
pos = {
322322
source: null,

0 commit comments

Comments
 (0)