Skip to content

Commit 1727021

Browse files
committed
chore lint auto fixes
1 parent 34225c7 commit 1727021

File tree

182 files changed

+1960
-1960
lines changed

Some content is hidden

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

182 files changed

+1960
-1960
lines changed

dev-utils/bitrot.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function saveCache () {
8282
// - Bad: blue (not visible on cmd.exe), grey (same color as background on
8383
// Solarized Dark theme from <https://github.com/altercation/solarized>, see
8484
// issue #160)
85-
var colors = {
85+
const colors = {
8686
bold: [1, 22],
8787
italic: [3, 23],
8888
underline: [4, 24],
@@ -100,7 +100,7 @@ var colors = {
100100

101101
function stylizeWithColor (str, color) {
102102
if (!str) { return '' }
103-
var codes = colors[color]
103+
const codes = colors[color]
104104
if (codes) {
105105
return '\x1B[' + codes[0] + 'm' + str + '\x1B[' + codes[1] + 'm'
106106
} else {
@@ -131,9 +131,9 @@ function rot (moduleName, s) {
131131
// I see in supported-technologies.asciidoc.
132132
function loadSupportedDoc () {
133133
const docPath = 'docs/supported-technologies.asciidoc'
134-
var html = fs.readFileSync(docPath, 'utf8')
135-
var rows = []
136-
var state = null // null | 'thead' | 'tbody'
134+
const html = fs.readFileSync(docPath, 'utf8')
135+
const rows = []
136+
let state = null // null | 'thead' | 'tbody'
137137
html.split(/\n/g).forEach(function (line) {
138138
if (!line.startsWith('|')) {
139139
// no op
@@ -150,8 +150,8 @@ function loadSupportedDoc () {
150150
// Examples:
151151
// |https://www.npmjs.com/package/generic-pool[generic-pool] | ^2.0.0 \|\| ^3.1.0 |Used by a lot of ...
152152
// |https://www.npmjs.com/package/bluebird[bluebird] |>=2.0.0 <4.0.0 |
153-
var escapePlaceholder = '6B1EC7E1-B273-40E9-94C4-197A59B55E24'
154-
var cells = line
153+
const escapePlaceholder = '6B1EC7E1-B273-40E9-94C4-197A59B55E24'
154+
const cells = line
155155
.trim()
156156
.slice(1) // remove leading '|'
157157
.replace(/\\\|/g, escapePlaceholder)
@@ -177,7 +177,7 @@ function loadSupportedDoc () {
177177
// The entries in the "Frameworks" table use the names of internal links in
178178
// these docs. The anchor name is *sometimes* the same name as the npm
179179
// module, but sometimes not.
180-
var results = []
180+
const results = []
181181
let match
182182
rows.forEach(function (row) {
183183
if (row[1] === 'N/A') {
@@ -187,7 +187,7 @@ function loadSupportedDoc () {
187187
if (!match) {
188188
throw new Error(`could not parse this table cell text from docs/supported-technologies.asciidoc: ${JSON.stringify(row[0])}`)
189189
}
190-
var moduleNames
190+
let moduleNames
191191
if (match[1] === 'nextjs') {
192192
moduleNames = ['next']
193193
} else if (match[2] === '@hapi/hapi') {
@@ -246,24 +246,24 @@ function getNpmInfo (name) {
246246

247247
function bitrot (moduleNames) {
248248
log.debug({ moduleNames }, 'bitrot')
249-
var tavYmls = [
249+
const tavYmls = [
250250
yaml.load(fs.readFileSync('.tav.yml', 'utf8')),
251251
yaml.load(fs.readFileSync('./test/opentelemetry-bridge/.tav.yml', 'utf8')),
252252
yaml.load(fs.readFileSync('./test/opentelemetry-metrics/fixtures/.tav.yml', 'utf8')),
253253
yaml.load(fs.readFileSync('test/instrumentation/modules/next/a-nextjs-app/.tav.yml', 'utf8'))
254254
]
255-
var supported = loadSupportedDoc()
255+
const supported = loadSupportedDoc()
256256

257257
// Merge into one data structure we can iterate through.
258-
var rangesFromName = {}
259-
var ensureKey = (name) => {
258+
const rangesFromName = {}
259+
const ensureKey = (name) => {
260260
if (!(name in rangesFromName)) {
261261
rangesFromName[name] = { tavRanges: [], supRanges: [] }
262262
}
263263
}
264264
tavYmls.forEach(tavYml => {
265265
for (const [label, tavInfo] of Object.entries(tavYml)) {
266-
var name = tavInfo.name || label
266+
const name = tavInfo.name || label
267267
ensureKey(name)
268268
rangesFromName[name].tavRanges.push(tavInfo.versions)
269269
}
@@ -275,7 +275,7 @@ function bitrot (moduleNames) {
275275

276276
// Reduce to `moduleNames` if given.
277277
if (moduleNames && moduleNames.length > 0) {
278-
var allNames = Object.keys(rangesFromName)
278+
const allNames = Object.keys(rangesFromName)
279279
moduleNames.forEach(name => {
280280
if (!(name in rangesFromName)) {
281281
throw new Error(`unknown module name: ${name} (known module names: ${allNames.join(', ')})`)
@@ -290,15 +290,15 @@ function bitrot (moduleNames) {
290290
log.debug({ rangesFromName }, 'rangesFromName')
291291

292292
// Check each module name.
293-
var namesToCheck = Object.keys(rangesFromName).sort()
293+
const namesToCheck = Object.keys(rangesFromName).sort()
294294
namesToCheck.forEach(name => {
295-
var npmInfo = getNpmInfo(name)
295+
const npmInfo = getNpmInfo(name)
296296
log.trace({ name, 'dist-tags': npmInfo['dist-tags'], time: npmInfo.time }, 'npmInfo')
297297

298298
// If the current latest version is in the supported and
299299
// tav ranges, then all is good.
300-
var latest = npmInfo['dist-tags'].latest
301-
var tavGood = false
300+
const latest = npmInfo['dist-tags'].latest
301+
let tavGood = false
302302
if (EXCUSE_FROM_TAV[name]) {
303303
tavGood = true
304304
} else {
@@ -309,7 +309,7 @@ function bitrot (moduleNames) {
309309
}
310310
}
311311
}
312-
var supGood = false
312+
let supGood = false
313313
if (EXCUSE_FROM_SUPPORTED_TECHNOLOGIES_DOC[name]) {
314314
supGood = true
315315
} else {
@@ -324,7 +324,7 @@ function bitrot (moduleNames) {
324324
log.debug(`latest ${name}@${latest} is in tav and supported ranges (a good thing)`)
325325
return
326326
}
327-
var issues = []
327+
const issues = []
328328
if (!tavGood) {
329329
issues.push(`is not in .tav.yml ranges (${rangesFromName[name].tavRanges.join(', ')})`)
330330
}
@@ -351,15 +351,15 @@ const options = [
351351
]
352352

353353
function main (argv) {
354-
var parser = dashdash.createParser({ options: options })
354+
const parser = dashdash.createParser({ options: options })
355355
try {
356356
var opts = parser.parse(argv)
357357
} catch (e) {
358358
console.error('help: error: %s', e.message)
359359
process.exit(1)
360360
}
361361
if (opts.help) {
362-
var help = parser.help().trimRight()
362+
const help = parser.help().trimRight()
363363
process.stdout.write(`Synopsis:
364364
dev-utils/bitrot.js [OPTIONS]
365365

examples/trace-graphql.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
const apm = require('../').start({ // elastic-apm-node
1111
serviceName: 'example-trace-graphql'
1212
})
13-
var { graphql, buildSchema } = require('graphql')
13+
const { graphql, buildSchema } = require('graphql')
1414

1515
// Construct a schema, using GraphQL schema language
16-
var schema = buildSchema(`
16+
const schema = buildSchema(`
1717
type Query {
1818
hello: String
1919
bye: String
2020
}
2121
`)
2222

2323
// The root provides a resolver function for each API endpoint
24-
var root = {
24+
const root = {
2525
hello: () => {
2626
return 'Hello world!'
2727
},

examples/trace-handlebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const handlebars = require('handlebars')
2121
// https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html
2222
const t1 = apm.startTransaction('t1')
2323

24-
var template = handlebars.compile('Hello, {{name}}!')
24+
const template = handlebars.compile('Hello, {{name}}!')
2525
console.log(template({ name: 'world' }))
2626
console.log(template({ name: 'Bob' }))
2727

examples/trace-pg.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ client.query('SELECT $1::text as message', ['bye'], (err, res) => {
4343

4444
// 2. Using streaming style, i.e. using a `Submittable` as node-postgres calls it.
4545
const t2 = apm.startTransaction('t2')
46-
var q = client.query(new Query('select 1 + 1 as solution'))
46+
const q = client.query(new Query('select 1 + 1 as solution'))
4747
q.on('error', (err) => {
4848
console.log('[t2] Failure: err is', err)
4949
t2.end()

examples/trace-pug.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const pug = require('pug')
2121
// https://www.elastic.co/guide/en/apm/agent/nodejs/current/custom-transactions.html
2222
const t1 = apm.startTransaction('t1')
2323

24-
var template = pug.compile('p Hello, #{name}!')
24+
const template = pug.compile('p Hello, #{name}!')
2525
console.log(template({ name: 'world' }))
2626
console.log(template({ name: 'Bob' }))
2727

examples/trace-tedious.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const conn2 = new tedious.Connection(connOpts)
6565
conn2.on('connect', onConnect2)
6666
conn2.connect()
6767
function onConnect2 () {
68-
var req = new tedious.Request("select @mynum=42, @mystr='qaz'", function (err, rowCount) {
68+
const req = new tedious.Request("select @mynum=42, @mystr='qaz'", function (err, rowCount) {
6969
console.log('select @mynum ...: err=%s rowCount=%s', err && err.message, rowCount)
7070
conn2.close()
7171
})

examples/trace-ws.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const apm = require('../').start({ // elastic-apm-node
2020
serviceName: 'example-trace-ws'
2121
})
2222

23-
var WebSocket = require('ws')
24-
var PORT = 4567
23+
const WebSocket = require('ws')
24+
const PORT = 4567
2525

2626
// Server
2727
const wss = new WebSocket.Server({ port: PORT })

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
'use strict'
88

9-
var Agent = require('./lib/agent')
9+
const Agent = require('./lib/agent')
1010

1111
module.exports = new Agent()

lib/activation-method.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const path = require('path')
1111
const errorStackParser = require('error-stack-parser')
1212
const semver = require('semver')
1313

14-
var { isLambdaExecutionEnvironment } = require('./lambda')
14+
const { isLambdaExecutionEnvironment } = require('./lambda')
1515

1616
const CONTAINS_R_ELASTIC_APM_NODE_START = /(-r\s+|--require\s*=?\s*).*elastic-apm-node\/start/
1717

lib/agent.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Agent.prototype.start = function (opts) {
251251
// Attempt to load package.json from process.argv.
252252
let pkg = null
253253
try {
254-
var basedir = path.dirname(process.argv[1] || '.')
254+
const basedir = path.dirname(process.argv[1] || '.')
255255
pkg = require(path.join(basedir, 'package.json'))
256256
} catch (e) {}
257257

@@ -343,14 +343,14 @@ Agent.prototype.setFramework = function ({ name, version, overwrite = true }) {
343343
}
344344

345345
Agent.prototype.setUserContext = function (context) {
346-
var trans = this._instrumentation.currTransaction()
346+
const trans = this._instrumentation.currTransaction()
347347
if (!trans) return false
348348
trans.setUserContext(context)
349349
return true
350350
}
351351

352352
Agent.prototype.setCustomContext = function (context) {
353-
var trans = this._instrumentation.currTransaction()
353+
const trans = this._instrumentation.currTransaction()
354354
if (!trans) return false
355355
trans.setCustomContext(context)
356356
return true
@@ -373,13 +373,13 @@ Agent.prototype.setGlobalLabel = function (key, value) {
373373
}
374374

375375
Agent.prototype.setLabel = function (key, value, stringify) {
376-
var trans = this._instrumentation.currTransaction()
376+
const trans = this._instrumentation.currTransaction()
377377
if (!trans) return false
378378
return trans.setLabel(key, value, stringify)
379379
}
380380

381381
Agent.prototype.addLabels = function (labels, stringify) {
382-
var trans = this._instrumentation.currTransaction()
382+
const trans = this._instrumentation.currTransaction()
383383
if (!trans) return false
384384
return trans.addLabels(labels, stringify)
385385
}
@@ -661,7 +661,7 @@ Agent.prototype.captureError = function (err, opts, cb) {
661661
// automatically terminate the process, so if you provide a callback you must
662662
// remember to terminate the process manually.
663663
Agent.prototype.handleUncaughtExceptions = function (cb) {
664-
var agent = this
664+
const agent = this
665665

666666
if (this._uncaughtExceptionListener) {
667667
process.removeListener('uncaughtException', this._uncaughtExceptionListener)
@@ -793,7 +793,7 @@ Agent.prototype._flush = function (opts, cb) {
793793
}
794794

795795
Agent.prototype.registerMetric = function (name, labelsOrCallback, callback) {
796-
var labels
796+
let labels
797797
if (typeof labelsOrCallback === 'function') {
798798
callback = labelsOrCallback
799799
} else {
@@ -816,7 +816,7 @@ Agent.prototype.registerMetric = function (name, labelsOrCallback, callback) {
816816
*/
817817
Agent.prototype._isMetricNameDisabled = function (name) {
818818
const regexps = this._conf.disableMetricsRegExp
819-
for (var i = 0; i < regexps.length; i++) {
819+
for (let i = 0; i < regexps.length; i++) {
820820
if (regexps[i].test(name)) {
821821
return true
822822
}

0 commit comments

Comments
 (0)